Implement GetChatId for Update

This commit is contained in:
Hirrolot 2022-04-22 23:42:39 +06:00
parent a0d5f50d89
commit 66b9a718d1
2 changed files with 11 additions and 2 deletions

View file

@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## unreleased
### Added
- Implement `GetChatId` for `Update`.
## 0.8.0 - 2022-04-18
### Removed

View file

@ -1,5 +1,4 @@
use crate::types::CallbackQuery;
use teloxide_core::types::{ChatId, Message};
use crate::types::{CallbackQuery, ChatId, Message, Update};
/// Something that may has a chat ID.
pub trait GetChatId {
@ -18,3 +17,9 @@ impl GetChatId for CallbackQuery {
self.message.as_ref().map(|mes| mes.chat.id)
}
}
impl GetChatId for Update {
fn chat_id(&self) -> Option<ChatId> {
self.chat().map(|chat| chat.id)
}
}