about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ebooks.cpp37
m---------vendor/libtwittercpp0
2 files changed, 20 insertions, 17 deletions
diff --git a/ebooks.cpp b/ebooks.cpp index 593f2fe..aa690c2 100644 --- a/ebooks.cpp +++ b/ebooks.cpp
@@ -47,26 +47,29 @@ int main(int argc, char** args)
47 client.setUserStreamNotifyCallback([&] (twitter::notification n) { 47 client.setUserStreamNotifyCallback([&] (twitter::notification n) {
48 if (n.getType() == twitter::notification::type::tweet) 48 if (n.getType() == twitter::notification::type::tweet)
49 { 49 {
50 std::string original = n.getTweet().getText(); 50 if (!n.getTweet().isRetweet())
51 std::string canonical;
52 std::transform(std::begin(original), std::end(original), std::back_inserter(canonical), [] (char ch) {
53 return std::tolower(ch);
54 });
55
56 if (canonical.find("@rawr_ebooks") != std::string::npos)
57 { 51 {
58 std::string doc = "@" + n.getTweet().getAuthor().getScreenName() + " "; 52 std::string original = n.getTweet().getText();
53 std::string canonical;
54 std::transform(std::begin(original), std::end(original), std::back_inserter(canonical), [] (char ch) {
55 return std::tolower(ch);
56 });
57
58 if (canonical.find("@rawr_ebooks") != std::string::npos)
59 { 59 {
60 std::lock_guard<std::mutex> stats_lock(stats_mutex); 60 std::string doc = "@" + n.getTweet().getAuthor().getScreenName() + " ";
61 doc += stats->randomSentence(140 - doc.length()); 61 {
62 doc.resize(140); 62 std::lock_guard<std::mutex> stats_lock(stats_mutex);
63 } 63 doc += stats->randomSentence(140 - doc.length());
64 doc.resize(140);
65 }
64 66
65 twitter::tweet tw; 67 twitter::tweet tw;
66 twitter::response resp = client.updateStatus(doc, tw, n.getTweet()); 68 twitter::response resp = client.updateStatus(doc, tw, n.getTweet());
67 if (resp != twitter::response::ok) 69 if (resp != twitter::response::ok)
68 { 70 {
69 std::cout << "Twitter error while tweeting: " << resp << std::endl; 71 std::cout << "Twitter error while tweeting: " << resp << std::endl;
72 }
70 } 73 }
71 } 74 }
72 } 75 }
diff --git a/vendor/libtwittercpp b/vendor/libtwittercpp
Subproject 77b6ba9a45714b0b91b9ad782877bce5ca92a25 Subproject 4bcf6d116b92f5969714602ed082ff2a7263edd