mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-20 13:59:00 +01:00
Adjust imports a little bit in examples/purchase.rs
This commit is contained in:
parent
0cb4bfef36
commit
a22c91df6c
2 changed files with 13 additions and 15 deletions
|
@ -13,7 +13,7 @@
|
||||||
// ```
|
// ```
|
||||||
|
|
||||||
use teloxide::{
|
use teloxide::{
|
||||||
dispatching::{dialogue::InMemStorage, UpdateHandler},
|
dispatching::{dialogue, dialogue::InMemStorage, UpdateHandler},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
types::{InlineKeyboardButton, InlineKeyboardMarkup},
|
types::{InlineKeyboardButton, InlineKeyboardMarkup},
|
||||||
utils::command::BotCommands,
|
utils::command::BotCommands,
|
||||||
|
@ -59,25 +59,26 @@ async fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
|
fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
|
||||||
|
use dptree::case;
|
||||||
|
|
||||||
let command_handler = teloxide::filter_command::<Command, _>()
|
let command_handler = teloxide::filter_command::<Command, _>()
|
||||||
.branch(
|
.branch(
|
||||||
dptree::case![State::Start]
|
case![State::Start]
|
||||||
.branch(dptree::case![Command::Help].endpoint(help))
|
.branch(case![Command::Help].endpoint(help))
|
||||||
.branch(dptree::case![Command::Start].endpoint(start)),
|
.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()
|
let message_handler = Update::filter_message()
|
||||||
.branch(command_handler)
|
.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));
|
.branch(dptree::endpoint(invalid_state));
|
||||||
|
|
||||||
let callback_query_handler = Update::filter_callback_query().branch(
|
let callback_query_handler = Update::filter_callback_query().branch(
|
||||||
dptree::case![State::ReceiveProductChoice { full_name }]
|
case![State::ReceiveProductChoice { full_name }].endpoint(receive_product_selection),
|
||||||
.endpoint(receive_product_selection),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
teloxide::dispatching::dialogue::enter::<Update, InMemStorage<State>, State, _>()
|
dialogue::enter::<Update, InMemStorage<State>, State, _>()
|
||||||
.branch(message_handler)
|
.branch(message_handler)
|
||||||
.branch(callback_query_handler)
|
.branch(callback_query_handler)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! # // That's a lot of context needed to compile this, oof
|
//! # // 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::utils::command::BotCommands;
|
||||||
//! # use teloxide::types::Update;
|
//! # use teloxide::types::Update;
|
||||||
//! # #[derive(Clone, Default)] pub enum State { #[default] Start, ReceiveFullName, ReceiveProductChoice { full_name: String } }
|
//! # #[derive(Clone, Default)] pub enum State { #[default] Start, ReceiveFullName, ReceiveProductChoice { full_name: String } }
|
||||||
|
@ -58,11 +58,9 @@
|
||||||
//! # async fn receive_product_selection() -> HandlerResult { Ok(()) }
|
//! # async fn receive_product_selection() -> HandlerResult { Ok(()) }
|
||||||
//! #
|
//! #
|
||||||
//! fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
|
//! fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
|
||||||
//! use teloxide::dispatching::dialogue;
|
|
||||||
//! use teloxide::filter_command;
|
|
||||||
//! use dptree::case;
|
//! use dptree::case;
|
||||||
//!
|
//!
|
||||||
//! let command_handler = filter_command::<Command, _>()
|
//! let command_handler = teloxide::filter_command::<Command, _>()
|
||||||
//! .branch(
|
//! .branch(
|
||||||
//! case![State::Start]
|
//! case![State::Start]
|
||||||
//! .branch(case![Command::Help].endpoint(help))
|
//! .branch(case![Command::Help].endpoint(help))
|
||||||
|
@ -76,8 +74,7 @@
|
||||||
//! .branch(dptree::endpoint(invalid_state));
|
//! .branch(dptree::endpoint(invalid_state));
|
||||||
//!
|
//!
|
||||||
//! let callback_query_handler = Update::filter_callback_query().branch(
|
//! let callback_query_handler = Update::filter_callback_query().branch(
|
||||||
//! case![State::ReceiveProductChoice { full_name }]
|
//! case![State::ReceiveProductChoice { full_name }].endpoint(receive_product_selection),
|
||||||
//! .endpoint(receive_product_selection),
|
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
//! dialogue::enter::<Update, InMemStorage<State>, State, _>()
|
//! dialogue::enter::<Update, InMemStorage<State>, State, _>()
|
||||||
|
|
Loading…
Add table
Reference in a new issue