mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Implement GetChatId
for Update
This commit is contained in:
parent
a0d5f50d89
commit
66b9a718d1
2 changed files with 11 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue