From 2000065970431cc2b678c6c09edfd613577382f7 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 13 Dec 2016 19:32:42 -0500 Subject: Bot now takes path to config file as argument That config file now also has to contain the paths to the verbly datafile and the forms file. --- nancy.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/nancy.cpp b/nancy.cpp index 47f9c18..a5a1433 100644 --- a/nancy.cpp +++ b/nancy.cpp @@ -34,13 +34,22 @@ std::string capitalize(std::string input) int main(int argc, char** argv) { + if (argc != 2) + { + std::cout << "usage: nancy [configfile]" << std::endl; + return -1; + } + + std::string configfile(argv[1]); + YAML::Node config = YAML::LoadFile(configfile); + std::random_device random_device; std::mt19937 random_engine{random_device()}; // Forms std::vector forms; { - std::ifstream formfile("forms.txt"); + std::ifstream formfile(config["forms"].as()); if (formfile.is_open()) { while (!formfile.eof()) @@ -59,17 +68,15 @@ int main(int argc, char** argv) if (forms.size() == 0) { - std::cout << "No forms found... check forms.txt." << std::endl; + std::cout << "No forms found... check forms file." << std::endl; return 2; } // verbly - verbly::data database("data.sqlite3"); + verbly::data database(config["verbly_datafile"].as()); // Twitter - YAML::Node config = YAML::LoadFile("config.yml"); - twitter::auth auth; auth.setConsumerKey(config["consumer_key"].as()); auth.setConsumerSecret(config["consumer_secret"].as()); -- cgit 1.4.1