From fa17b48793a6b549ea4c6d8bb9a9e62fba7eeb6e Mon Sep 17 00:00:00 2001 From: Akshett Rai Jindal Date: Wed, 21 Aug 2024 01:02:32 +0530 Subject: [PATCH] Add `BusinessIntro` class and corres. field to `ChatPrivate` --- crates/teloxide-core/src/types.rs | 2 ++ .../teloxide-core/src/types/business_intro.rs | 15 ++++++++++++++ crates/teloxide-core/src/types/chat.rs | 20 +++++++++++++++---- crates/teloxide-core/src/types/message.rs | 1 + crates/teloxide-core/src/types/update.rs | 1 + 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 crates/teloxide-core/src/types/business_intro.rs diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index f8219d75..0f8a6315 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -9,6 +9,7 @@ pub use bot_command_scope::*; pub use bot_description::*; pub use bot_name::*; pub use bot_short_description::*; +pub use business_intro::*; pub use callback_game::*; pub use callback_query::*; pub use chat::*; @@ -164,6 +165,7 @@ mod bot_command_scope; mod bot_description; mod bot_name; mod bot_short_description; +mod business_intro; mod callback_game; mod callback_query; mod chat; diff --git a/crates/teloxide-core/src/types/business_intro.rs b/crates/teloxide-core/src/types/business_intro.rs new file mode 100644 index 00000000..fbfd4b66 --- /dev/null +++ b/crates/teloxide-core/src/types/business_intro.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::types::Sticker; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct BusinessIntro { + /// Title text of the business intro + pub title: Option, + + /// Message text of the business intro + pub message: Option, + + /// Sticker of the business intro + pub sticker: Option, +} diff --git a/crates/teloxide-core/src/types/chat.rs b/crates/teloxide-core/src/types/chat.rs index 41fae489..fed38b57 100644 --- a/crates/teloxide-core/src/types/chat.rs +++ b/crates/teloxide-core/src/types/chat.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; use crate::types::{ - ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, ReactionType, Seconds, - True, User, + BusinessIntro, ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, + ReactionType, Seconds, True, User, }; use super::Birthdate; @@ -147,6 +147,12 @@ pub struct ChatPrivate { /// /// [`GetChat`]: crate::payloads::GetChat pub birthdate: Option, + + /// For private chats with business accounts, the intro of the business. + /// Returned only in [`GetChat`]. + /// + /// [`GetChat`]: crate::payloads::GetChat + pub business_intro: Option, } #[serde_with::skip_serializing_none] @@ -577,8 +583,7 @@ impl Chat { } mod serde_helper { - use super::Birthdate; - use crate::types::True; + use crate::types::{Birthdate, BusinessIntro, True}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] @@ -601,6 +606,7 @@ mod serde_helper { has_restricted_voice_and_video_messages: Option, personal_chat: Option>, birthdate: Option, + business_intro: Option, } impl From for super::ChatPrivate { @@ -615,6 +621,7 @@ mod serde_helper { has_restricted_voice_and_video_messages, personal_chat, birthdate, + business_intro, }: ChatPrivate, ) -> Self { Self { @@ -626,6 +633,7 @@ mod serde_helper { has_restricted_voice_and_video_messages, personal_chat, birthdate, + business_intro, } } } @@ -641,6 +649,7 @@ mod serde_helper { has_restricted_voice_and_video_messages, personal_chat, birthdate, + business_intro, }: super::ChatPrivate, ) -> Self { Self { @@ -653,6 +662,7 @@ mod serde_helper { has_restricted_voice_and_video_messages, personal_chat, birthdate, + business_intro, } } } @@ -717,6 +727,7 @@ mod tests { has_restricted_voice_and_video_messages: None, personal_chat: None, birthdate: None, + business_intro: None, }), photo: None, available_reactions: Some(vec![ReactionType::Emoji { emoji: "🌭".to_owned() }]), @@ -757,6 +768,7 @@ mod tests { has_restricted_voice_and_video_messages: None, personal_chat: None, birthdate: None, + business_intro: None, }), photo: None, available_reactions: None, diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index 71b6cd9e..ba5186ad 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -1904,6 +1904,7 @@ mod tests { has_restricted_voice_and_video_messages: None, personal_chat: None, birthdate: None, + business_intro: None, }), photo: None, available_reactions: None, diff --git a/crates/teloxide-core/src/types/update.rs b/crates/teloxide-core/src/types/update.rs index ca33cc8c..3f9251fe 100644 --- a/crates/teloxide-core/src/types/update.rs +++ b/crates/teloxide-core/src/types/update.rs @@ -537,6 +537,7 @@ mod test { has_restricted_voice_and_video_messages: None, personal_chat: None, birthdate: None, + business_intro: None, }), photo: None, available_reactions: None,