From 397ed69f8fc5c8abde1546165a07faa1cb9e452e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Apr 2024 11:53:33 +0300 Subject: [PATCH 1/2] Bot API 7.2 - Information about Business Accounts --- src/objects.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/objects.rs b/src/objects.rs index dc84abc..cc09cfd 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -505,6 +505,18 @@ pub struct Chat { #[builder(setter(into, strip_option), default)] pub active_usernames: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub business_intro: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub business_location: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub business_opening_hours: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub available_reactions: Option>, @@ -1975,6 +1987,45 @@ pub struct ChatPermissions { pub can_manage_topics: Option, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct BusinessIntro { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub title: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub message: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub sticker: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct BusinessLocation { + #[builder(setter(into))] + pub address: String, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub location: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct BusinessOpeningHoursInterval { + pub opening_minute: u16, + + pub closing_minute: u16, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct BusinessOpeningHours { + pub time_zone_name: String, + + pub opening_hours: Vec, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] pub struct ChatLocation { pub location: Location, From 36ec56a4b0ced009be5a95ceed01318922ba0dad Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Apr 2024 14:27:54 +0300 Subject: [PATCH 2/2] Bot API 7.2 - Mixed-Format Sticker Packs (#158) * Bot API 7.2 - Mixed-Format Sticker Packs * Bot API 7.2 - Request Chat Improvements (#159) * Bot API 7.2 - Request Chat Improvements * Bot API 7.2 - Other Changes (#160) --- src/api/telegram_api_impl.rs | 2 +- src/api_params.rs | 17 +++++- src/api_traits/async_telegram_api.rs | 8 +++ src/api_traits/telegram_api.rs | 8 +++ src/objects.rs | 89 ++++++++++++++++++++++++++-- 5 files changed, 116 insertions(+), 8 deletions(-) diff --git a/src/api/telegram_api_impl.rs b/src/api/telegram_api_impl.rs index e14a297..a2b6d7a 100644 --- a/src/api/telegram_api_impl.rs +++ b/src/api/telegram_api_impl.rs @@ -1750,7 +1750,7 @@ mod tests { #[test] fn get_sticker_set_success() { - let response_string = "{\"ok\":true,\"result\":{\"name\":\"unocards\",\"title\":\"UNO Bot\",\"sticker_type\":\"regular\",\"is_animated\":false,\"is_video\":false,\"contains_masks\":false,\"stickers\":[{\"file_id\":\"CAACAgQAAxUAAWCDxAQVJ6X7FGiBD5NyjN5DDvgfAALZAQACX1eZAAEqnpNt3SpG_x8E\",\"file_unique_id\":\"AgAD2QEAAl9XmQAB\",\"type\":\"regular\",\"width\":342,\"height\":512,\"is_animated\":false,\"is_video\":false,\"thumbnail\":{\"file_id\":\"AAMCBAADFQABYIPEBBUnpfsUaIEPk3KM3kMO-B8AAtkBAAJfV5kAASqek23dKkb_P75BGQAEAQAHbQADBBEAAh8E\",\"file_unique_id\":\"AQADP75BGQAEBBEAAg\",\"width\":85,\"height\":128,\"file_size\":2452},\"emoji\":\"dd\",\"set_name\":\"unocards\",\"file_size\":8898}]}}"; + let response_string = "{\"ok\":true,\"result\":{\"name\":\"unocards\",\"title\":\"UNO Bot\",\"sticker_type\":\"regular\",\"contains_masks\":false,\"stickers\":[{\"file_id\":\"CAACAgQAAxUAAWCDxAQVJ6X7FGiBD5NyjN5DDvgfAALZAQACX1eZAAEqnpNt3SpG_x8E\",\"file_unique_id\":\"AgAD2QEAAl9XmQAB\",\"type\":\"regular\",\"width\":342,\"height\":512,\"is_animated\":false,\"is_video\":false,\"thumbnail\":{\"file_id\":\"AAMCBAADFQABYIPEBBUnpfsUaIEPk3KM3kMO-B8AAtkBAAJfV5kAASqek23dKkb_P75BGQAEAQAHbQADBBEAAh8E\",\"file_unique_id\":\"AQADP75BGQAEBBEAAg\",\"width\":85,\"height\":128,\"file_size\":2452},\"emoji\":\"dd\",\"set_name\":\"unocards\",\"file_size\":8898}]}}"; let params = GetStickerSetParams::builder().name("unocards").build(); let mut server = mockito::Server::new(); diff --git a/src/api_params.rs b/src/api_params.rs index 2379a02..a0520bf 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -1983,8 +1983,6 @@ pub struct CreateNewStickerSetParams { pub stickers: Vec, - pub sticker_format: StickerFormat, - #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option))] pub sticker_type: Option, @@ -2024,6 +2022,19 @@ pub struct DeleteStickerFromSetParams { pub sticker: String, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct ReplaceStickerInSetParams { + pub user_id: u64, + + #[builder(setter(into))] + pub name: String, + + #[builder(setter(into))] + pub old_sticker: String, + + pub sticker: InputSticker, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct SetStickerEmojiListParams { #[builder(setter(into))] @@ -2071,6 +2082,8 @@ pub struct SetStickerSetThumbnailParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub thumbnail: Option, + + pub format: StickerFormat, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] diff --git a/src/api_traits/async_telegram_api.rs b/src/api_traits/async_telegram_api.rs index b498499..aad0d64 100644 --- a/src/api_traits/async_telegram_api.rs +++ b/src/api_traits/async_telegram_api.rs @@ -65,6 +65,7 @@ use crate::api_params::PinChatMessageParams; use crate::api_params::PromoteChatMemberParams; use crate::api_params::ReopenForumTopicParams; use crate::api_params::ReopenGeneralForumTopicParams; +use crate::api_params::ReplaceStickerInSetParams; use crate::api_params::RestrictChatMemberParams; use crate::api_params::RevokeChatInviteLinkParams; use crate::api_params::SendAnimationParams; @@ -1174,6 +1175,13 @@ pub trait AsyncTelegramApi { self.request("setStickerPositionInSet", Some(params)).await } + async fn replace_sticker_in_set( + &self, + params: &ReplaceStickerInSetParams, + ) -> Result, Self::Error> { + self.request("replaceStickerInSet", Some(params)).await + } + async fn delete_sticker_from_set( &self, params: &DeleteStickerFromSetParams, diff --git a/src/api_traits/telegram_api.rs b/src/api_traits/telegram_api.rs index 9e749cc..d08abc8 100644 --- a/src/api_traits/telegram_api.rs +++ b/src/api_traits/telegram_api.rs @@ -64,6 +64,7 @@ use crate::api_params::PinChatMessageParams; use crate::api_params::PromoteChatMemberParams; use crate::api_params::ReopenForumTopicParams; use crate::api_params::ReopenGeneralForumTopicParams; +use crate::api_params::ReplaceStickerInSetParams; use crate::api_params::RestrictChatMemberParams; use crate::api_params::RevokeChatInviteLinkParams; use crate::api_params::SendAnimationParams; @@ -1126,6 +1127,13 @@ pub trait TelegramApi { self.request("deleteStickerFromSet", Some(params)) } + fn replace_sticker_in_set( + &self, + params: &ReplaceStickerInSetParams, + ) -> Result, Self::Error> { + self.request("replaceStickerInSet", Some(params)) + } + fn set_sticker_emoji_list( &self, params: &SetStickerEmojiListParams, diff --git a/src/objects.rs b/src/objects.rs index cc09cfd..49312df 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -468,6 +468,10 @@ pub struct User { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub supports_inline_queries: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub can_connect_to_business: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] @@ -505,6 +509,10 @@ pub struct Chat { #[builder(setter(into, strip_option), default)] pub active_usernames: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub birthdate: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub business_intro: Option, @@ -517,6 +525,10 @@ pub struct Chat { #[builder(setter(into, strip_option), default)] pub business_opening_hours: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub personal_chat: Option>, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub available_reactions: Option>, @@ -703,6 +715,10 @@ pub struct Message { #[builder(setter(into, strip_option), default)] pub has_protected_content: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub is_from_offline: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub media_group_id: Option, @@ -1530,11 +1546,32 @@ pub struct GeneralForumTopicHidden {} #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct GeneralForumTopicUnhidden {} +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct SharedUser { + pub user_id: u64, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub first_name: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub last_name: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub username: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub photo: Option>, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct UsersShared { pub request_id: i32, - pub user_ids: Vec, + pub users: Vec, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -1542,6 +1579,18 @@ pub struct ChatShared { pub request_id: i32, pub chat_id: u64, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub title: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub username: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub photo: Option>, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -1665,6 +1714,18 @@ pub struct KeyboardButtonRequestUsers { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub max_quantity: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub request_name: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub request_username: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub request_photo: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -1696,6 +1757,18 @@ pub struct KeyboardButtonRequestChat { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub bot_is_member: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub request_title: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub request_username: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub request_photo: Option, } #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -1987,6 +2060,15 @@ pub struct ChatPermissions { pub can_manage_topics: Option, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct Birthdate { + pub day: u8, + + pub month: u8, + + pub year: u16, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] pub struct BusinessIntro { #[serde(skip_serializing_if = "Option::is_none")] @@ -2183,6 +2265,7 @@ pub struct Sticker { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] pub struct InputSticker { pub sticker: FileUpload, + pub format: StickerFormat, pub emoji_list: Vec, #[serde(skip_serializing_if = "Option::is_none")] @@ -2211,10 +2294,6 @@ pub struct StickerSet { #[serde(rename = "sticker_type")] pub sticker_type: StickerType, - pub is_animated: bool, - - pub is_video: bool, - #[doc(hidden)] #[deprecated(since = "0.19.2", note = "Please use `sticker_type` instead")] pub contains_masks: bool,