MessageReactionHandler

class telegram.ext.MessageReactionHandler(callback, chat_id=None, chat_username=None, user_id=None, user_username=None, message_reaction_types=1, block=True)[source]

Bases: telegram.ext.BaseHandler

Handler class to handle Telegram updates that contain a message reaction.

Note

The following rules apply to both username and the chat_id param groups, respectively:

  • If none of them are passed, the handler does not filter the update for that specific

    attribute.

  • If a chat ID or a username is passed, the updates will be filtered with that

    specific attribute.

  • If a chat ID and a username are passed, an update containing any of them will be

    filtered.

  • telegram.MessageReactionUpdated.actor_chat is not considered for user_id and user_username filtering.

Warning

When setting block to False, you cannot rely on adding custom attributes to telegram.ext.CallbackContext. See its docs for more info.

Added in version 20.8.

Parameters:
callback[source]

The callback function for this handler.

Type:

coroutine function

message_reaction_types[source]

Optional. Specifies if this handler should handle only updates with telegram.Update.message_reaction, telegram.Update.message_reaction_count or both.

Type:

int

block[source]

Determines whether the callback will run in a blocking way.

Type:

bool

MESSAGE_REACTION = 1[source]

Used as a constant to handle both telegram.Update.message_reaction and telegram.Update.message_reaction_count.

Type:

int

MESSAGE_REACTION_COUNT_UPDATED = 0[source]

Used as a constant to handle only telegram.Update.message_reaction_count.

Type:

int

MESSAGE_REACTION_UPDATED = -1[source]

Used as a constant to handle only telegram.Update.message_reaction.

Type:

int

check_update(update)[source]

Determines whether an update should be passed to this handler’s callback.

Parameters:

update (telegram.Update | object) – Incoming update.

Returns:

bool