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

Added the method setStickerKeywords for changing the search keywords assigned to a sticker.

This commit is contained in:
coder2020official 2023-03-11 22:58:41 +04:00
parent de5a32e45c
commit 9fa5b91e58
4 changed files with 50 additions and 0 deletions

View File

@ -4564,6 +4564,23 @@ class TeleBot:
result = apihelper.get_custom_emoji_stickers(self.token, custom_emoji_ids)
return [types.Sticker.de_json(sticker) for sticker in result]
def set_sticker_keywords(self, sticker: str, keywords: List[str]=None) -> bool:
"""
Use this method to change search keywords assigned to a regular or custom emoji sticker.
The sticker must belong to a sticker set created by the bot.
Returns True on success.
:param sticker: File identifier of the sticker.
:type sticker: :obj:`str`
:param keywords: A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
:type keywords: :obj:`list` of :obj:`str`
:return: On success, True is returned.
:rtype: :obj:`bool`
"""
return apihelper.set_sticker_keywords(self.token, sticker, keywords)
def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None) -> bool:
"""

View File

@ -1620,6 +1620,14 @@ 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': json.dumps(custom_emoji_ids)})
def set_sticker_keywords(token, sticker, keywords=None):
method_url = 'setStickerKeywords'
payload = {'sticker': sticker}
if keywords:
payload['keywords'] = json.dumps(keywords)
return _make_request(token, method_url, params=payload, method='post')
def upload_sticker_file(token, user_id, sticker, sticker_format):
method_url = 'uploadStickerFile'

View File

@ -5412,6 +5412,23 @@ class AsyncTeleBot:
"""
result = await asyncio_helper.get_sticker_set(self.token, name)
return types.StickerSet.de_json(result)
async def set_sticker_keywords(self, sticker: str, keywords: List[str]=None) -> bool:
"""
Use this method to change search keywords assigned to a regular or custom emoji sticker.
The sticker must belong to a sticker set created by the bot.
Returns True on success.
:param sticker: File identifier of the sticker.
:type sticker: :obj:`str`
:param keywords: A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters
:type keywords: :obj:`list` of :obj:`str`
:return: On success, True is returned.
:rtype: :obj:`bool`
"""
return await asyncio_helper.set_sticker_keywords(self.token, sticker, keywords)
async def get_custom_emoji_stickers(self, custom_emoji_ids: List[str]) -> List[types.Sticker]:
"""

View File

@ -1608,6 +1608,14 @@ 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': json.dumps(custom_emoji_ids)})
async def set_sticker_keywords(token, sticker, keywords=None):
method_url = 'setStickerKeywords'
payload = {'sticker': sticker}
if keywords:
payload['keywords'] = json.dumps(keywords)
return await _process_request(token, method_url, params=payload, method='post')
async def upload_sticker_file(token, user_id, sticker, sticker_format):
method_url = 'uploadStickerFile'
payload = {'user_id': user_id, 'sticker_format': sticker_format}