Skip to content

Instantly share code, notes, and snippets.

@siyo siyo/friendship_weather.rb
Last active Dec 16, 2015

Embed
What would you like to do?
相互フォローかそうじゃないかとかをお天気マークとかで見れるやつプラギン
# -*- coding: utf-8 -*-
# frindship weather plugin / earthquake.gem plugin
#
require 'singleton'
Earthquake.once do
class Followers
include Singleton
attr_reader :ids
def initialize
@ids = []
end
def update_ids(twitter)
followers = twitter.followers_ids
@ids = followers["ids"]
end
end
end
Earthquake.init do
output_filter do |item|
# Miscellaneous Symbols [UTF8 Unicode Characters]
# http://utf8-characters.com/miscellaneous-symbols/#weather-and-astrological-symbols
#
# ANSI escape code - Wikipedia, the free encyclopedia
# http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
mark_infos = {
fine: [
'',
90 + 3 # bright yellow
],
cloud: [
'',
30 + 7 # normal grey
],
rain: [
'',
90 + 4 # bright blue
],
star: [
'',
30 + 3 # normal yellow
],
}
followers = Followers.instance
if followers.ids.empty? || (item['event'] && item['event'] =~ /follow/)
followers.update_ids(twitter)
end
mark = color = nil
if item['text'] && item['text'] =~ /@#{twitter.info['screen_name']}\s/
mark, color = mark_infos[:fine]
elsif item['retweeted_status']
mark, color = mark_infos[:star]
else
if item['user']
mark, color = if item['user']['id'] == twitter.info['id']
mark_infos[:cloud]
elsif followers.ids.include?(item['user']['id'])
mark_infos[:fine]
else
mark_infos[:rain]
end
end
end
item['_mark'] = mark.c(color) + ' ' if mark && color
true
end
command :update_follower_ids do
followers = Followers.instance
last_ids = followers.ids
ids = followers.update_ids(twitter)
puts ("followers: %d => %d" % [last_ids.size, ids.size]).c(:info)
end
end
@siyo

This comment has been minimized.

Copy link
Owner Author

commented Apr 29, 2013

こんなやつ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.