Skip to content

Instantly share code, notes, and snippets.

@morygonzalez
Forked from siyo/favstar.rb
Created November 27, 2011 05:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save morygonzalez/1397000 to your computer and use it in GitHub Desktop.
Save morygonzalez/1397000 to your computer and use it in GitHub Desktop.
favstar 見るやつ(色つき) / earthquakge.gem plugin
# -*- coding: utf-8 -*-
# favstar / earthquakge.gem plugin
#
# e.g. :favstar #=> your favstar
# :favstar who #=> who's favstar
#
require 'rss'
Earthquake.init do
command %r|^:favstar\s*(.+)*|, :as => :favstar do |m|
user = m[1] || twitter.info["screen_name"]
url = "http://favstar.fm/users/#{user}/rss"
feed = RSS::Parser.parse(open(url){|f| f.read}, false)
feed.items.reverse.each{|item|
status_id = item.link.gsub(/^.+\/([\d]+?)$/, "\\1")
star,text = item.title.scan(/^(\d+)\s+stars?:\s(.+)$/).flatten
pub_date = item.pubDate.strftime("%d %B %H:%M")
puts "%s %s %s %s %s" % ["[#{id2var(status_id)}]".c(:info), "#{user.c(color_of(user))}:", text, "#{star.c(:notice)} favs", pub_date.c(:info)]
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment