Created
April 5, 2011 01:38
-
-
Save jugyo/902864 to your computer and use it in GitHub Desktop.
user_filter
This file contains hidden or 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
# 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