From 492657b1e968be9530ebfd3e8f506e71056d0e50 Mon Sep 17 00:00:00 2001 From: ENCRYPTED <48645524+ENCRYPTEDFOREVER@users.noreply.github.com> Date: Sat, 17 Sep 2022 21:08:59 +0300 Subject: [PATCH 1/4] Fixed possible incorrect escaping of list[str]. By default if you call str() on collection python will escape strings inside of it using single quotes, which will cause "Can't parse custom emoji identifiers json object" error when calling getCustomEmojiStickers. json.dumps() escapes strings by double quotes so no error occurs. --- aiogram/bot/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index f287e32f47..6089dcbf06 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -166,7 +166,10 @@ def compose_data(params=None, files=None): if params: for key, value in params.items(): - data.add_field(key, str(value)) + if isinstance(value, (list, dict)): + data.add_field(key, json.dumps(value)) + else: + data.add_field(key, str(value)) if files: for key, f in files.items(): From 95cfddf13e2c2856e6bb27bf1d36f7fd78311a34 Mon Sep 17 00:00:00 2001 From: ENCRYPTED <48645524+ENCRYPTEDFOREVER@users.noreply.github.com> Date: Sat, 17 Sep 2022 21:16:10 +0300 Subject: [PATCH 2/4] get_custom_emoji_stickers docstring fix --- aiogram/bot/bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 27c1ed6311..3277292cb0 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -3051,9 +3051,9 @@ async def get_custom_emoji_stickers(self, custom_emoji_ids: typing.List[base.Str Use this method to get information about custom emoji stickers by their identifiers. - Source: https://core.telegram.org/bots/api#uploadstickerfile + Source: https://core.telegram.org/bots/api#getcustomemojistickers - :param custom_emoji_ids: User identifier of sticker file owner + :param custom_emoji_ids: List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. :type custom_emoji_ids: :obj:`typing.List[base.String]` :return: Returns an Array of Sticker objects. :rtype: :obj:`typing.List[types.Sticker]` From d47db33fe1652ce0eee1a7087b1b916208aafe0d Mon Sep 17 00:00:00 2001 From: ENCRYPTED <48645524+ENCRYPTEDFOREVER@users.noreply.github.com> Date: Sun, 18 Sep 2022 16:05:35 +0300 Subject: [PATCH 3/4] Revert compose_data changes --- aiogram/bot/api.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 6089dcbf06..f287e32f47 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -166,10 +166,7 @@ def compose_data(params=None, files=None): if params: for key, value in params.items(): - if isinstance(value, (list, dict)): - data.add_field(key, json.dumps(value)) - else: - data.add_field(key, str(value)) + data.add_field(key, str(value)) if files: for key, f in files.items(): From f4d229cdd8825f7581d64a78714ff76c45623e4b Mon Sep 17 00:00:00 2001 From: ENCRYPTED <48645524+ENCRYPTEDFOREVER@users.noreply.github.com> Date: Sun, 18 Sep 2022 16:06:33 +0300 Subject: [PATCH 4/4] Correctly fixed get_custom_emoji_stickers method --- aiogram/bot/bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 3277292cb0..a641d4e70c 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -3058,6 +3058,7 @@ async def get_custom_emoji_stickers(self, custom_emoji_ids: typing.List[base.Str :return: Returns an Array of Sticker objects. :rtype: :obj:`typing.List[types.Sticker]` """ + custom_emoji_ids = prepare_arg(custom_emoji_ids) payload = generate_payload(**locals()) result = await self.request(api.Methods.GET_CUSTOM_EMOJI_STICKERS, payload)