Class: Lita::Handlers::MessageRouter
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::MessageRouter
- Defined in:
- lib/lita/handlers/message_router.rb
Instance Method Summary collapse
Instance Method Details
#match(message) ⇒ Object
28 29 30 31 32 |
# File 'lib/lita/handlers/message_router.rb', line 28 def match() regex = Regexp.new('^(' + config.robot_mention_names.join('|') + ') (.+)') matches = .match(regex) matches[2] if matches end |
#maybe_route(chat) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lita/handlers/message_router.rb', line 8 def maybe_route(chat) return if chat.command? = chat.matches[0].strip match = match() if match command = robot.mention_name + ' ' + match source = if chat.room Lita::Source.new(room: chat.room) else Lita::Source.new(user: chat.user) end = Lita::Message.new(robot, command, source) robot.receive() end end |