diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-12-14 02:10:28 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-12-14 02:10:28 -0500 |
commit | 6ce9e71bd0f188bcb5a66ecbad8af348b3e348af (patch) | |
tree | 01eb612f0e67416f1bc2acb8bc6a872e8d73855a | |
parent | beb58a9aa0ddc3d8d85014105745ad4f2629e8c5 (diff) | |
download | snitch-6ce9e71bd0f188bcb5a66ecbad8af348b3e348af.tar.gz snitch-6ce9e71bd0f188bcb5a66ecbad8af348b3e348af.tar.bz2 snitch-6ce9e71bd0f188bcb5a66ecbad8af348b3e348af.zip |
Bot now takes path to config file as argument
That config file now also has to contain the path to the image to post.
-rw-r--r-- | snitch.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/snitch.cpp b/snitch.cpp index 700a0a9..3758dc0 100644 --- a/snitch.cpp +++ b/snitch.cpp | |||
@@ -8,7 +8,14 @@ | |||
8 | 8 | ||
9 | int main(int argc, char** argv) | 9 | int main(int argc, char** argv) |
10 | { | 10 | { |
11 | YAML::Node config = YAML::LoadFile("config.yml"); | 11 | if (argc != 2) |
12 | { | ||
13 | std::cout << "usage: snitch [configfile]" << std::endl; | ||
14 | return -1; | ||
15 | } | ||
16 | |||
17 | std::string configfile(argv[1]); | ||
18 | YAML::Node config = YAML::LoadFile(configfile); | ||
12 | 19 | ||
13 | twitter::auth auth; | 20 | twitter::auth auth; |
14 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | 21 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); |
@@ -16,7 +23,7 @@ int main(int argc, char** argv) | |||
16 | auth.setAccessKey(config["access_key"].as<std::string>()); | 23 | auth.setAccessKey(config["access_key"].as<std::string>()); |
17 | auth.setAccessSecret(config["access_secret"].as<std::string>()); | 24 | auth.setAccessSecret(config["access_secret"].as<std::string>()); |
18 | 25 | ||
19 | std::ifstream img_file("image.jpg"); | 26 | std::ifstream img_file(config["image"].as<std::string>()); |
20 | img_file.seekg(0, std::ios::end); | 27 | img_file.seekg(0, std::ios::end); |
21 | size_t img_len = img_file.tellg(); | 28 | size_t img_len = img_file.tellg(); |
22 | char* img_buf = new char[img_len]; | 29 | char* img_buf = new char[img_len]; |