telegram.ext.MessageHandler#

class telegram.ext.MessageHandler(filters, callback, block=True)[source]#

Bases: telegram.ext.Handler

Handler class to handle Telegram messages. They might contain text, media or status updates.

Warning

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

Parameters
filters[source]#

Only allow updates with these Filters. See telegram.ext.filters for a full list of all available filters.

Type

telegram.ext.filters.BaseFilter

callback[source]#

The callback function for this handler.

Type

coroutine function

block[source]#

Determines whether the return value of the callback should be awaited before processing the next handler in telegram.ext.Application.process_update().

Type

bool

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

collect_additional_context(context, update, application, check_result)[source]#

Adds possible output of data filters to the CallbackContext.