diff --git a/src/api_params.rs b/src/api_params.rs index 0864a08..023e53d 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -1622,6 +1622,14 @@ pub struct AnswerCallbackQueryParams { pub cache_time: Option, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct GetUserChatBoostsParams { + #[builder(setter(into))] + pub chat_id: ChatId, + + pub user_id: u64, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct SetMyCommandsParams { pub commands: Vec, diff --git a/src/api_traits/async_telegram_api.rs b/src/api_traits/async_telegram_api.rs index e2805d9..85edcb7 100644 --- a/src/api_traits/async_telegram_api.rs +++ b/src/api_traits/async_telegram_api.rs @@ -54,6 +54,7 @@ use crate::api_params::GetMyNameParams; use crate::api_params::GetMyShortDescriptionParams; use crate::api_params::GetStickerSetParams; use crate::api_params::GetUpdatesParams; +use crate::api_params::GetUserChatBoostsParams; use crate::api_params::GetUserProfilePhotosParams; use crate::api_params::HideGeneralForumTopicParams; use crate::api_params::InputMedia; @@ -134,6 +135,7 @@ use crate::objects::SentWebAppMessage; use crate::objects::StickerSet; use crate::objects::Update; use crate::objects::User; +use crate::objects::UserChatBoosts; use crate::objects::UserProfilePhotos; use crate::objects::WebhookInfo; use crate::Sticker; @@ -815,6 +817,13 @@ pub trait AsyncTelegramApi { self.request("answerCallbackQuery", Some(params)).await } + async fn get_user_chat_boosts( + &self, + params: &GetUserChatBoostsParams, + ) -> Result, Self::Error> { + self.request("getUserChatBoosts", Some(params)).await + } + async fn get_my_commands( &self, params: &GetMyCommandsParams, diff --git a/src/api_traits/telegram_api.rs b/src/api_traits/telegram_api.rs index f82e787..1fa8271 100644 --- a/src/api_traits/telegram_api.rs +++ b/src/api_traits/telegram_api.rs @@ -53,6 +53,7 @@ use crate::api_params::GetMyNameParams; use crate::api_params::GetMyShortDescriptionParams; use crate::api_params::GetStickerSetParams; use crate::api_params::GetUpdatesParams; +use crate::api_params::GetUserChatBoostsParams; use crate::api_params::GetUserProfilePhotosParams; use crate::api_params::HideGeneralForumTopicParams; use crate::api_params::InputMedia; @@ -133,6 +134,7 @@ use crate::objects::SentWebAppMessage; use crate::objects::StickerSet; use crate::objects::Update; use crate::objects::User; +use crate::objects::UserChatBoosts; use crate::objects::UserProfilePhotos; use crate::objects::WebhookInfo; use crate::GetCustomEmojiStickersParams; @@ -770,6 +772,13 @@ pub trait TelegramApi { self.request("answerCallbackQuery", Some(params)) } + fn get_user_chat_boosts( + &self, + params: &GetUserChatBoostsParams, + ) -> Result, Self::Error> { + self.request("getUserChatBoosts", Some(params)) + } + fn get_my_commands( &self, params: &GetMyCommandsParams, diff --git a/src/objects.rs b/src/objects.rs index 0c5f496..519e6b7 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -357,6 +357,8 @@ pub enum UpdateContent { MyChatMember(ChatMemberUpdated), ChatMember(ChatMemberUpdated), ChatJoinRequest(ChatJoinRequest), + ChatBoost(ChatBoost), + RemovedChatBoost(ChatBoostRemoved), } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -416,6 +418,8 @@ pub enum AllowedUpdate { MyChatMember, ChatMember, ChatJoinRequest, + ChatBoost, + RemovedChatBoost, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -499,6 +503,22 @@ pub struct Chat { #[builder(setter(into, strip_option), default)] pub available_reactions: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub accent_color_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub background_custom_emoji_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub profile_accent_color_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub profile_background_custom_emoji_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub emoji_status_custom_emoji_id: Option, @@ -563,6 +583,10 @@ pub struct Chat { #[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 has_visible_history: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub sticker_set_name: Option, @@ -603,27 +627,7 @@ pub struct Message { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub forward_from: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_from_chat: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_from_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_signature: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_sender_name: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_date: Option, + pub forward_origin: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -795,7 +799,7 @@ pub struct Message { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub pinned_message: Option>, + pub pinned_message: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -807,7 +811,7 @@ pub struct Message { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub user_shared: Option>, + pub users_shared: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -853,6 +857,22 @@ pub struct Message { #[builder(setter(into, strip_option), default)] pub general_forum_topic_unhidden: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway_created: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway_winners: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway_completed: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub video_chat_started: Option>, @@ -1460,17 +1480,17 @@ pub struct GeneralForumTopicHidden {} pub struct GeneralForumTopicUnhidden {} #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] -pub struct UserShared { +pub struct UsersShared { pub request_id: i32, - pub user_id: u64, + pub user_ids: Vec, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct ChatShared { pub request_id: i32, - pub user_id: u64, + pub chat_id: u64, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -1556,7 +1576,7 @@ pub struct KeyboardButton { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub request_user: Option, + pub request_users: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -1580,7 +1600,7 @@ pub struct KeyboardButton { } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] -pub struct KeyboardButtonRequestUser { +pub struct KeyboardButtonRequestUsers { pub request_id: i32, #[serde(skip_serializing_if = "Option::is_none")] @@ -1590,6 +1610,10 @@ pub struct KeyboardButtonRequestUser { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub user_is_premium: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub max_quantity: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -1737,7 +1761,7 @@ pub struct CallbackQuery { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub message: Option, + pub message: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -3460,6 +3484,9 @@ pub struct GameHighScore { pub score: i32, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct GiveawayCreated {} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] pub struct Giveaway { pub chats: Vec, @@ -3526,6 +3553,19 @@ pub struct GiveawayWinners { pub prize_description: Option, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct GiveawayCompleted { + pub winner_count: u32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub unclaimed_prize_count: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway_message: Option>, +} + #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct ChatAdministratorRights { pub is_anonymous: bool, @@ -3594,6 +3634,88 @@ pub struct WebAppData { pub button_text: String, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(tag = "source", rename_all = "snake_case")] +pub enum ChatBoostSource { + Premium(ChatBoostSourcePremium), + GiftCode(ChatBoostSourceGiftCode), + Giveaway(ChatBoostSourceGiveaway), +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct ChatBoostSourcePremium { + pub user: User, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct ChatBoostSourceGiftCode { + pub user: User, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct ChatBoostSourceGiveaway { + pub giveaway_message_id: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub user: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub is_unclaimed: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct ChatBoost { + #[builder(setter(into))] + pub boost_id: String, + + pub add_date: u64, + + pub expiration_date: u64, + + pub source: ChatBoostSource, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct ChatBoostUpdated { + pub chat: Chat, + + pub boost: ChatBoost, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct ChatBoostRemoved { + pub chat: Chat, + + #[builder(setter(into))] + pub boost_id: String, + + pub remove_date: u64, + + pub source: ChatBoostSource, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct UserChatBoosts { + pub boosts: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub enum MaybeInaccessibleMessage { + Message(Message), + InaccessibleMessage(InaccessibleMessage), +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct InaccessibleMessage { + pub chat: Chat, + + pub message_id: i32, + + pub date: u64, +} + #[cfg(test)] mod serde_tests { use super::*;