Class: Lita::Handlers::Hal9000
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Hal9000
- Defined in:
- lib/lita/handlers/hal_9000.rb
Instance Method Summary collapse
- #format_reply(message:) ⇒ Object
- #handle_unhandled(payload:) ⇒ Object
- #reply_target(message:) ⇒ Object
- #should_reply?(message:) ⇒ Boolean
Instance Method Details
#format_reply(message:) ⇒ Object
31 32 33 34 |
# File 'lib/lita/handlers/hal_9000.rb', line 31 def format_reply(message:) "I'm sorry, I can't do that @#{message.user.mention_name} " + config.hal_image end |
#handle_unhandled(payload:) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/lita/handlers/hal_9000.rb', line 10 def handle_unhandled(payload:) = payload[:message] if should_reply?(message: ) target = reply_target(message: ) robot.(target, format_reply( message: )) end end |
#reply_target(message:) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/lita/handlers/hal_9000.rb', line 23 def reply_target(message:) if .source. Source.new(user: .user, private_message: true) else Source.new(room: .source.room) end end |
#should_reply?(message:) ⇒ Boolean
19 20 21 |
# File 'lib/lita/handlers/hal_9000.rb', line 19 def should_reply?(message:) .command? && .match(/^@#{robot.name}/) end |