Discussion

exception telegram_bot_discussion.bot.bot.ApplicationWasNotInit(*args)[source]

Bases: Exception

Exception 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: object

Discussion is the main class of your Telegram-bot application.

It could be said that the Discussion is the Telegram-bot itself.

Parameters:
config: Config
get_application()[source]
Return type:

Application

bot()[source]
Returns:

native Telegram-bot object.

Return type:

ExtBot

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]

get_logger()[source]
Return type:

LoggerInterface

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:

Discussion

set_commands_handler(commands_handler)[source]
Return type:

Discussion

Parameters:

commands_handler (CommandsHandler)

set_replicas_handler(replicas_handler)[source]
Return type:

Discussion

Parameters:

replicas_handler (ReplicasHandler)

set_buttons_handler(buttons_handler)[source]
Return type:

Discussion

Parameters:

buttons_handler (ButtonsHandler)

get_buttons_handler()[source]
Return type:

ButtonsHandler

get_commands_handler()[source]
Return type:

CommandsHandler

get_replicas_handler()[source]
Return type:

ReplicasHandler

start()[source]
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)

exception telegram_bot_discussion.bot.contextual.ContextObjectIsNotDiscussion[source]

Bases: Exception