Skip to content

Instantly share code, notes, and snippets.

@siyo
Last active September 27, 2015 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siyo/1296430 to your computer and use it in GitHub Desktop.
Save siyo/1296430 to your computer and use it in GitHub Desktop.
パクリツイートを通知するearthquake.gem plugin
# -*- coding: utf-8 -*-
#
Earthquake.init do
output_filter do |item|
("aa".."zz").to_a.each{|v|
break unless id = var2id("$#{v}");
next unless st = cache.read("status:#{id}");
if st["text"] \
&& st["user"] \
&& st["text"] == item["text"] \
&& st["user"]["screen_name"] != item["user"]["screen_name"]
echo = "Echo"
src = st["user"]["screen_name"]
dst = item["user"]["screen_name"]
txt = item["text"]
arg = {
"-t" => "%s: %s -> %s" % [echo, src, dst],
"-m" => txt
}
system("growlnotify", *arg.to_a.flatten)
puts "%s: %s / %s -> %s" % [ echo.c(:event),
txt,
src.c( color_of(src) ),
dst.c( color_of(dst) )]
end
}
end
end
# https://gist.github.com/1296430
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment