#289 Added the ability to change thumbnails of sticker sets created by the bot using the method setStickerSetThumb.

This commit is contained in:
Oleg A 2020-04-05 19:04:48 +03:00
parent 3d632fea1c
commit 9bbc7510f4
2 changed files with 34 additions and 0 deletions

View file

@ -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

View file

@ -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,