diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/core/filters_ui.rb | 11 | ||||
-rw-r--r-- | lib/rbot/core/utils/filters.rb | 11 | ||||
-rw-r--r-- | lib/rbot/ircbot.rb | 3 |
3 files changed, 22 insertions, 3 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 ||= {} diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index f15cb351..9a6685da 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -103,7 +103,6 @@ require 'rbot/rbotconfig' require 'rbot/load-gettext' require 'rbot/config' require 'rbot/config-compat' -# require 'rbot/utils' require 'rbot/irc' require 'rbot/rfc2812' @@ -111,12 +110,10 @@ require 'rbot/ircsocket' require 'rbot/botuser' require 'rbot/timer' require 'rbot/plugins' -# require 'rbot/channel' require 'rbot/message' require 'rbot/language' require 'rbot/dbhash' require 'rbot/registry' -# require 'rbot/httputil' module Irc |