Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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