added function handle<T> in dispatcher
@@ -328,11 +328,21 @@ where
}
}
UpdateKind::Poll(poll) => {
- if let Some(poll_handler) = &self.poll_handler {
- if let Err(error) = poll_handler
+ self.handle(&self.poll_handler, poll).await;
+ }
+ }
+ })
+ .await
+ }
+
+ async fn handle<U>(&self, handler: &Option<Box<dyn AsyncHandler<HandlerCtx<U>, Result<(), HandlerE>> + 'a>>, update: U)
+ {
+ if let Some(handler) = &handler {
+ if let Err(error) =
+ handler
.handle(HandlerCtx {
bot: Arc::clone(&self.bot),
- update: poll,
+ update
})
.await
{
@@ -341,7 +351,3 @@ where
}
}
}
- })
- .await
- }
-}
