cleartonic / twitchtriviabot

Twitch Trivia Bot
MIT License
23 stars 13 forks source link

Twitch Trivia Bot

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.

img

Features:

Setup

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.

To 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.

Running the bot

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.

Misc. Functionalities

Hints and question timing

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

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.

Commands

The GUI and these commands below will yield the same results. Some commands are available only during active trivia sessions.

Admin only:

All users:

Credits

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/)