mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
#289 added setMyCommands method; added BotCommand type
This commit is contained in:
parent
0f245bbf56
commit
b77ed1ad92
4 changed files with 32 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
12
aiogram/types/bot_command.py
Normal file
12
aiogram/types/bot_command.py
Normal file
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue