Module: Boty::MatchHandler

Includes:
Logger
Included in:
Bot
Defined in:
lib/boty/match_handler.rb

Instance Attribute Summary collapse

Attributes included from Logger

#logger

Instance Method Summary collapse

Methods included from Logger

adapter, adapter=, #log_error

Instance Attribute Details

#trigger_messageObject (readonly)

Returns the value of attribute trigger_message.



5
6
7
# File 'lib/boty/match_handler.rb', line 5

def trigger_message
  @trigger_message
end

Instance Method Details

#commandsObject



11
12
13
# File 'lib/boty/match_handler.rb', line 11

def commands
  @commands ||= []
end

#desc(command, description = nil) ⇒ Object



15
16
17
18
# File 'lib/boty/match_handler.rb', line 15

def desc(command, description = nil)
  @current_desc = ActionDescription.new command,
                                        description: description
end

#execute_commands(message) ⇒ Object



45
46
47
# File 'lib/boty/match_handler.rb', line 45

def execute_commands(message)
  execute_actions message, commands
end

#execute_matches(message) ⇒ Object



41
42
43
# File 'lib/boty/match_handler.rb', line 41

def execute_matches(message)
  execute_actions message, listeners
end

#listenersObject



7
8
9
# File 'lib/boty/match_handler.rb', line 7

def listeners
  @listeners ||= []
end

#match(*regexes, &block) ⇒ Object



20
21
22
# File 'lib/boty/match_handler.rb', line 20

def match(*regexes, &block)
  create_action_on_collection listeners, regexes, &block
end

#no(command) ⇒ Object



36
37
38
39
# File 'lib/boty/match_handler.rb', line 36

def no(command)
  remove_action listeners, command: command
  remove_action commands, command: command
end

#no_match(regex, &block) ⇒ Object



28
29
30
# File 'lib/boty/match_handler.rb', line 28

def no_match(regex, &block)
  remove_action listeners, regex, block
end

#no_respond(regex, &block) ⇒ Object



32
33
34
# File 'lib/boty/match_handler.rb', line 32

def no_respond(regex, &block)
  remove_action commands, regex, block
end

#respond(*regexes, &block) ⇒ Object



24
25
26
# File 'lib/boty/match_handler.rb', line 24

def respond(*regexes, &block)
  create_action_on_collection commands, regexes, &block
end