Discussion
- exception telegram_bot_discussion.bot.bot.ApplicationWasNotInit(*args)[source]
Bases:
ExceptionException raised when Telegram-bot application was not init in some reason (in the general case Telegram-bot application initialized automatically).
- Return type:
None
- class telegram_bot_discussion.bot.bot.Discussion(logger, config, *args, **kwargs)[source]
Bases:
objectDiscussion is the main class of your Telegram-bot application.
It could be said that the Discussion is the Telegram-bot itself.
- Parameters:
logger (LoggerInterface)
config (Config)
- get_dialogues()[source]
Dialogues structure Dict[int, Iterable] - is a dictionary collection of pairs of Telegram-user ID and the next stage of Telegram-bot dialogue.
- Return type:
Dict[int,Iterable]
- init_application(read_timeout=600, get_updates_read_timeout=600, write_timeout=600, get_updates_write_timeout=600, pool_timeout=600, get_updates_pool_timeout=600, connect_timeout=600, get_updates_connect_timeout=600)[source]
- Return type:
- set_commands_handler(commands_handler)[source]
- Return type:
- Parameters:
commands_handler (CommandsHandler)
- set_replicas_handler(replicas_handler)[source]
- Return type:
- Parameters:
replicas_handler (ReplicasHandler)
- set_buttons_handler(buttons_handler)[source]
- Return type:
- Parameters:
buttons_handler (ButtonsHandler)
- class telegram_bot_discussion.bot.contextual.Contextual(context)[source]
Bases:
Generic[T]Contextual-generic helps to fetch your Discussion inheritance from the context.
Example:
// It is your bot class YourBot(Discussion): additional_filed: str ... // Everywhere you need (Dialogues, Handlers, Middlewares) // get your Telegram-bot properties (like config, params, additional methods and etc.) // use this construction your_discussion_bot: YourBot = Contextual[YourBot](context)() print(your_discussion_bot.child_filed)
- Parameters:
context (CallbackContext)
-
context:
CallbackContext
- instance()[source]
Fetch instance of your Discussion-child from the context.
But it’s better to use shorter syntactic sugar:
your_discussion_bot: YourBot = Contextual[YourBot](context)()
- Raises:
ContextObjectIsNotDiscussion – when fetched object is not detected as Discussion-child.
- Return type:
TypeVar(T)