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_delete(options = {}) ⇒ Object
This method deletes a message from a channel.
-
#chat_meMessage(options = {}) ⇒ Object
This method sends a me message to a channel from the calling user.
-
#chat_postMessage(options = {}) ⇒ Object
This method posts a message to a public channel, private channel, or direct message/IM channel.
-
#chat_update(options = {}) ⇒ Object
This method updates a message in a channel.
Instance Method Details
#chat_delete(options = {}) ⇒ Object
This method deletes a message from a channel.
19 20 21 22 23 24 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 19 def chat_delete( = {}) throw ArgumentError.new('Required arguments :ts missing') if [:ts].nil? throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? = .merge(channel: channels_id()['channel']['id']) if [:channel] post('chat.delete', ) end |
#chat_meMessage(options = {}) ⇒ Object
This method sends a me message to a channel from the calling user.
35 36 37 38 39 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 35 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_postMessage(options = {}) ⇒ Object
This method posts a message to a public channel, private channel, or direct message/IM channel.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 72 def chat_postMessage( = {}) throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :text or :attachments missing') if [:text].nil? && [:attachments].nil? # attachments must be passed as an encoded JSON string if .key?(:attachments) = [:attachments] = JSON.dump() unless .is_a?(String) = .merge(attachments: ) end post('chat.postMessage', ) 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.
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/slack/web/api/endpoints/chat.rb', line 103 def chat_update( = {}) throw ArgumentError.new('Required arguments :ts missing') if [:ts].nil? throw ArgumentError.new('Required arguments :channel missing') if [:channel].nil? throw ArgumentError.new('Required arguments :text or :attachments missing') if [:text].nil? && [:attachments].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 post('chat.update', ) end |