diff --git a/src/api_params.rs b/src/api_params.rs index 87b3223..e1224df 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -11,7 +11,7 @@ use crate::objects::{ MenuButton, MessageEntity, PassportElementErrorDataField, PassportElementErrorFile, PassportElementErrorFiles, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorTranslationFile, - PassportElementErrorTranslationFiles, PassportElementErrorUnspecified, PollType, + PassportElementErrorTranslationFiles, PassportElementErrorUnspecified, PollType, ReactionType, ReplyKeyboardMarkup, ReplyKeyboardRemove, ShippingOption, StickerFormat, StickerType, WebAppInfo, }; @@ -1135,6 +1135,20 @@ pub struct SendChatActionParams { pub action: ChatAction, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct SetMessageReactionParams { + #[builder(setter(into))] + pub chat_id: ChatId, + + pub message_id: i32, + + pub reacion: Vec, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub is_big: Option, +} + #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct GetUserProfilePhotosParams { pub user_id: u64, diff --git a/src/api_traits/telegram_api.rs b/src/api_traits/telegram_api.rs index e29e837..c8a38d8 100644 --- a/src/api_traits/telegram_api.rs +++ b/src/api_traits/telegram_api.rs @@ -88,6 +88,7 @@ use crate::api_params::SetChatStickerSetParams; use crate::api_params::SetChatTitleParams; use crate::api_params::SetCustomEmojiStickerSetThumbnailParams; use crate::api_params::SetGameScoreParams; +use crate::api_params::SetMessageReactionParams; use crate::api_params::SetMyCommandsParams; use crate::api_params::SetMyDefaultAdministratorRightsParams; use crate::api_params::SetMyDescriptionParams; @@ -454,6 +455,13 @@ pub trait TelegramApi { self.request("sendChatAction", Some(params)) } + fn set_message_reaction( + &self, + params: &SetMessageReactionParams, + ) -> Result, Self::Error> { + self.request("setMessageReaction", Some(params)) + } + fn get_user_profile_photos( &self, params: &GetUserProfilePhotosParams, diff --git a/src/objects.rs b/src/objects.rs index dfdd6d7..fdfaae9 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -345,6 +345,8 @@ pub enum UpdateContent { EditedMessage(Message), ChannelPost(Message), EditedChannelPost(Message), + MessageReaction(MessageReactionUpdated), + MessageReactionCount(MessageReactionCountUpdated), InlineQuery(InlineQuery), ChosenInlineResult(ChosenInlineResult), CallbackQuery(CallbackQuery), @@ -402,6 +404,8 @@ pub enum AllowedUpdate { EditedMessage, ChannelPost, EditedChannelPost, + MessageReaction, + MessageReactionCount, InlineQuery, ChosenInlineResult, CallbackQuery, @@ -491,6 +495,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 available_reactions: Option>, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub emoji_status_custom_emoji_id: Option, @@ -1722,6 +1730,74 @@ pub struct ChatLocation { pub address: String, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(tag = "type", rename_all = "snake_case")] +pub enum ReactionType { + Emoji(ReactionTypeEmoji), + CustomEmoji(ReactionTypeCustomEmoji), +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder, Eq)] +pub struct ReactionTypeEmoji { + #[builder(setter(into))] + #[serde(rename = "type")] + pub type_field: String, + + #[builder(setter(into))] + pub emoji: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder, Eq)] +pub struct ReactionTypeCustomEmoji { + #[builder(setter(into))] + #[serde(rename = "type")] + pub type_field: String, + + #[builder(setter(into))] + pub custom_emoji: String, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct ReactionCount { + #[builder(setter(into))] + #[serde(rename = "type")] + pub type_field: ReactionType, + + pub total_count: i32, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct MessageReactionUpdated { + pub chat: Chat, + + pub 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 actor_chat: Option, + + pub date: u64, + + pub old_reaction: Vec, + + pub new_reaction: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct MessageReactionCountUpdated { + pub chat: Chat, + + pub message_id: i32, + + pub date: u64, + + pub reactions: Vec, +} + #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Builder)] pub struct ForumTopic { pub message_thread_id: i32,