Method: Slack::Web::Api::Endpoints::Chat#chat_update

Defined in:
lib/slack/web/api/endpoints/chat.rb

#chat_update(options = {}) ⇒ Object

This method updates a message in a channel. Though related to chat.postMessage, some parameters of chat.update are handled differently.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :ts (timestamp)

    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.

  • :attachments (Object)

    Structured message attachments.

  • :parse (Object)

    Change how messages are treated. Defaults to client, unlike chat.postMessage. See below.

  • :link_names (Object)

    Find and link channel names and usernames. Defaults to none. This parameter should be used in conjunction with parse. To set link_names to 1, specify a parse mode of full.

  • :as_user (Object)

    Pass true to update the message as the authed user. Bot users in this context are considered authed users.

See Also:



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/slack/web/api/endpoints/chat.rb', line 84

def chat_update(options = {})
  throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
  options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
  # attachments must be passed as an encoded JSON string
  if options.key?(:attachments)
    attachments = options[:attachments]
    attachments = JSON.dump(attachments) unless attachments.is_a?(String)
    options = options.merge(attachments: attachments)
  end
  post('chat.update', options)
end