summary refs log tree commit diff stats
path: root/composite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'composite.cpp')
-rw-r--r--composite.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/composite.cpp b/composite.cpp new file mode 100644 index 0000000..891f179 --- /dev/null +++ b/composite.cpp
@@ -0,0 +1,39 @@
1#include <verbly.h>
2#include <yaml-cpp/yaml.h>
3#include <twitter.h>
4#include <chrono>
5#include <string>
6#include <thread>
7#include <iostream>
8
9int main(int argc, char** argv)
10{
11 YAML::Node config = YAML::LoadFile("config.yml");
12
13 twitter::auth auth;
14 auth.setConsumerKey(config["consumer_key"].as<std::string>());
15 auth.setConsumerSecret(config["consumer_secret"].as<std::string>());
16 auth.setAccessKey(config["access_key"].as<std::string>());
17 auth.setAccessSecret(config["access_secret"].as<std::string>());
18
19 twitter::client client(auth);
20 verbly::data database("data.sqlite3");
21
22 for (;;)
23 {
24 std::cout << "Generating..." << std::endl;
25 auto nq = database.nouns().with_stress({{true, false, false}}).random().limit(1).run().front();
26 std::string output = "full metal " + nq.singular_form();
27 std::cout << output << std::endl;
28
29 twitter::tweet sent;
30 twitter::response resp = client.updateStatus(output, sent);
31 if (resp != twitter::response::ok)
32 {
33 std::cout << "Twitter error: " << resp << std::endl;
34 }
35
36 std::cout << "Waiting..." << std::endl;
37 std::this_thread::sleep_for(std::chrono::hours(1));
38 }
39} \ No newline at end of file