From 0f2802b3c8f3d1096df7ac483eba390ae952e13f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 14 Dec 2016 02:30:14 -0500 Subject: Bot now takes path to config file as argument That config file now also has to contain the path to the forms file. --- README.md | 3 ++- yandere.cpp | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 08fc3b5..2e271a3 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,12 @@ There is one "special" group name: `{\n}` is always replaced by a newline. ## Configuration -`yandere` looks for a file named `data.txt` in its working directory, and uses it as its datafile. As explained above, this datafile should at least have a group named `MAIN`. The bot also looks for a file named `config.yml`, from which it reads the details for authenticating with Twitter. This configuration file should have the following format, with the appropriate tokens inserted between the appropriate pairs of double quotes: +When you run `yandere`, you pass it the path of a configuration file that tells the bot where to look for its datafile, which it calls "forms". As explained above, this datafile should at least have a group named `MAIN`. The bot also reads the details for authenticating with Twitter from this configuration file. This file should have the following format, with the appropriate tokens inserted between the appropriate pairs of double quotes: ```yaml --- consumer_key: "" consumer_secret: "" access_key: "" access_secret: "" + forms: "data.txt" ``` diff --git a/yandere.cpp b/yandere.cpp index ec7322d..b9d42ec 100644 --- a/yandere.cpp +++ b/yandere.cpp @@ -51,7 +51,14 @@ Container split(std::string input, std::string delimiter) int main(int argc, char** argv) { - YAML::Node config = YAML::LoadFile("config.yml"); + if (argc != 2) + { + std::cout << "usage: yandere [configfile]" << std::endl; + return -1; + } + + std::string configfile(argv[1]); + YAML::Node config = YAML::LoadFile(configfile); twitter::auth auth; auth.setConsumerKey(config["consumer_key"].as()); @@ -62,10 +69,10 @@ int main(int argc, char** argv) twitter::client client(auth); std::map> groups; - std::ifstream datafile("data.txt"); + std::ifstream datafile(config["forms"].as()); if (!datafile.is_open()) { - std::cout << "Could not find data.txt" << std::endl; + std::cout << "Could not find forms file." << std::endl; return 1; } -- cgit 1.4.1