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 thechat_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 foruser_id
anduser_username
filtering.
Warning
When setting
block
toFalse
, you cannot rely on adding custom attributes totelegram.ext.CallbackContext
. See its docs for more info.Available In
Added in version 20.8.
- Parameters:
callback (coroutine function) –
The callback function for this handler. Will be called when
check_update()
has determined that an update should be processed by this handler. Callback signature:async def callback(update: Update, context: CallbackContext)
The return value of the callback is usually ignored except for the special case of
telegram.ext.ConversationHandler
.message_reaction_types (
int
, optional) – Pass one ofMESSAGE_REACTION_UPDATED
,MESSAGE_REACTION_COUNT_UPDATED
orMESSAGE_REACTION
to specify if this handler should handle only updates withtelegram.Update.message_reaction
,telegram.Update.message_reaction_count
or both. Defaults toMESSAGE_REACTION
.chat_id (
int
| Collection[int
], optional) – Filters reactions to allow only those which happen in the specified chat ID(s).chat_username (
str
| Collection[str
], optional) – Filters reactions to allow only those which happen in the specified username(s).user_id (
int
| Collection[int
], optional) – Filters reactions to allow only those which are set by the specified chat ID(s) (this can be the chat itself in the case of anonymous users, see thetelegram.MessageReactionUpdated.actor_chat
).user_username (
str
| Collection[str
], optional) – Filters reactions to allow only those which are set by the specified username(s) (this can be the chat itself in the case of anonymous users, see thetelegram.MessageReactionUpdated.actor_chat
).Determines whether the return value of the callback should be awaited before processing the next handler in
telegram.ext.Application.process_update()
. Defaults toTrue
.See also
- 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:
- MESSAGE_REACTION = 1[source]¶
Used as a constant to handle both
telegram.Update.message_reaction
andtelegram.Update.message_reaction_count
.- Type:
- MESSAGE_REACTION_COUNT_UPDATED = 0[source]¶
Used as a constant to handle only
telegram.Update.message_reaction_count
.- Type:
- MESSAGE_REACTION_UPDATED = -1[source]¶
Used as a constant to handle only
telegram.Update.message_reaction
.- Type: