From a22c91df6ce693b6abbf91a0707e5a7283fb0c6e Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Thu, 21 Jul 2022 16:53:52 +0600 Subject: [PATCH] Adjust imports a little bit in `examples/purchase.rs` --- examples/purchase.rs | 19 ++++++++++--------- src/dispatching.rs | 9 +++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/examples/purchase.rs b/examples/purchase.rs index f2f68729..0eac1ad3 100644 --- a/examples/purchase.rs +++ b/examples/purchase.rs @@ -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> { + use dptree::case; + let command_handler = teloxide::filter_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::, State, _>() + dialogue::enter::, State, _>() .branch(message_handler) .branch(callback_query_handler) } diff --git a/src/dispatching.rs b/src/dispatching.rs index e8a744bb..e0440705 100644 --- a/src/dispatching.rs +++ b/src/dispatching.rs @@ -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> { -//! use teloxide::dispatching::dialogue; -//! use teloxide::filter_command; //! use dptree::case; //! -//! let command_handler = filter_command::() +//! let command_handler = teloxide::filter_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::, State, _>()