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
29 30 31 32 |
# File 'lib/lita/handlers/hal_9000.rb', line 29 def format_reply(message:) "I'm sorry, I can't do that @#{.user.mention_name} " \ "http://bit.ly/11wwIP2" end |
#handle_unhandled(payload:) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/lita/handlers/hal_9000.rb', line 8 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
21 22 23 24 25 26 27 |
# File 'lib/lita/handlers/hal_9000.rb', line 21 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
17 18 19 |
# File 'lib/lita/handlers/hal_9000.rb', line 17 def should_reply?(message:) .command? && .match(/^@#{robot.name}/) end |