#[derive(BotCommands)]
{
// Attributes available to this derive:
#[command]
}
Expand description
Derive macro that generates command-parsing infrastructure for a Telegram bot.
Annotate an enum with #[derive(BotCommands)] to automatically generate:
parse(text, bot_name) -> Result<Self, ParseError>– parse incoming message textdescriptions() -> String– formatted help text for all commandsbot_commands() -> Vec<BotCommand>– suitable for thesetMyCommandsAPI call
§Enum-level attributes
| Attribute | Default | Description |
|---|---|---|
rename_rule | "identity" | How variant names map to command strings |
prefix | "/" | Command prefix character(s) |
description | none | Global description header for help text |
command_separator | " " | Separator between the command and its arguments |
§Variant-level attributes
| Attribute | Description |
|---|---|
description | Help text for this command |
rename | Override the command string for this variant |
parse_with | "default", "split", or a custom fn(String) -> Result<T, E> |
separator | Argument separator when using parse_with = "split" |
hide | Exclude from help text and bot_commands() |