Skip to content

Commit

Permalink
Added fetch_available_communities and added a new variable on CCommun…
Browse files Browse the repository at this point in the history
…ity object.
  • Loading branch information
FeralAmagai committed Jul 20, 2023
1 parent f613a50 commit a5b861f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pymino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pymino/ext/entities/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions pymino/ext/global_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
))
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit a5b861f

Please sign in to comment.