Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created April 5, 2011 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jugyo/902864 to your computer and use it in GitHub Desktop.
Save jugyo/902864 to your computer and use it in GitHub Desktop.
user_filter
# user_filter plugin
# ====
#
Earthquake.init do
_ = config[:user_filter] ||= {}
_[:enable] ||= true
_[:default] ||= :show # :show or :hide
_[:excludes] ||= []
_[:includes] ||= []
command :enable_user_filter do
_[:enable] = true
end
command :disable_user_filter do
_[:enable] = false
end
command :exclude_users do
ap _[:excludes]
end
command :include_users do
ap _[:includes]
end
command :mark_as_exclude do |m|
_[:excludes].tap do |a|
a << m[1]
a.uniq!
end
end
command :mark_as_include do |m|
_[:includes].tap do |a|
a << m[1]
a.uniq!
end
end
command :clear_user_filter do
_[:excludes].clear
_[:includes].clear
end
output_filter do |item|
next true unless _[:enable]
if item["text"] && item["_stream"]
case _[:default]
when :show
!_[:excludes].include?(item["user"]["screen_name"])
when :hide
_[:includes].include?(item["user"]["screen_name"])
end
else
true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment