From 1f95c1d2b3bf8150362b3669810e653da1548d9b Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Mon, 21 Mar 2022 21:11:46 +0600 Subject: [PATCH] Don't warn abount unhandled updates in `repls2` --- CHANGELOG.md | 1 + src/dispatching2/repls/commands_repl.rs | 5 +++++ src/dispatching2/repls/repl.rs | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e209ec5..6cef4f5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Log `UpdateKind::Error` in `teloxide::dispatching2::Dispatcher`. +- Don't warn about unhandled updates in `repls2` ([issue 557](https://github.com/teloxide/teloxide/issues/557)). ## 0.7.1 - 2022-03-09 diff --git a/src/dispatching2/repls/commands_repl.rs b/src/dispatching2/repls/commands_repl.rs index 320381fa..488d8313 100644 --- a/src/dispatching2/repls/commands_repl.rs +++ b/src/dispatching2/repls/commands_repl.rs @@ -76,10 +76,15 @@ pub async fn commands_repl_with_listener<'a, R, Cmd, H, L, ListenerE, E, Args>( { use crate::dispatching2::Dispatcher; + // Other update types are of no interest to use since this REPL is only for + // commands. See . + let ignore_update = |_upd| Box::pin(async {}); + let mut dispatcher = Dispatcher::builder( bot, Update::filter_message().filter_command::().branch(dptree::endpoint(handler)), ) + .default_handler(ignore_update) .build(); #[cfg(feature = "ctrlc_handler")] diff --git a/src/dispatching2/repls/repl.rs b/src/dispatching2/repls/repl.rs index 6a047b98..497e4f3a 100644 --- a/src/dispatching2/repls/repl.rs +++ b/src/dispatching2/repls/repl.rs @@ -56,9 +56,14 @@ where { use crate::dispatching2::Dispatcher; + // Other update types are of no interest to use since this REPL is only for + // messages. See . + let ignore_update = |_upd| Box::pin(async {}); + #[allow(unused_mut)] let mut dispatcher = Dispatcher::builder(bot, Update::filter_message().branch(dptree::endpoint(handler))) + .default_handler(ignore_update) .build(); #[cfg(feature = "ctrlc_handler")]