slack-ruby-client 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +40 -39
- data/.travis.yml +1 -9
- data/CHANGELOG.md +24 -0
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +3 -1
- data/README.md +40 -12
- data/Rakefile +1 -1
- data/UPGRADING.md +1 -1
- data/bin/commands/api.rb +2 -2
- data/bin/commands/apps_permissions.rb +22 -0
- data/bin/commands/auth.rb +4 -4
- data/bin/commands/bots.rb +2 -2
- data/bin/commands/channels.rb +52 -40
- data/bin/commands/chat.rb +63 -25
- data/bin/commands/conversations.rb +178 -0
- data/bin/commands/dialog.rb +14 -0
- data/bin/commands/dnd.rb +8 -8
- data/bin/commands/emoji.rb +2 -2
- data/bin/commands/files.rb +38 -17
- data/bin/commands/files_comments.rb +6 -6
- data/bin/commands/groups.rb +44 -51
- data/bin/commands/im.rb +16 -13
- data/bin/commands/migration.rb +14 -0
- data/bin/commands/mpim.rb +11 -11
- data/bin/commands/oauth.rb +15 -2
- data/bin/commands/pins.rb +6 -6
- data/bin/commands/reactions.rb +13 -13
- data/bin/commands/reminders.rb +10 -10
- data/bin/commands/rtm.rb +9 -6
- data/bin/commands/search.rb +9 -9
- data/bin/commands/stars.rb +8 -8
- data/bin/commands/team.rb +10 -10
- data/bin/commands/team_profile.rb +2 -2
- data/bin/commands/usergroups.rb +16 -16
- data/bin/commands/usergroups_users.rb +4 -4
- data/bin/commands/users.rb +40 -36
- data/bin/commands/users_admin.rb +28 -0
- data/bin/commands/users_prefs.rb +12 -0
- data/bin/commands/users_profile.rb +7 -7
- data/bin/commands.rb +7 -1
- data/bin/slack +1 -1
- data/examples/hi_real_time/hi.rb +1 -1
- data/examples/hi_real_time_and_web/hi.rb +1 -1
- data/examples/hi_real_time_async_celluloid/hi.rb +1 -1
- data/examples/hi_real_time_async_eventmachine/hi.rb +1 -1
- data/examples/hi_web/hi.rb +1 -1
- data/examples/new_ticket/new_ticket.rb +1 -1
- data/lib/slack/messages/formatting.rb +4 -4
- data/lib/slack/messages/message.rb +1 -2
- data/lib/slack/real_time/api/templates/event_handler.erb +1 -1
- data/lib/slack/real_time/client.rb +11 -10
- data/lib/slack/real_time/concurrency/celluloid.rb +6 -2
- data/lib/slack/real_time/config.rb +11 -11
- data/lib/slack/real_time/models/base.rb +1 -2
- data/lib/slack/real_time/socket.rb +2 -2
- data/lib/slack/real_time/stores/base.rb +1 -2
- data/lib/slack/real_time/stores/starter.rb +92 -72
- data/lib/slack/real_time/stores/store.rb +120 -90
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/endpoints/api.rb +2 -2
- data/lib/slack/web/api/endpoints/apps_permissions.rb +35 -0
- data/lib/slack/web/api/endpoints/auth.rb +4 -4
- data/lib/slack/web/api/endpoints/bots.rb +2 -2
- data/lib/slack/web/api/endpoints/channels.rb +57 -34
- data/lib/slack/web/api/endpoints/chat.rb +107 -37
- data/lib/slack/web/api/endpoints/conversations.rb +301 -0
- data/lib/slack/web/api/endpoints/dialog.rb +32 -0
- data/lib/slack/web/api/endpoints/dnd.rb +9 -9
- data/lib/slack/web/api/endpoints/emoji.rb +2 -2
- data/lib/slack/web/api/endpoints/files.rb +53 -23
- data/lib/slack/web/api/endpoints/files_comments.rb +11 -11
- data/lib/slack/web/api/endpoints/groups.rb +38 -50
- data/lib/slack/web/api/endpoints/im.rb +27 -17
- data/lib/slack/web/api/endpoints/migration.rb +25 -0
- data/lib/slack/web/api/endpoints/mpim.rb +13 -15
- data/lib/slack/web/api/endpoints/oauth.rb +24 -3
- data/lib/slack/web/api/endpoints/pins.rb +6 -8
- data/lib/slack/web/api/endpoints/presence.rb +1 -1
- data/lib/slack/web/api/endpoints/reactions.rb +18 -20
- data/lib/slack/web/api/endpoints/reminders.rb +10 -10
- data/lib/slack/web/api/endpoints/rtm.rb +14 -8
- data/lib/slack/web/api/endpoints/search.rb +12 -12
- data/lib/slack/web/api/endpoints/stars.rb +10 -12
- data/lib/slack/web/api/endpoints/team.rb +12 -13
- data/lib/slack/web/api/endpoints/team_profile.rb +2 -2
- data/lib/slack/web/api/endpoints/usergroups.rb +22 -22
- data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -4
- data/lib/slack/web/api/endpoints/users.rb +34 -24
- data/lib/slack/web/api/endpoints/users_admin.rb +46 -0
- data/lib/slack/web/api/endpoints/users_prefs.rb +19 -0
- data/lib/slack/web/api/endpoints/users_profile.rb +10 -10
- data/lib/slack/web/api/endpoints.rb +14 -2
- data/lib/slack/web/api/mixins/ids.id.rb +1 -1
- data/lib/slack/web/api/mixins/users.search.rb +38 -36
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +1 -1
- data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +4 -3
- data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +17 -0
- data/lib/slack/web/api/patches/dialog.1.open-json-support.patch +17 -0
- data/lib/slack/web/api/templates/command.erb +4 -3
- data/lib/slack/web/api/templates/commands.erb +1 -1
- data/lib/slack/web/api/templates/endpoints.erb +2 -2
- data/lib/slack/web/api/templates/method.erb +18 -3
- data/lib/slack/web/api/templates/method_spec.erb +1 -1
- data/lib/slack/web/config.rb +16 -12
- data/lib/slack/web/faraday/connection.rb +1 -1
- data/lib/slack/web/faraday/response/raise_error.rb +3 -3
- data/lib/slack/web/pagination/cursor.rb +48 -0
- data/lib/slack-ruby-client.rb +6 -0
- data/lib/tasks/git.rake +1 -1
- data/lib/tasks/real_time.rake +1 -1
- data/lib/tasks/web.rake +4 -1
- data/slack-ruby-client.gemspec +2 -3
- data/spec/fixtures/slack/web/paginated_users_list.yml +181 -0
- data/spec/integration/integration_spec.rb +1 -1
- data/spec/slack/messages/formatting_spec.rb +1 -1
- data/spec/slack/real_time/client_spec.rb +62 -63
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +41 -31
- data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +1 -1
- data/spec/slack/real_time/event_handlers/bot_spec.rb +4 -2
- data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +1 -1
- data/spec/slack/real_time/event_handlers/user_spec.rb +4 -2
- data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +15 -0
- data/spec/slack/web/api/endpoints/conversations_spec.rb +100 -0
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +37 -1
- data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +28 -0
- data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +16 -6
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +8 -8
- data/spec/slack/web/api/endpoints/files_spec.rb +16 -5
- data/spec/slack/web/api/endpoints/migration_spec.rb +12 -0
- data/spec/slack/web/api/endpoints/oauth_spec.rb +11 -0
- data/spec/slack/web/api/endpoints/users_admin_spec.rb +17 -0
- data/spec/slack/web/api/endpoints/users_prefs_spec.rb +7 -0
- data/spec/slack/web/api/error_spec.rb +1 -1
- data/spec/slack/web/api/errors/slack_error_spec.rb +1 -1
- data/spec/slack/web/api/mixins/users_spec.rb +6 -4
- data/spec/slack/web/api/pagination/cursor_spec.rb +70 -0
- data/spec/support/queue_with_timeout.rb +1 -1
- data/spec/support/real_time/concurrency/mock.rb +1 -2
- metadata +47 -30
@@ -0,0 +1,35 @@
|
|
1
|
+
# This file was auto-generated by lib/tasks/web.rake
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module Web
|
5
|
+
module Api
|
6
|
+
module Endpoints
|
7
|
+
module AppsPermissions
|
8
|
+
#
|
9
|
+
# Returns list of permissions this app has on a team.
|
10
|
+
#
|
11
|
+
# @see https://api.slack.com/methods/apps.permissions.info
|
12
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.permissions/apps.permissions.info.json
|
13
|
+
def apps_permissions_info(options = {})
|
14
|
+
post('apps.permissions.info', options)
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Allows an app to request additional scopes
|
19
|
+
#
|
20
|
+
# @option options [Object] :scopes
|
21
|
+
# A comma separated list of scopes to request for.
|
22
|
+
# @option options [Object] :trigger_id
|
23
|
+
# Token used to trigger the permissions API.
|
24
|
+
# @see https://api.slack.com/methods/apps.permissions.request
|
25
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.permissions/apps.permissions.request.json
|
26
|
+
def apps_permissions_request(options = {})
|
27
|
+
throw ArgumentError.new('Required arguments :scopes missing') if options[:scopes].nil?
|
28
|
+
throw ArgumentError.new('Required arguments :trigger_id missing') if options[:trigger_id].nil?
|
29
|
+
post('apps.permissions.request', options)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -6,21 +6,21 @@ module Slack
|
|
6
6
|
module Endpoints
|
7
7
|
module Auth
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# Revokes a token.
|
10
10
|
#
|
11
11
|
# @option options [Object] :test
|
12
12
|
# Setting this parameter to 1 triggers a testing mode where the specified token will not actually be revoked.
|
13
13
|
# @see https://api.slack.com/methods/auth.revoke
|
14
|
-
# @see https://github.com/
|
14
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/auth/auth.revoke.json
|
15
15
|
def auth_revoke(options = {})
|
16
16
|
post('auth.revoke', options)
|
17
17
|
end
|
18
18
|
|
19
19
|
#
|
20
|
-
#
|
20
|
+
# Checks authentication & identity.
|
21
21
|
#
|
22
22
|
# @see https://api.slack.com/methods/auth.test
|
23
|
-
# @see https://github.com/
|
23
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/auth/auth.test.json
|
24
24
|
def auth_test(options = {})
|
25
25
|
post('auth.test', options)
|
26
26
|
end
|
@@ -6,12 +6,12 @@ module Slack
|
|
6
6
|
module Endpoints
|
7
7
|
module Bots
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# Gets information about a bot user.
|
10
10
|
#
|
11
11
|
# @option options [Object] :bot
|
12
12
|
# Bot user to get info on.
|
13
13
|
# @see https://api.slack.com/methods/bots.info
|
14
|
-
# @see https://github.com/
|
14
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/bots/bots.info.json
|
15
15
|
def bots_info(options = {})
|
16
16
|
post('bots.info', options)
|
17
17
|
end
|
@@ -6,12 +6,12 @@ module Slack
|
|
6
6
|
module Endpoints
|
7
7
|
module Channels
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# Archives a channel.
|
10
10
|
#
|
11
11
|
# @option options [channel] :channel
|
12
12
|
# Channel to archive.
|
13
13
|
# @see https://api.slack.com/methods/channels.archive
|
14
|
-
# @see https://github.com/
|
14
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.archive.json
|
15
15
|
def channels_archive(options = {})
|
16
16
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
17
17
|
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
@@ -19,34 +19,46 @@ module Slack
|
|
19
19
|
end
|
20
20
|
|
21
21
|
#
|
22
|
-
#
|
22
|
+
# Creates a channel.
|
23
23
|
#
|
24
24
|
# @option options [Object] :name
|
25
25
|
# Name of channel to create.
|
26
26
|
# @option options [Object] :validate
|
27
27
|
# Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.
|
28
28
|
# @see https://api.slack.com/methods/channels.create
|
29
|
-
# @see https://github.com/
|
29
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.create.json
|
30
30
|
def channels_create(options = {})
|
31
31
|
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
|
32
32
|
post('channels.create', options)
|
33
33
|
end
|
34
34
|
|
35
35
|
#
|
36
|
-
#
|
36
|
+
# Delete a channel (undocumented)
|
37
|
+
#
|
38
|
+
# @option options [channel] :channel
|
39
|
+
# Channel to delete.
|
40
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/undocumented/channels/channels.delete.json
|
41
|
+
def channels_delete(options = {})
|
42
|
+
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
43
|
+
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
44
|
+
post('channels.delete', options)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Fetches history of messages and events from a channel.
|
37
49
|
#
|
38
50
|
# @option options [channel] :channel
|
39
51
|
# Channel to fetch history for.
|
52
|
+
# @option options [Object] :inclusive
|
53
|
+
# Include messages with latest or oldest timestamp in results.
|
40
54
|
# @option options [timestamp] :latest
|
41
55
|
# End of time range of messages to include in results.
|
42
56
|
# @option options [timestamp] :oldest
|
43
57
|
# Start of time range of messages to include in results.
|
44
|
-
# @option options [Object] :inclusive
|
45
|
-
# Include messages with latest or oldest timestamp in results.
|
46
58
|
# @option options [Object] :unreads
|
47
59
|
# Include unread_count_display in the output?.
|
48
60
|
# @see https://api.slack.com/methods/channels.history
|
49
|
-
# @see https://github.com/
|
61
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.history.json
|
50
62
|
def channels_history(options = {})
|
51
63
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
52
64
|
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
@@ -54,12 +66,14 @@ module Slack
|
|
54
66
|
end
|
55
67
|
|
56
68
|
#
|
57
|
-
#
|
69
|
+
# Gets information about a channel.
|
58
70
|
#
|
59
71
|
# @option options [channel] :channel
|
60
72
|
# Channel to get info on.
|
73
|
+
# @option options [Object] :include_locale
|
74
|
+
# Set this to true to receive the locale for this channel. Defaults to false.
|
61
75
|
# @see https://api.slack.com/methods/channels.info
|
62
|
-
# @see https://github.com/
|
76
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.info.json
|
63
77
|
def channels_info(options = {})
|
64
78
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
65
79
|
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
@@ -67,14 +81,14 @@ module Slack
|
|
67
81
|
end
|
68
82
|
|
69
83
|
#
|
70
|
-
#
|
84
|
+
# Invites a user to a channel.
|
71
85
|
#
|
72
86
|
# @option options [channel] :channel
|
73
87
|
# Channel to invite user to.
|
74
88
|
# @option options [user] :user
|
75
89
|
# User to invite to channel.
|
76
90
|
# @see https://api.slack.com/methods/channels.invite
|
77
|
-
# @see https://github.com/
|
91
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.invite.json
|
78
92
|
def channels_invite(options = {})
|
79
93
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
80
94
|
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
|
@@ -84,29 +98,28 @@ module Slack
|
|
84
98
|
end
|
85
99
|
|
86
100
|
#
|
87
|
-
#
|
88
|
-
# created.
|
101
|
+
# Joins a channel, creating it if needed.
|
89
102
|
#
|
90
103
|
# @option options [Object] :name
|
91
104
|
# Name of channel to join.
|
92
105
|
# @option options [Object] :validate
|
93
106
|
# Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.
|
94
107
|
# @see https://api.slack.com/methods/channels.join
|
95
|
-
# @see https://github.com/
|
108
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.join.json
|
96
109
|
def channels_join(options = {})
|
97
110
|
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
|
98
111
|
post('channels.join', options)
|
99
112
|
end
|
100
113
|
|
101
114
|
#
|
102
|
-
#
|
115
|
+
# Removes a user from a channel.
|
103
116
|
#
|
104
117
|
# @option options [channel] :channel
|
105
118
|
# Channel to remove user from.
|
106
119
|
# @option options [user] :user
|
107
120
|
# User to remove from channel.
|
108
121
|
# @see https://api.slack.com/methods/channels.kick
|
109
|
-
# @see https://github.com/
|
122
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.kick.json
|
110
123
|
def channels_kick(options = {})
|
111
124
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
112
125
|
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
|
@@ -116,12 +129,12 @@ module Slack
|
|
116
129
|
end
|
117
130
|
|
118
131
|
#
|
119
|
-
#
|
132
|
+
# Leaves a channel.
|
120
133
|
#
|
121
134
|
# @option options [channel] :channel
|
122
135
|
# Channel to leave.
|
123
136
|
# @see https://api.slack.com/methods/channels.leave
|
124
|
-
# @see https://github.com/
|
137
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.leave.json
|
125
138
|
def channels_leave(options = {})
|
126
139
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
127
140
|
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
@@ -129,27 +142,37 @@ module Slack
|
|
129
142
|
end
|
130
143
|
|
131
144
|
#
|
132
|
-
#
|
145
|
+
# Lists all channels in a Slack team.
|
133
146
|
#
|
147
|
+
# @option options [Object] :cursor
|
148
|
+
# Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first "page" of the collection. See pagination for more detail.
|
134
149
|
# @option options [Object] :exclude_archived
|
135
150
|
# Exclude archived channels from the list.
|
136
151
|
# @option options [Object] :exclude_members
|
137
152
|
# Exclude the members collection from each channel.
|
153
|
+
# @option options [Object] :limit
|
154
|
+
# The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.
|
138
155
|
# @see https://api.slack.com/methods/channels.list
|
139
|
-
# @see https://github.com/
|
156
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.list.json
|
140
157
|
def channels_list(options = {})
|
141
|
-
|
158
|
+
if block_given?
|
159
|
+
Pagination::Cursor.new(self, :channels_list, options).each do |page|
|
160
|
+
yield page
|
161
|
+
end
|
162
|
+
else
|
163
|
+
post('channels.list', options)
|
164
|
+
end
|
142
165
|
end
|
143
166
|
|
144
167
|
#
|
145
|
-
#
|
168
|
+
# Sets the read cursor in a channel.
|
146
169
|
#
|
147
170
|
# @option options [channel] :channel
|
148
171
|
# Channel to set reading cursor in.
|
149
172
|
# @option options [timestamp] :ts
|
150
173
|
# Timestamp of the most recently seen message.
|
151
174
|
# @see https://api.slack.com/methods/channels.mark
|
152
|
-
# @see https://github.com/
|
175
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.mark.json
|
153
176
|
def channels_mark(options = {})
|
154
177
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
155
178
|
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
|
@@ -158,7 +181,7 @@ module Slack
|
|
158
181
|
end
|
159
182
|
|
160
183
|
#
|
161
|
-
#
|
184
|
+
# Renames a channel.
|
162
185
|
#
|
163
186
|
# @option options [channel] :channel
|
164
187
|
# Channel to rename.
|
@@ -167,7 +190,7 @@ module Slack
|
|
167
190
|
# @option options [Object] :validate
|
168
191
|
# Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.
|
169
192
|
# @see https://api.slack.com/methods/channels.rename
|
170
|
-
# @see https://github.com/
|
193
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.rename.json
|
171
194
|
def channels_rename(options = {})
|
172
195
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
173
196
|
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
|
@@ -176,14 +199,14 @@ module Slack
|
|
176
199
|
end
|
177
200
|
|
178
201
|
#
|
179
|
-
#
|
202
|
+
# Retrieve a thread of messages posted to a channel
|
180
203
|
#
|
181
204
|
# @option options [channel] :channel
|
182
205
|
# Channel to fetch thread from.
|
183
206
|
# @option options [Object] :thread_ts
|
184
207
|
# Unique identifier of a thread's parent message.
|
185
208
|
# @see https://api.slack.com/methods/channels.replies
|
186
|
-
# @see https://github.com/
|
209
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.replies.json
|
187
210
|
def channels_replies(options = {})
|
188
211
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
189
212
|
throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
|
@@ -192,14 +215,14 @@ module Slack
|
|
192
215
|
end
|
193
216
|
|
194
217
|
#
|
195
|
-
#
|
218
|
+
# Sets the purpose for a channel.
|
196
219
|
#
|
197
220
|
# @option options [channel] :channel
|
198
221
|
# Channel to set the purpose of.
|
199
222
|
# @option options [Object] :purpose
|
200
223
|
# The new purpose.
|
201
224
|
# @see https://api.slack.com/methods/channels.setPurpose
|
202
|
-
# @see https://github.com/
|
225
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.setPurpose.json
|
203
226
|
def channels_setPurpose(options = {})
|
204
227
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
205
228
|
throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
|
@@ -208,14 +231,14 @@ module Slack
|
|
208
231
|
end
|
209
232
|
|
210
233
|
#
|
211
|
-
#
|
234
|
+
# Sets the topic for a channel.
|
212
235
|
#
|
213
236
|
# @option options [channel] :channel
|
214
237
|
# Channel to set the topic of.
|
215
238
|
# @option options [Object] :topic
|
216
239
|
# The new topic.
|
217
240
|
# @see https://api.slack.com/methods/channels.setTopic
|
218
|
-
# @see https://github.com/
|
241
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.setTopic.json
|
219
242
|
def channels_setTopic(options = {})
|
220
243
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
221
244
|
throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
|
@@ -224,12 +247,12 @@ module Slack
|
|
224
247
|
end
|
225
248
|
|
226
249
|
#
|
227
|
-
#
|
250
|
+
# Unarchives a channel.
|
228
251
|
#
|
229
252
|
# @option options [channel] :channel
|
230
253
|
# Channel to unarchive.
|
231
254
|
# @see https://api.slack.com/methods/channels.unarchive
|
232
|
-
# @see https://github.com/
|
255
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.unarchive.json
|
233
256
|
def channels_unarchive(options = {})
|
234
257
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
235
258
|
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
@@ -6,32 +6,65 @@ module Slack
|
|
6
6
|
module Endpoints
|
7
7
|
module Chat
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# Execute a slash command in a public channel (undocumented)
|
10
|
+
#
|
11
|
+
# @option options [channel] :channel
|
12
|
+
# Channel to execute the command in.
|
13
|
+
# @option options [Object] :command
|
14
|
+
# Slash command to be executed. Leading backslash is required.
|
15
|
+
# @option options [Object] :text
|
16
|
+
# Additional parameters provided to the slash command.
|
17
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/undocumented/chat/chat.command.json
|
18
|
+
def chat_command(options = {})
|
19
|
+
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
20
|
+
throw ArgumentError.new('Required arguments :command missing') if options[:command].nil?
|
21
|
+
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
22
|
+
post('chat.command', options)
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Deletes a message.
|
10
27
|
#
|
11
|
-
# @option options [timestamp] :ts
|
12
|
-
# Timestamp of the message to be deleted.
|
13
28
|
# @option options [channel] :channel
|
14
29
|
# Channel containing the message to be deleted.
|
30
|
+
# @option options [timestamp] :ts
|
31
|
+
# Timestamp of the message to be deleted.
|
15
32
|
# @option options [Object] :as_user
|
16
|
-
# Pass true to delete the message as the authed user. Bot users in this context are considered authed users.
|
33
|
+
# Pass true to delete the message as the authed user with chat:write:user scope. Bot users in this context are considered authed users. If unused or false, the message will be deleted with chat:write:bot scope.
|
17
34
|
# @see https://api.slack.com/methods/chat.delete
|
18
|
-
# @see https://github.com/
|
35
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.delete.json
|
19
36
|
def chat_delete(options = {})
|
20
|
-
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
|
21
37
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
38
|
+
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
|
22
39
|
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
23
40
|
post('chat.delete', options)
|
24
41
|
end
|
25
42
|
|
26
43
|
#
|
27
|
-
#
|
44
|
+
# Retrieve a permalink URL for a specific extant message
|
45
|
+
#
|
46
|
+
# @option options [channel] :channel
|
47
|
+
# The ID of the conversation or channel containing the message.
|
48
|
+
# @option options [Object] :message_ts
|
49
|
+
# A message's ts value, uniquely identifying it within a channel.
|
50
|
+
# @see https://api.slack.com/methods/chat.getPermalink
|
51
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.getPermalink.json
|
52
|
+
def chat_getPermalink(options = {})
|
53
|
+
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
54
|
+
throw ArgumentError.new('Required arguments :message_ts missing') if options[:message_ts].nil?
|
55
|
+
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
56
|
+
post('chat.getPermalink', options)
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Share a me message into a channel.
|
28
61
|
#
|
29
62
|
# @option options [channel] :channel
|
30
63
|
# Channel to send message to. Can be a public channel, private group or IM channel. Can be an encoded ID, or a name.
|
31
64
|
# @option options [Object] :text
|
32
65
|
# Text of the message to send.
|
33
66
|
# @see https://api.slack.com/methods/chat.meMessage
|
34
|
-
# @see https://github.com/
|
67
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.meMessage.json
|
35
68
|
def chat_meMessage(options = {})
|
36
69
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
37
70
|
throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
|
@@ -39,36 +72,69 @@ module Slack
|
|
39
72
|
end
|
40
73
|
|
41
74
|
#
|
42
|
-
#
|
75
|
+
# Sends an ephemeral message to a user in a channel.
|
43
76
|
#
|
44
77
|
# @option options [channel] :channel
|
45
|
-
# Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.
|
78
|
+
# Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.
|
46
79
|
# @option options [Object] :text
|
47
80
|
# Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead.
|
81
|
+
# @option options [user] :user
|
82
|
+
# id of the user who will receive the ephemeral message. The user should be in the channel specified by the channel argument.
|
83
|
+
# @option options [Object] :as_user
|
84
|
+
# Pass true to post the message as the authed bot. Defaults to false.
|
85
|
+
# @option options [Object] :attachments
|
86
|
+
# A JSON-based array of structured attachments, presented as a URL-encoded string.
|
87
|
+
# @option options [Object] :link_names
|
88
|
+
# Find and link channel names and usernames.
|
48
89
|
# @option options [Object] :parse
|
49
90
|
# Change how messages are treated. Defaults to none. See below.
|
91
|
+
# @see https://api.slack.com/methods/chat.postEphemeral
|
92
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postEphemeral.json
|
93
|
+
def chat_postEphemeral(options = {})
|
94
|
+
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
95
|
+
throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
|
96
|
+
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
|
97
|
+
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
|
98
|
+
# attachments must be passed as an encoded JSON string
|
99
|
+
if options.key?(:attachments)
|
100
|
+
attachments = options[:attachments]
|
101
|
+
attachments = JSON.dump(attachments) unless attachments.is_a?(String)
|
102
|
+
options = options.merge(attachments: attachments)
|
103
|
+
end
|
104
|
+
post('chat.postEphemeral', options)
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# Sends a message to a channel.
|
109
|
+
#
|
110
|
+
# @option options [channel] :channel
|
111
|
+
# Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.
|
112
|
+
# @option options [Object] :text
|
113
|
+
# Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead.
|
114
|
+
# @option options [Object] :as_user
|
115
|
+
# Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below.
|
116
|
+
# @option options [Object] :attachments
|
117
|
+
# A JSON-based array of structured attachments, presented as a URL-encoded string.
|
118
|
+
# @option options [Object] :icon_emoji
|
119
|
+
# Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
|
120
|
+
# @option options [Object] :icon_url
|
121
|
+
# URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
|
50
122
|
# @option options [Object] :link_names
|
51
123
|
# Find and link channel names and usernames.
|
52
|
-
# @option options [Object] :
|
53
|
-
#
|
124
|
+
# @option options [Object] :parse
|
125
|
+
# Change how messages are treated. Defaults to none. See below.
|
126
|
+
# @option options [Object] :reply_broadcast
|
127
|
+
# Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false.
|
128
|
+
# @option options [Object] :thread_ts
|
129
|
+
# Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead.
|
54
130
|
# @option options [Object] :unfurl_links
|
55
131
|
# Pass true to enable unfurling of primarily text-based content.
|
56
132
|
# @option options [Object] :unfurl_media
|
57
133
|
# Pass false to disable unfurling of media content.
|
58
134
|
# @option options [Object] :username
|
59
135
|
# Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
|
60
|
-
# @option options [Object] :as_user
|
61
|
-
# Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below.
|
62
|
-
# @option options [Object] :icon_url
|
63
|
-
# URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
|
64
|
-
# @option options [Object] :icon_emoji
|
65
|
-
# Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.
|
66
|
-
# @option options [Object] :thread_ts
|
67
|
-
# Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead.
|
68
|
-
# @option options [Object] :reply_broadcast
|
69
|
-
# Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false.
|
70
136
|
# @see https://api.slack.com/methods/chat.postMessage
|
71
|
-
# @see https://github.com/
|
137
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.postMessage.json
|
72
138
|
def chat_postMessage(options = {})
|
73
139
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
74
140
|
throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
|
@@ -82,18 +148,22 @@ module Slack
|
|
82
148
|
end
|
83
149
|
|
84
150
|
#
|
85
|
-
#
|
151
|
+
# Provide custom unfurl behavior for user-posted URLs
|
86
152
|
#
|
87
153
|
# @option options [channel] :channel
|
88
154
|
# Channel ID of the message.
|
89
155
|
# @option options [timestamp] :ts
|
90
156
|
# Timestamp of the message to add unfurl behavior to.
|
91
157
|
# @option options [Object] :unfurls
|
92
|
-
# JSON
|
158
|
+
# URL-encoded JSON map with keys set to URLs featured in the the message, pointing to their unfurl message attachments.
|
159
|
+
# @option options [Object] :user_auth_message
|
160
|
+
# Provide a simply-formatted string to send as an ephemeral message to the user as invitation to authenticate further and enable full unfurling behavior.
|
93
161
|
# @option options [Object] :user_auth_required
|
94
162
|
# Set to true or 1 to indicate the user must install your Slack app to trigger unfurls for this domain.
|
163
|
+
# @option options [Object] :user_auth_url
|
164
|
+
# Send users to this custom URL where they will complete authentication in your app to fully trigger unfurling. Value should be properly URL-encoded.
|
95
165
|
# @see https://api.slack.com/methods/chat.unfurl
|
96
|
-
# @see https://github.com/
|
166
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.unfurl.json
|
97
167
|
def chat_unfurl(options = {})
|
98
168
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
99
169
|
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
|
@@ -103,28 +173,28 @@ module Slack
|
|
103
173
|
end
|
104
174
|
|
105
175
|
#
|
106
|
-
#
|
176
|
+
# Updates a message.
|
107
177
|
#
|
108
|
-
# @option options [timestamp] :ts
|
109
|
-
# Timestamp of the message to be updated.
|
110
178
|
# @option options [channel] :channel
|
111
179
|
# Channel containing the message to be updated.
|
112
180
|
# @option options [Object] :text
|
113
|
-
# New text for the message, using the default formatting rules.
|
181
|
+
# New text for the message, using the default formatting rules. It's not required when presenting attachments.
|
182
|
+
# @option options [timestamp] :ts
|
183
|
+
# Timestamp of the message to be updated.
|
184
|
+
# @option options [Object] :as_user
|
185
|
+
# Pass true to update the message as the authed user. Bot users in this context are considered authed users.
|
114
186
|
# @option options [Object] :attachments
|
115
|
-
#
|
116
|
-
# @option options [Object] :parse
|
117
|
-
# Change how messages are treated. Defaults to client, unlike chat.postMessage. See below.
|
187
|
+
# A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting text.
|
118
188
|
# @option options [Object] :link_names
|
119
189
|
# 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.
|
120
|
-
# @option options [Object] :
|
121
|
-
#
|
190
|
+
# @option options [Object] :parse
|
191
|
+
# Change how messages are treated. Defaults to client, unlike chat.postMessage. See below.
|
122
192
|
# @see https://api.slack.com/methods/chat.update
|
123
|
-
# @see https://github.com/
|
193
|
+
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/chat/chat.update.json
|
124
194
|
def chat_update(options = {})
|
125
|
-
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
|
126
195
|
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
127
196
|
throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
|
197
|
+
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
|
128
198
|
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
|
129
199
|
# attachments must be passed as an encoded JSON string
|
130
200
|
if options.key?(:attachments)
|