module Slack::Web::Chat

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

Constants

SCOPE

Endpoint scope

Public Instance Methods

chat_delete(params = {}) click to toggle source

Deletes a message.

@param [Hash] params

API call arguments

@option params [Object] 'ts'

Timestamp of the message to be deleted.

@option params [channel] 'channel'

Channel containing the message to be deleted.

@see api.slack.com/methods/chat.delete

# File lib/slack/web/chat.rb, line 22
def chat_delete(params = {})
  fail ArgumentError, "Required arguments 'ts' missing" if params['ts'].nil?
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  response = @session.do_post "#{SCOPE}.delete", params
  Slack.parse_response(response)
end
chat_post_message(params = {}) click to toggle source

Sends a message to a channel.

@param [Hash] params

API call arguments

@option 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.

@option params [Object] 'text'

Text of the message to send.

@option params [Object] 'username'

Name of bot.

@option params [Object] 'as_user'

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

@option params [Object] 'parse'

Change how messages are treated.

@option params [Object] 'link_names'

Find and link channel names and usernames.

@option params [Object] 'attachments'

Structured message attachments.

@option params [Object] 'unfurl_links'

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

@option params [Object] 'unfurl_media'

Pass false to disable unfurling of media content.

@option params [Object] 'icon_url'

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

@option params [Object] 'icon_emoji'

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

@see api.slack.com/methods/chat.postMessage

# File lib/slack/web/chat.rb, line 57
def chat_post_message(params = {})
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'text' missing" if params['text'].nil?
  response = @session.do_post "#{SCOPE}.postMessage", params
  Slack.parse_response(response)
end
chat_update(params = {}) click to toggle source

Updates a message.

@param [Hash] params

API call arguments

@option params [Object] 'ts'

Timestamp of the message to be updated.

@option params [channel] 'channel'

Channel containing the message to be updated.

@option params [Object] 'text'

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

@see api.slack.com/methods/chat.update

# File lib/slack/web/chat.rb, line 76
def chat_update(params = {})
  fail ArgumentError, "Required arguments 'ts' missing" if params['ts'].nil?
  fail ArgumentError, "Required arguments 'channel' missing" if params['channel'].nil?
  fail ArgumentError, "Required arguments 'text' missing" if params['text'].nil?
  response = @session.do_post "#{SCOPE}.update", params
  Slack.parse_response(response)
end