Class: CampfireBot::Event::Command

Inherits:
EventHandler show all
Defined in:
lib/event.rb

Instance Attribute Summary

Attributes inherited from EventHandler

#kind, #matcher, #method, #plugin

Instance Method Summary collapse

Methods inherited from EventHandler

handles, #initialize, #run

Constructor Details

This class inherits a constructor from CampfireBot::Event::EventHandler

Instance Method Details

#match?(msg) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
43
44
# File 'lib/event.rb', line 37

def match?(msg)
  (
    msg[:message][0..0] == '!' ||
    msg[:message]       =~ Regexp.new("^#{bot.config['nickname']}(,|:)", Regexp::IGNORECASE)
  ) &&
  msg[:message].gsub(/^\!/, '').gsub(Regexp.new("^#{bot.config['nickname']}(,|:)?\\s*", Regexp::IGNORECASE), '').split(' ')[0].to_s.downcase == @matcher.downcase
  # FIXME - the above should be just done with one regexp to pull out the first non-! non-<bot name> word.
end