diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | 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. | |||
81 | 81 | ||
82 | ## Configuration | 82 | ## Configuration |
83 | 83 | ||
84 | `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: | 84 | 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: |
85 | ```yaml | 85 | ```yaml |
86 | --- | 86 | --- |
87 | consumer_key: "" | 87 | consumer_key: "" |
88 | consumer_secret: "" | 88 | consumer_secret: "" |
89 | access_key: "" | 89 | access_key: "" |
90 | access_secret: "" | 90 | access_secret: "" |
91 | forms: "data.txt" | ||
91 | ``` | 92 | ``` |
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) | |||
51 | 51 | ||
52 | int main(int argc, char** argv) | 52 | int main(int argc, char** argv) |
53 | { | 53 | { |
54 | YAML::Node config = YAML::LoadFile("config.yml"); | 54 | if (argc != 2) |
55 | { | ||
56 | std::cout << "usage: yandere [configfile]" << std::endl; | ||
57 | return -1; | ||
58 | } | ||
59 | |||
60 | std::string configfile(argv[1]); | ||
61 | YAML::Node config = YAML::LoadFile(configfile); | ||
55 | 62 | ||
56 | twitter::auth auth; | 63 | twitter::auth auth; |
57 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | 64 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); |
@@ -62,10 +69,10 @@ int main(int argc, char** argv) | |||
62 | twitter::client client(auth); | 69 | twitter::client client(auth); |
63 | 70 | ||
64 | std::map<std::string, std::vector<std::string>> groups; | 71 | std::map<std::string, std::vector<std::string>> groups; |
65 | std::ifstream datafile("data.txt"); | 72 | std::ifstream datafile(config["forms"].as<std::string>()); |
66 | if (!datafile.is_open()) | 73 | if (!datafile.is_open()) |
67 | { | 74 | { |
68 | std::cout << "Could not find data.txt" << std::endl; | 75 | std::cout << "Could not find forms file." << std::endl; |
69 | return 1; | 76 | return 1; |
70 | } | 77 | } |
71 | 78 | ||