Skip to content

Vote and Regiter handler

Lazaro Raul edited this page Nov 10, 2020 · 3 revisions

This handlers servers as private and public handlers to manage the process of registration and voting in a chat discussion.

Step 1: Registration

Once the creation and configuration process, through commands create and config, is done all users in the chat can register to the active discussion. This is done using the command /register or /vote in the group with the active discussion. The bot will notify if the registration goes well.

All registered groups can be selected in the private chat with the bot using the /vote command.

Step 2: Vote

When the /vote command is used in the private chat with the bot all registered chats will be showed up. Upon selection of the chat, the message will become a self contained vote with all operations needed to modify its content. Such actions are:

Add Option

The add option is showed for all options added during the configuration process that are not included in the vote. Clicking on an add option will insert it in the vote content as the last option, also the vote message will be updated to reflect the new content.

Remove Option

The remove option is showed for all options added during the configuration process that are included in the vote. Clicking on a remove option will remove it from the vote content, also the vote message will be updated to reflect the new content.

Cancel Option

The cancel option is always showed. Clicking on the cancel option will invalidate the current vote and it will not affect the discussion. This option is final and cannot be undone, so the /vote command should be used again to initiate a new vote.

Confirm Option

The confirm option is only available when all options added during the configuration process are included in the vote. Clicking on the confirm option will confirm the vote as a valid one and will be taken into account for the group discussion. This option is final and cannot be undone, so the /vote command should be used again to initiate a new vote.


The code related to the vote and register commands can be find in the vote.py. This section will explain the key methods of the vote.py do.

This method is the one that handles the registration process descrived in step-1.

This methods are the beginning of the step-2. They handle the group discussion selection and the initialization of the vote message content.

This methods is the one that handles the rest of step-2 and thus the application of the different options attached to the message. This is done using the inline buttons and callbacks query wich have the information related to the change aplied to the vote message content. Due to the callback nature of the options it is possible that votes lose relevance to the group discussion(for example: the discussion has ended) and there for be invalidated.

Last variables correspond to the handlers used to manage the process, one for each of the previous mentioned methods. Those handlers are CallbackQueryHandler and CommandHandler handlers classes from the python-telegram-bot package.