mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Added the ability to get the current bot name in the given language as the class BotName using the method getMyName.
This commit is contained in:
parent
77e1928628
commit
1d62adc262
@ -3462,6 +3462,22 @@ class TeleBot:
|
|||||||
|
|
||||||
return apihelper.set_my_name(self.token, name, language_code)
|
return apihelper.set_my_name(self.token, name, language_code)
|
||||||
|
|
||||||
|
def get_my_name(self, language_code: Optional[str]=None):
|
||||||
|
"""
|
||||||
|
Use this method to get the current bot name for the given user language.
|
||||||
|
Returns BotName on success.
|
||||||
|
|
||||||
|
Telegram documentation: https://core.telegram.org/bots/api#getmyname
|
||||||
|
|
||||||
|
:param language_code: Optional. A two-letter ISO 639-1 language code or an empty string
|
||||||
|
:type language_code: :obj:`str`
|
||||||
|
|
||||||
|
:return: :class:`telebot.types.BotName`
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = apihelper.get_my_name(self.token, language_code)
|
||||||
|
return types.BotName.de_json(result)
|
||||||
|
|
||||||
def set_my_description(self, description: Optional[str]=None, language_code: Optional[str]=None):
|
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
|
Use this method to change the bot's description, which is shown in
|
||||||
|
@ -1205,6 +1205,13 @@ def set_my_name(token, name=None, language_code=None):
|
|||||||
payload['language_code'] = language_code
|
payload['language_code'] = language_code
|
||||||
return _make_request(token, method_url, params=payload, method='post')
|
return _make_request(token, method_url, params=payload, method='post')
|
||||||
|
|
||||||
|
def get_my_name(token, language_code=None):
|
||||||
|
method_url = r'getMyName'
|
||||||
|
payload = {}
|
||||||
|
if language_code is not None:
|
||||||
|
payload['language_code'] = language_code
|
||||||
|
return _make_request(token, method_url, params=payload)
|
||||||
|
|
||||||
def set_chat_menu_button(token, chat_id=None, menu_button=None):
|
def set_chat_menu_button(token, chat_id=None, menu_button=None):
|
||||||
method_url = r'setChatMenuButton'
|
method_url = r'setChatMenuButton'
|
||||||
payload = {}
|
payload = {}
|
||||||
|
@ -4379,6 +4379,22 @@ class AsyncTeleBot:
|
|||||||
|
|
||||||
return await asyncio_helper.set_my_name(self.token, name, language_code)
|
return await asyncio_helper.set_my_name(self.token, name, language_code)
|
||||||
|
|
||||||
|
async def get_my_name(self, language_code: Optional[str]=None):
|
||||||
|
"""
|
||||||
|
Use this method to get the current bot name for the given user language.
|
||||||
|
Returns BotName on success.
|
||||||
|
|
||||||
|
Telegram documentation: https://core.telegram.org/bots/api#getmyname
|
||||||
|
|
||||||
|
:param language_code: Optional. A two-letter ISO 639-1 language code or an empty string
|
||||||
|
:type language_code: :obj:`str`
|
||||||
|
|
||||||
|
:return: :class:`telebot.types.BotName`
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = await asyncio_helper.get_my_name(self.token, language_code)
|
||||||
|
return types.BotName.de_json(result)
|
||||||
|
|
||||||
async def set_chat_menu_button(self, chat_id: Union[int, str]=None,
|
async def set_chat_menu_button(self, chat_id: Union[int, str]=None,
|
||||||
menu_button: types.MenuButton=None) -> bool:
|
menu_button: types.MenuButton=None) -> bool:
|
||||||
"""
|
"""
|
||||||
|
@ -1193,6 +1193,13 @@ async def set_my_name(token, name=None, language_code=None):
|
|||||||
payload['language_code'] = language_code
|
payload['language_code'] = language_code
|
||||||
return await _process_request(token, method_url, params=payload, method='post')
|
return await _process_request(token, method_url, params=payload, method='post')
|
||||||
|
|
||||||
|
async def get_my_name(token, language_code=None):
|
||||||
|
method_url = r'getMyName'
|
||||||
|
payload = {}
|
||||||
|
if language_code is not None:
|
||||||
|
payload['language_code'] = language_code
|
||||||
|
return await _process_request(token, method_url, params=payload)
|
||||||
|
|
||||||
async def set_chat_menu_button(token, chat_id=None, menu_button=None):
|
async def set_chat_menu_button(token, chat_id=None, menu_button=None):
|
||||||
method_url = r'setChatMenuButton'
|
method_url = r'setChatMenuButton'
|
||||||
payload = {}
|
payload = {}
|
||||||
|
@ -7658,3 +7658,27 @@ class SwitchInlineQueryChosenChat(JsonDeserializable, Dictionaryable, JsonSerial
|
|||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return json.dumps(self.to_dict())
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
|
||||||
|
class BotName(JsonDeserializable):
|
||||||
|
"""
|
||||||
|
This object represents a bot name.
|
||||||
|
|
||||||
|
Telegram Documentation: https://core.telegram.org/bots/api#botname
|
||||||
|
|
||||||
|
:param name: The bot name
|
||||||
|
:type name: :obj:`str`
|
||||||
|
|
||||||
|
:return: Instance of the class
|
||||||
|
:rtype: :class:`BotName`
|
||||||
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def de_json(cls, json_string):
|
||||||
|
if json_string is None:
|
||||||
|
return None
|
||||||
|
obj = cls.check_json(json_string)
|
||||||
|
return cls(**obj)
|
||||||
|
|
||||||
|
def __init__(self, name: str):
|
||||||
|
self.name: str = name
|
Loading…
Reference in New Issue
Block a user