Rename (trivia-bot -> Toast)

This commit is contained in:
Jack Bond-Preston 2016-11-14 00:40:02 +00:00
parent 301d99ca2f
commit a802e6ae38
33 changed files with 16 additions and 79 deletions

12
.gitignore vendored
View File

@ -1,14 +1,14 @@
# VS files
/.vs/
/TriviaBot.sln
/TriviaBot.VC*
/TriviaBot/TriviaBot.vcxproj*
/TriviaBot/x64/
/Toast.sln
/Toast.VC*
/Toast/Toast.vcxproj*
/Toast/x64/
/x64/
# Data files
/TriviaBot/data_management/questions
/TriviaBot/bot/db/trivia.db
/Toast/data_management/questions
/Toast/bot/db/trivia.db
# Config file
config.json

View File

@ -1,4 +1,4 @@
#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" />
# Toast <img src="https://www.ahealthiermichigan.org/wp-content/uploads/2014/09/Transform-toast-into-breakfast.jpg" width="30" height="30" />
A bot which provides a Trivia game for [Discord](https://discordapp.com/).
@ -16,7 +16,7 @@ If you want to install a version for which a release does not exist, you will al
### Running
To run simply execute the program: `./TriviaBot`
To run simply execute the program: `./Toast`
#### 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.
@ -53,8 +53,9 @@ LoadDB.cpp takes some time to execute.
#### 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.
2. Properties *are* case sensitive. You must use `server.Name`, not `server.name`. This will not be changed.
### Compiling
#### Dependencies
@ -70,11 +71,11 @@ The Javascript system is designed to mirror the old [Boobot implementation](http
#### Linux (Debian)
c++14 support is required. gcc 5 and above recommended, however it compiles on 4.9.2 (and possibly some versions below.)
1. Clone the github repo: `git clone https://github.com/jackb-p/TriviaDiscord.git TriviaDiscord`
2. Navigate to repository directory: `cd TriviaDiscord`
1. Clone the github repo: `git clone https://github.com/jackb-p/Toast.git ToastBot`
2. Navigate to repository directory: `cd ToastBot`
3. Clone the submodules: `git submodule init` and `git submodule update`
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`
6. `cd Toast`
7. `cmake .`
8. `make`

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.7)
project(TriviaBot)
project(Toast)
###############################################################################
## get source ## ##############################################################
@ -14,7 +14,7 @@ link_directories(../lib/v8/lib)
###############################################################################
# add the data to the target, so it becomes visible in some IDE
add_executable(TriviaBot ${sources})
add_executable(Toast ${sources})
# add some compiler flags
set (CMAKE_CXX_FLAGS "-std=c++14 -Wall ${CMAKE_CXX_FLAGS}")
@ -27,7 +27,7 @@ find_package(Boost COMPONENTS system thread regex REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(CURL REQUIRED)
target_link_libraries(TriviaBot PUBLIC
target_link_libraries(Toast PUBLIC
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
${CURL_LIBRARIES}

View File

@ -1,64 +0,0 @@
#include <curl/curl.h>
#include <include/libplatform/libplatform.>
#include <include/v8.h>
#include "ClientConnection.hpp"
#include "Logger.hpp"
#include "DiscordAPI.hpp"
std::string bot_token;
int main(int argc, char *argv[]) {
curl_global_init(CURL_GLOBAL_DEFAULT);
v8::V8::InitializeICUDefaultLocation(argv[0]);
v8::V8::InitializeExternalStartupData(argv[0]);
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
Logger::write("Initialised V8 and curl", Logger::LogLevel::Debug);
if (argc == 2) {
bot_token = argv[1];
}
else {
std::cout << "Please enter your bot token: " << std::endl;
std::cin >> bot_token;
}
std::string args = "/?v=5&encoding=json";
std::string url = DiscordAPI::get_gateway().value("url", "wss://gateway.discord.gg");
bool retry = true;
while (retry) {
try {
ClientConnection conn;
conn.start(url + args);
}
catch (const std::exception &e) {
Logger::write("std exception: " + std::string(e.what()), Logger::LogLevel::Severe);
retry = false;
}
catch (websocketpp::lib::error_code e) {
Logger::write("websocketpp exception: " + e.message(), Logger::LogLevel::Severe);
}
catch (...) {
Logger::write("other exception.", Logger::LogLevel::Severe);
retry = false;
}
}
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
curl_global_cleanup();
Logger::write("Cleaned up", Logger::LogLevel::Info);
std::cout << "Press enter to exit" << std::endl;
std::getchar();
return 0;
}