Skip to content

Commit

Permalink
Fixed start_chat output and added amino store related methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkyAmagai committed Jun 21, 2023
1 parent 0cd7f93 commit 1e1ef27
Show file tree
Hide file tree
Showing 5 changed files with 487 additions and 7 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.1.2
Version: 1.2.1.3
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.1.2'
__version__ = '1.2.1.3'
__description__ = 'A Python wrapper for the aminoapps.com API'

from .bot import Bot as Bot
Expand Down
244 changes: 242 additions & 2 deletions pymino/ext/async_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -4852,7 +4852,7 @@ async def start_chat(
"type": 0,
"publishToGlobal": 0,
"timestamp": int(time() * 1000)
})).status
}))


@community
Expand Down Expand Up @@ -7102,4 +7102,244 @@ async def purchase(self,
"isAutoRenew": autoRenew
}
}
))
))

@community
async def fetch_store_bubbles(self, start: int = 0, size: int = 25, comId: Union[str, int] = None) -> BubbleList:
"""
Fetches a list of chat bubbles from the store.
:param start: The starting index of the bubbles to fetch. (Default: 0)
:type start: int, optional
:param size: The number of bubbles to fetch. (Default: 25)
:type size: int, optional
:param comId: The ID of the community to fetch the bubbles from. If not provided, the current community ID is used.
:type comId: Union[str, int], optional
:return: A `BubbleList` object containing the fetched chat bubbles.
:rtype: BubbleList
This function sends a GET request to the API to fetch a list of chat bubbles from the store.
`BubbleList` represents a list of chat bubbles.
**Example usage:**
>>> bubbles = client.community.fetch_store_bubbles(start=0, size=10)
... for bubble in bubbles.name:
... print(bubble)
"""
return Bubble(await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/store/items?sectionGroupId=chat-bubble&start={start}&size={size}"
))

@community
async def fetch_store_stickers(self, start: int = 0, size: int = 25, comId: Union[str, int] = None) -> StickerList:
"""
Fetches a list of stickers from the community store.
:param start: The index of the first sticker to retrieve. (Default: 0)
:type start: int, optional
:param size: The number of stickers to retrieve. (Default: 25)
:type size: int, optional
:param comId: The ID of the community to fetch stickers from. If not provided, the current community ID is used.
:type comId: Union[str, int], optional
:return: A `StickerList` object containing the fetched stickers.
:rtype: StickerList
This function sends a GET request to the API to fetch a list of stickers from the community store.
`StickerList` represents a list of stickers in the community store.
**Example usage:**
>>> stickers = client.community.fetch_store_stickers(start=0, size=10)
... for sticker in stickers.name:
... print(sticker)
"""
return StickerList(await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/store/items?sectionGroupId=sticker&start={start}&size={size}"
))

@community
async def fetch_community_stickers(self, start: int = 0, size: int = 25, comId: Union[str, int] = None) -> CommunityStickerList:
"""
Fetches a list of community stickers.
:param start: The starting index of the sticker list to fetch. (Default: 0)
:type start: int, optional
:param size: The number of stickers to fetch. (Default: 25)
:type size: int, optional
:param comId: The ID of the community to fetch stickers from. If not provided, the current community ID is used.
:type comId: Union[str, int], optional
:return: A `CommunityStickerList` object containing the fetched community stickers.
:rtype: CommunityStickerList
This function sends a GET request to the API to fetch a list of community stickers. The fetched stickers are returned
as a `CommunityStickerList` object.
`CommunityStickerList` represents a list of community stickers.
**Example usage:**
>>> stickers = client.community.fetch_community_stickers(start=0, size=10)
... for sticker in stickers.name:
... print(sticker)
"""
return CommunityStickerList(await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/sticker-collection?type=community-shared"
))

