Helpers for defining and registering Telegram bot commands.
defcommand/3 defines a regular handle_message/2 clause for messages that
start with a Telegram command and stores metadata for setMyCommands.
register_all/2 is called by TelegramEx.Server on startup. It reads command
metadata from the bot module and its routers, then sends the list to Telegram
using setMyCommands.
See Commands for examples and binding rules.
Fields
:command- The command name (string):description- Command description used by Telegram clients:message- The original message struct (TelegramEx.Types.Message.t())
Summary
Functions
Defines a command handler and adds the command to the module metadata.
Registers all commands defined in a bot module and its routers.
Types
@type t() :: %TelegramEx.Command{ command: String.t(), description: String.t() | nil, message: TelegramEx.Types.Message.t() }
Command struct type.
Contains all fields related to a Telegram command.
Functions
Defines a command handler and adds the command to the module metadata.
The command name should be passed without the leading slash. :description
is required because Telegram requires it for setMyCommands.
See Commands for full examples.
Registers all commands defined in a bot module and its routers.