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

Fix set_sticker_set_thumb and set_sticker_set_thumbnail

This commit is contained in:
Badiboy 2023-03-25 14:56:31 +03:00
parent e56c60ac00
commit 6a9c25cf80
4 changed files with 25 additions and 28 deletions

View File

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

View File

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

View File

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

View File

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