Skip to content

Create Handler and Data Management

Miguel Tenorio edited this page Nov 10, 2020 · 2 revisions

The /create command tries to make the current chat available for configuration by the administrator that trigger this handler. Is helpful to understand how we manage our data, so that's what this wiki is about.

python-telegram-bot allow us to save wherever data we need to save in some dictionaries in a CallbackContext object. These dictionaries are named chat_data, user_data and bot_data.

Read the docs of python-telegram-bot for details about python-telegram-bot objects and features.

The data we save is:

  • chat_data['active'] : True if a chat group has a active discussion, False otherwise.
  • chat_data['manager'] : User id of the user that start the discussion of the chat, and the one who configures it
  • chat_data['model'] : Current model
  • chat_data['voters'] : Dict of user_id : vote. vote is None if the user with user ID user_id is registered in the discussion but isn't voted yet.
  • user_data['owner'] : Contain the chat IDs of the chats of which the user is manager
  • user_data['options'] : List of the options which order will be discussed
  • user_data['chat_id'] : Chat ID of the chat being configured by the user
  • user_data['voting_in'] : List of chat IDs of the chats the user is voting on.