Module: Slack::RealTime::Api::Message

Included in:
Client
Defined in:
lib/slack/real_time/api/message.rb

Instance Method Summary collapse

Instance Method Details

#message(options = {}) ⇒ Object

Sends a message to a channel.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel to send message to. Can be a public channel, private group or IM channel. Can be an encoded ID, or a name.

  • :text (Object)

    Text of the message to send. See below for an explanation of formatting.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/slack/real_time/api/message.rb', line 14

def message(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :text missing' if options[:text].nil?

  send_json({ type: 'message', id: next_id }.merge(options))
end