Class: Lita::Handlers::HookForward

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/hook_forward.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_config(handler_config) ⇒ Object



8
9
10
# File 'lib/lita/handlers/hook_forward.rb', line 8

def self.default_config(handler_config)
  handler_config.default_room = nil
end

Instance Method Details

#receive(request, response) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lita/handlers/hook_forward.rb', line 12

def receive(request, response)
  message = request.params['message']
  targets = request.params['targets'] || Lita.config.handlers.hook_forward.default_room || nil
  rooms = []
  targets.split(',').each do |param_target|
    rooms << param_target
  end
  rooms.each do |room|
    target = Source.new(room: room)
    robot.send_message(target, message)
  end
end