Twitch Trivia Bot (TTB) is a Python script to run a trivia session in Twitch chat. The bot will load a quiz set, run a session of trivia, assign a winner and save scores dynamically.
The latest Python 3 install is required for this bot. You will need to install Python 3 to be able to run. One can either use standard Python 3 distribution with IDLE, or use something like the Anaconda distribution with Spyder (what I use).
You will likely need to install a few dependencies, including PyYaml
and PyQt5
. You can do this via command line pip install [x]
or pip3 install [x]
(e.g. "pip install PyYaml"). On your first few runs if the program/GUI does not load, make sure to check config/output_log.log
to read the error codes to identify what needs to be installed.
Please use the latest Release download for initial install.
poll
modes for how long to wait before pollingsingle
- Standard trivia, first to answer wins the pointpoll
- In this mode, during the entirety of the skip_time, questions are polled for answers from players. At the end of each question, the first and second player to respond earn more points, then all others get some less amount of pointpoll2
- This is the same as above, but every question has a separate answer pool for "answer" and "answer2". This means, for example, one question can have two separate answers, and players can score on each answer separatelytrue
or false
. Music mode is a manually-driven mode where the admin can start and stop questions via "Start Q" and "End Q" buttons on the GUI. Instead of loading the trivia set csv file, every question is loaded from /config/music/artist.txt
and track.txt
. Questions do not automatically start after their alloted time is up to answer - instead, the admin will manually choose when the next song is ready to be played.
poll2
and length infinite
must be selected for music_mode true
random
or ordered
. This allows the questions to be answered in order of the original trivia set, or to be chosen randomly. If ordered
is chosen, likely it is advised to set question_count
equal to the number of questions in the trivia set, which will yield all questions in order. random
or distributed
. After the full trivia csv file is loaded, this will decide how to cull down the full set into the desired question_count
number of questions. random
will randomly choose the questions, regardless of category. distributed
will attempt to distribute the categories of questions semi-evenly, meaning that both a sampling method for culling the full set is used, and then averages per category are checked to ensure a decently distributed final trivia session set. finite
or infinite
. When using infinite
, questions will never stop being asked until the admin chooses to end trivia. Questions are not reshuffled - they will continually be reasked in the same order. finite
ends trivia after the question_count
defined aboveutf-8
or ISO-8859-1
. Somewhat experimental, default to utf-8
for safetyTo set up triviaset.csv properly, consider the following: 5 headers in this release are specified: ‘category, ‘question’, ‘answer’, ‘answer2’, ‘creator’. Keep them in this order, but your trivia set does not need to keep the column header. Fill out row by row each question, filling in topic/game, and at least 1 Answer column. Creator and Answer2 are not required fields.
A log will be saved per run to config/output_log.log
. This will accumulate over time, and is useful for debugging problems. At any point, you can delete the log file if it becomes too large.
With a command line/terminal open:
python twitchtriviabot.py
or python3 twitchtriviabot.py
From here, you can monitor the bot’s activity. All user responses in the Twitch channel will appear in the console. Each question’s answer will appear in the console.
If you need to close the GUI and stop the program, usually holding Ctrl+C will kill the program in the console/terminal.
All timings can be manually adjusted in trivia_config.yml. By default, after a question is asked, automatically generated hints will trigger (specified by trivia_config.yml). Later, the question will be skipped. After the specified session question limit is hit, the game will end, and a winner will be assigned.
Bonus can be activated by an admin via !bonus command. Bonus mode makes questions worth more points, default 3 points (configurable in trivia_config.yml). Can be toggled on/off at any time.
The GUI and these commands below will yield the same results. Some commands are available only during active trivia sessions.
Created by @cleartonic
Thanks to cormac-obrien’s publicly available instructions to navigate Twitch's IRC API via Python & socket, which was used in various forms within this release (http://www.instructables.com/id/Twitchtv-Moderator-Bot/)