mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Use doc attr for help message instead of #[command(description = "...")]
This commit is contained in:
parent
aaf75fd82c
commit
3ce998e8b8
6 changed files with 34 additions and 28 deletions
|
@ -12,21 +12,19 @@ use teloxide::{prelude::*, types::ChatPermissions, utils::command::BotCommands};
|
|||
// your commands in this format:
|
||||
// %GENERAL-DESCRIPTION%
|
||||
// %PREFIX%%COMMAND% - %DESCRIPTION%
|
||||
|
||||
/// Use commands in format /%command% %num% %unit%
|
||||
#[derive(BotCommands, Clone)]
|
||||
#[command(
|
||||
rename_rule = "lowercase",
|
||||
description = "Use commands in format /%command% %num% %unit%",
|
||||
parse_with = "split"
|
||||
)]
|
||||
#[command(rename_rule = "lowercase", parse_with = "split")]
|
||||
enum Command {
|
||||
#[command(description = "kick user from chat.")]
|
||||
/// Kick user from chat.
|
||||
Kick,
|
||||
#[command(description = "ban user in chat.")]
|
||||
/// Ban user in chat.
|
||||
Ban {
|
||||
time: u64,
|
||||
unit: UnitOfTime,
|
||||
},
|
||||
#[command(description = "mute user in chat.")]
|
||||
/// Mute user in chat.
|
||||
Mute {
|
||||
time: u64,
|
||||
unit: UnitOfTime,
|
||||
|
|
|
@ -9,12 +9,13 @@ use teloxide::{
|
|||
utils::command::BotCommands,
|
||||
};
|
||||
|
||||
/// These commands are supported:
|
||||
#[derive(BotCommands)]
|
||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
||||
#[command(rename_rule = "lowercase")]
|
||||
enum Command {
|
||||
#[command(description = "Display this text")]
|
||||
/// Display this text
|
||||
Help,
|
||||
#[command(description = "Start")]
|
||||
/// Start
|
||||
Start,
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,16 @@ async fn main() {
|
|||
Command::repl(bot, answer).await;
|
||||
}
|
||||
|
||||
/// These commands are supported:
|
||||
#[derive(BotCommands, Clone)]
|
||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
||||
#[command(rename_rule = "lowercase")]
|
||||
enum Command {
|
||||
#[command(description = "display this text.")]
|
||||
/// Display this text.
|
||||
Help,
|
||||
#[command(description = "handle a username.")]
|
||||
/// Handle a username.
|
||||
Username(String),
|
||||
#[command(description = "handle a username and an age.", parse_with = "split")]
|
||||
/// Handle a username and an age.
|
||||
#[command(parse_with = "split")]
|
||||
UsernameAndAge { username: String, age: u8 },
|
||||
}
|
||||
|
||||
|
|
|
@ -21,12 +21,13 @@ pub enum State {
|
|||
GotNumber(i32),
|
||||
}
|
||||
|
||||
/// These commands are supported:
|
||||
#[derive(Clone, BotCommands)]
|
||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
||||
#[command(rename_rule = "lowercase")]
|
||||
pub enum Command {
|
||||
#[command(description = "get your number.")]
|
||||
/// Get your number.
|
||||
Get,
|
||||
#[command(description = "reset your number.")]
|
||||
/// Reset your number.
|
||||
Reset,
|
||||
}
|
||||
|
||||
|
|
|
@ -95,21 +95,24 @@ struct ConfigParameters {
|
|||
maintainer_username: Option<String>,
|
||||
}
|
||||
|
||||
/// Simple commands
|
||||
#[derive(BotCommands, Clone)]
|
||||
#[command(rename_rule = "lowercase", description = "Simple commands")]
|
||||
#[command(rename_rule = "lowercase")]
|
||||
enum SimpleCommand {
|
||||
#[command(description = "shows this message.")]
|
||||
/// Shows this message.
|
||||
Help,
|
||||
#[command(description = "shows maintainer info.")]
|
||||
/// Shows maintainer info.
|
||||
Maintainer,
|
||||
#[command(description = "shows your ID.")]
|
||||
/// Shows your ID.
|
||||
MyId,
|
||||
}
|
||||
|
||||
/// Maintainer commands
|
||||
#[derive(BotCommands, Clone)]
|
||||
#[command(rename_rule = "lowercase", description = "Maintainer commands")]
|
||||
#[command(rename_rule = "lowercase")]
|
||||
enum MaintainerCommands {
|
||||
#[command(parse_with = "split", description = "generate a number within range")]
|
||||
/// Generate a number within range
|
||||
#[command(parse_with = "split")]
|
||||
Rand { from: u64, to: u64 },
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,15 @@ pub enum State {
|
|||
},
|
||||
}
|
||||
|
||||
/// These commands are supported:
|
||||
#[derive(BotCommands, Clone)]
|
||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
||||
#[command(rename_rule = "lowercase")]
|
||||
enum Command {
|
||||
#[command(description = "display this text.")]
|
||||
/// Display this text.
|
||||
Help,
|
||||
#[command(description = "start the purchase procedure.")]
|
||||
/// Start the purchase procedure.
|
||||
Start,
|
||||
#[command(description = "cancel the purchase procedure.")]
|
||||
/// Cancel the purchase procedure.
|
||||
Cancel,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue