mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Add setMessageReaction
TBA method
This commit is contained in:
parent
50768a1af0
commit
409c3d5403
12 changed files with 110 additions and 1 deletions
|
@ -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"),
|
||||
|
|
|
@ -116,6 +116,7 @@ where
|
|||
send_poll,
|
||||
send_dice,
|
||||
send_chat_action,
|
||||
set_message_reaction,
|
||||
get_user_profile_photos,
|
||||
get_file,
|
||||
kick_chat_member,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -197,6 +197,7 @@ where
|
|||
send_contact,
|
||||
send_dice,
|
||||
send_chat_action,
|
||||
set_message_reaction,
|
||||
get_user_profile_photos,
|
||||
get_file,
|
||||
kick_chat_member,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -145,6 +145,7 @@ where
|
|||
send_poll,
|
||||
send_dice,
|
||||
send_chat_action,
|
||||
set_message_reaction,
|
||||
get_user_profile_photos,
|
||||
get_file,
|
||||
kick_chat_member,
|
||||
|
|
|
@ -309,6 +309,18 @@ impl Requester for Bot {
|
|||
Self::SendChatAction::new(self.clone(), payloads::SendChatAction::new(chat_id, action))
|
||||
}
|
||||
|
||||
type SetMessageReaction = JsonRequest<payloads::SetMessageReaction>;
|
||||
|
||||
fn set_message_reaction<C>(&self, chat_id: C, message_id: MessageId) -> Self::SetMessageReaction
|
||||
where
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SetMessageReaction::new(
|
||||
self.clone(),
|
||||
payloads::SetMessageReaction::new(chat_id, message_id),
|
||||
)
|
||||
}
|
||||
|
||||
type GetUserProfilePhotos = JsonRequest<payloads::GetUserProfilePhotos>;
|
||||
|
||||
fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos {
|
||||
|
|
|
@ -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<C>(&self, chat_id: C, message_id: MessageId) -> Self::SetMessageReaction where C: Into<Recipient> {
|
||||
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];
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
25
crates/teloxide-core/src/payloads/set_message_reaction.rs
Normal file
25
crates/teloxide-core/src/payloads/set_message_reaction.rs
Normal file
|
@ -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<ReactionType> [collect],
|
||||
/// Pass True to set the reaction with a big animation
|
||||
pub is_big: bool,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 _,
|
||||
|
|
|
@ -413,6 +413,17 @@ pub trait Requester {
|
|||
where
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SetMessageReaction: Request<Payload = SetMessageReaction, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SetMessageReaction`].
|
||||
fn set_message_reaction<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_id: MessageId,
|
||||
) -> Self::SetMessageReaction
|
||||
where
|
||||
C: Into<Recipient>;
|
||||
|
||||
type GetUserProfilePhotos: Request<Payload = GetUserProfilePhotos, Err = Self::Err>;
|
||||
|
||||
/// 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,
|
||||
|
|
Loading…
Reference in a new issue