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

Fixed custom_emoji_ids and added set_sticker_emoji_list, and and fixed some typehints

This commit is contained in:
coder2020official 2023-03-11 22:53:33 +04:00
parent db087427fc
commit de5a32e45c
4 changed files with 53 additions and 8 deletions

View File

@ -4565,7 +4565,7 @@ class TeleBot:
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):
def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None) -> bool:
"""
Use this method to set the thumbnail of a custom emoji sticker set.
Returns True on success.
@ -4581,7 +4581,7 @@ class TeleBot:
"""
return apihelper.set_custom_emoji_sticker_set_thumbnail(self.token, name, custom_emoji_id)
def set_sticker_set_title(self, name: str, title: str):
def set_sticker_set_title(self, name: str, title: str) -> bool:
"""
Use this method to set the title of a created sticker set.
Returns True on success.
@ -4598,7 +4598,7 @@ class TeleBot:
return apihelper.set_sticker_set_title(self.token, name, title)
def delete_sticker_set(self, name:str):
def delete_sticker_set(self, name:str) -> bool:
"""
Use this method to delete a sticker set. Returns True on success.
@ -4610,6 +4610,24 @@ class TeleBot:
"""
return apihelper.delete_sticker_set(self.token, name)
def set_sticker_emoji_list(self, sticker: str, emoji_list: List[str]) -> bool:
"""
Use this method to set the emoji list of a custom emoji sticker set.
Returns True on success.
:param sticker: Sticker identifier
:type sticker: :obj:`str`
:param emoji_list: List of emoji
:type emoji_list: :obj:`list` of :obj:`str`
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.set_sticker_emoji_list(self.token, sticker, emoji_list)
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

@ -1619,7 +1619,7 @@ def get_sticker_set(token, name):
def get_custom_emoji_stickers(token, custom_emoji_ids):
method_url = r'getCustomEmojiStickers'
return _make_request(token, method_url, params={'custom_emoji_ids': custom_emoji_ids})
return _make_request(token, method_url, params={'custom_emoji_ids': json.dumps(custom_emoji_ids)})
def upload_sticker_file(token, user_id, sticker, sticker_format):
method_url = 'uploadStickerFile'
@ -1646,6 +1646,11 @@ def delete_sticker_set(token, name):
payload = {'name': name}
return _make_request(token, method_url, params=payload, method='post')
def set_sticker_emoji_list(token, sticker, emoji_list):
method_url = 'setStickerEmojiList'
payload = {'sticker': sticker, 'emoji_list': json.dumps(emoji_list)}
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

@ -5459,7 +5459,7 @@ 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):
async def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None) -> bool:
"""
Use this method to set the thumbnail of a custom emoji sticker set.
Returns True on success.
@ -5475,7 +5475,7 @@ class AsyncTeleBot:
"""
return await asyncio_helper.set_custom_emoji_sticker_set_thumbnail(self.token, name, custom_emoji_id)
async def set_sticker_set_title(self, name: str, title: str):
async def set_sticker_set_title(self, name: str, title: str) -> bool:
"""
Use this method to set the title of a created sticker set.
Returns True on success.
@ -5492,7 +5492,7 @@ class AsyncTeleBot:
return await asyncio_helper.set_sticker_set_title(self.token, name, title)
async def delete_sticker_set(self, name:str):
async def delete_sticker_set(self, name:str) -> bool:
"""
Use this method to delete a sticker set. Returns True on success.
@ -5504,6 +5504,24 @@ class AsyncTeleBot:
"""
return await asyncio_helper.delete_sticker_set(self.token, name)
async def set_sticker_emoji_list(self, name: str, emoji_list: List[str]) -> bool:
"""
Use this method to set the emoji list of a sticker set.
Returns True on success.
:param name: Sticker set name
:type name: :obj:`str`
:param emoji_list: List of emojis
:type emoji_list: :obj:`list` of :obj:`str`
:return: Returns True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.set_sticker_emoji_list(self.token, name, emoji_list)
async def create_new_sticker_set(

View File

@ -1606,7 +1606,7 @@ async def get_sticker_set(token, name):
async def get_custom_emoji_stickers(token, custom_emoji_ids):
method_url = r'getCustomEmojiStickers'
return await _process_request(token, method_url, params={'custom_emoji_ids': custom_emoji_ids})
return await _process_request(token, method_url, params={'custom_emoji_ids': json.dumps(custom_emoji_ids)})
async def upload_sticker_file(token, user_id, sticker, sticker_format):
method_url = 'uploadStickerFile'
@ -1614,6 +1614,10 @@ async def upload_sticker_file(token, user_id, sticker, sticker_format):
files = {'sticker': sticker}
return await _process_request(token, method_url, params=payload, files=files, method='post')
async def set_sticker_emoji_list(token, sticker, emoji_list):
method_url = 'setStickerEmojiList'
payload = {'sticker': sticker, 'emoji_list': json.dumps(emoji_list)}
return await _process_request(token, method_url, params=payload, method='post')
async def delete_sticker_set(token, name):
method_url = 'deleteStickerSet'