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
This method deletes a message from a channel.
-
#chat_deleteScheduledMessage(options = {}) ⇒ Object
This method deletes a pending scheduled message before it is sent.
-
#chat_getPermalink(options = {}) ⇒ Object
Easily exchange a message timestamp and a channel ID for a friendly HTTP-based permalink to that message.
-
#chat_meMessage(options = {}) ⇒ Object
This method sends a me message to a channel from the calling user.
-
#chat_postEphemeral(options = {}) ⇒ Object
This method posts an ephemeral message, which is visible only to the assigned user in a specific public channel, private channel, or private conversation.
-
#chat_postMessage(options = {}) ⇒ Object
This method posts a message to a public channel, private channel, or direct message/IM channel.
-
#chat_scheduleMessage(options = {}) ⇒ Object
This method schedules a message for delivery to a public channel, private channel, or direct message/IM channel at a specified time in the future.
-
#chat_unfurl(options = {}) ⇒ Object
This method attaches Slack app unfurl behavior to a specified and relevant message.
-
#chat_update(options = {}) ⇒ Object
This method updates a message in a channel.
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
This method deletes a message from a channel.
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_deleteScheduledMessage(options = {}) ⇒ Object
This method deletes a pending scheduled message before it is sent.
55 56 57 58 59 60 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 55 def chat_deleteScheduledMessage( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :scheduled_message_id missing') if [:scheduled_message_id].nil? = .merge(channel: channels_id()['channel']['id']) if [:channel] post('chat.deleteScheduledMessage', ) end |
#chat_getPermalink(options = {}) ⇒ Object
Easily exchange a message timestamp and a channel ID for a friendly HTTP-based permalink to that message. Handles message threads and all conversation types.
71 72 73 74 75 76 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 71 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
This method sends a me message to a channel from the calling user.
87 88 89 90 91 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 87 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
This method posts an ephemeral message, which is visible only to the assigned user in a specific public channel, private channel, or private conversation.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 116 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
This method posts a message to a public channel, private channel, or direct message/IM channel.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 171 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_scheduleMessage(options = {}) ⇒ Object
This method schedules a message for delivery to a public channel, private channel, or direct message/IM channel at a specified time in the future.
218 219 220 221 222 223 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 218 def chat_scheduleMessage( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :post_at missing') if [:post_at].nil? throw ArgumentError.new('Required arguments :text missing') if [:text].nil? post('chat.scheduleMessage', ) end |
#chat_unfurl(options = {}) ⇒ Object
This method attaches Slack app unfurl behavior to a specified and relevant message. A user token is required as this method does not support bot user tokens.
242 243 244 245 246 247 248 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 242 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
This method updates a message in a channel. Though related to chat.postMessage, some parameters of chat.update are handled differently.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 271 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 |