Module: Slack::Web::Chat

Included in:
Slack::Web
Defined in:
lib/slack/web/chat.rb

Overview

Module for the chat methods. Post chat messages to Slack.

Constant Summary collapse

SCOPE =

Endpoint scope

"chat"

Instance Method Summary collapse

Instance Method Details

#chat_delete(params = {}) ⇒ Object

Deletes a message.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'ts' (Object)

    Timestamp of the message to be deleted.

  • 'channel' (channel)

    Channel containing the message to be deleted.

Raises:

  • (ArgumentError)

See Also:



22
23
24
25
26
27
# File 'lib/slack/web/chat.rb', line 22

def chat_delete(params={})
  raise ArgumentError.new("Required arguments 'ts' missing") if params['ts'].nil?
  raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
  response = @session.do_get "#{SCOPE}.delete", params
  Slack::parse_response(response)
end

#chat_post_message(params = {}) ⇒ Object

Sends a message to a channel.

Parameters:

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

    API call arguments

Options Hash (params):

  • '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.

  • 'username' (Object)

    Name of bot.

  • 'as_user' (Object)

    Pass true to post the message as the authed user, instead of as a bot

  • 'parse' (Object)

    Change how messages are treated.

  • 'link_names' (Object)

    Find and link channel names and usernames.

  • 'attachments' (Object)

    Structured message attachments.

  • 'unfurl_links' (Object)

    Pass true to enable unfurling of primarily text-based content.

  • 'unfurl_media' (Object)

    Pass false to disable unfurling of media content.

  • 'icon_url' (Object)

    URL to an image to use as the icon for this message

  • 'icon_emoji' (Object)

    emoji to use as the icon for this message. Overrides ‘icon_url`.

Raises:

  • (ArgumentError)

See Also:



57
58
59
60
61
62
# File 'lib/slack/web/chat.rb', line 57

def chat_post_message(params={})
  raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
  raise ArgumentError.new("Required arguments 'text' missing") if params['text'].nil?
  response = @session.do_get "#{SCOPE}.postMessage", params
  Slack::parse_response(response)
end

#chat_update(params = {}) ⇒ Object

Updates a message.

Parameters:

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

    API call arguments

Options Hash (params):

  • 'ts' (Object)

    Timestamp of the message to be updated.

  • 'channel' (channel)

    Channel containing the message to be updated.

  • 'text' (Object)

    New text for the message, using the default formatting rules.

Raises:

  • (ArgumentError)

See Also:



76
77
78
79
80
81
82
# File 'lib/slack/web/chat.rb', line 76

def chat_update(params={})
  raise ArgumentError.new("Required arguments 'ts' missing") if params['ts'].nil?
  raise ArgumentError.new("Required arguments 'channel' missing") if params['channel'].nil?
  raise ArgumentError.new("Required arguments 'text' missing") if params['text'].nil?
  response = @session.do_get "#{SCOPE}.update", params
  Slack::parse_response(response)
end