Module: IIRC::RegexHooks

Included in:
Batteries
Defined in:
lib/iirc/modules/regex_hooks.rb

Instance Method Summary collapse

Instance Method Details

#configure_regex_hooksObject (private)



8
9
10
# File 'lib/iirc/modules/regex_hooks.rb', line 8

def configure_regex_hooks
  on :privmsg, :do_regex_matches
end

#do_regex_matches(evt) ⇒ Object (private)



12
13
14
15
16
17
18
# File 'lib/iirc/modules/regex_hooks.rb', line 12

def do_regex_matches(evt)
  regex_hooks
    .filter { |k,v| k === evt.message }
    .each_value { |actions|
      actions.each { |action| call action, evt, *Regexp.last_match&.values_at(1..) }
    }
end

#regex_hooksObject



3
4
5
# File 'lib/iirc/modules/regex_hooks.rb', line 3

def regex_hooks
  hooks.filter { |k,v| Regexp === k }.freeze
end