From 9bbc7510f4dbd252847626df09023b21c080f894 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Sun, 5 Apr 2020 19:04:48 +0300 Subject: [PATCH] #289 Added the ability to change thumbnails of sticker sets created by the bot using the method setStickerSetThumb. --- aiogram/bot/api.py | 1 + aiogram/bot/bot.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 5b760d07..f0553644 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -225,6 +225,7 @@ class Methods(Helper): ADD_STICKER_TO_SET = Item() # addStickerToSet SET_STICKER_POSITION_IN_SET = Item() # setStickerPositionInSet DELETE_STICKER_FROM_SET = Item() # deleteStickerFromSet + SET_STICKER_SET_THUMB = Item() # setStickerSetThumb # Inline mode ANSWER_INLINE_QUERY = Item() # answerInlineQuery diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 9d242681..d6946513 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -1970,6 +1970,39 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): result = await self.request(api.Methods.DELETE_STICKER_FROM_SET, payload) return result + async def set_sticker_set_thumb(self, + name: base.String, + user_id: base.Integer, + thumb: typing.Union[base.InputFile, base.String] = None) -> base.Boolean: + """ + Use this method to set the thumbnail of a sticker set. + Animated thumbnails can be set for animated sticker sets only. + + Source: https://core.telegram.org/bots/api#setstickersetthumb + + :param name: Sticker set name + :type name: :obj:`base.String` + :param user_id: User identifier of the sticker set owner + :type user_id: :obj:`base.Integer` + :param thumb: A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height + exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; + see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical + requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, + pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using + multipart/form-data. More info on https://core.telegram.org/bots/api#sending-files. + Animated sticker set thumbnail can't be uploaded via HTTP URL. + :type thumb: :obj:`typing.Union[base.InputFile, base.String]` + :return: Returns True on success + :rtype: :obj:`base.Boolean` + """ + payload = generate_payload(**locals(), exclude=['thumb']) + + files = {} + prepare_file(payload, files, 'thumb', thumb) + + result = await self.request(api.Methods.SET_STICKER_SET_THUMB, payload, files) + return result + async def answer_inline_query(self, inline_query_id: base.String, results: typing.List[types.InlineQueryResult], cache_time: typing.Union[base.Integer, None] = None,