diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-12-13 19:32:42 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-12-13 19:32:42 -0500 |
commit | 2000065970431cc2b678c6c09edfd613577382f7 (patch) | |
tree | c25176de8d2e3ffcc410528126e9ebbb2179def7 /nancy.cpp | |
parent | 4aedd681a0ddf511f3bb4254e2960fce7f400b04 (diff) | |
download | nancy-2000065970431cc2b678c6c09edfd613577382f7.tar.gz nancy-2000065970431cc2b678c6c09edfd613577382f7.tar.bz2 nancy-2000065970431cc2b678c6c09edfd613577382f7.zip |
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.
Diffstat (limited to 'nancy.cpp')
-rw-r--r-- | nancy.cpp | 17 |
1 files 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) | |||
34 | 34 | ||
35 | int main(int argc, char** argv) | 35 | int main(int argc, char** argv) |
36 | { | 36 | { |
37 | if (argc != 2) | ||
38 | { | ||
39 | std::cout << "usage: nancy [configfile]" << std::endl; | ||
40 | return -1; | ||
41 | } | ||
42 | |||
43 | std::string configfile(argv[1]); | ||
44 | YAML::Node config = YAML::LoadFile(configfile); | ||
45 | |||
37 | std::random_device random_device; | 46 | std::random_device random_device; |
38 | std::mt19937 random_engine{random_device()}; | 47 | std::mt19937 random_engine{random_device()}; |
39 | 48 | ||
40 | // Forms | 49 | // Forms |
41 | std::vector<std::string> forms; | 50 | std::vector<std::string> forms; |
42 | { | 51 | { |
43 | std::ifstream formfile("forms.txt"); | 52 | std::ifstream formfile(config["forms"].as<std::string>()); |
44 | if (formfile.is_open()) | 53 | if (formfile.is_open()) |
45 | { | 54 | { |
46 | while (!formfile.eof()) | 55 | while (!formfile.eof()) |
@@ -59,17 +68,15 @@ int main(int argc, char** argv) | |||
59 | 68 | ||
60 | if (forms.size() == 0) | 69 | if (forms.size() == 0) |
61 | { | 70 | { |
62 | std::cout << "No forms found... check forms.txt." << std::endl; | 71 | std::cout << "No forms found... check forms file." << std::endl; |
63 | 72 | ||
64 | return 2; | 73 | return 2; |
65 | } | 74 | } |
66 | 75 | ||
67 | // verbly | 76 | // verbly |
68 | verbly::data database("data.sqlite3"); | 77 | verbly::data database(config["verbly_datafile"].as<std::string>()); |
69 | 78 | ||
70 | 79 | ||
71 | YAML::Node config = YAML::LoadFile("config.yml"); | ||
72 | |||
73 | twitter::auth auth; | 80 | twitter::auth auth; |
74 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | 81 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); |
75 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); | 82 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); |