TypeHandler¶
class telegram.ext.TypeHandler(type, callback, strict=False, block=True)[source]¶Bases: telegram.ext.BaseHandler
Handler class to handle updates of custom types.
Warning
When setting block to False, you cannot rely on adding custom attributes to telegram.ext.CallbackContext. See its docs for more info.
Use In
Available In
type (type) – The type of updates this handler should process, as determined by isinstance
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: object, context: CallbackContext)The return value of the callback is usually ignored except for the special case of telegram.ext.ConversationHandler.
strict (bool, optional) – Use type instead of isinstance. Default is False.
Determines whether the return value of the callback should be awaited before processing the next handler in telegram.ext.Application.process_update(). Defaults to True.
See also
The type of updates this handler should process.
Type: callback[source]¶The callback function for this handler.
Type: strict[source]¶Use type instead of isinstance. Default is False.
Type: 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: check_update(update)[source]¶Determines whether an update should be passed to this handler’s callback.
Parameters:update (object) – Incoming update.
Returns: