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.



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

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:



33
34
# File 'lib/lita/response.rb', line 33

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

#match_dataMatchData

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

Returns:

  • (MatchData)

    The MatchData.



57
58
59
# File 'lib/lita/response.rb', line 57

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.



51
52
53
# File 'lib/lita/response.rb', line 51

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

#private_message?Object

See Also:

Since:

  • 4.5.0



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

See Also:



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?

#roomObject

See Also:

Since:

  • 4.5.0



39
# File 'lib/lita/response.rb', line 39

def_delegator :message, :room_object, :room

#userObject

See Also:



33
34
# File 'lib/lita/response.rb', line 33

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