diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index 7d6ff142..5b382979 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -1851,6 +1851,37 @@ Schema( ), ], ), + Method( + names: ("setMessageReaction", "SetMessageReaction", "set_message_reaction"), + return_ty: True, + doc: Doc( + md: "Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Returns True on success." + ), + tg_doc: "https://core.telegram.org/bots/api#setmessagereaction", + tg_category: "Available methods", + params: [ + Param( + name: "chat_id", + ty: RawTy("Recipient"), + descr: Doc(md: "Unique identifier for the target chat or username of the target channel (in the format @channelusername)") + ), + Param( + name: "message_id", + ty: RawTy("MessageId"), + descr: Doc(md: "Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead.") + ), + Param( + name: "reaction", + ty: Option(ArrayOf(RawTy("ReactionType"))), + descr: Doc(md: "New list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.") + ), + Param( + name: "is_big", + ty: Option(bool), + descr: Doc(md: "Pass True to set the reaction with a big animation") + ), + ], + ), Method( names: ("getUserProfilePhotos", "GetUserProfilePhotos", "get_user_profile_photos"), return_ty: RawTy("UserProfilePhotos"), diff --git a/crates/teloxide-core/src/adaptors/cache_me.rs b/crates/teloxide-core/src/adaptors/cache_me.rs index caab3f87..4ab96541 100644 --- a/crates/teloxide-core/src/adaptors/cache_me.rs +++ b/crates/teloxide-core/src/adaptors/cache_me.rs @@ -116,6 +116,7 @@ where send_poll, send_dice, send_chat_action, + set_message_reaction, get_user_profile_photos, get_file, kick_chat_member, diff --git a/crates/teloxide-core/src/adaptors/erased.rs b/crates/teloxide-core/src/adaptors/erased.rs index 1e3ca58b..0c2a907d 100644 --- a/crates/teloxide-core/src/adaptors/erased.rs +++ b/crates/teloxide-core/src/adaptors/erased.rs @@ -215,6 +215,7 @@ where send_poll, send_dice, send_chat_action, + set_message_reaction, get_user_profile_photos, get_file, kick_chat_member, @@ -480,6 +481,12 @@ trait ErasableRequester<'a> { action: ChatAction, ) -> ErasedRequest<'a, SendChatAction, Self::Err>; + fn set_message_reaction( + &self, + chat_id: Recipient, + message_id: MessageId, + ) -> ErasedRequest<'a, SetMessageReaction, Self::Err>; + fn get_user_profile_photos( &self, user_id: UserId, @@ -1222,6 +1229,14 @@ where Requester::send_chat_action(self, chat_id, action).erase() } + fn set_message_reaction( + &self, + chat_id: Recipient, + message_id: MessageId, + ) -> ErasedRequest<'a, SetMessageReaction, Self::Err> { + Requester::set_message_reaction(self, chat_id, message_id).erase() + } + fn get_user_profile_photos( &self, user_id: UserId, diff --git a/crates/teloxide-core/src/adaptors/parse_mode.rs b/crates/teloxide-core/src/adaptors/parse_mode.rs index f9458bca..1b4fba80 100644 --- a/crates/teloxide-core/src/adaptors/parse_mode.rs +++ b/crates/teloxide-core/src/adaptors/parse_mode.rs @@ -197,6 +197,7 @@ where send_contact, send_dice, send_chat_action, + set_message_reaction, get_user_profile_photos, get_file, kick_chat_member, diff --git a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs index eb9cbb41..0fbe3a5f 100644 --- a/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs +++ b/crates/teloxide-core/src/adaptors/throttle/requester_impl.rs @@ -99,6 +99,7 @@ where stop_message_live_location, stop_message_live_location_inline, send_chat_action, + set_message_reaction, get_user_profile_photos, get_file, kick_chat_member, diff --git a/crates/teloxide-core/src/adaptors/trace.rs b/crates/teloxide-core/src/adaptors/trace.rs index cef5fa7e..7c6ebfa8 100644 --- a/crates/teloxide-core/src/adaptors/trace.rs +++ b/crates/teloxide-core/src/adaptors/trace.rs @@ -145,6 +145,7 @@ where send_poll, send_dice, send_chat_action, + set_message_reaction, get_user_profile_photos, get_file, kick_chat_member, diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 7da6ee98..27912b41 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -309,6 +309,18 @@ impl Requester for Bot { Self::SendChatAction::new(self.clone(), payloads::SendChatAction::new(chat_id, action)) } + type SetMessageReaction = JsonRequest; + + fn set_message_reaction(&self, chat_id: C, message_id: MessageId) -> Self::SetMessageReaction + where + C: Into, + { + Self::SetMessageReaction::new( + self.clone(), + payloads::SetMessageReaction::new(chat_id, message_id), + ) + } + type GetUserProfilePhotos = JsonRequest; fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos { diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index 41ae27a6..242f807b 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -667,6 +667,14 @@ macro_rules! requester_forward { $body!(send_chat_action this (chat_id: C, action: ChatAction)) } }; + (@method set_message_reaction $body:ident $ty:ident) => { + type SetMessageReaction = $ty![SetMessageReaction]; + + fn set_message_reaction(&self, chat_id: C, message_id: MessageId) -> Self::SetMessageReaction where C: Into { + let this = self; + $body!(set_message_reaction this (chat_id: C, message_id: MessageId)) + } + }; (@method get_user_profile_photos $body:ident $ty:ident) => { type GetUserProfilePhotos = $ty![GetUserProfilePhotos]; diff --git a/crates/teloxide-core/src/payloads.rs b/crates/teloxide-core/src/payloads.rs index ee3f845e..cdcd85f1 100644 --- a/crates/teloxide-core/src/payloads.rs +++ b/crates/teloxide-core/src/payloads.rs @@ -117,6 +117,7 @@ mod set_chat_title; mod set_custom_emoji_sticker_set_thumbnail; mod set_game_score; mod set_game_score_inline; +mod set_message_reaction; mod set_my_commands; mod set_my_default_administrator_rights; mod set_my_description; @@ -256,6 +257,7 @@ pub use set_custom_emoji_sticker_set_thumbnail::{ }; pub use set_game_score::{SetGameScore, SetGameScoreSetters}; pub use set_game_score_inline::{SetGameScoreInline, SetGameScoreInlineSetters}; +pub use set_message_reaction::{SetMessageReaction, SetMessageReactionSetters}; pub use set_my_commands::{SetMyCommands, SetMyCommandsSetters}; pub use set_my_default_administrator_rights::{ SetMyDefaultAdministratorRights, SetMyDefaultAdministratorRightsSetters, diff --git a/crates/teloxide-core/src/payloads/set_message_reaction.rs b/crates/teloxide-core/src/payloads/set_message_reaction.rs new file mode 100644 index 00000000..834336ba --- /dev/null +++ b/crates/teloxide-core/src/payloads/set_message_reaction.rs @@ -0,0 +1,25 @@ +//! Generated by `codegen_payloads`, do not edit by hand. + +use serde::Serialize; + +use crate::types::{MessageId, ReactionType, Recipient, True}; + +impl_payload! { + /// Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Returns True on success. + #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)] + pub SetMessageReaction (SetMessageReactionSetters) => True { + required { + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + pub chat_id: Recipient [into], + /// Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead. + #[serde(flatten)] + pub message_id: MessageId, + } + optional { + /// New list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. + pub reaction: Vec [collect], + /// Pass True to set the reaction with a big animation + pub is_big: bool, + } + } +} diff --git a/crates/teloxide-core/src/payloads/setters.rs b/crates/teloxide-core/src/payloads/setters.rs index 96ba6712..279fda1d 100644 --- a/crates/teloxide-core/src/payloads/setters.rs +++ b/crates/teloxide-core/src/payloads/setters.rs @@ -39,7 +39,7 @@ pub use crate::payloads::{ SetChatMenuButtonSetters as _, SetChatPermissionsSetters as _, SetChatPhotoSetters as _, SetChatStickerSetSetters as _, SetChatTitleSetters as _, SetCustomEmojiStickerSetThumbnailSetters as _, SetGameScoreInlineSetters as _, - SetGameScoreSetters as _, SetMyCommandsSetters as _, + SetGameScoreSetters as _, SetMessageReactionSetters as _, SetMyCommandsSetters as _, SetMyDefaultAdministratorRightsSetters as _, SetMyDescriptionSetters as _, SetMyNameSetters as _, SetMyShortDescriptionSetters as _, SetPassportDataErrorsSetters as _, SetStickerEmojiListSetters as _, SetStickerKeywordsSetters as _, diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 0b97abf9..2936e8b2 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -413,6 +413,17 @@ pub trait Requester { where C: Into; + type SetMessageReaction: Request; + + /// For Telegram documentation see [`SetMessageReaction`]. + fn set_message_reaction( + &self, + chat_id: C, + message_id: MessageId, + ) -> Self::SetMessageReaction + where + C: Into; + type GetUserProfilePhotos: Request; /// For Telegram documentation see [`GetUserProfilePhotos`]. @@ -1307,6 +1318,7 @@ macro_rules! forward_all { send_poll, send_dice, send_chat_action, + set_message_reaction, get_user_profile_photos, get_file, kick_chat_member,