controller.controller_telegram

This file contains the Controller class which controls the flow of the conversation while the user interacts with the agent using Telegram.

Module Contents

Classes

ControllerTelegram

Helper class that provides a standard way to create an ABC using

Attributes

logger

CONTINUE

controller.controller_telegram.logger
controller.controller_telegram.CONTINUE
class controller.controller_telegram.ControllerTelegram

Bases: moviebot.controller.controller.Controller

Helper class that provides a standard way to create an ABC using inheritance.

load_bot_token(bot_token_path: str) str

Loads the Token for the Telegram bot.

Parameters:

bot_token_path – Path to the file with Telegram token.

Raises:
  • FileNotFoundError – If the file with the token is not found.

  • ValueError – If the type of the file name is not string or the token is not found in the file.

Returns:

The token of the Telegram Bot.

start(update: telegram.Update, context: telegram.ext.CallbackContext) int

Starts the conversation.

This indicates initializing the components, starting the conversation from scratch, and identifying if the users are new or have used this system before.

Parameters:
  • update – The update object from Telegram.

  • context – The context object from Telegram.

Returns:

The “continue” state of the conversation.

Return type:

CONTINUE

help(update: telegram.Update, context: telegram.ext.CallbackContext) int

Sends the users the instructions if they ask for help.

Parameters:
  • update – The update object from Telegram.

  • context – The context object from Telegram.

Returns:

The “continue” state of the conversation.

Return type:

CONTINUE

restart(update: telegram.Update, context: telegram.ext.CallbackContext) int

Restarts the conversation. This is similar to start function. However, it starts the conversation with a welcome message and elicits the uses to begin with.

Parameters:
  • update – The update object from Telegram.

  • context – The context object from Telegram.

Returns:

The “continue” state of the conversation.

Return type:

CONTINUE

continue_conv(update: telegram.Update, context: telegram.ext.CallbackContext) int

Continues the conversation until the users want to restart of exit.

Parameters:
  • update – The update object from Telegram.

  • context – The context object from Telegram.

Returns:

The “continue” status of the conversation or the “end of conversation” status.

exit(update: telegram.Update, context: telegram.ext.CallbackContext) int

Exit the conversation.

Parameters:
  • update – Object representing an incoming update.

  • context – Context object.

Returns:

The “end of the conversation” status.

error(update: telegram.Update, context: telegram.ext.CallbackContext) None

Log Errors caused by updates.

Parameters:
  • update – Object representing an incoming update.

  • context – Context object.

execute_agent(configuration: Dict[str, Any]) None

Runs the conversational agent and executes the dialogue by calling the basic components of IAI MovieBot.

Parameters:

configuration – The settings for the agent.

new_user(user_id: str) bool

Checks if the users are new or they have already conversed with the system before.

Parameters:

user_id – ID of the user.

Returns:

Flag indication if users are new.