Class: Lita::Response

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(message, pattern) ⇒ Response

Returns a new instance of Response

Parameters:

  • message (Lita::Message)

    The incoming message.

  • pattern (Regexp)

    The pattern the incoming message matched.



35
36
37
38
39
# File 'lib/lita/response.rb', line 35

def initialize(message, pattern)
  self.message = message
  self.extensions = {}
  self.pattern = pattern
end

Instance Attribute Details

#extensionsHash

A hash of arbitrary data that can be populated by Lita extensions.

Returns:

  • (Hash)

    The extensions data.

Since:

  • 3.2.0



14
15
16
# File 'lib/lita/response.rb', line 14

def extensions
  @extensions
end

#messageLita::Message

The incoming message.

Returns:



9
10
11
# File 'lib/lita/response.rb', line 9

def message
  @message
end

#patternRegexp

The pattern the incoming message matched.

Returns:

  • (Regexp)

    The pattern.



18
19
20
# File 'lib/lita/response.rb', line 18

def pattern
  @pattern
end

Instance Method Details

#argsObject

See Also:



30
31
# File 'lib/lita/response.rb', line 30

def_delegators :message, :args, :reply, :reply_privately,
:reply_with_mention, :user, :command?

#match_dataMatchData

A MatchData object from running the pattern against the message body.

Returns:

  • (MatchData)

    The MatchData.



49
50
51
# File 'lib/lita/response.rb', line 49

def match_data
  @match_data ||= pattern.match(message.body)
end

#matchesArray<String>+

An array of matches from scanning the message against the route pattern.

Returns:

  • (Array<String>, Array<Array<String>>)

    The array of matches.



43
44
45
# File 'lib/lita/response.rb', line 43

def matches
  @matches ||= message.match(pattern)
end

#replyObject

See Also:



30
31
# File 'lib/lita/response.rb', line 30

def_delegators :message, :args, :reply, :reply_privately,
:reply_with_mention, :user, :command?

#reply_privatelyObject



30
31
# File 'lib/lita/response.rb', line 30

def_delegators :message, :args, :reply, :reply_privately,
:reply_with_mention, :user, :command?

#reply_with_mentionObject



30
31
# File 'lib/lita/response.rb', line 30

def_delegators :message, :args, :reply, :reply_privately,
:reply_with_mention, :user, :command?

#userObject

See Also:



30
31
# File 'lib/lita/response.rb', line 30

def_delegators :message, :args, :reply, :reply_privately,
:reply_with_mention, :user, :command?