From 4e7652be7ac89fab297b9389e0920e8a3ee96446 Mon Sep 17 00:00:00 2001 From: _run Date: Tue, 1 Feb 2022 14:47:42 +0400 Subject: [PATCH] Bot API 5.7 --- telebot/__init__.py | 12 ++++++++---- telebot/apihelper.py | 8 ++++++-- telebot/async_telebot.py | 12 ++++++++---- telebot/asyncio_helper.py | 9 +++++++-- telebot/types.py | 6 ++++-- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index c1948a3..2bc716e 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -2409,8 +2409,9 @@ class TeleBot: def create_new_sticker_set( self, user_id: int, name: str, title: str, emojis: str, - png_sticker: Union[Any, str], - tgs_sticker: Union[Any, str], + png_sticker: Union[Any, str]=None, + tgs_sticker: Union[Any, str]=None, + webm_sticker: Union[Any, str]=None, contains_masks: Optional[bool]=None, mask_position: Optional[types.MaskPosition]=None) -> bool: """ @@ -2423,18 +2424,20 @@ class TeleBot: :param emojis: :param png_sticker: :param tgs_sticker: + :param webm_sticker: :param contains_masks: :param mask_position: :return: """ return apihelper.create_new_sticker_set( self.token, user_id, name, title, emojis, png_sticker, tgs_sticker, - contains_masks, mask_position) + contains_masks, mask_position, webm_sticker) def add_sticker_to_set( self, user_id: int, name: str, emojis: str, png_sticker: Optional[Union[Any, str]]=None, tgs_sticker: Optional[Union[Any, str]]=None, + webm_sticker: Optional[Union[Any, str]]=None, mask_position: Optional[types.MaskPosition]=None) -> bool: """ Use this method to add a new sticker to a set created by the bot. @@ -2445,11 +2448,12 @@ class TeleBot: :param emojis: :param png_sticker: Required if `tgs_sticker` is None :param tgs_sticker: Required if `png_sticker` is None + :webm_sticker: :param mask_position: :return: """ return apihelper.add_sticker_to_set( - self.token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position) + self.token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker) def set_sticker_position_in_set(self, sticker: str, position: int) -> bool: """ diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 870c609..0e76a67 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1533,7 +1533,7 @@ def upload_sticker_file(token, user_id, png_sticker): def create_new_sticker_set( token, user_id, name, title, emojis, png_sticker, tgs_sticker, - contains_masks=None, mask_position=None): + contains_masks=None, mask_position=None, webm_sticker=None): method_url = 'createNewStickerSet' payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis} stype = 'png_sticker' if png_sticker else 'tgs_sticker' @@ -1547,10 +1547,12 @@ def create_new_sticker_set( payload['contains_masks'] = contains_masks if mask_position: payload['mask_position'] = mask_position.to_json() + if webm_sticker: + payload['webm_sticker'] = webm_sticker return _make_request(token, method_url, params=payload, files=files, method='post') -def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position): +def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker): method_url = 'addStickerToSet' payload = {'user_id': user_id, 'name': name, 'emojis': emojis} stype = 'png_sticker' if png_sticker else 'tgs_sticker' @@ -1562,6 +1564,8 @@ def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, m payload[stype] = sticker if mask_position: payload['mask_position'] = mask_position.to_json() + if webm_sticker: + payload['webm_sticker'] = webm_sticker return _make_request(token, method_url, params=payload, files=files, method='post') diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 0d83c40..be9e08d 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -2996,8 +2996,9 @@ class AsyncTeleBot: async def create_new_sticker_set( self, user_id: int, name: str, title: str, emojis: str, - png_sticker: Union[Any, str], - tgs_sticker: Union[Any, str], + png_sticker: Union[Any, str]=None, + tgs_sticker: Union[Any, str]=None, + webm_sticker: Union[Any, str]=None, contains_masks: Optional[bool]=None, mask_position: Optional[types.MaskPosition]=None) -> bool: """ @@ -3010,19 +3011,21 @@ class AsyncTeleBot: :param emojis: :param png_sticker: :param tgs_sticker: + :webm_sticker: :param contains_masks: :param mask_position: :return: """ return await asyncio_helper.create_new_sticker_set( self.token, user_id, name, title, emojis, png_sticker, tgs_sticker, - contains_masks, mask_position) + contains_masks, mask_position, webm_sticker) async def add_sticker_to_set( self, user_id: int, name: str, emojis: str, png_sticker: Optional[Union[Any, str]]=None, tgs_sticker: Optional[Union[Any, str]]=None, + webm_sticker: Optional[Union[Any, str]]=None, mask_position: Optional[types.MaskPosition]=None) -> bool: """ Use this method to add a new sticker to a set created by the bot. @@ -3033,11 +3036,12 @@ class AsyncTeleBot: :param emojis: :param png_sticker: Required if `tgs_sticker` is None :param tgs_sticker: Required if `png_sticker` is None + :webm_sticker: :param mask_position: :return: """ return await asyncio_helper.add_sticker_to_set( - self.token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position) + self.token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker) async def set_sticker_position_in_set(self, sticker: str, position: int) -> bool: diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index f21c204..a5fdb5a 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -1497,7 +1497,7 @@ async def upload_sticker_file(token, user_id, png_sticker): async def create_new_sticker_set( token, user_id, name, title, emojis, png_sticker, tgs_sticker, - contains_masks=None, mask_position=None): + contains_masks=None, mask_position=None, webm_sticker=None): method_url = 'createNewStickerSet' payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis} stype = 'png_sticker' if png_sticker else 'tgs_sticker' @@ -1511,10 +1511,12 @@ async def create_new_sticker_set( payload['contains_masks'] = contains_masks if mask_position: payload['mask_position'] = mask_position.to_json() + if webm_sticker: + payload['webm_sticker'] = webm_sticker return await _process_request(token, method_url, params=payload, files=files, method='post') -async def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position): +async def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker): method_url = 'addStickerToSet' payload = {'user_id': user_id, 'name': name, 'emojis': emojis} stype = 'png_sticker' if png_sticker else 'tgs_sticker' @@ -1526,6 +1528,9 @@ async def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_stic payload[stype] = sticker if mask_position: payload['mask_position'] = mask_position.to_json() + + if webm_sticker: + payload['webm_sticker'] = webm_sticker return await _process_request(token, method_url, params=payload, files=files, method='post') diff --git a/telebot/types.py b/telebot/types.py index a200b73..1cce817 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -2484,10 +2484,11 @@ class StickerSet(JsonDeserializable): obj['thumb'] = None return cls(**obj) - def __init__(self, name, title, is_animated, contains_masks, stickers, thumb=None, **kwargs): + def __init__(self, name, title, is_animated, is_video, contains_masks, stickers, thumb=None, **kwargs): self.name: str = name self.title: str = title self.is_animated: bool = is_animated + self.is_video: bool = is_video self.contains_masks: bool = contains_masks self.stickers: List[Sticker] = stickers self.thumb: PhotoSize = thumb @@ -2507,12 +2508,13 @@ class Sticker(JsonDeserializable): return cls(**obj) def __init__(self, file_id, file_unique_id, width, height, is_animated, - thumb=None, emoji=None, set_name=None, mask_position=None, file_size=None, **kwargs): + is_video=None, thumb=None, emoji=None, set_name=None, mask_position=None, file_size=None, **kwargs): self.file_id: str = file_id self.file_unique_id: str = file_unique_id self.width: int = width self.height: int = height self.is_animated: bool = is_animated + self.is_video: bool = is_video self.thumb: PhotoSize = thumb self.emoji: str = emoji self.set_name: str = set_name