Class: FiltersModule

Inherits:
CoreBotModule
  • Object
show all
Defined in:
/home/apoc/projects/ruby/rbot/lib/rbot/core/filters_ui.rb

Overview

– vim:sw=2:et ++

:title: filters management from IRC

Author

Giuseppe “Oblomov” Bilotta <giuseppe.bilotta@gmail.com>

Instance Method Summary (collapse)

Constructor Details

- (FiltersModule) initialize

Returns a new instance of FiltersModule



10
11
12
13
14
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/filters_ui.rb', line 10

def initialize
  super
  @bot.clear_filters
  @bot.register_filter(:htmlinfo) { |s| Utils.get_html_info(s.to_s, s) }
end

Instance Method Details

- (Object) do_list(m, params)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/filters_ui.rb', line 20

def do_list(m, params)
  g = params[:group]
  ar = @bot.filter_names(g).map { |s| s.to_s }.sort!
  if ar.empty?
    if g
      msg = _("no filters in group %{g}") % {:g => g}
    else
      msg = _("no known filters")
    end
  else
    msg = _("known filters: ") << ar.join(", ")
  end
  m.reply msg
end

- (Object) do_listgroups(m, params)



35
36
37
38
39
40
41
42
43
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/filters_ui.rb', line 35

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

- (Object) do_search(m, params)



45
46
47
48
49
50
51
52
53
54
55
56
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/filters_ui.rb', line 45

def do_search(m, params)
  l = @bot.filter_names.map { |s| s.to_s }
  pat = params[:pat].to_s
  sl = l.grep(Regexp.new(pat))
  if sl.empty?
    msg = _("no filters match %{pat}") % { :pat => pat }
  else
    msg = _("filters matching %{pat}: ") % { :pat => pat }
    msg << sl.sort!.join(", ")
  end
  m.reply msg
end

- (Object) help(plugin, topic = "")



16
17
18
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/filters_ui.rb', line 16

def help(plugin, topic="")
  "filters list [<group>] => list filters (in group <group>) | filters search <pat> => list filters matching regexp <pat>"
end