@community
async def reorder_featured_users(self, userIds: list[str], comId: Union[str, int] = None) -> ApiResponse:
"""
Reorders the featured users in the community.
:param userIds: A list of user IDs representing the desired order of the featured users.
:type userIds: list[str]
:param comId: The ID of the community to reorder the featured users in. If not provided, the current community ID is used.
:type comId: Union[str, int], optional
:return: An `ApiResponse` object representing the result of the reorder operation.
:rtype: ApiResponse
This function sends a POST request to the API to reorder the featured users in the specified community.
`ApiResponse` represents the response received from the API.
**Example usage:**
>>> response = client.community.reorder_featured_users(["user1", "user2", "user3"])
... print(response.status_code)
... print(response.json())
"""
return ApiResponse(await self.session.handler(
method = "POST",
url = f"/x{comId or self.community_id}/s/user-profile/featured/reorder",
data = {
"uidList": userIds,
"timestamp": int(time() * 1000)
}
))

@community
async def add_to_favorites(self, userId: str, comId: Union[str, int] = None) -> ApiResponse:
"""
Adds a user to yout favorite users list in the community.
:param userId: The ID of the user to add to the favorites list.
:type userId: str
:param comId: The ID of the community to add the user to the favorites list in.
If not provided, the current community ID is used.
:type comId: Union[str, int], optional
:return: An `ApiResponse` object representing the response of the API request.
:rtype: ApiResponse
This function sends a POST request to the API to add a user to your favorite users in the community.
`ApiResponse` represents the response from the API.
**Example usage:**
>>> response = client.community.add_to_favorites("123456789")
... print(response.status_code)
... print(response.json())
"""
return ApiResponse(await self.session.handler(
method = "POST",
url = f"/x{comId or self.community_id}/s/user-group/quick-access/{userId}"
))

@community
async def fetch_admin_log(self,
userId: str = None,
blogId: str = None,
wikiId: str = None,
quizId: str = None,
fileId: str = None,
pageToken: str = None,
size: int = 25,
comId: Union[str, int] = None):
"""
Fetches the admin log entries for the specified parameters.
:param userId: The ID of the user to filter the admin log by. (Optional)
:type userId: str, optional
:param blogId: The ID of the blog to filter the admin log by. (Optional)
:type blogId: str, optional
:param wikiId: The ID of the wiki to filter the admin log by. (Optional)
:type wikiId: str, optional
:param quizId: The ID of the quiz to filter the admin log by. (Optional)
:type quizId: str, optional
:param fileId: The ID of the file to filter the admin log by. (Optional)
:type fileId: str, optional
:param pageToken: The token for pagination. (Optional)
:type pageToken: str, optional
:param size: The number of log entries to fetch per page. (Default: 25)
:type size: int, optional
:param comId: The ID of the community to fetch the admin log from. If not provided, the current community ID is used.
:type comId: Union[str, int], optional
:return: The admin log entries matching the specified parameters.
:rtype: response object
This function fetches the admin log entries for the specified parameters in the community.
Note: The response object may vary based on the implementation.
**Example usage:**
>>> admin_log = client.community.fetch_admin_log(userId="12345")
... for entry in admin_log:
... print(entry.action)
... print(entry.timestamp)
"""
if pageToken is None:
if userId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={userId}&objectType=0&pagingType=t&size={size}"
)
elif blogId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={blogId}&objectType=1&pagingType=t&size={size}"
)
elif wikiId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={wikiId}&objectType=2&pagingType=t&size={size}"
)
elif quizId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={quizId}&objectType=1&pagingType=t&size={size}"
)
elif fileId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={fileId}&objectType=109&pagingType=t&size={size}"
)
else: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?pagingType=t&size={size}"
)
elif userId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={userId}&objectType=0&pagingType=t&size={size}&pageToken={pageToken}"
)
elif blogId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={blogId}&objectType=1&pagingType=t&size={size}&pageToken={pageToken}"
)
elif wikiId: return await self.session.hadler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={wikiId}&objectType=2&pagingType=t&size={size}&pageToken={pageToken}"
)
elif quizId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={quizId}&objectType=1&pagingType=t&size={size}&pageToken={pageToken}"
)
elif fileId: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?objectId={fileId}&objectType=109&pagingType=t&size={size}&pageToken={pageToken}"
)
else: return await self.session.handler(
method = "GET",
url = f"/x{comId or self.community_id}/s/admin/operation?pagingType=t&size={size}&pageToken={pageToken}"
)
Loading

0 comments on commit 1e1ef27

Please sign in to comment.