Class: Lita::Response
- Inherits:
-
Object
- Object
- Lita::Response
- Extended by:
- Forwardable
- Defined in:
- lib/lita/response.rb
Overview
A wrapper object that provides the primary interface for handlers to respond to incoming chat messages.
Instance Attribute Summary collapse
-
#extensions ⇒ Hash
A hash of arbitrary data that can be populated by Lita extensions.
-
#message ⇒ Lita::Message
The incoming message.
-
#pattern ⇒ Regexp
The pattern the incoming message matched.
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(message, pattern) ⇒ Response
constructor
A new instance of Response.
-
#match_data ⇒ MatchData
A
MatchData
object from running the pattern against the message body. -
#matches ⇒ Array<String>+
An array of matches from scanning the message against the route pattern.
- #private_message? ⇒ Object
- #reply(*strings) ⇒ Object
- #reply_privately(*strings) ⇒ Object
- #reply_with_mention(*strings) ⇒ Object
- #room ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(message, pattern) ⇒ Response
Returns a new instance of Response.
43 44 45 46 47 |
# File 'lib/lita/response.rb', line 43 def initialize(, pattern) self. = self.extensions = {} self.pattern = pattern end |
Instance Attribute Details
#extensions ⇒ Hash
A hash of arbitrary data that can be populated by Lita extensions.
14 15 16 |
# File 'lib/lita/response.rb', line 14 def extensions @extensions end |
#message ⇒ Lita::Message
The incoming message.
9 10 11 |
# File 'lib/lita/response.rb', line 9 def end |
#pattern ⇒ Regexp
The pattern the incoming message matched.
18 19 20 |
# File 'lib/lita/response.rb', line 18 def pattern @pattern end |
Instance Method Details
#args ⇒ Object
33 34 |
# File 'lib/lita/response.rb', line 33 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :private_message?, :command? |
#match_data ⇒ MatchData
A MatchData
object from running the pattern against the message body.
57 58 59 |
# File 'lib/lita/response.rb', line 57 def match_data @match_data ||= pattern.match(.body) end |
#matches ⇒ Array<String>+
An array of matches from scanning the message against the route pattern.
51 52 53 |
# File 'lib/lita/response.rb', line 51 def matches @matches ||= .match(pattern) end |
#private_message? ⇒ Object
33 34 |
# File 'lib/lita/response.rb', line 33 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :private_message?, :command? |
#reply(*strings) ⇒ Object
33 34 |
# File 'lib/lita/response.rb', line 33 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :private_message?, :command? |
#reply_privately(*strings) ⇒ Object
33 34 |
# File 'lib/lita/response.rb', line 33 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :private_message?, :command? |
#reply_with_mention(*strings) ⇒ Object
33 34 |
# File 'lib/lita/response.rb', line 33 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :private_message?, :command? |
#room ⇒ Object
39 |
# File 'lib/lita/response.rb', line 39 def_delegator :message, :room_object, :room |
#user ⇒ Object
33 34 |
# File 'lib/lita/response.rb', line 33 def_delegators :message, :args, :reply, :reply_privately, :reply_with_mention, :user, :private_message?, :command? |