This is a context object passed to the callback called by
telegram.ext.Handleror by the
telegram.ext.Dispatcherin an error handler added by
telegram.ext.Dispatcher.add_error_handleror to the callback of a
telegram.ext.Dispatcherwill create a single context for an entire update. This means that if you got 2 handlers in different groups and they both get called, they will get passed the same CallbackContext object (of course with proper attributes like .matches differing). This allows you to add custom attributes in a lower handler group callback, and then subsequently access those attributes in a higher handler group callback. Note that the attributes on CallbackContext might change in the future, so make sure to use a fairly unique name for the attributes.
Do not combine custom attributes and @run_async. Due to how @run_async works, it will almost certainly execute the callbacks for an update out of order, and the attributes that you think you added will not be present.
dict, optional – A dict that can be used to keep any data in. For each update from the same chat it will be the same
dict, optional – A dict that can be used to keep any data in. For each update from the same user it will be the same
re match object], optional – If the associated update originated from a regex-supported handler or had a
Filters.regex, this will contain a list of match objects for every pattern where
re.search(pattern, string)returned a match.
str], optional – Arguments passed to a command if the associated update is handled by
telegram.ext.StringCommandHandler. It contains a list of the words in the text after the command, using any whitespace string as a delimiter.
telegram.TelegramError, optional – The Telegram error that was raised. Only present when passed to a error handler registered with