mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Merge pull request #1005 from Henriquelay/master
Implement `GetChatId` for `teloxide-core::types::*`
This commit is contained in:
commit
60d092882f
2 changed files with 23 additions and 2 deletions
|
@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `filter_video_chat_ended`
|
||||
- `filter_video_chat_participants_invited`
|
||||
- `filter_web_app_data`
|
||||
- Implement `GetChatId` for `teloxide_core::types::{Chat, ChatJoinRequest, ChatMemberUpdated}`.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use crate::types::{CallbackQuery, ChatId, Message, Update};
|
||||
use crate::types::{
|
||||
CallbackQuery, Chat, ChatId, ChatJoinRequest, ChatMemberUpdated, Message, Update,
|
||||
};
|
||||
|
||||
/// Something that may has a chat ID.
|
||||
/// Something that may have a chat ID.
|
||||
pub trait GetChatId {
|
||||
#[must_use]
|
||||
fn chat_id(&self) -> Option<ChatId>;
|
||||
|
@ -23,3 +25,21 @@ impl GetChatId for Update {
|
|||
self.chat().map(|chat| chat.id)
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for Chat {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
Some(self.id)
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for ChatMemberUpdated {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
Some(self.chat.id)
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for ChatJoinRequest {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
Some(self.chat.id)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue