about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-02-06 21:05:15 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-02-06 21:05:15 -0500
commitf33210aebfa4fc8055566fe3bc2f38713b7fe1fb (patch)
tree4c8ea52f829733be298e6bb0036c4e34ef2b5a48
parent7d42f16171533fd9ef19688d39f30cd6774961ec (diff)
downloadblessed-f33210aebfa4fc8055566fe3bc2f38713b7fe1fb.tar.gz
blessed-f33210aebfa4fc8055566fe3bc2f38713b7fe1fb.tar.bz2
blessed-f33210aebfa4fc8055566fe3bc2f38713b7fe1fb.zip
Updated verbly (new API)
Also updated libtwitter++, and blacklisted ethnic slurs.
-rw-r--r--blessed.cpp67
m---------vendor/libtwittercpp0
m---------vendor/verbly0
3 files changed, 34 insertions, 33 deletions
diff --git a/blessed.cpp b/blessed.cpp index 2649f45..8bb8d3f 100644 --- a/blessed.cpp +++ b/blessed.cpp
@@ -20,19 +20,19 @@ int main(int argc, char** argv)
20 20
21 std::random_device random_device; 21 std::random_device random_device;
22 std::mt19937 random_engine{random_device()}; 22 std::mt19937 random_engine{random_device()};
23 23
24 YAML::Node config = YAML::LoadFile(configfile); 24 YAML::Node config = YAML::LoadFile(configfile);
25 25
26 twitter::auth auth; 26 twitter::auth auth;
27 auth.setConsumerKey(config["consumer_key"].as<std::string>()); 27 auth.setConsumerKey(config["consumer_key"].as<std::string>());
28 auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); 28 auth.setConsumerSecret(config["consumer_secret"].as<std::string>());
29 auth.setAccessKey(config["access_key"].as<std::string>()); 29 auth.setAccessKey(config["access_key"].as<std::string>());
30 auth.setAccessSecret(config["access_secret"].as<std::string>()); 30 auth.setAccessSecret(config["access_secret"].as<std::string>());
31 31
32 twitter::client client(auth); 32 twitter::client client(auth);
33 33
34 verbly::data database {config["verbly_datafile"].as<std::string>()}; 34 verbly::database database {config["verbly_datafile"].as<std::string>()};
35 35
36 std::vector<std::string> emojis; 36 std::vector<std::string> emojis;
37 { 37 {
38 std::ifstream emojifile(config["emoji_file"].as<std::string>()); 38 std::ifstream emojifile(config["emoji_file"].as<std::string>());
@@ -49,33 +49,33 @@ int main(int argc, char** argv)
49 { 49 {
50 line.pop_back(); 50 line.pop_back();
51 } 51 }
52 52
53 emojis.push_back(line); 53 emojis.push_back(line);
54 } 54 }
55 } 55 }
56 56
57 std::uniform_int_distribution<int> emojidist(0, emojis.size()-1); 57 std::uniform_int_distribution<int> emojidist(0, emojis.size()-1);
58 std::bernoulli_distribution continuedist(1.0/2.0); 58 std::bernoulli_distribution continuedist(1.0/2.0);
59 59
60 verbly::query<verbly::form> verbQuery = database.forms(
61 (verbly::notion::partOfSpeech == verbly::part_of_speech::verb)
62 && (verbly::pronunciation::rhymes));
63
60 for (;;) 64 for (;;)
61 { 65 {
62 std::cout << "Generating tweet..." << std::endl; 66 std::cout << "Generating tweet..." << std::endl;
63 67
64 std::string exclamation; 68 verbly::form verb = verbQuery.first();
65 while (exclamation.empty()) 69
66 { 70 verbly::form noun = database.forms(
67 verbly::verb v = database.verbs().random().limit(1).has_pronunciation().run().front(); 71 (verbly::notion::partOfSpeech == verbly::part_of_speech::noun)
68 auto rhyms = database.nouns().rhymes_with(v).random().limit(1).is_not_proper().run(); 72 && (verbly::pronunciation::rhymes %= verb)
69 if (!rhyms.empty()) 73 && (verbly::form::proper == false)
70 { 74 && (verbly::form::id != verb.getId())
71 auto n = rhyms.front(); 75 && !(verbly::word::usageDomains %= (verbly::notion::wnid == 106718862))).first();
72 if (n.base_form() != v.base_form()) 76
73 { 77 std::string exclamation = "god " + verb.getText() + " this " + noun.getText();
74 exclamation = "god " + v.base_form() + " this " + n.base_form(); 78
75 }
76 }
77 }
78
79 std::string emojibef; 79 std::string emojibef;
80 std::string emojiaft; 80 std::string emojiaft;
81 int emn = 0; 81 int emn = 0;
@@ -86,7 +86,7 @@ int main(int argc, char** argv)
86 emojibef += em; 86 emojibef += em;
87 emojiaft = em + emojiaft; 87 emojiaft = em + emojiaft;
88 } while (continuedist(random_engine)); 88 } while (continuedist(random_engine));
89 89
90 std::string result; 90 std::string result;
91 if (emn > 3) 91 if (emn > 3)
92 { 92 {
@@ -94,22 +94,23 @@ int main(int argc, char** argv)
94 } else { 94 } else {
95 result = emojibef + " " + exclamation + " " + emojiaft; 95 result = emojibef + " " + exclamation + " " + emojiaft;
96 } 96 }
97 97
98 result.resize(140); 98 result.resize(140);
99 std::cout << result << std::endl; 99 std::cout << result << std::endl;
100 100
101 try 101 try
102 { 102 {
103 client.updateStatus(result); 103 client.updateStatus(result);
104 104
105 std::cout << "Tweeted!" << std::endl; 105 std::cout << "Tweeted!" << std::endl;
106 std::cout << "Waiting..." << std::endl;
107
108 std::this_thread::sleep_for(std::chrono::hours(1));
109
110 std::cout << std::endl;
106 } catch (const twitter::twitter_error& e) 111 } catch (const twitter::twitter_error& e)
107 { 112 {
108 std::cout << "Twitter error: " << e.what() << std::endl; 113 std::cout << "Twitter error: " << e.what() << std::endl;
109 } 114 }
110
111 std::cout << "Waiting..." << std::endl;
112
113 std::this_thread::sleep_for(std::chrono::hours(1));
114 } 115 }
115} 116}
diff --git a/vendor/libtwittercpp b/vendor/libtwittercpp
Subproject d783c17151a98466e304b1e5f33bfca0be885fd Subproject df906121dd862c0f704e44f28ee079158c431c4
diff --git a/vendor/verbly b/vendor/verbly
Subproject 1f898f3bd66c29672275c2c884b17ba662ced62 Subproject f1f67e62cebb4144f0599196263cd93b41fa972