mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
🤖 An elegant Telegram bots framework for Rust
https://docs.rs/teloxide
.github/workflows | ||
src | ||
.gitignore | ||
Cargo.toml | ||
CHANGELOG.md | ||
LICENSE | ||
Readme.md |
teloxide-macros
The teloxide's procedural macros.
Example
use teloxide::utils::command::BotCommand;
#[derive(BotCommand, PartialEq, Debug)]
#[command(rename = "lowercase")]
enum AdminCommand {
Mute,
Ban,
}
let (command, args) = AdminCommand::parse("/ban 5 h", "bot_name").unwrap();
assert_eq!(command, AdminCommand::Ban);
assert_eq!(args, vec!["5", "h"]);
Enum attributes
-
#[command(rename = "rule")]
Rename all commands by rule. Allowed rules arelowercase
. If you will not use this attribute, commands will be parsed by their original names. -
#[command(prefix = "prefix")]
Change a prefix for all commands (the default is/
). -
#[command(description = "description")]
Add a sumary description of commands before all commands.
Variant attributes
-
#[command(rename = "rule")]
Rename one command by a rule. Allowed rules arelowercase
,%some_name%
, where%some_name%
is any string, a new name. -
#[command(prefix = "prefix")]
Change a prefix for one command (the default is/
). -
#[command(description = "description")]
Add a description of one command.
All variant attributes overlap the enum
attributes.