Method: Slack::Web::Api::Endpoints::Chat#chat_postMessage
- Defined in:
- lib/slack/web/api/endpoints/chat.rb
#chat_postMessage(options = {}) ⇒ Object
Sends a message to a channel.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 180 def chat_postMessage( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :text, :attachments or :blocks missing') if [:text].nil? && [:attachments].nil? && [:blocks].nil? # attachments must be passed as an encoded JSON string if .key?(:attachments) = [:attachments] = JSON.dump() unless .is_a?(String) = .merge(attachments: ) end # blocks must be passed as an encoded JSON string if .key?(:blocks) blocks = [:blocks] blocks = JSON.dump(blocks) unless blocks.is_a?(String) = .merge(blocks: blocks) end post('chat.postMessage', ) end |