Module: Slack::Web::Api::Endpoints::Chat
- Included in:
- Slack::Web::Api::Endpoints
- Defined in:
- lib/slack/web/api/endpoints/chat.rb
Instance Method Summary collapse
-
#chat_command(options = {}) ⇒ Object
Execute a slash command in a public channel (undocumented).
-
#chat_delete(options = {}) ⇒ Object
Deletes a message.
-
#chat_getPermalink(options = {}) ⇒ Object
Retrieve a permalink URL for a specific extant message.
-
#chat_meMessage(options = {}) ⇒ Object
Share a me message into a channel.
-
#chat_postEphemeral(options = {}) ⇒ Object
Sends an ephemeral message to a user in a channel.
-
#chat_postMessage(options = {}) ⇒ Object
Sends a message to a channel.
-
#chat_unfurl(options = {}) ⇒ Object
Provide custom unfurl behavior for user-posted URLs.
-
#chat_update(options = {}) ⇒ Object
Updates a message.
Instance Method Details
#chat_command(options = {}) ⇒ Object
Execute a slash command in a public channel (undocumented)
18 19 20 21 22 23 24 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 18 def chat_command( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :command missing') if [:command].nil? = .merge(channel: channels_id()['channel']['id']) if [:channel] logger.warn('The chat.command method is undocumented.') post('chat.command', ) end |
#chat_delete(options = {}) ⇒ Object
Deletes a message.
37 38 39 40 41 42 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 37 def chat_delete( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :ts missing') if [:ts].nil? = .merge(channel: channels_id()['channel']['id']) if [:channel] post('chat.delete', ) end |
#chat_getPermalink(options = {}) ⇒ Object
Retrieve a permalink URL for a specific extant message
53 54 55 56 57 58 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 53 def chat_getPermalink( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :message_ts missing') if [:message_ts].nil? = .merge(channel: channels_id()['channel']['id']) if [:channel] post('chat.getPermalink', ) end |
#chat_meMessage(options = {}) ⇒ Object
Share a me message into a channel.
69 70 71 72 73 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 69 def chat_meMessage( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :text missing') if [:text].nil? post('chat.meMessage', ) end |
#chat_postEphemeral(options = {}) ⇒ Object
Sends an ephemeral message to a user in a channel.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 98 def chat_postEphemeral( = {}) 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? throw ArgumentError.new('Required arguments :user missing') if [:user].nil? = .merge(user: users_id()['user']['id']) if [:user] # 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.postEphemeral', ) end |
#chat_postMessage(options = {}) ⇒ Object
Sends a message to a channel.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 153 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 |
#chat_unfurl(options = {}) ⇒ Object
Provide custom unfurl behavior for user-posted URLs
188 189 190 191 192 193 194 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 188 def chat_unfurl( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :ts missing') if [:ts].nil? throw ArgumentError.new('Required arguments :unfurls missing') if [:unfurls].nil? = .merge(channel: channels_id()['channel']['id']) if [:channel] post('chat.unfurl', ) end |
#chat_update(options = {}) ⇒ Object
Updates a message.
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 217 def chat_update( = {}) 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? throw ArgumentError.new('Required arguments :ts missing') if [:ts].nil? = .merge(channel: channels_id()['channel']['id']) if [:channel] # 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.update', ) end |