diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-20 21:34:09 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-20 21:34:09 -0400 |
commit | a9c391efd5f0f73b5374dcfd807cdf59ed663e6b (patch) | |
tree | a2dde7f2ec53d981d77d447d1f00794cf9869d1a | |
parent | b9524e9c9dc98a17f09986ff7ab319114f81aebe (diff) | |
download | rawr-ebooks-a9c391efd5f0f73b5374dcfd807cdf59ed663e6b.tar.gz rawr-ebooks-a9c391efd5f0f73b5374dcfd807cdf59ed663e6b.tar.bz2 rawr-ebooks-a9c391efd5f0f73b5374dcfd807cdf59ed663e6b.zip |
Now ignoring retweets as they aren't really mentions
-rw-r--r-- | ebooks.cpp | 37 | ||||
m--------- | vendor/libtwittercpp | 0 |
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 | ||