Fix the examples

This commit is contained in:
Temirkhan Myrzamadi 2020-02-23 19:36:31 +06:00
parent 1f1234c9bf
commit fb6e295447
4 changed files with 5 additions and 4 deletions

View file

@ -136,7 +136,7 @@ async fn answer(
async fn handle_commands(rx: DispatcherHandlerRx<Message>) {
// Only iterate through commands in a proper format:
rx.commands::<Command>()
rx.commands::<Command, &str>(panic!("Insert here your bot's name"))
// Execute all incoming commands concurrently:
.for_each_concurrent(None, |(cx, command, _)| async move {
answer(cx, command).await.log_on_error().await;

View file

@ -179,7 +179,7 @@ async fn handle_commands(rx: DispatcherHandlerRx<Message>) {
// Only iterate through messages from groups:
rx.filter(|cx| future::ready(cx.update.chat.is_group()))
// Only iterate through commands in a proper format:
.commands::<Command, &str>(panic!("Insert here bot username"))
.commands::<Command, &str>(panic!("Insert here your bot's name"))
// Execute all incoming commands concurrently:
.for_each_concurrent(None, |(cx, command, args)| async move {
action(cx, command, &args).await.log_on_error().await;

View file

@ -32,7 +32,7 @@ async fn answer(
async fn handle_commands(rx: DispatcherHandlerRx<Message>) {
// Only iterate through commands in a proper format:
rx.commands::<Command, &str>(panic!("Insert here bot username"))
rx.commands::<Command, &str>(panic!("Insert here your bot's name"))
// Execute all incoming commands concurrently:
.for_each_concurrent(None, |(cx, command, _)| async move {
answer(cx, command).await.log_on_error().await;

View file

@ -72,6 +72,7 @@
//! ([Full](https://github.com/teloxide/teloxide/blob/master/examples/simple_commands_bot/src/main.rs))
//! ```no_run
//! // Imports are omitted...
//! # #[allow(unreachable_code)]
//! # use teloxide::{prelude::*, utils::command::BotCommand};
//! # use rand::{thread_rng, Rng};
//!
@ -108,7 +109,7 @@
//!
//! async fn handle_commands(rx: DispatcherHandlerRx<Message>) {
//! // Only iterate through commands in a proper format:
//! rx.commands::<Command, _>("bot_name")
//! rx.commands::<Command, &str>(panic!("Insert here your bot's name"))
//! // Execute all incoming commands concurrently:
//! .for_each_concurrent(None, |(cx, command, _)| async move {
//! answer(cx, command).await.log_on_error().await;