Skip to content

Instantly share code, notes, and snippets.

@siyo
Created October 18, 2011 10:53
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/1295153 to your computer and use it in GitHub Desktop.
Save siyo/1295153 to your computer and use it in GitHub Desktop.
パクリツイートを見つけてさらにパクる時用earthquake.gem plugin
# -*- coding: utf-8 -*-
#
# e.g.
# [$ab] foo: yo!
# .
# .
# [$nz] who: yo!
#
# ⚡ :echo
# update 'yo!' [Yn]
#
Earthquake.init do
command :echo do
a = ("aa".."zz").to_a.inject([]){|s,v|
break s unless id = var2id("$#{v}");
next s unless st = cache.read("status:#{id}");
s << st if st["text"] && !(/^RT\s/ =~ st["text"])
s
}
txts = a.sort_by{|e| e["id"]}.reverse.map{|st| st["text"]}
if txt = txts.uniq.detect{|e| txts.index(e) != txts.rindex(e)}
input(":update #{txt}")
else
puts "Not found echo tweet."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment