diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-11-05 03:39:00 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-11-05 03:39:00 -0400 |
| commit | 51c0f61bde2799d8c1c903d95578b9d05778a22f (patch) | |
| tree | af20170b9046f32e010518781ea0648a0d3287b4 /owo.cpp | |
| download | fruity-51c0f61bde2799d8c1c903d95578b9d05778a22f.tar.gz fruity-51c0f61bde2799d8c1c903d95578b9d05778a22f.tar.bz2 fruity-51c0f61bde2799d8c1c903d95578b9d05778a22f.zip | |
Initial commit
Diffstat (limited to 'owo.cpp')
| -rw-r--r-- | owo.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
| diff --git a/owo.cpp b/owo.cpp new file mode 100644 index 0000000..d6b3043 --- /dev/null +++ b/owo.cpp | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #include <yaml-cpp/yaml.h> | ||
| 2 | #include <iostream> | ||
| 3 | #include <sstream> | ||
| 4 | #include <twitter.h> | ||
| 5 | #include <verbly.h> | ||
| 6 | #include <chrono> | ||
| 7 | #include <thread> | ||
| 8 | |||
| 9 | int 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 | |||
| 21 | verbly::data database {"data.sqlite3"}; | ||
| 22 | |||
| 23 | verbly::noun bp = database.nouns().with_wnid(105220461).run().front(); // body part | ||
| 24 | verbly::noun pp = database.nouns().with_wnid(104723816).run().front(); // quality | ||
| 25 | verbly::noun cp = database.nouns().with_wnid(103051540).run().front(); // clothing | ||
| 26 | verbly::filter<verbly::noun> filt {bp, pp, cp}; | ||
| 27 | filt.set_orlogic(true); | ||
| 28 | |||
| 29 | for (;;) | ||
| 30 | { | ||
| 31 | std::cout << "Generating tweet" << std::endl; | ||
| 32 | |||
| 33 | auto ns = database.nouns().full_hyponym_of(filt).is_not_proper().random().limit(1).run(); | ||
| 34 | verbly::noun n = ns.front(); | ||
| 35 | |||
| 36 | std::string result = "*notices ur " + n.base_form() + "* OwO whats this..?"; | ||
| 37 | result.resize(140); | ||
| 38 | |||
| 39 | try | ||
| 40 | { | ||
| 41 | client.updateStatus(result); | ||
| 42 | } catch (const twitter::twitter_error& e) | ||
| 43 | { | ||
| 44 | std::cout << "Twitter error: " << e.what() << std::endl; | ||
| 45 | } | ||
| 46 | |||
| 47 | std::cout << result << std::endl; | ||
| 48 | |||
| 49 | std::this_thread::sleep_for(std::chrono::hours(1)); | ||
| 50 | } | ||
| 51 | } | ||
