ContextTypes¶
- class telegram.ext.ContextTypes(context=<class 'telegram.ext._callbackcontext.CallbackContext'>, bot_data=<class 'dict'>, chat_data=<class 'dict'>, user_data=<class 'dict'>)[source]¶
Bases:
typing.GenericConvenience class to gather customizable types of the
telegram.ext.CallbackContextinterface.Examples
Added in version 13.6.
- Parameters:
context (
type, optional) – Determines the type of thecontextargument of all (error-)handler callbacks and job callbacks. Must be a subclass oftelegram.ext.CallbackContext. Defaults totelegram.ext.CallbackContext.bot_data (
type, optional) – Determines the type ofcontext.bot_dataof all (error-)handler callbacks and job callbacks. Defaults todict. Must support instantiating without arguments.chat_data (
type, optional) – Determines the type ofcontext.chat_dataof all (error-)handler callbacks and job callbacks. Defaults todict. Must support instantiating without arguments.user_data (
type, optional) – Determines the type ofcontext.user_dataof all (error-)handler callbacks and job callbacks. Defaults todict. Must support instantiating without arguments.
- DEFAULT_TYPE[source]¶
Shortcut for the type annotation for the
contextargument that’s correct for the default settings, i.e. iftelegram.ext.ContextTypesis not used.Example
async def callback(update: Update, context: ContextTypes.DEFAULT_TYPE): ...
alias of
CallbackContext[ExtBot[None],dict[Any,Any],dict[Any,Any],dict[Any,Any]]
- property bot_data[source]¶
The type of
context.bot_dataof all (error-)handler callbacks and job callbacks.
- property chat_data[source]¶
The type of
context.chat_dataof all (error-)handler callbacks and job callbacks.
- property context[source]¶
The type of the
contextargument of all (error-)handler callbacks and job callbacks.
- property user_data[source]¶
The type of
context.user_dataof all (error-)handler callbacks and job callbacks.