mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
1. Bump futures to 0.3.15 version (Abortable::is_aborted()).
2. Fix simple_commands_bot example.
This commit is contained in:
parent
4752b22c43
commit
635c18142a
3 changed files with 14 additions and 10 deletions
|
@ -93,7 +93,7 @@ mime = "0.3"
|
|||
derive_more = "0.99"
|
||||
thiserror = "1.0"
|
||||
async-trait = "0.1"
|
||||
futures = "0.3"
|
||||
futures = "0.3.15"
|
||||
pin-project = "1.0"
|
||||
serde_with_macros = "1.4"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use teloxide::{prelude::*, utils::command::BotCommand};
|
||||
|
||||
use std::error::Error;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(BotCommand)]
|
||||
#[command(rename = "lowercase", description = "These commands are supported:")]
|
||||
|
@ -14,16 +15,19 @@ enum Command {
|
|||
}
|
||||
|
||||
async fn answer(
|
||||
cx: UpdateWithCx<AutoSend<Bot>, Message>,
|
||||
command: Command,
|
||||
bot: Arc<AutoSend<Bot>>,
|
||||
message: Arc<Message>,
|
||||
command: Arc<Command>,
|
||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
match command {
|
||||
Command::Help => cx.answer(Command::descriptions()).await?,
|
||||
match command.as_ref() {
|
||||
Command::Help => {
|
||||
bot.send_message(message.chat.id, Command::descriptions()).await?
|
||||
}
|
||||
Command::Username(username) => {
|
||||
cx.answer(format!("Your username is @{}.", username)).await?
|
||||
bot.send_message(message.chat.id, format!("Your username is @{}.", username)).await?
|
||||
}
|
||||
Command::UsernameAndAge { username, age } => {
|
||||
cx.answer(format!("Your username is @{} and age is {}.", username, age)).await?
|
||||
bot.send_message(message.chat.id, format!("Your username is @{} and age is {}.", username, age)).await?
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -41,6 +45,6 @@ async fn run() {
|
|||
|
||||
let bot = Bot::from_env().auto_send();
|
||||
|
||||
let bot_name: String = panic!("Your bot's name here");
|
||||
teloxide::commands_repl(bot, bot_name, answer).await;
|
||||
let bot_name: String = "".into();// panic!("Your bot's name here");
|
||||
teloxide::commands_repl(bot, bot_name, answer, Command::ty()).await;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ pub use dispatching::repls::{
|
|||
};
|
||||
|
||||
#[cfg(not(feature = "old_dispatching"))]
|
||||
pub use dispatching2::repls::{repl, repl_with_listener};
|
||||
pub use dispatching2::repls::{repl, repl_with_listener, commands_repl, commands_repl_with_listener};
|
||||
|
||||
mod logging;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue