diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-25 12:44:48 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-03-25 12:44:48 +0100 |
commit | a280ce2fd50834bffdaff365869bde2c909264ec (patch) | |
tree | 5383d06a715200bf9ec5857af1e287fb4da80261 | |
parent | ab5703bcdf888e0ea9d65ba194eaeea922f72146 (diff) |
filters: UI and methods to list filter groups
-rw-r--r-- | lib/rbot/core/filters_ui.rb | 11 | ||||
-rw-r--r-- | lib/rbot/core/utils/filters.rb | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/rbot/core/filters_ui.rb b/lib/rbot/core/filters_ui.rb index ed3e65d7..6f5ecbb3 100644 --- a/lib/rbot/core/filters_ui.rb +++ b/lib/rbot/core/filters_ui.rb @@ -34,6 +34,16 @@ class FiltersModule < CoreBotModule m.reply msg end + def do_listgroups(m, params) + ar = @bot.filter_groups.map { |s| s.to_s }.sort! + if ar.empty? + msg = _("no known filter groups") + else + msg = _("known filter groups: ") << ar.join(", ") + end + m.reply msg + end + def do_search(m, params) l = @bot.filter_names.map { |s| s.to_s } pat = params[:pat].to_s @@ -53,3 +63,4 @@ plugin = FiltersModule.new plugin.map "filters list [:group]", :action => :do_list plugin.map "filters search *pat", :action => :do_search +plugin.map "filter groups", :action => :do_listgroups diff --git a/lib/rbot/core/utils/filters.rb b/lib/rbot/core/utils/filters.rb index 2da89d08..6d560c91 100644 --- a/lib/rbot/core/utils/filters.rb +++ b/lib/rbot/core/utils/filters.rb @@ -96,6 +96,11 @@ module ::Irc @filters.key?(global_filter_name(name, group)) end + # This method checks if the bot has a filter group named _name_ + def has_filter_group?(name) + @filter_group.key?(name) + end + # This method is used to register a new filter def register_filter(name, group=nil, &block) raise "No block provided" unless block_given? @@ -129,6 +134,12 @@ module ::Irc end end + # This method is used to retrieve the filter group names + def filter_groups + return [] unless defined? @filter_group + return @filter_group.keys + end + # This method clears the filter list and installs the identity filter def clear_filters @filters ||= {} |