slack-trivia
is yet another integration for Slack workspaces to run quizzes (multiple choice questions) in a Slack channel. This runs as a Python script and is
based on the Slack Python API.
- Slack bot - instructions on how to create one at https://api.slack.com/bot-users
- Python v3.7+
- Clone or download the repository into a local folder.
- Add this folder to your
$PYTHONPATH
. - Create an environment variable
TOKEN
with the bot token. - Edit
quizz.py
and definesu
as a list of user IDs who will be allowed to operate the bot commands (hint: add the bot name) - Run
python quizz.py
All users in same channel as the bot may play and answers questions. The following commands are for superusers only.
!quizz [channel]
: post random question in given channel and wait for answers
!next [channel]
: solve question and display scores
!create question [option_a, option_b, .., option_x] correct_letter
: create a
new question and adds it to the database
!scores
: display current scores
!scores_reset
: reset current scores
!json
: export current questions in a JSON file
!table
: display the workspace's user table
The cron
script allows to send !quizz
and !next
commands to the bot
at a given frequency so that questions are asked and solved automatically.
Run it in parallel of quizz.py
.