Skip to content

Instantly share code, notes, and snippets.

@siyo
Last active December 16, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siyo/5479578 to your computer and use it in GitHub Desktop.
Save siyo/5479578 to your computer and use it in GitHub Desktop.
相互フォローかそうじゃないかとかをお天気マークとかで見れるやつプラギン
# -*- 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
Copy link
Author

siyo commented Apr 29, 2013

こんなやつ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment