DragonDev15 / triviabot

A Discord Trivia/Quiz bot with over 100,000 questions and lots of features!

Home Page:https://triviabot.co.uk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TriviaBot, the discord bot with over 100,000 questions!

This project contains the source code for the Brainbox.cc TriviaBot. Written in C++17 using Aegis.cpp and ASIO.

It was originally FruitLoopy Trivia on irc.chatspike.net and i've been running this bot in some form since 2004.

This source code repository is for reference and learning only as it won't work without a TriviaBot API key, which i'm not prepared to give out to people (no, this isn't "open trivia database"). Without this key, the bot will start, but will be unable to start any games, or retrieve any statistics or update the cache.

Project and System status

Discord Dashboard Codacy Badge CircleCI

Service Status

Listing Badges

Discord Bots Discord Boats DiscordBotList Bots for Discord

Supported Platforms

Currently only Linux is supported, but other UNIX-style platforms should build and run the bot fine. I build the bot under Debian Linux 10.

Dependencies

  • cmake (version 3.13+)
  • g++ (version 8+)
  • gdb for debugging on development servers (any recent version)
  • aegis.cpp (development branch)
  • asio (included with aegis.cpp)
  • websocketpp (included with aegis.cpp)
  • nlohmann::json (included with aegis.cpp)
  • PCRE (whichever -dev package comes with your OS)
  • MySQL Client Libraries (whichever -dev package comes with your OS)
  • ZLib (whichever -dev package comes with your OS)

Setup

1. Build Source Code

mkdir build
cmake ..
make -j8

Replace the number after -j with a number suitable for your setup, usually the same as the number of cores on your machine.

2. Setup Database

You should have a database configured with the mysql schemas from the mysql-schemas directory. use mysqlimport to import this. Note that the database schema included only has the bare minimum tables to boot the client bot. There is no question database structure, or API schema included in this dump.

3. Edit Configuration File

Edit the config-example.json file and save it as config.json. The configuration variables are documented below:

Key Name Description
devtoken Discord bot token for a development version of the bot, allowing you to keep development and live copies separate
livetoken Discord bot token for live version of the bot (see above)
shardcount Number of shards in total, split across clusters
dbhost Hostname or IP address of MySQL server where the triviabot client schema is hosted
dbuser Username for MySQL server
dbpass Password for MySQL server
dbname Database name for MySQL database on the server containing the triviabot schema
dbport TCP Port number for the MySQL server
utr_readonly_key Readonly API key for uptimerobot, used to update status pages if you are using uptimerobot to monitor uptime
error_recipient E-Mail address to receive core files in the event of a client crash (!)
owner Snowflake ID of the bot owner. There can only be one bot owner
apikey TriviaBot API key. This is NOT an Open Trivia Database key. Speak to Brain#0001 about API keys.
modules A list of modules to load. For basic functionality you should load at least module_diagnostics.so and module_trivia.so
shitlist An array of snowflake IDs of guilds where trivia cannot be started. Instead, the person issuing the !trivia start command will get a friendly message encouraging them to invite the bot to their own server. Put places like bot lists in here.

4. Start Bot

Before the initial startup, you should first make a log directory inside your build directory:

mkdir my-bot-dir/build/log

Once this is done, you will be able to start the bot so long as you've set up the database and configuration file, above.

cd my-bot-dir
./run.sh

run.sh will restart the bot executable continually if it dies. If the bot quits, run.sh will trigger mail-core-fire.sh which will email a coredump to the admin user, if GDB is installed.

Command line parameters

./bot [--dev|--test] [--members] [--clusterid <id> --maxclusters <n>]
Argument Meaning
--dev Run using the development token in the config file. Mutually exclusive with --test
--test Run using the live token in the config file, but squelch all outbound messages unless they originate from the test server (also defined in the config file)
--members Send a GUILD_MEMBERS intent when identifying to the discord gateway. Note that you'll need this after October 2020 for bots in over 100 servers.
--clusterid The id of this process in a cluster of maxclusters processes. Shards are equally shared between all clusters, e.g. if you have two clusters and ten shards each cluster process will have 5 shards on it.
--maxclusters Number of cluster processes to share shards across. You must launch at least this many processes, each of which has a unique cluster id between 0 and max - 1 as it's id using the --clusterid command line parameter

Version History

Version/Date Protocol Platform/Libraries Language Status
1.0 / 2004 IRC WinBot 2.3 WinBotScript (WBS) Discontinued
2.0 / 2005 IRC WinBot 2.3 PlugPerl (Perl 5.6) Discontinued
3.0 / 2005 IRC Botnix 1.0 Beta 1 Perl 5.6 Discontinued
4.0 / 2020 Discord Sporks, aegis.cpp C++17 Active

About

A Discord Trivia/Quiz bot with over 100,000 questions and lots of features!

https://triviabot.co.uk/

License:Apache License 2.0


Languages

Language:C++ 96.8%Language:CMake 0.9%Language:Python 0.8%Language:Perl 0.5%Language:Makefile 0.4%Language:Shell 0.2%Language:PHP 0.2%Language:C 0.1%Language:HTML 0.1%Language:CSS 0.0%Language:Meson 0.0%