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

Added the ability to set different bot short descriptions for different user languages using the method setMyShortDescription.

This commit is contained in:
coder2020official 2023-03-11 15:40:54 +04:00
parent 65dcd67140
commit 9b81a29a6a
4 changed files with 54 additions and 0 deletions

View File

@ -3431,6 +3431,24 @@ class TeleBot:
"""
return types.BotDescription.de_json(apihelper.get_my_description(self.token, language_code))
def set_my_short_description(self, short_description:Optional[str]=None, language_code:Optional[str]=None):
"""
Use this method to change the bot's short description, which is shown on the bot's profile page and
is sent together with the link when users share the bot.
Returns True on success.
:param short_description: New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
:type short_description: :obj:`str`
:param language_code: A two-letter ISO 639-1 language code.
If empty, the short description will be applied to all users for whose language there is no dedicated short description.
:type language_code: :obj:`str`
:return: True on success.
"""
return apihelper.set_my_short_description(self.token, short_description, language_code)
def set_chat_menu_button(self, chat_id: Union[int, str]=None,
menu_button: types.MenuButton=None) -> bool:

View File

@ -1160,6 +1160,7 @@ def set_my_description(token, description=None, language_code=None):
if language_code:
payload['language_code'] = language_code
return _make_request(token, method_url, params=payload, method='post')
def get_my_description(token, language_code=None):
method_url = r'getMyDescription'
@ -1168,6 +1169,15 @@ def get_my_description(token, language_code=None):
payload['language_code'] = language_code
return _make_request(token, method_url, params=payload)
def set_my_short_description(token, short_description=None, language_code=None):
method_url = r'setMyShortDescription'
payload = {}
if short_description:
payload['short_description'] = short_description
if language_code:
payload['language_code'] = language_code
return _make_request(token, method_url, params=payload, method='post')
def get_my_commands(token, scope=None, language_code=None):
method_url = r'getMyCommands'
payload = {}

View File

@ -4269,6 +4269,24 @@ class AsyncTeleBot:
result = await asyncio_helper.get_my_description(self.token, language_code)
return types.BotDescription.de_json(result)
async def set_my_short_description(self, short_description:Optional[str]=None, language_code:Optional[str]=None):
"""
Use this method to change the bot's short description, which is shown on the bot's profile page and
is sent together with the link when users share the bot.
Returns True on success.
:param short_description: New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
:type short_description: :obj:`str`
:param language_code: A two-letter ISO 639-1 language code.
If empty, the short description will be applied to all users for whose language there is no dedicated short description.
:type language_code: :obj:`str`
:return: True on success.
"""
return await asyncio_helper.set_my_short_description(self.token, short_description, language_code)
async def get_my_commands(self, scope: Optional[types.BotCommandScope],
language_code: Optional[str]) -> List[types.BotCommand]:
"""

View File

@ -1154,6 +1154,14 @@ async def get_my_description(token, language_code=None):
payload['language_code'] = language_code
return await _process_request(token, method_url, params=payload)
async def set_my_short_description(token, short_description=None, language_code=None):
method_url = r'setMyShortDescription'
payload = {}
if short_description:
payload['short_description'] = short_description
if language_code:
payload['language_code'] = language_code
return await _process_request(token, method_url, params=payload, method='post')
async def get_my_commands(token, scope=None, language_code=None):
method_url = r'getMyCommands'