Toast/README.md

79 lines
4.4 KiB
Markdown
Raw Normal View History

2016-08-16 01:58:24 +01:00
#trivia-bot <img src="https://cdn.discordapp.com/attachments/164732409919569920/205700949304541184/emoji.png" width="30" height="30" /> <img src="http://vps307652.ovh.net:8080/buildStatus/icon?job=trivia-bot" />
2016-07-21 16:02:33 +01:00
2016-07-21 15:01:36 +01:00
A bot which provides a Trivia game for [Discord](https://discordapp.com/).
### Adding to a server
You can either self-host trivia-bot, or use the hosted version.
To invite the bot to your server use [this invite link](https://discordapp.com/oauth2/authorize?client_id=199657080083316737&scope=bot).
It requires no special permissions at this time (only read/write to channels).
2016-08-01 00:59:25 +01:00
### Installation
2016-08-16 01:34:17 +01:00
[Releases](https://github.com/jackb-p/trivia-bot/releases) are available for tagged versions. These are compiled on Debian Jessie by Jenkins. Note that you still require the dependency library files, so you will still have to build V8 and add it to your `LD_LIBRARY_PATH`. To run on other systems you will need to compile yourself - a CMake configuration is included. Windows releases will happen one day.
2016-08-01 00:59:25 +01:00
If you want to install a version for which a release does not exist, you will also have to compile manually. Compilation instructions are available for Linux below.
### Running
To run simply execute the program: `./TriviaBot`
2016-08-16 01:34:17 +01:00
#### Configuration
The config file is automatically generated if it is not present. The JSON format is used. You must edit the config file for the bot to work correctly, the bot token is required.
The current configuration options are as follows:
1. **General**
* `api_cert_file`: The path to the Discord API .crt file for HTTPS.
* `bot_token`: Your Discord bot token.
* `owner_id`: The user ID of the owner of the bot. This allows owner-only (maintenance) commands, such as `shutdown`.
2. **V8**
* `createjs_allowed_roles`: List of role names which are allowed to use the `createjs` command.
2016-08-01 00:59:25 +01:00
2016-07-21 15:01:36 +01:00
### Trivia Questions
Questions are obtained from [trivia-db on Sourceforge](https://sourceforge.net/projects/triviadb/).
To parse the `.txt` question files, place them in `/data_management/questions/` then run `LoadDB.cpp`.
You need to create the database first. Use the included schema and create the database as `/bot/db/trivia.db`.
LoadDB.cpp takes some time to execute.
### Commands
2016-08-16 01:34:17 +01:00
#### Trivia Game
2016-07-21 15:01:36 +01:00
`` `trivia`` is the base command.
2016-08-04 02:53:54 +01:00
| Argument | Description |
| --- | --- |
| `questions` `interval` | Where `questions` and `interval` are integers. Makes the game last `questions` number of questions, optionally sets the time interval between hints to `interval` seconds. |
| stop | Stops the trivia game currently in the channel the message is sent from, if there is one. |
| help | Prints a help list, similar to this table. |
2016-07-21 15:01:36 +01:00
2016-08-16 01:34:17 +01:00
#### Javascript Commands
The Javascript system is designed to mirror the old [Boobot implementation](https://www.boobot.party/). For now there are some exceptions:
1. Message objects aren't implemented.
2. Properties are not case sensitive. You must use `server.Name`, not `server.name`. This will not be changed.
2016-07-21 15:01:36 +01:00
### Compiling
#### Dependencies
2016-08-04 02:53:54 +01:00
| Name | Website | Notes |
| --- | --- | --- |
| boost | [boost.org](http://www.boost.org/) | |
| websocketpp | [zaphoyd/websocketpp](https://github.com/zaphoyd/websocketpp) | Included as submodule. |
| cURL | [curl.haxx.se](https://curl.haxx.se/) | |
| sqlite3 | [sqlite.org](https://www.sqlite.org/) | Included as submodule. Uses a [different repo](https://github.com/azadkuh/sqlite-amalgamation/). |
| nlohmann/json | [nlohmann/json](https://github.com/nlohmann/json) | (Slightly modified) source file included in repo. |
2016-08-16 01:34:17 +01:00
| V8 | [Google V8](https://developers.google.com/v8/) | Debian/Ubuntu `libv8` packages are too outdated. Must be built manually. |
2016-07-21 15:01:36 +01:00
2016-08-16 01:34:17 +01:00
#### Linux (Debian)
c++14 support is required. gcc 5 and above recommended, however it compiles on 4.9.2 (and possibly some versions below.)
2016-08-01 00:59:25 +01:00
2016-07-21 15:01:36 +01:00
1. Clone the github repo: `git clone https://github.com/jackb-p/TriviaDiscord.git TriviaDiscord`
2. Navigate to repository directory: `cd TriviaDiscord`
3. Clone the submodules: `git submodule init` and `git submodule update`
2016-08-16 01:34:17 +01:00
4. Install other dependencies: `sudo apt-get install build-essential cmake libboost-all-dev libcurl4-openssl-dev libssl-dev` (Package managers and names may vary, but all of these should be easy to find through a simple Google search.) V8 may require other dependencies.
5. Build V8. Put the library files into lib/v8/lib/ and the include files into lib/v8/include. More instructions will be added at some point for this step.
6. `cd TriviaBot`
7. `cmake .`
8. `make`