-
Notifications
You must be signed in to change notification settings - Fork 2
AutoConv Handler
Moris Doratiotto edited this page Jun 30, 2021
·
5 revisions
This is a simple interface between our FSM (Conversation) and the python-telegram-bot API.
All the magic behind this package is here. In fact, there isn't much to say.
The simple manage_conversation
will handle the Conversation, you can choose to delete the user trigger message.
In addition, there is a restart
function (go back to a fresh start) and a force_state
function to jump around between State.
AutoConvHandler(
conversation: Conversation,
telegram_state_name: Any
)
-
conversation
: conversation to handle. -
telegram_state_name
: Telegram state name to handle callback, text and other things.
Usage example: autoconv_handler.py
# manage conversation with update and context
AutoConvHandler.manage_conversation(
update: Telegram.Update,
context: Telegram.Context,
delete_first: bool = True
)
-
update
,context
: from telegram bot function. -
delete_first
: if you want to delete the user message that trigger this handler.
Usage example: autoconv_handler.py
# restart the conversation to initial configuration
AutoConvHandler.restart(
update: Telegram.Update,
context: Telegram.Context
)
-
update
,context
: from telegram bot function.
Usage example: autoconv_handler.py
# force a state in the conversation
AutoConvHandler.force_state(
state: Union[State, str],
update: Telegram.Update
)
-
state
: force the conversation to a specific state. -
update
: from telegram bot function.