Added the method setCustomEmojiStickerSetThumbnail for editing the thumbnail of custom emoji sticker sets created by the bot.

This commit is contained in:
coder2020official 2023-03-11 22:19:49 +04:00
parent ae44b0022d
commit ac0b386625
4 changed files with 47 additions and 0 deletions

View File

@ -4563,6 +4563,23 @@ class TeleBot:
"""
result = apihelper.get_custom_emoji_stickers(self.token, custom_emoji_ids)
return [types.Sticker.de_json(sticker) for sticker in result]
def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None):
"""
Use this method to set the thumbnail of a custom emoji sticker set.
Returns True on success.
:param name: Sticker set name
:type name: :obj:`str`
:param custom_emoji_id: Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail.
:type custom_emoji_id: :obj:`str`
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.set_custom_emoji_sticker_set_thumbnail(self.token, name, custom_emoji_id)
def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=None, sticker: Optional[types.InputFile]=None, sticker_format: Optional[str]=None) -> types.File:
"""

View File

@ -1628,6 +1628,13 @@ def upload_sticker_file(token, user_id, sticker, sticker_format):
return _make_request(token, method_url, params=payload, files=files, method='post')
def set_custom_emoji_sticker_set_thumbnail(token, name, custom_emoji_id=None):
method_url = 'setCustomEmojiStickerSetThumbnail'
payload = {'name': name}
if custom_emoji_id:
payload['custom_emoji_id'] = custom_emoji_id
return _make_request(token, method_url, params=payload, method='post')
def create_new_sticker_set(
token, user_id, name, title, stickers, sticker_format=None, sticker_type=None, needs_repainting=None):
method_url = 'createNewStickerSet'

View File

@ -5458,6 +5458,22 @@ class AsyncTeleBot:
result = await asyncio_helper.upload_sticker_file(self.token, user_id, sticker, sticker_format)
return types.File.de_json(result)
async def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None):
"""
Use this method to set the thumbnail of a custom emoji sticker set.
Returns True on success.
:param name: Sticker set name
:type name: :obj:`str`
:param custom_emoji_id: Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail.
:type custom_emoji_id: :obj:`str`
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.set_custom_emoji_sticker_set_thumbnail(self.token, name, custom_emoji_id)
async def create_new_sticker_set(
self, user_id: int, name: str, title: str,

View File

@ -1615,6 +1615,13 @@ async def upload_sticker_file(token, user_id, sticker, sticker_format):
return await _process_request(token, method_url, params=payload, files=files, method='post')
async def set_custom_emoji_sticker_set_thumbnail(token, name, custom_emoji_id=None):
method_url = 'setCustomEmojiStickerSetThumbnail'
payload = {'name': name}
if custom_emoji_id:
payload['custom_emoji_id'] = custom_emoji_id
return await _process_request(token, method_url, params=payload, method='post')
async def create_new_sticker_set(
token, user_id, name, title, stickers, sticker_format=None, sticker_type=None, needs_repainting=None):
method_url = 'createNewStickerSet'