mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Remove useless impl, order diff
This commit is contained in:
parent
301f5929ad
commit
69874823d7
2 changed files with 7 additions and 36 deletions
|
@ -44,7 +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::{BotCommandScope, Chat, ChatJoinRequest, ChatMemberUpdated, MessageCommon, Recipient, ResponseParameters, TargetMessage}`.
|
||||
- Implement `GetChatId` for `teloxide_core::types::{Chat, ChatJoinRequest, ChatMemberUpdated, Recipient, TargetMessage}`.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::types::{
|
||||
BotCommandScope, CallbackQuery, Chat, ChatId, ChatJoinRequest, ChatMemberUpdated, Message,
|
||||
MessageCommon, Recipient, ResponseParameters, TargetMessage, Update,
|
||||
CallbackQuery, Chat, ChatId, ChatJoinRequest, ChatMemberUpdated, Message,
|
||||
Recipient, TargetMessage, Update,
|
||||
};
|
||||
|
||||
/// Something that may have a chat ID.
|
||||
|
@ -9,15 +9,15 @@ pub trait GetChatId {
|
|||
fn chat_id(&self) -> Option<ChatId>;
|
||||
}
|
||||
|
||||
impl GetChatId for CallbackQuery {
|
||||
impl GetChatId for Message {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
self.message.as_ref().map(|mes| mes.chat.id)
|
||||
Some(self.chat.id)
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for MessageCommon {
|
||||
impl GetChatId for CallbackQuery {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
self.sender_chat.as_ref().map(|chat| chat.id)
|
||||
self.message.as_ref().map(|mes| mes.chat.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,35 +36,12 @@ impl GetChatId for Recipient {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetChatId for BotCommandScope {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
match self {
|
||||
BotCommandScope::Default
|
||||
| BotCommandScope::AllPrivateChats
|
||||
| BotCommandScope::AllGroupChats
|
||||
| BotCommandScope::AllChatAdministrators => None,
|
||||
BotCommandScope::Chat { chat_id: recipient }
|
||||
| BotCommandScope::ChatAdministrators { chat_id: recipient }
|
||||
| BotCommandScope::ChatMember { chat_id: recipient, .. } => recipient.chat_id(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for Chat {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
Some(self.id)
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for ResponseParameters {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
match self {
|
||||
ResponseParameters::MigrateToChatId(chat_id) => Some(*chat_id),
|
||||
ResponseParameters::RetryAfter(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for TargetMessage {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
match self {
|
||||
|
@ -74,12 +51,6 @@ impl GetChatId for TargetMessage {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetChatId for Message {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
Some(self.chat.id)
|
||||
}
|
||||
}
|
||||
|
||||
impl GetChatId for ChatMemberUpdated {
|
||||
fn chat_id(&self) -> Option<ChatId> {
|
||||
Some(self.chat.id)
|
||||
|
|
Loading…
Reference in a new issue