mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +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_ended`
|
||||||
- `filter_video_chat_participants_invited`
|
- `filter_video_chat_participants_invited`
|
||||||
- `filter_web_app_data`
|
- `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
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
BotCommandScope, CallbackQuery, Chat, ChatId, ChatJoinRequest, ChatMemberUpdated, Message,
|
CallbackQuery, Chat, ChatId, ChatJoinRequest, ChatMemberUpdated, Message,
|
||||||
MessageCommon, Recipient, ResponseParameters, TargetMessage, Update,
|
Recipient, TargetMessage, Update,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Something that may have a chat ID.
|
/// Something that may have a chat ID.
|
||||||
|
@ -9,15 +9,15 @@ pub trait GetChatId {
|
||||||
fn chat_id(&self) -> Option<ChatId>;
|
fn chat_id(&self) -> Option<ChatId>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetChatId for CallbackQuery {
|
impl GetChatId for Message {
|
||||||
fn chat_id(&self) -> Option<ChatId> {
|
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> {
|
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 {
|
impl GetChatId for Chat {
|
||||||
fn chat_id(&self) -> Option<ChatId> {
|
fn chat_id(&self) -> Option<ChatId> {
|
||||||
Some(self.id)
|
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 {
|
impl GetChatId for TargetMessage {
|
||||||
fn chat_id(&self) -> Option<ChatId> {
|
fn chat_id(&self) -> Option<ChatId> {
|
||||||
match self {
|
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 {
|
impl GetChatId for ChatMemberUpdated {
|
||||||
fn chat_id(&self) -> Option<ChatId> {
|
fn chat_id(&self) -> Option<ChatId> {
|
||||||
Some(self.chat.id)
|
Some(self.chat.id)
|
||||||
|
|
Loading…
Reference in a new issue