diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 8e2538a6..6f3dc951 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -206,6 +206,7 @@ class Methods(Helper): SET_CHAT_STICKER_SET = Item() # setChatStickerSet DELETE_CHAT_STICKER_SET = Item() # deleteChatStickerSet ANSWER_CALLBACK_QUERY = Item() # answerCallbackQuery + SET_MY_COMMANDS = Item() # setMyCommands # Updating messages EDIT_MESSAGE_TEXT = Item() # editMessageText diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 914fbd82..1b1e8615 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -1520,6 +1520,24 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): result = await self.request(api.Methods.ANSWER_CALLBACK_QUERY, payload) return result + async def set_my_commands(self, commands: typing.List[types.BotCommand]) -> base.Boolean: + """ + Use this method to change the list of the bot's commands. + + Source: https://core.telegram.org/bots/api#setmycommands + + :param commands: A JSON-serialized list of bot commands to be set as the list of the bot's commands. + At most 100 commands can be specified. + :type commands: :obj: `typing.List[types.BotCommand]` + :return: Returns True on success. + :rtype: base.Boolean + """ + commands = prepare_arg(commands) + payload = generate_payload(**locals()) + + result = await self.request(api.Methods.SET_MY_COMMANDS, payload) + return result + async def edit_message_text(self, text: base.String, chat_id: typing.Union[base.Integer, base.String, None] = None, message_id: typing.Union[base.Integer, None] = None, diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index 7d201ede..693bd7d5 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -3,6 +3,7 @@ from . import fields from .animation import Animation from .audio import Audio from .auth_widget_data import AuthWidgetData +from .bot_command import BotCommand from .callback_game import CallbackGame from .callback_query import CallbackQuery from .chat import Chat, ChatActions, ChatType diff --git a/aiogram/types/bot_command.py b/aiogram/types/bot_command.py new file mode 100644 index 00000000..a97238e5 --- /dev/null +++ b/aiogram/types/bot_command.py @@ -0,0 +1,12 @@ +from . import base +from . import fields + + +class BotCommand(base.TelegramObject): + """ + This object represents a bot command. + + https://core.telegram.org/bots/api#botcommand + """ + command: base.String = fields.Field() + description: base.String = fields.Field()