telegram.ext.ChosenInlineResultHandler#
- class telegram.ext.ChosenInlineResultHandler(callback, block=True, pattern=None)[source]#
Bases:
telegram.ext.HandlerHandler class to handle Telegram updates that contain
telegram.Update.chosen_inline_result.Warning
When setting
blocktoFalse, you cannot rely on adding custom attributes totelegram.ext.CallbackContext. See its docs for more info.- 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.block (
bool, optional) – Determines whether the return value of the callback should be awaited before processing the next handler intelegram.ext.Application.process_update(). Defaults toTrue.pattern (
str|re.Pattern, optional) –Regex pattern. If not
None,re.match()is used ontelegram.ChosenInlineResult.result_idto determine if an update should be handled by this handler. This is accessible in the callback astelegram.ext.CallbackContext.matches.New in version 13.6.
- 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
- pattern[source]#
Optional. Regex pattern to test
telegram.ChosenInlineResult.result_idagainst.New in version 13.6.
- Type
Pattern
- check_update(update)[source]#
Determines whether an update should be passed to this handler’s
callback.- Parameters
update (
telegram.Update|object) – Incoming update.- Returns
- collect_additional_context(context, update, application, check_result)[source]#
This function adds the matched regex pattern result to
telegram.ext.CallbackContext.matches.