Skip to content

Commit 8d42743

Browse files
committed
Filter retweets, clarify some corner cases
Related: #9
1 parent f0cb197 commit 8d42743

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

EV0002.rb

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
}
104104

105105
config.plugins.options[Cinch::TwitterWebhooks] = {
106+
:user => "EasyRPG",
106107
:secret => $secrets["twitter_hooks"]["secret"]
107108
}
108109

plugins/twitter_webhooks.rb

+24-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,31 @@ class Cinch::TwitterWebhooks
4343

4444
when "mention"
4545

46-
template = "New tweet by %s (https://twitter.com/%s/status/%s):"
46+
# FIXME: all fields sent by zapier are strings
47+
48+
# ignore normal retweets
49+
retweet = data["retweet_count"]
50+
halt 202 if retweet != "0"
51+
52+
type = "tweet"
53+
54+
# retweet with added message
55+
type = "quoted tweet" if data["is_quote"] == "True"
56+
57+
if data.has_key?('in_reply_to')
58+
59+
type = "tweet in conversation"
60+
61+
# replied to us?
62+
if data["in_reply_to"] == bot.config.plugins.options[Cinch::TwitterWebhooks][:user]
63+
type = "reply"
64+
end
65+
66+
end
67+
68+
template = "New %s by %s (https://twitter.com/%s/status/%s):"
4769
message = sprintf(template,
70+
type,
4871
data["name"],
4972
user,
5073
data["id"])

0 commit comments

Comments
 (0)