diff --git a/telebot/__init__.py b/telebot/__init__.py index e91eb4d..cf79684 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -3449,6 +3449,19 @@ class TeleBot: """ return apihelper.set_my_short_description(self.token, short_description, language_code) + + def get_my_short_description(self, language_code: Optional[str]=None): + """ + Use this method to get the current bot short description for the given user language. + Returns BotShortDescription on success. + + :param language_code: A two-letter ISO 639-1 language code or an empty string + :type language_code: :obj:`str` + + :return: :class:`telebot.types.BotShortDescription` + """ + + return types.BotShortDescription.de_json(apihelper.get_my_short_description(self.token, language_code)) def set_chat_menu_button(self, chat_id: Union[int, str]=None, menu_button: types.MenuButton=None) -> bool: diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 3807f24..955b655 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1178,6 +1178,13 @@ def set_my_short_description(token, short_description=None, language_code=None): payload['language_code'] = language_code return _make_request(token, method_url, params=payload, method='post') +def get_my_short_description(token, language_code=None): + method_url = r'getMyShortDescription' + payload = {} + if language_code: + payload['language_code'] = language_code + return _make_request(token, method_url, params=payload) + def get_my_commands(token, scope=None, language_code=None): method_url = r'getMyCommands' payload = {} diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 0e1c51e..14b1f6c 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -4287,6 +4287,19 @@ class AsyncTeleBot: return await asyncio_helper.set_my_short_description(self.token, short_description, language_code) + async def get_my_short_description(self, language_code: Optional[str]=None): + """ + Use this method to get the current bot short description for the given user language. + Returns BotShortDescription on success. + + :param language_code: A two-letter ISO 639-1 language code or an empty string + :type language_code: :obj:`str` + + :return: :class:`telebot.types.BotShortDescription` + """ + result = await asyncio_helper.get_my_short_description(self.token, language_code) + return types.BotShortDescription.de_json(result) + async def get_my_commands(self, scope: Optional[types.BotCommandScope], language_code: Optional[str]) -> List[types.BotCommand]: """ diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 2460dd5..cbf7fdc 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -1163,6 +1163,13 @@ async def set_my_short_description(token, short_description=None, language_code= payload['language_code'] = language_code return await _process_request(token, method_url, params=payload, method='post') +async def get_my_short_description(token, language_code=None): + method_url = r'getMyShortDescription' + payload = {} + if language_code: + payload['language_code'] = language_code + return await _process_request(token, method_url, params=payload) + async def get_my_commands(token, scope=None, language_code=None): method_url = r'getMyCommands' payload = {} diff --git a/telebot/types.py b/telebot/types.py index 7ae6b52..bc6dc44 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -7317,4 +7317,27 @@ class BotDescription(JsonDeserializable): return cls(**obj) def __init__(self, description: str) -> None: - self.description: str = description \ No newline at end of file + self.description: str = description + + +class BotShortDescription(JsonDeserializable): + """ + This object represents a bot short description. + + Telegram documentation: https://core.telegram.org/bots/api#botshortdescription + + :param short_description: Bot short description + :type short_description: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotShortDescription` + """ + + @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, short_description: str) -> None: + self.short_description: str = short_description \ No newline at end of file