about summary refs log tree commit diff stats
path: root/difference.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-12-13 19:02:11 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-12-13 19:02:11 -0500
commit95e89d24d998c75dae191ceefbe17c0d44c2d78a (patch)
treeeb6de938a993d4b0e05b4153fd1794ec44063265 /difference.cpp
parent2e15e8d865319ca4b85b40266b856f2f45383829 (diff)
downloaddifference-95e89d24d998c75dae191ceefbe17c0d44c2d78a.tar.gz
difference-95e89d24d998c75dae191ceefbe17c0d44c2d78a.tar.bz2
difference-95e89d24d998c75dae191ceefbe17c0d44c2d78a.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 font to use.
Diffstat (limited to 'difference.cpp')
-rw-r--r--difference.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/difference.cpp b/difference.cpp index c2e3b37..b9290cb 100644 --- a/difference.cpp +++ b/difference.cpp
@@ -88,10 +88,18 @@ bool downloadImage(std::string url, curl::curl_header headers, Magick::Blob& img
88int main(int argc, char** argv) 88int main(int argc, char** argv)
89{ 89{
90 Magick::InitializeMagick(nullptr); 90 Magick::InitializeMagick(nullptr);
91 91
92 if (argc != 2)
93 {
94 std::cout << "usage: difference [configfile]" << std::endl;
95 return -1;
96 }
97
98 std::string configfile(argv[1]);
99 YAML::Node config = YAML::LoadFile(configfile);
100
92 int delay = 60 * 60; 101 int delay = 60 * 60;
93 102
94 YAML::Node config = YAML::LoadFile("config.yml");
95 twitter::auth auth; 103 twitter::auth auth;
96 auth.setConsumerKey(config["consumer_key"].as<std::string>()); 104 auth.setConsumerKey(config["consumer_key"].as<std::string>());
97 auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); 105 auth.setConsumerSecret(config["consumer_secret"].as<std::string>());
@@ -103,7 +111,9 @@ int main(int argc, char** argv)
103 std::random_device random_device; 111 std::random_device random_device;
104 std::mt19937 random_engine{random_device()}; 112 std::mt19937 random_engine{random_device()};
105 113
106 verbly::data database("data.sqlite3"); 114 std::string fontfile = "@" + config["font"].as<std::string>();
115
116 verbly::data database(config["verbly_datafile"].as<std::string>());
107 117
108 auto whitelist = database.nouns(); 118 auto whitelist = database.nouns();
109 whitelist.with_wnid(111530512); // Crops (plants) 119 whitelist.with_wnid(111530512); // Crops (plants)
@@ -264,7 +274,7 @@ int main(int argc, char** argv)
264 Magick::Image composite(Magick::Geometry(width*2, height, 0, 0), "white"); 274 Magick::Image composite(Magick::Geometry(width*2, height, 0, 0), "white");
265 composite.draw(Magick::DrawableCompositeImage(0, 0, pic1)); 275 composite.draw(Magick::DrawableCompositeImage(0, 0, pic1));
266 composite.draw(Magick::DrawableCompositeImage(width, 0, pic2)); 276 composite.draw(Magick::DrawableCompositeImage(width, 0, pic2));
267 composite.font("@coolvetica.ttf"); 277 composite.font(fontfile);
268 278
269 double fontsize = 72; 279 double fontsize = 72;
270 for (;;) 280 for (;;)