From 1e1ef27610104641a41b2f85ce0051faba9bfe18 Mon Sep 17 00:00:00 2001 From: Fernando Davis Mejia Date: Wed, 21 Jun 2023 12:57:18 -0700 Subject: [PATCH] Fixed start_chat output and added amino store related methods. --- PKG-INFO | 2 +- pymino/__init__.py | 2 +- pymino/ext/async_community.py | 244 +++++++++++++++++++++++++++++++++- pymino/ext/community.py | 244 +++++++++++++++++++++++++++++++++- setup.cfg | 2 +- 5 files changed, 487 insertions(+), 7 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index c624879a..955b562d 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -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 diff --git a/pymino/__init__.py b/pymino/__init__.py index 565b9735..70a9b9a5 100644 --- a/pymino/__init__.py +++ b/pymino/__init__.py @@ -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 diff --git a/pymino/ext/async_community.py b/pymino/ext/async_community.py index 489eeaee..10a15a5a 100644 --- a/pymino/ext/async_community.py +++ b/pymino/ext/async_community.py @@ -4852,7 +4852,7 @@ async def start_chat( "type": 0, "publishToGlobal": 0, "timestamp": int(time() * 1000) - })).status + })) @community @@ -7102,4 +7102,244 @@ async def purchase(self, "isAutoRenew": autoRenew } } - )) \ No newline at end of file + )) + + @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}" + ) \ No newline at end of file diff --git a/pymino/ext/community.py b/pymino/ext/community.py index d05e899c..e95041f3 100644 --- a/pymino/ext/community.py +++ b/pymino/ext/community.py @@ -4773,7 +4773,7 @@ def start_chat( "type": 0, "publishToGlobal": 0, "timestamp": int(time() * 1000) - })).status + })) @community @@ -7019,4 +7019,244 @@ def purchase(self, "isAutoRenew": autoRenew } } - )) \ No newline at end of file + )) + + @community + 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(self.session.handler( + method = "GET", + url = f"/x{comId or self.community_id}/s/store/items?sectionGroupId=chat-bubble&start={start}&size={size}" + )) + + @community + 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(self.session.handler( + method = "GET", + url = f"/x{comId or self.community_id}/s/store/items?sectionGroupId=sticker&start={start}&size={size}" + )) + + @community + 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(self.session.handler( + method = "GET", + url = f"/x{comId or self.community_id}/s/sticker-collection?type=community-shared" + )) + + @community + 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(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 + 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(self.session.handler( + method = "POST", + url = f"/x{comId or self.community_id}/s/user-group/quick-access/{userId}" + )) + + @community + 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 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 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 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 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 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 self.session.handler( + method = "GET", + url = f"/x{comId or self.community_id}/s/admin/operation?pagingType=t&size={size}" + ) + elif userId: return 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 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 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 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 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 self.session.handler( + method = "GET", + url = f"/x{comId or self.community_id}/s/admin/operation?pagingType=t&size={size}&pageToken={pageToken}" + ) \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index d7cc4942..fc770c35 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pymino -version = 1.2.1.2 +version = 1.2.1.3 author = forevercynical author_email = me@cynical.gg description = Easily create a bot for Amino Apps using a modern easy to use synchronous library.