From a5b861f2821535cd8d7d5913a8d64f249072f798 Mon Sep 17 00:00:00 2001 From: "DarkyAmagai@gmail.com" Date: Wed, 19 Jul 2023 18:30:31 -0700 Subject: [PATCH] Added fetch_available_communities and added a new variable on CCommunity object. --- PKG-INFO | 2 +- pymino/__init__.py | 2 +- pymino/ext/entities/general.py | 3 +++ pymino/ext/global_client.py | 33 +++++++++++++++++++++++++++++++++ setup.cfg | 2 +- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index c5ca555b..ebbc9ac9 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pymino -Version: 1.2.3.5 +Version: 1.2.3.6 Summary: Easily create a bot for Amino Apps using a modern easy to use synchronous library. Home-page: https://github.com/forevercynical/pymino Author: forevercynical diff --git a/pymino/__init__.py b/pymino/__init__.py index 994758fa..91bd4adc 100644 --- a/pymino/__init__.py +++ b/pymino/__init__.py @@ -2,7 +2,7 @@ __author__ = 'cynical' __license__ = 'MIT' __copyright__ = 'Copyright 2023 Cynical' -__version__ = '1.2.3.5' +__version__ = '1.2.3.6' __description__ = 'A Python wrapper for the aminoapps.com API' from .bot import Bot as Bot diff --git a/pymino/ext/entities/general.py b/pymino/ext/entities/general.py index f1a33213..823e420f 100644 --- a/pymino/ext/entities/general.py +++ b/pymino/ext/entities/general.py @@ -110,6 +110,7 @@ def __init__(self, data: Union[dict, str]) -> None: self.ndcId = None self.comId = None self.icon = None + self.joinType = None if isinstance(data, dict): self.data: dict = data.get("community", self.data) @@ -134,6 +135,7 @@ def __init__(self, data: Union[dict, str]) -> None: self.templateId: Union[int, None] = self.data.get("templateId", self.templateId) self.searchable: Union[bool, None] = self.data.get("searchable", self.searchable) self.createdTime: Union[str, None] = self.data.get("createdTime", self.createdTime) + self.joinType: Union[int, None] = self.data.get("joinType", self.joinType) self.invitation: InvitationId = InvitationId(self.data.get("invitation", self.invitation)) try: @@ -175,6 +177,7 @@ def __init__(self, data: Union[dict, str]) -> None: self.ndcId: list = [x.ndcId for x in parser] self.comId: list = [x.comId for x in parser] self.icon: list = [x.icon for x in parser] + self.joinType: list = [x.joinType for x in parser] def json(self) -> Union[dict, str]: return self.data diff --git a/pymino/ext/global_client.py b/pymino/ext/global_client.py index f4abd370..e8b5d966 100644 --- a/pymino/ext/global_client.py +++ b/pymino/ext/global_client.py @@ -1893,4 +1893,37 @@ def fetch_public_communities(self, type: str = "discover"): return CCommunityList(self.make_request( method = "GET", url = f"/g/s/topic/0/feed/community?type={type}&categoryKey=recommendation&moduleId=0c56a709-1f96-474d-ae2f-4225d0e998e5" + )) + + def fetch_available_communities(self, start: int = 0, size: int = 25, language: str = "en"): + """ + Fetches a list of available communities. + + This method retrieves a list of communities that are available for exploration. + + :param start: The starting index of the communities to fetch (default is 0). + :type start: int + :param size: The number of communities to fetch in a single request (default is 25). + :type size: int + :param language: The language code used for filtering communities (default is "en"). + :type language: str + :return: A CCommunityList object containing information about the available communities. + :rtype: CCommunityList + :raises: Any exceptions raised during the API request process. + + The `CCommunityList` object provides access to information about multiple communities: + + - `json`: The raw response data from the API. + - `comId`: The list of community Ids. + - `name`: The list of community names. + + **Example usage:** + + >>> community_list = client.community.fetch_available_communities(start=0, size=10, language="en") + >>> for name, comId in zip(community_list.name, community_list.comId): + >>> print(name, comId]) + """ + return CCommunityList(self.make_request( + method = "GET", + url = f"/g/s/topic/0/feed/community?language={language}&type=web-explore&categoryKey=recommendation&start={start}&size={size}&pagingType=t" )) \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 0b2bb09e..876d9db0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pymino -version = 1.2.3.5 +version = 1.2.3.6 author = forevercynical author_email = me@cynical.gg description = Easily create a bot for Amino Apps using a modern easy to use synchronous library.