Adjust imports a little bit in examples/purchase.rs

This commit is contained in:
Hirrolot 2022-07-21 16:53:52 +06:00
parent 0cb4bfef36
commit a22c91df6c
2 changed files with 13 additions and 15 deletions

View file

@ -13,7 +13,7 @@
// ```
use teloxide::{
dispatching::{dialogue::InMemStorage, UpdateHandler},
dispatching::{dialogue, dialogue::InMemStorage, UpdateHandler},
prelude::*,
types::{InlineKeyboardButton, InlineKeyboardMarkup},
utils::command::BotCommands,
@ -59,25 +59,26 @@ async fn main() {
}
fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
use dptree::case;
let command_handler = teloxide::filter_command::<Command, _>()
.branch(
dptree::case![State::Start]
.branch(dptree::case![Command::Help].endpoint(help))
.branch(dptree::case![Command::Start].endpoint(start)),
case![State::Start]
.branch(case![Command::Help].endpoint(help))
.branch(case![Command::Start].endpoint(start)),
)
.branch(dptree::case![Command::Cancel].endpoint(cancel));
.branch(case![Command::Cancel].endpoint(cancel));
let message_handler = Update::filter_message()
.branch(command_handler)
.branch(dptree::case![State::ReceiveFullName].endpoint(receive_full_name))
.branch(case![State::ReceiveFullName].endpoint(receive_full_name))
.branch(dptree::endpoint(invalid_state));
let callback_query_handler = Update::filter_callback_query().branch(
dptree::case![State::ReceiveProductChoice { full_name }]
.endpoint(receive_product_selection),
case![State::ReceiveProductChoice { full_name }].endpoint(receive_product_selection),
);
teloxide::dispatching::dialogue::enter::<Update, InMemStorage<State>, State, _>()
dialogue::enter::<Update, InMemStorage<State>, State, _>()
.branch(message_handler)
.branch(callback_query_handler)
}

View file

@ -44,7 +44,7 @@
//!
//! ```no_run
//! # // That's a lot of context needed to compile this, oof
//! # use teloxide::dispatching::{UpdateHandler, UpdateFilterExt, dialogue::InMemStorage};
//! # use teloxide::dispatching::{UpdateHandler, UpdateFilterExt, dialogue, dialogue::InMemStorage};
//! # use teloxide::utils::command::BotCommands;
//! # use teloxide::types::Update;
//! # #[derive(Clone, Default)] pub enum State { #[default] Start, ReceiveFullName, ReceiveProductChoice { full_name: String } }
@ -58,11 +58,9 @@
//! # async fn receive_product_selection() -> HandlerResult { Ok(()) }
//! #
//! fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
//! use teloxide::dispatching::dialogue;
//! use teloxide::filter_command;
//! use dptree::case;
//!
//! let command_handler = filter_command::<Command, _>()
//! let command_handler = teloxide::filter_command::<Command, _>()
//! .branch(
//! case![State::Start]
//! .branch(case![Command::Help].endpoint(help))
@ -76,8 +74,7 @@
//! .branch(dptree::endpoint(invalid_state));
//!
//! let callback_query_handler = Update::filter_callback_query().branch(
//! case![State::ReceiveProductChoice { full_name }]
//! .endpoint(receive_product_selection),
//! case![State::ReceiveProductChoice { full_name }].endpoint(receive_product_selection),
//! );
//!
//! dialogue::enter::<Update, InMemStorage<State>, State, _>()