summary refs log tree commit diff stats
path: root/owo.cpp
blob: d6b304320ae2cb86dbfdf7a8e7a1b1fa8df7ccbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <yaml-cpp/yaml.h>
#include <iostream>
#include <sstream>
#include <twitter.h>
#include <verbly.h>
#include <chrono>
#include <thread>

int main(int argc, char** argv)
{
  YAML::Node config = YAML::LoadFile("config.yml");
  
  twitter::auth auth;
  auth.setConsumerKey(config["consumer_key"].as<std::string>());
  auth.setConsumerSecret(config["consumer_secret"].as<std::string>());
  auth.setAccessKey(config["access_key"].as<std::string>());
  auth.setAccessSecret(config["access_secret"].as<std::string>());
  
  twitter::client client(auth);
  
  verbly::data database {"data.sqlite3"};

  verbly::noun bp = database.nouns().with_wnid(105220461).run().front(); // body part
  verbly::noun pp = database.nouns().with_wnid(104723816).run().front(); // quality
  verbly::noun cp = database.nouns().with_wnid(103051540).run().front(); // clothing
  verbly::filter<verbly::noun> filt {bp, pp, cp};
  filt.set_orlogic(true);
  
  for (;;)
  {
    std::cout << "Generating tweet" << std::endl;
    
    auto ns = database.nouns().full_hyponym_of(filt).is_not_proper().random().limit(1).run();
    verbly::noun n = ns.front();
    
    std::string result = "*notices ur " + n.base_form() + "* OwO whats this..?";
    result.resize(140);
    
    try
    {
      client.updateStatus(result);
    } catch (const twitter::twitter_error& e)
    {
      std::cout << "Twitter error: " << e.what() << std::endl;
    }
    
    std::cout << result << std::endl;
    
    std::this_thread::sleep_for(std::chrono::hours(1));
  }
}