Bunk Command

misbot.bunk.bunk(bot, update)

Starting point of bunk_handler. Sends a KeyboardMarkup (https://core.telegram.org/bots#keyboards) Passes control to bunk_choose()

Parameters:
  • bot (telegram.bot.Bot) – Telegram Bot object
  • update (telegram.update.Update) – Telegram Update object
Returns:

CHOOSING

Return type:

int

misbot.bunk.bunk_choose(bot, update, user_data)

Removes keyboardMarkup sent in previous handler.

Stores the response (for Lectures/Practicals message sent in previous handler) in a user_data dictionary with the key “stype”. user_data is a user relative dictionary which holds data between different handlers/functions in a ConversationHandler.

Selects the appropriate table (Lecture or Practical) based on stype value. Checks if records exist in the table for a user and sends a warning message or proceeds to list names of all subjects in the table.

Passes control to bunk_input()

Parameters:
  • bot (telegram.bot.Bot) – Telegram Bot object
  • update (telegram.update.Update) – Telegram Update object
  • user_data (dict) – User data dictionary
Returns:

ConversationHandler.END if no records else INPUT

Return type:

int

misbot.bunk.bunk_input(bot, update, user_data)

Stores index of the chosen subject in user_data['index'] from update.message.text. Passes control to bunk_calc()

Parameters:
  • bot (telegram.bot.Bot) – Telegram Bot object
  • update (telegram.update.Update) – Telegram Update object
  • user_data (dict) – User data dictionary
Returns:

ConversationHandler.END if message is “Cancel” else CALCULATING

Return type:

int

misbot.bunk.bunk_calc(bot, update, user_data)

Calculate the % drop/rise with the previously given values from the user and send the response to the user.

user_data contains: type, index, figures.

Incorrect no. of arguments resets the state and user is asked for input again.

Parameters:
  • bot (telegram.bot.Bot) – Telegram Bot object
  • update (telegram.update.Update) – Telegram Update object
  • user_data (dict) – User data dictionary
Returns:

None if incorrect values else INPUT

Return type:

None or int