mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 17:52:12 +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:
|
// your commands in this format:
|
||||||
// %GENERAL-DESCRIPTION%
|
// %GENERAL-DESCRIPTION%
|
||||||
// %PREFIX%%COMMAND% - %DESCRIPTION%
|
// %PREFIX%%COMMAND% - %DESCRIPTION%
|
||||||
|
|
||||||
|
/// Use commands in format /%command% %num% %unit%
|
||||||
#[derive(BotCommands, Clone)]
|
#[derive(BotCommands, Clone)]
|
||||||
#[command(
|
#[command(rename_rule = "lowercase", parse_with = "split")]
|
||||||
rename_rule = "lowercase",
|
|
||||||
description = "Use commands in format /%command% %num% %unit%",
|
|
||||||
parse_with = "split"
|
|
||||||
)]
|
|
||||||
enum Command {
|
enum Command {
|
||||||
#[command(description = "kick user from chat.")]
|
/// Kick user from chat.
|
||||||
Kick,
|
Kick,
|
||||||
#[command(description = "ban user in chat.")]
|
/// Ban user in chat.
|
||||||
Ban {
|
Ban {
|
||||||
time: u64,
|
time: u64,
|
||||||
unit: UnitOfTime,
|
unit: UnitOfTime,
|
||||||
},
|
},
|
||||||
#[command(description = "mute user in chat.")]
|
/// Mute user in chat.
|
||||||
Mute {
|
Mute {
|
||||||
time: u64,
|
time: u64,
|
||||||
unit: UnitOfTime,
|
unit: UnitOfTime,
|
||||||
|
|
|
@ -9,12 +9,13 @@ use teloxide::{
|
||||||
utils::command::BotCommands,
|
utils::command::BotCommands,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// These commands are supported:
|
||||||
#[derive(BotCommands)]
|
#[derive(BotCommands)]
|
||||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
#[command(rename_rule = "lowercase")]
|
||||||
enum Command {
|
enum Command {
|
||||||
#[command(description = "Display this text")]
|
/// Display this text
|
||||||
Help,
|
Help,
|
||||||
#[command(description = "Start")]
|
/// Start
|
||||||
Start,
|
Start,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,16 @@ async fn main() {
|
||||||
Command::repl(bot, answer).await;
|
Command::repl(bot, answer).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// These commands are supported:
|
||||||
#[derive(BotCommands, Clone)]
|
#[derive(BotCommands, Clone)]
|
||||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
#[command(rename_rule = "lowercase")]
|
||||||
enum Command {
|
enum Command {
|
||||||
#[command(description = "display this text.")]
|
/// Display this text.
|
||||||
Help,
|
Help,
|
||||||
#[command(description = "handle a username.")]
|
/// Handle a username.
|
||||||
Username(String),
|
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 },
|
UsernameAndAge { username: String, age: u8 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,13 @@ pub enum State {
|
||||||
GotNumber(i32),
|
GotNumber(i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// These commands are supported:
|
||||||
#[derive(Clone, BotCommands)]
|
#[derive(Clone, BotCommands)]
|
||||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
#[command(rename_rule = "lowercase")]
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
#[command(description = "get your number.")]
|
/// Get your number.
|
||||||
Get,
|
Get,
|
||||||
#[command(description = "reset your number.")]
|
/// Reset your number.
|
||||||
Reset,
|
Reset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,21 +95,24 @@ struct ConfigParameters {
|
||||||
maintainer_username: Option<String>,
|
maintainer_username: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Simple commands
|
||||||
#[derive(BotCommands, Clone)]
|
#[derive(BotCommands, Clone)]
|
||||||
#[command(rename_rule = "lowercase", description = "Simple commands")]
|
#[command(rename_rule = "lowercase")]
|
||||||
enum SimpleCommand {
|
enum SimpleCommand {
|
||||||
#[command(description = "shows this message.")]
|
/// Shows this message.
|
||||||
Help,
|
Help,
|
||||||
#[command(description = "shows maintainer info.")]
|
/// Shows maintainer info.
|
||||||
Maintainer,
|
Maintainer,
|
||||||
#[command(description = "shows your ID.")]
|
/// Shows your ID.
|
||||||
MyId,
|
MyId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Maintainer commands
|
||||||
#[derive(BotCommands, Clone)]
|
#[derive(BotCommands, Clone)]
|
||||||
#[command(rename_rule = "lowercase", description = "Maintainer commands")]
|
#[command(rename_rule = "lowercase")]
|
||||||
enum MaintainerCommands {
|
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 },
|
Rand { from: u64, to: u64 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,15 @@ pub enum State {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// These commands are supported:
|
||||||
#[derive(BotCommands, Clone)]
|
#[derive(BotCommands, Clone)]
|
||||||
#[command(rename_rule = "lowercase", description = "These commands are supported:")]
|
#[command(rename_rule = "lowercase")]
|
||||||
enum Command {
|
enum Command {
|
||||||
#[command(description = "display this text.")]
|
/// Display this text.
|
||||||
Help,
|
Help,
|
||||||
#[command(description = "start the purchase procedure.")]
|
/// Start the purchase procedure.
|
||||||
Start,
|
Start,
|
||||||
#[command(description = "cancel the purchase procedure.")]
|
/// Cancel the purchase procedure.
|
||||||
Cancel,
|
Cancel,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue