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 descriptions for different user languages using the method setMyDescription.

This commit is contained in:
coder2020official 2023-03-10 21:36:44 +04:00
parent 2bd81a5f5c
commit c84b771e5a
4 changed files with 53 additions and 0 deletions

View File

@ -3401,6 +3401,24 @@ class TeleBot:
result = apihelper.get_my_commands(self.token, scope, language_code)
return [types.BotCommand.de_json(cmd) for cmd in result]
def set_my_description(self, description: Optional[str]=None, language_code: Optional[str]=None):
"""
Use this method to change the bot's description, which is shown in
the chat with the bot if the chat is empty.
Returns True on success.
:param description: New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
:type description: :obj:`str`
:param language_code: A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for
whose language there is no dedicated description.
:type language_code: :obj:`str`
:return: True on success.
"""
return apihelper.set_my_description(self.token, description, language_code)
def set_chat_menu_button(self, chat_id: Union[int, str]=None,
menu_button: types.MenuButton=None) -> bool:
"""

View File

@ -1152,6 +1152,15 @@ def set_chat_title(token, chat_id, title):
return _make_request(token, method_url, params=payload, method='post')
def set_my_description(token, description=None, language_code=None):
method_url = r'setMyDescription'
payload = {}
if description:
payload['description'] = 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

@ -4238,6 +4238,24 @@ class AsyncTeleBot:
"""
return await asyncio_helper.delete_chat_photo(self.token, chat_id)
async def set_my_description(self, description: Optional[str]=None, language_code: Optional[str]=None):
"""
Use this method to change the bot's description, which is shown in
the chat with the bot if the chat is empty.
Returns True on success.
:param description: New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
:type description: :obj:`str`
:param language_code: A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for
whose language there is no dedicated description.
:type language_code: :obj:`str`
:return: True on success.
"""
return await asyncio_helper.set_my_description(self.token, description, language_code)
async def get_my_commands(self, scope: Optional[types.BotCommandScope],
language_code: Optional[str]) -> List[types.BotCommand]:
"""

View File

@ -1138,6 +1138,14 @@ async def set_chat_title(token, chat_id, title):
payload = {'chat_id': chat_id, 'title': title}
return await _process_request(token, method_url, params=payload, method='post')
async def set_my_description(token, description=None, language_code=None):
method_url = r'setMyDescription'
payload = {}
if description:
payload['description'] = 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'