From e5aafe324539fc2dab246689d6da84956f250e39 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Mon, 25 Apr 2022 19:20:47 +0600 Subject: [PATCH] Separate handlers in `examples/purchase.rs` --- examples/purchase.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/purchase.rs b/examples/purchase.rs index 08e10d03..c547c00a 100644 --- a/examples/purchase.rs +++ b/examples/purchase.rs @@ -61,21 +61,21 @@ async fn main() { ) .branch(teloxide::handler![Command::Cancel].endpoint(cancel)); + let message_handler = Update::filter_message() + .branch(command_handler) + .branch(teloxide::handler![State::ReceiveFullName].endpoint(receive_full_name)) + .branch(dptree::endpoint(invalid_state)); + + let callback_query_handler = Update::filter_callback_query().chain( + teloxide::handler![State::ReceiveProductChoice { full_name }] + .endpoint(receive_product_selection), + ); + Dispatcher::builder( bot, dialogue::enter::, State, _>() - .branch( - Update::filter_message() - .branch(command_handler) - .branch(teloxide::handler![State::ReceiveFullName].endpoint(receive_full_name)) - .branch(dptree::endpoint(invalid_state)), - ) - .branch( - Update::filter_callback_query().chain( - teloxide::handler![State::ReceiveProductChoice { full_name }] - .endpoint(receive_product_selection), - ), - ), + .branch(message_handler) + .branch(callback_query_handler), ) .dependencies(dptree::deps![InMemStorage::::new()]) .build()