diff --git a/Cargo.toml b/Cargo.toml index 71fb7fc4..a4fb8abc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,12 +58,12 @@ full = [ [dependencies] teloxide-core = { version = "0.4", default-features = false } -teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros.git", branch = "dispatching2", optional = true } +teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros.git", rev = "57d3e266fa25a6ee2ccbfe140016cdb5d3223147", optional = true } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -dptree = { git = "https://github.com/p0lunin/dptree", optional = true } +dptree = { git = "https://github.com/p0lunin/dptree", rev = "9abc500782e55ed18909e223551f3b6998c9e1f4", optional = true } tokio = { version = "1.8", features = ["fs"] } tokio-util = "0.6" diff --git a/examples/dispatching2_features.rs b/examples/dispatching2_features.rs index bfda06fe..19feb9af 100644 --- a/examples/dispatching2_features.rs +++ b/examples/dispatching2_features.rs @@ -25,7 +25,7 @@ async fn main() { // Filter allow you to filter updates by some condition. dptree::filter( // Note that `async move` is obligatory. - |msg: Message| async move { msg.chat.is_group() || msg.chat.is_supergroup() }, + |msg: Message| msg.chat.is_group() || msg.chat.is_supergroup(), ) // Endpoint is a last message handler. .endpoint(|msg: Message, bot: AutoSend| async move { @@ -60,7 +60,7 @@ async fn main() { ) .branch( // Filter maintainer by used ID. - dptree::filter(|msg: Message, cfg: ConfigParameters| async move { + dptree::filter(|msg: Message, cfg: ConfigParameters| { msg.from().map(|user| user.id == cfg.bot_maintainer).unwrap_or_default() }) .filter_command::() diff --git a/src/dispatching2/filter_ext.rs b/src/dispatching2/filter_ext.rs index f82208cb..5f37f2a0 100644 --- a/src/dispatching2/filter_ext.rs +++ b/src/dispatching2/filter_ext.rs @@ -26,7 +26,7 @@ macro_rules! define_ext { (@impl $for_ty:ty, $func:ident, $proj_fn:expr) => { fn $func() -> Handler<'static, DependencyMap, Out> { dptree::filter_map(move |input: $for_ty| { - async move { $proj_fn(input) } + $proj_fn(input) }) } }; diff --git a/src/dispatching2/handler_ext.rs b/src/dispatching2/handler_ext.rs index bcce99cc..c997f7ef 100644 --- a/src/dispatching2/handler_ext.rs +++ b/src/dispatching2/handler_ext.rs @@ -47,7 +47,7 @@ where { self.chain(dptree::filter_map(move |message: Message, me: Me| { let bot_name = me.user.username.expect("Bots must have a username"); - async move { message.text().and_then(|text| C::parse(text, bot_name).ok()) } + message.text().and_then(|text| C::parse(text, bot_name).ok()) })) } @@ -58,11 +58,11 @@ where D: Default + Send + Sync + 'static, Upd: GetChatId + Clone + Send + Sync + 'static, { - self.chain(dptree::filter_map(|storage: Arc, upd: Upd| async move { + self.chain(dptree::filter_map(|storage: Arc, upd: Upd| { let chat_id = upd.chat_id()?; Some(Dialogue::new(storage, chat_id)) })) - .chain(dptree::filter_map(|dialogue: Dialogue| async move { + .chain(dptree::filter_map_async(|dialogue: Dialogue| async move { dialogue.get_or_default().await.ok() })) }