mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-22 06:45:37 +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
|
## unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Implement `GetChatId` for `Update`.
|
||||||
|
|
||||||
## 0.8.0 - 2022-04-18
|
## 0.8.0 - 2022-04-18
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::types::CallbackQuery;
|
use crate::types::{CallbackQuery, ChatId, Message, Update};
|
||||||
use teloxide_core::types::{ChatId, Message};
|
|
||||||
|
|
||||||
/// Something that may has a chat ID.
|
/// Something that may has a chat ID.
|
||||||
pub trait GetChatId {
|
pub trait GetChatId {
|
||||||
|
@ -18,3 +17,9 @@ impl GetChatId for CallbackQuery {
|
||||||
self.message.as_ref().map(|mes| mes.chat.id)
|
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…
Add table
Reference in a new issue