set_reaction()#
- Client.set_reaction()#
Use this method to change the chosen reactions on a message. Bots can’t react to service messages. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can’t use paid reactions.
You must use exactly one of
message_id
ORstory_id
.If you specify,
message_id
Usable by ✅ Users ✅ BotsIf you specify,
story_id
Usable by ✅ Users ❌ Bots- Parameters:
chat_id (
int
|str
) – Unique identifier (int) or username (str) of the target chat.message_id (
int
, optional) – 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.story_id (
int
, optional) – Identifier of the story.reaction (List of
ReactionType
, optional) – New list of reaction types to set on the message. Pass None as emoji (default) to retract the reaction. Useadd_paid_message_reaction()
instead to add a paid reaction.is_big (
bool
, optional) – Pass True to set the reaction with a big animation. Defaults to False.add_to_recent (
bool
, optional) – Pass True if the reaction should appear in the recently used reactions. This option is applicable only for users. Defaults to True.
- Returns:
On success,
MessageReactions
– is returned.
Example
# Send a reaction as a bot await app.set_reaction(chat_id, message_id, [ReactionTypeEmoji(emoji="👍")]) # Send multiple reaction as a premium user await app.set_reaction(chat_id, message_id, [ReactionTypeEmoji(emoji="👍"),ReactionTypeEmoji(emoji="😍")],True) # Retract a reaction await app.set_reaction(chat_id, message_id=message_id)