From 6a9c25cf809ef069faa88e8bf81b8f1b851feca2 Mon Sep 17 00:00:00 2001 From: Badiboy Date: Sat, 25 Mar 2023 14:56:31 +0300 Subject: [PATCH] Fix set_sticker_set_thumb and set_sticker_set_thumbnail --- telebot/__init__.py | 17 ++++++++--------- telebot/apihelper.py | 10 +++++----- telebot/async_telebot.py | 16 +++++++--------- telebot/asyncio_helper.py | 10 +++++----- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index dd1f8d2..b0161bc 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -4547,8 +4547,7 @@ class TeleBot: """ return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert, url, cache_time) - def set_sticker_set_thumbnail( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: 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. @@ -4561,16 +4560,17 @@ class TeleBot: :param user_id: User identifier :type user_id: :obj:`int` - :param thumb: - :type thumb: :obj:`filelike object` + :param thumbnail: A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video 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 information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + :type thumbnail: :obj:`filelike object` :return: On success, True is returned. :rtype: :obj:`bool` """ - return apihelper.set_sticker_set_thumb(self.token, name, user_id, thumb) + + return apihelper.set_sticker_set_thumbnail(self.token, name, user_id, thumbnail) - def set_sticker_set_thumb( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + @util.deprecated(deprecation_text="Use set_sticker_set_thumbnail instead") + 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. @@ -4590,8 +4590,7 @@ class TeleBot: :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) + return self.set_sticker_set_thumbnail(name, user_id, thumb) def get_sticker_set(self, name: str) -> types.StickerSet: """ diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 32e38bc..b5eb065 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -355,15 +355,15 @@ def get_chat_member_count(token, chat_id): return _make_request(token, method_url, params=payload) -def set_sticker_set_thumb(token, name, user_id, thumb): +def set_sticker_set_thumbnail(token, name, user_id, thumbnail): method_url = r'setStickerSetThumbnail' payload = {'name': name, 'user_id': user_id} files = {} - if thumb: - if not isinstance(thumb, str): - files['thumb'] = thumb + if thumbnail: + if not isinstance(thumbnail, str): + files['thumbnail'] = thumbnail else: - payload['thumb'] = thumb + payload['thumbnail'] = thumbnail return _make_request(token, method_url, params=payload, files=files or None) diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index cd952ae..247440c 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -5407,8 +5407,7 @@ class AsyncTeleBot: """ return await asyncio_helper.answer_callback_query(self.token, callback_query_id, text, show_alert, url, cache_time) - async def set_sticker_set_thumbnail( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + async def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: 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. @@ -5421,16 +5420,16 @@ class AsyncTeleBot: :param user_id: User identifier :type user_id: :obj:`int` - :param thumb: - :type thumb: :obj:`filelike object` + :param thumbnail: A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video 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 information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + :type thumbnail: :obj:`filelike object` :return: On success, True is returned. :rtype: :obj:`bool` """ - return await asyncio_helper.set_sticker_set_thumb(self.token, name, user_id, thumb) + return await asyncio_helper.set_sticker_set_thumbnail(self.token, name, user_id, thumbnail) - async def set_sticker_set_thumb( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + @util.deprecated(deprecation_text="Use set_sticker_set_thumbnail instead") + async 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. @@ -5450,8 +5449,7 @@ class AsyncTeleBot: :rtype: :obj:`bool` """ # deprecated - logger.warning('set_sticker_set_thumb is deprecated, use set_sticker_set_thumbnail instead') - return await asyncio_helper.set_sticker_set_thumb(self.token, name, user_id, thumb) + return await self.set_sticker_set_thumbnail(name, user_id, thumb) async def get_sticker_set(self, name: str) -> types.StickerSet: """ diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index dc8e9b8..6f7ef0f 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -343,15 +343,15 @@ async def get_chat_member_count(token, chat_id): return await _process_request(token, method_url, params=payload) -async def set_sticker_set_thumb(token, name, user_id, thumb): +async def set_sticker_set_thumbnail(token, name, user_id, thumbnail): method_url = r'setStickerSetThumbnail' payload = {'name': name, 'user_id': user_id} files = {} - if thumb: - if not isinstance(thumb, str): - files['thumb'] = thumb + if thumbnail: + if not isinstance(thumbnail, str): + files['thumbnail'] = thumbnail else: - payload['thumb'] = thumb + payload['thumbnail'] = thumbnail return await _process_request(token, method_url, params=payload, files=files or None)