Class: Codebot::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/codebot/message.rb

Overview

An IRC message generated by a Request and sent to a Channel.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel, event, payload, integration) ⇒ Message

Constructs a new message for delivery to an IRC channel.

Parameters:

  • channel (Channel)

    the channel to send this message to

  • event (Symbol)

    the event that caused this message to be sent

  • payload (Payload)

    the parsed request payload



23
24
25
26
27
28
# File 'lib/codebot/message.rb', line 23

def initialize(channel, event, payload, integration)
  @channel = channel
  @event   = event
  @payload = payload
  @integration = integration
end

Instance Attribute Details

#channelChannel (readonly)

Returns the channel to send this message to.

Returns:

  • (Channel)

    the channel to send this message to



10
11
12
# File 'lib/codebot/message.rb', line 10

def channel
  @channel
end

#eventSymbol (readonly)

Returns the event that caused this message to be sent.

Returns:

  • (Symbol)

    the event that caused this message to be sent



13
14
15
# File 'lib/codebot/message.rb', line 13

def event
  @event
end

#payloadPayload (readonly)

Returns the parsed request payload.

Returns:

  • (Payload)

    the parsed request payload



16
17
18
# File 'lib/codebot/message.rb', line 16

def payload
  @payload
end

Instance Method Details

#formatArray<String>

Formats this message for delivery to an IRC channel.

Returns:

  • (Array<String>)

    the formatted IRC messages



33
34
35
# File 'lib/codebot/message.rb', line 33

def format
  Formatters.format(@event, @payload.to_json, @integration)
end