diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-06-02 20:09:50 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-06-02 20:09:50 -0400 |
commit | c2ca6cc9bdc827fa5290f94d2c7fcc9d1146f89d (patch) | |
tree | 7af64fd889c782d7eeb4e25080dda4d2952f7fa2 /snitch.cpp | |
parent | 1f826b63bbfc90e88537a5f9251040c9807497c2 (diff) | |
download | snitch-c2ca6cc9bdc827fa5290f94d2c7fcc9d1146f89d.tar.gz snitch-c2ca6cc9bdc827fa5290f94d2c7fcc9d1146f89d.tar.bz2 snitch-c2ca6cc9bdc827fa5290f94d2c7fcc9d1146f89d.zip |
Added another trigger
Diffstat (limited to 'snitch.cpp')
-rw-r--r-- | snitch.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/snitch.cpp b/snitch.cpp index b1f01a3..88d9d3b 100644 --- a/snitch.cpp +++ b/snitch.cpp | |||
@@ -24,6 +24,11 @@ int main(int argc, char** argv) | |||
24 | img_file.read(img_buf, img_len); | 24 | img_file.read(img_buf, img_len); |
25 | img_file.close(); | 25 | img_file.close(); |
26 | 26 | ||
27 | std::vector<std::string> triggers { | ||
28 | "calling the cops", | ||
29 | "calling the police" | ||
30 | }; | ||
31 | |||
27 | twitter::client client(auth); | 32 | twitter::client client(auth); |
28 | std::set<twitter::user_id> streamed_friends; | 33 | std::set<twitter::user_id> streamed_friends; |
29 | client.setUserStreamReceiveAllReplies(true); | 34 | client.setUserStreamReceiveAllReplies(true); |
@@ -47,23 +52,28 @@ int main(int argc, char** argv) | |||
47 | std::transform(std::begin(orig), std::end(orig), std::back_inserter(canonical), [] (char ch) { | 52 | std::transform(std::begin(orig), std::end(orig), std::back_inserter(canonical), [] (char ch) { |
48 | return std::tolower(ch); | 53 | return std::tolower(ch); |
49 | }); | 54 | }); |
50 | |||
51 | if (canonical.find("calling the cops") != std::string::npos) | ||
52 | { | ||
53 | std::cout << "Calling the cops on @" << n.getTweet().getAuthor().getScreenName() << std::endl; | ||
54 | 55 | ||
55 | long media_id; | 56 | for (auto trigger : triggers) |
56 | twitter::response resp = client.uploadMedia("image/jpeg", (const char*) img_buf, img_len, media_id); | 57 | { |
57 | if (resp != twitter::response::ok) | 58 | if (canonical.find(trigger) != std::string::npos) |
58 | { | 59 | { |
59 | std::cout << "Twitter error while uploading image: " << resp << std::endl; | 60 | std::cout << "Calling the cops on @" << n.getTweet().getAuthor().getScreenName() << std::endl; |
60 | } else { | 61 | |
61 | twitter::tweet tw; | 62 | long media_id; |
62 | resp = client.updateStatus(client.generateReplyPrefill(n.getTweet()), tw, n.getTweet(), {media_id}); | 63 | twitter::response resp = client.uploadMedia("image/jpeg", (const char*) img_buf, img_len, media_id); |
63 | if (resp != twitter::response::ok) | 64 | if (resp != twitter::response::ok) |
64 | { | 65 | { |
65 | std::cout << "Twitter error while tweeting: " << resp << std::endl; | 66 | std::cout << "Twitter error while uploading image: " << resp << std::endl; |
67 | } else { | ||
68 | twitter::tweet tw; | ||
69 | resp = client.updateStatus(client.generateReplyPrefill(n.getTweet()), tw, n.getTweet(), {media_id}); | ||
70 | if (resp != twitter::response::ok) | ||
71 | { | ||
72 | std::cout << "Twitter error while tweeting: " << resp << std::endl; | ||
73 | } | ||
66 | } | 74 | } |
75 | |||
76 | break; | ||
67 | } | 77 | } |
68 | } | 78 | } |
69 | } | 79 | } |