Skip to content

Instantly share code, notes, and snippets.

@siyo
Forked from morygonzalez/favstar.rb
Created November 27, 2011 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save siyo/1397366 to your computer and use it in GitHub Desktop.
Save siyo/1397366 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"]
mark_color = config[:colors].sample + 10
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.gsub(/\r?\n/," ").scan(/^(\d+)\s+stars?:\s(.+)$/).flatten
pub_date = item.pubDate.strftime("%d %B %H:%M")
puts "%s%s %s %s %s %s" % [' '.c(mark_color),"[#{id2var(status_id.to_i)}]".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