4 # :title: filters management from IRC
6 # Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
8 class FiltersModule < CoreBotModule
13 @bot.register_filter(:htmlinfo) { |s| Utils.get_html_info(s.to_s, s) }
16 def help(plugin, topic="")
17 "filters list [<group>] => list filters (in group <group>) | filters search <pat> => list filters matching regexp <pat>"
20 def do_list(m, params)
22 ar = @bot.filter_names(g).map { |s| s.to_s }.sort!
25 msg = _("no filters in group %{g}") % {:g => g}
27 msg = _("no known filters")
30 msg = _("known filters: ") << ar.join(", ")
35 def do_listgroups(m, params)
36 ar = @bot.filter_groups.map { |s| s.to_s }.sort!
38 msg = _("no known filter groups")
40 msg = _("known filter groups: ") << ar.join(", ")
45 def do_search(m, params)
46 l = @bot.filter_names.map { |s| s.to_s }
47 pat = params[:pat].to_s
48 sl = l.grep(Regexp.new(pat))
50 msg = _("no filters match %{pat}") % { :pat => pat }
52 msg = _("filters matching %{pat}: ") % { :pat => pat }
53 msg << sl.sort!.join(", ")
60 plugin = FiltersModule.new
62 plugin.map "filters list [:group]", :action => :do_list
63 plugin.map "filters search *pat", :action => :do_search
64 plugin.map "filter groups", :action => :do_listgroups