Skip to content

Instantly share code, notes, and snippets.

@masarakki
Created April 21, 2011 17:57
Show Gist options
  • Save masarakki/935104 to your computer and use it in GitHub Desktop.
Save masarakki/935104 to your computer and use it in GitHub Desktop.
earthquake_ng_plguin
module Earthquake
attr_accessor :ng_list
def self.ng_list
@ng_list ||= []
end
def self.ng_list=(ng_list)
@ng_list = ng_list
end
def self.init_ng_list
f = File.join(ENV['HOME'], '.earthquake', 'ng_list')
if File.exists?(f)
Earthquake.ng_list = File.open(f).lines.map(&:strip)
end
end
end
Earthquake.init do
Earthquake.init_ng_list
command :ng do |params|
Earthquake.ng_list << keyword = params[1]
end
command :ng_clear do
Earthquake.ng_list.clear
end
command :ng_list do
puts Earthquake.ng_list.join(",")
end
output_filter do |post|
!Earthquake.ng_list.any? do |word|
post["text"].present? && post["text"].match(word) || post["user"].present? && post["user"]["screen_name"].match(word)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment