1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Bot API 6.6 review changes

This commit is contained in:
coder2020official
2023-03-19 17:31:53 +04:00
parent 9d2f7c02a4
commit 1e450ebd15
5 changed files with 96 additions and 31 deletions

View File

@ -4559,7 +4559,29 @@ class TeleBot:
"""
return apihelper.set_sticker_set_thumb(self.token, name, user_id, thumb)
set_sticker_set_thumb = set_sticker_set_thumbnail
def set_sticker_set_thumb(
self, name: str, user_id: int, thumb: Union[Any, str]=None):
"""
Use this method to set the thumbnail of a sticker set.
Animated thumbnails can be set for animated sticker sets only. Returns True on success.
Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumb
:param name: Sticker set name
:type name: :obj:`str`
:param user_id: User identifier
:type user_id: :obj:`int`
:param thumb:
:type thumb: :obj:`filelike object`
:return: On success, True is returned.
:rtype: :obj:`bool`
"""
# deprecated
logger.warning('set_sticker_set_thumb is deprecated. Use set_sticker_set_thumbnail instead.')
return apihelper.set_sticker_set_thumb(self.token, name, user_id, thumb)
def get_sticker_set(self, name: str) -> types.StickerSet:
"""
@ -4817,7 +4839,7 @@ class TeleBot:
def add_sticker_to_set(
self, user_id: int, name: str, emojis: List[str]=None,
self, user_id: int, name: str, emojis: Union[List[str], str],
png_sticker: Optional[Union[Any, str]]=None,
tgs_sticker: Optional[Union[Any, str]]=None,
webm_sticker: Optional[Union[Any, str]]=None,
@ -4833,7 +4855,7 @@ class TeleBot:
Telegram documentation: https://core.telegram.org/bots/api#addstickertoset
.. note::
**_sticker parameters are deprecated, use stickers instead
**_sticker, mask_position, emojis parameters are deprecated, use stickers instead
:param user_id: User identifier of created sticker set owner
:type user_id: :obj:`int`
@ -4859,15 +4881,26 @@ class TeleBot:
:type mask_position: :class:`telebot.types.MaskPosition`
:param sticker: A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
:type sticker: :class:`telebot.types.InputSticker`
:type sticker: :obj:`list` of :class:`telebot.types.InputSticker`
:return: On success, True is returned.
:rtype: :obj:`bool`
"""
# split emojis if string
if isinstance(emojis, str):
emojis = list(emojis)
# Replaced the parameters png_sticker, tgs_sticker, webm_sticker, emojis and mask_position
if sticker is None:
sticker = png_sticker or tgs_sticker or webm_sticker
sticker = types.InputSticker(sticker, emojis, mask_position)
old_sticker = png_sticker or tgs_sticker or webm_sticker
if old_sticker is not None:
logger.warning(
'The parameters "png_sticker", "tgs_sticker", "webm_sticker", "emojis" and "mask_position" are deprecated, '
'use "sticker" instead'
)
if not old_sticker:
raise ValueError('You must pass at least one sticker.')
sticker = types.InputSticker(old_sticker, emojis, mask_position)
return apihelper.add_sticker_to_set(
self.token, user_id, name, sticker)