mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 15:01:45 +01:00
parent
e7ef38c1b2
commit
69096dc01d
1 changed files with 4 additions and 25 deletions
|
@ -227,16 +227,16 @@ where
|
|||
|
||||
match kind {
|
||||
UpdateKind::Message(mes) => {
|
||||
self.handle_message(mes, &self.message_handlers).await;
|
||||
call!(self.message_handlers, mes)
|
||||
}
|
||||
UpdateKind::EditedMessage(mes) => {
|
||||
self.handle_message(mes, &self.edited_message_handlers).await;
|
||||
call!(self.edited_message_handlers, mes)
|
||||
}
|
||||
UpdateKind::ChannelPost(post) => {
|
||||
self.handle_message(post, &self.channel_post_handlers).await;
|
||||
call!(self.channel_post_handlers, post)
|
||||
}
|
||||
UpdateKind::EditedChannelPost(post) => {
|
||||
self.handle_message(post, &self.edited_channel_post_handlers).await;
|
||||
call!(self.edited_channel_post_handlers, post)
|
||||
}
|
||||
UpdateKind::InlineQuery(query) => {
|
||||
call!(self.inline_query_handlers, query)
|
||||
|
@ -252,27 +252,6 @@ where
|
|||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn handle_message(&self, message: Message, handlers: &Handlers<'a, Message, E>) {
|
||||
let handler = handlers.iter().find_map(|e|{
|
||||
let (filter, handler) = e;
|
||||
if filter.test(&message) {
|
||||
Some(handler)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
match handler {
|
||||
Some(handler) => {
|
||||
if let Err(err) = handler.handle(message).await {
|
||||
self.error_policy.handle_error(err).await
|
||||
}
|
||||
}
|
||||
None => {
|
||||
log::warn!("unhandled update {:?}", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(? Send)]
|
||||
|
|
Loading…
Reference in a new issue