-
-
Save siyo/2335545 to your computer and use it in GitHub Desktop.
favstar ふぁぼったりRTしたユーザ名も見るやつ(色つき) / earthquakge.gem plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# favstar / earthquakge.gem plugin | |
# | |
# e.g. :favstar #=> your favstar | |
# :favstar who #=> who's favstar | |
# | |
require 'open-uri' | |
require 'nokogiri' | |
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}/recent" | |
html = Nokogiri::HTML(open(url)) | |
html.css(".tweetWithStats").reverse.each{|st| | |
status_id = st.at(".tweetTop a").attribute("name").text.sub(/^tweet_/,'') | |
tweet = st.at(".theTweet").text | |
favs = st.css("div[id^='faved_by'] a.avatar").map{|a| | |
fav_user = a.attribute("title").text | |
"#{fav_user} ".c(color_of(fav_user)) | |
} | |
rts = st.css("div[id^='rt_by'] a.avatar").map{|a| | |
rt_user = a.attribute("title").text | |
"#{rt_user} ".c(color_of(rt_user)) | |
} | |
puts "%s%s %s %s %s %s %s%s" % [ | |
' '.c(mark_color), | |
"[#{id2var(status_id.to_i)}]".c(:info), | |
"#{user.c(color_of(user))}:", | |
tweet, | |
favs.empty? ? "" : "#{favs.size.to_s.c(:notice)} favs", | |
rts.empty? ? "" : "#{rts.size.to_s.c(:notice)} RTs", | |
favs.empty? ? "" : "Faved by ".c(:info) + favs.join(' '), | |
rts.empty? ? "" : "RT by ".c(:info) + rts.join(' ') | |
] | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment