slack-ruby-client 3.3.0 → 3.4.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/danger-comment.yml +11 -2
  3. data/.github/workflows/danger.yml +10 -2
  4. data/.github/workflows/lint.yml +21 -8
  5. data/.github/workflows/release.yml +27 -0
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +93 -1
  8. data/.spellcheck.txt +256 -0
  9. data/AGENTS.md +1 -1
  10. data/CHANGELOG.md +17 -0
  11. data/CONTRIBUTING.md +53 -62
  12. data/Gemfile +20 -4
  13. data/LICENSE.md +1 -1
  14. data/README.md +94 -104
  15. data/RELEASING.md +20 -58
  16. data/Rakefile +22 -0
  17. data/SECURITY.md +1 -1
  18. data/UPGRADING.md +39 -43
  19. data/benchmarks/events.rb +26 -0
  20. data/benchmarks/formatting.rb +17 -0
  21. data/benchmarks/support.rb +67 -0
  22. data/benchmarks/web_client.rb +28 -0
  23. data/bin/commands/admin_analytics_members.rb +39 -0
  24. data/bin/commands/admin_analytics_messages.rb +2 -2
  25. data/bin/commands/admin_analytics_slackbot.rb +33 -0
  26. data/bin/commands/admin_apps_permissions.rb +1 -1
  27. data/bin/commands/admin_conversations.rb +11 -1
  28. data/bin/commands/admin_slackbot_skills.rb +56 -0
  29. data/bin/commands/admin_users.rb +11 -2
  30. data/bin/commands/admin_users_access.rb +31 -0
  31. data/bin/commands/agents_conversations.rb +122 -0
  32. data/bin/commands/apps_managed_permissions.rb +2 -2
  33. data/bin/commands/chat.rb +1 -1
  34. data/bin/commands/pins.rb +1 -1
  35. data/bin/commands/slackLists_download.rb +1 -0
  36. data/bin/commands/slackLists_items.rb +1 -1
  37. data/bin/commands/slackbot_skills.rb +71 -0
  38. data/bin/commands/slackbot_skills_library.rb +29 -0
  39. data/bin/commands/team.rb +1 -0
  40. data/bin/commands/team_externalTeams.rb +1 -1
  41. data/examples/files_upload_v2/README.md +4 -3
  42. data/examples/oauth_v2/README.md +5 -4
  43. data/lib/slack/messages/formatting.rb +29 -20
  44. data/lib/slack/version.rb +1 -1
  45. data/lib/slack/web/api/endpoints/admin_analytics_members.rb +66 -0
  46. data/lib/slack/web/api/endpoints/admin_analytics_messages.rb +1 -1
  47. data/lib/slack/web/api/endpoints/admin_analytics_slackbot.rb +54 -0
  48. data/lib/slack/web/api/endpoints/admin_apps_permissions.rb +1 -1
  49. data/lib/slack/web/api/endpoints/admin_conversations.rb +16 -1
  50. data/lib/slack/web/api/endpoints/admin_slackbot_skills.rb +84 -0
  51. data/lib/slack/web/api/endpoints/admin_users.rb +13 -1
  52. data/lib/slack/web/api/endpoints/admin_users_access.rb +40 -0
  53. data/lib/slack/web/api/endpoints/agents_conversations.rb +186 -0
  54. data/lib/slack/web/api/endpoints/apps_managed_permissions.rb +1 -1
  55. data/lib/slack/web/api/endpoints/chat.rb +1 -1
  56. data/lib/slack/web/api/endpoints/pins.rb +1 -1
  57. data/lib/slack/web/api/endpoints/slackLists_download.rb +2 -0
  58. data/lib/slack/web/api/endpoints/slackLists_items.rb +1 -1
  59. data/lib/slack/web/api/endpoints/slackbot_skills.rb +107 -0
  60. data/lib/slack/web/api/endpoints/slackbot_skills_library.rb +36 -0
  61. data/lib/slack/web/api/endpoints/team.rb +2 -0
  62. data/lib/slack/web/api/endpoints/team_externalTeams.rb +1 -1
  63. data/lib/slack/web/api/endpoints.rb +14 -0
  64. data/lib/slack/web/api/errors.rb +258 -2
  65. data/lib/slack/web/api/mixins/ids.id.rb +2 -1
  66. data/script/release.rb +33 -0
  67. data/slack-ruby-client.gemspec +1 -2
  68. metadata +24 -3
data/README.md CHANGED
@@ -1,13 +1,10 @@
1
- Slack Ruby Client
2
- =================
1
+ # Slack Ruby Client
3
2
 
4
- [![Gem Version](https://badge.fury.io/rb/slack-ruby-client.svg)](http://badge.fury.io/rb/slack-ruby-client)
5
- [![Tests](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml)
6
- [![Coverage Status](https://coveralls.io/repos/github/slack-ruby/slack-ruby-client/badge.svg?branch=master)](https://coveralls.io/github/slack-ruby/slack-ruby-client?branch=master)
3
+ [![Gem Version](https://badge.fury.io/rb/slack-ruby-client.svg)](http://badge.fury.io/rb/slack-ruby-client) [![Tests](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/slack-ruby/slack-ruby-client/badge.svg?branch=master)](https://coveralls.io/github/slack-ruby/slack-ruby-client?branch=master)
7
4
 
8
- A Ruby client for the Slack [Web](https://api.slack.com/web) and [Events](https://api.slack.com/events-api) APIs. Comes with a handy command-line client, too. If you are not familiar with these concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
5
+ A Ruby client for the Slack [Web](https://docs.slack.dev/apis/web-api/) and [Events](https://docs.slack.dev/apis/events-api/) APIs. Comes with a handy command-line client, too. If you are not familiar with these concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
9
6
 
10
- ![](slack.png)
7
+ ![Slack Ruby Client](slack.png)
11
8
 
12
9
  # Table of Contents
13
10
 
@@ -64,19 +61,19 @@ A Ruby client for the Slack [Web](https://api.slack.com/web) and [Events](https:
64
61
 
65
62
  ## Useful to Me?
66
63
 
67
- * This library lets you send messages to Slack via the Web API and facilitates integration with the Events API.
68
- * To write a complete bot for Slack you need more than this library, and it's much easier to start with [slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events).
69
- * To respond to slash commands, interactive components, or events at the lowest level, implement a web application using your favorite web framework, and use this library to call the Slack Web API, and to verify that events are coming from Slack.
64
+ - This library lets you send messages to Slack via the Web API and facilitates integration with the Events API.
65
+ - To write a complete bot for Slack you need more than this library, and it's much easier to start with [slack-ruby-bot-server-events](https://github.com/slack-ruby/slack-ruby-bot-server-events).
66
+ - To respond to slash commands, interactive components, or events at the lowest level, implement a web application using your favorite web framework, and use this library to call the Slack Web API, and to verify that events are coming from Slack.
70
67
 
71
68
  ## Stable Release
72
69
 
73
- You're reading the documentation for the **stable** release of slack-ruby-client, 3.3.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
70
+ You're reading the documentation for the **stable** release of slack-ruby-client, 3.4.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
74
71
 
75
72
  ## Installation
76
73
 
77
74
  Add to Gemfile.
78
75
 
79
- ```
76
+ ```ruby
80
77
  gem 'slack-ruby-client'
81
78
  ```
82
79
 
@@ -90,28 +87,28 @@ To integrate your bot with Slack, you must first create a new [Slack App](https:
90
87
 
91
88
  ### OAuth Code Grant
92
89
 
93
- Once created, go to the app's Basic Info tab and grab the Client ID and Client Secret. You'll need these in order complete an [OAuth Workflow](https://api.slack.com/authentication/oauth-v2). A working sample that starts a local web server and obtains a bot or a user token for your app using OAuth v2 is available in [examples/oauth_v2](examples/oauth_v2).
90
+ Once created, go to the app's Basic Info tab and grab the Client ID and Client Secret. You'll need these in order to complete an [OAuth workflow](https://docs.slack.dev/authentication/installing-with-oauth/). A working sample that starts a local web server and obtains a bot or a user token for your app using OAuth v2 is available in [examples/oauth_v2](examples/oauth_v2).
94
91
 
95
92
  ### Using an API Token
96
93
 
97
- Although OAuth is recommended, you can also [generate an API token](https://api.slack.com/tutorials/tracks/getting-a-token) for your app and use it for some interactions.
94
+ Although OAuth is recommended, you can also [generate an API token](https://docs.slack.dev/authentication/tokens/) for your app and use it for some interactions.
98
95
 
99
96
  ```ruby
100
97
  Slack.configure do |config|
101
- config.token = ENV['SLACK_API_TOKEN']
98
+ config.token = ENV.fetch('SLACK_API_TOKEN', nil)
102
99
  end
103
100
  ```
104
101
 
105
- This sets a global default token. You can also pass a token into the initializer of both `Slack::Web::Client` and `Slack::RealTime::Client` or configure those separately via `Slack::Web::Config.configure` and `Slack::RealTime::Config.configure`. The instance token will be used over the client type token over the global default.
102
+ This sets a global default token. You can also pass a token into the `Slack::Web::Client` initializer or configure Web clients separately via `Slack::Web::Config.configure`. An instance token takes precedence over the Web client token, which takes precedence over the global default.
106
103
 
107
104
  ### Global Settings
108
105
 
109
106
  The following global settings are supported via `Slack.configure`.
110
107
 
111
- setting | description
112
- -------------|-------------------------------------------------------------------------------------------------
113
- token | Slack API token.
114
- logger | An optional logger, defaults to `::Logger.new(STDOUT)` at `Logger::WARN` level.
108
+ setting | description
109
+ ------------- | -------------------------------------------------------------------------------------------------
110
+ token | Slack API token.
111
+ logger | An optional logger, defaults to `::Logger.new(STDOUT)` at `Logger::WARN` level.
115
112
 
116
113
  ### Web Client
117
114
 
@@ -130,7 +127,7 @@ client.auth_test
130
127
 
131
128
  ##### Send Messages
132
129
 
133
- Send messages with [chat_PostMessage](https://api.slack.com/methods/chat.postMessage).
130
+ Send messages with [chat_postMessage](https://docs.slack.dev/reference/methods/chat.postMessage/).
134
131
 
135
132
  ```ruby
136
133
  client.chat_postMessage(channel: '#general', text: 'Hello World', as_user: true)
@@ -138,11 +135,11 @@ client.chat_postMessage(channel: '#general', text: 'Hello World', as_user: true)
138
135
 
139
136
  See a fully working example in [examples/hi_web](examples/hi_web/hi.rb).
140
137
 
141
- ![](examples/hi_web/hi.gif)
138
+ ![Sending a message with the hi_web example](examples/hi_web/hi.gif)
142
139
 
143
140
  ##### List Channels
144
141
 
145
- List channels with [conversations_list](https://api.slack.com/methods/conversations.list).
142
+ List channels with [conversations_list](https://docs.slack.dev/reference/methods/conversations.list/).
146
143
 
147
144
  ```ruby
148
145
  channels = client.conversations_list.channels
@@ -152,7 +149,7 @@ general_channel = channels.detect { |c| c.name == 'general' }
152
149
 
153
150
  ##### Upload a File
154
151
 
155
- Upload files with [sequenced API calls](https://api.slack.com/messaging/files#uploading_files).
152
+ Upload files with [sequenced API calls](https://docs.slack.dev/messaging/working-with-files/).
156
153
 
157
154
  This library provides a helper method `files_upload_v2` that wraps the three separate API calls.
158
155
 
@@ -165,7 +162,7 @@ client.files_upload_v2(
165
162
  content: File.read('/users/me/results.pdf'), # the string contents of the file
166
163
 
167
164
  # optional options
168
- channels: ['C000000', 'C000001'], # channel IDs to share the file in (:channel_id, :channel, or :channels are all supported)
165
+ channels: %w[C000000 C000001], # channel IDs to share the file in (:channel_id, :channel, or :channels are all supported)
169
166
  initial_comment: 'Sharing the Q1 results :tada:', # the message that is included with the file share thread
170
167
  snippet_type: 'text', # the type of snippet
171
168
  title: 'Q1 Results', # sets the title of the file, overriding the filename
@@ -186,24 +183,13 @@ client.files_upload_v2(
186
183
  )
187
184
  ```
188
185
 
189
- You can use a channel ID passed as `channel_id`, a single channel as `channel`, an array of channel IDs as `channels`, or a channel name or names (prefixed with `#`) in `files_upload_v2`. Lookup by name is not supported by the Slack API and this method called invokes `conversations_list` in order to locate the channel ID. This invocation can have a cost if you have many Slack channels and is only recommended when you intend to list channels anyway.
186
+ You can use a channel ID passed as `channel_id`, a single channel as `channel`, an array of channel IDs as `channels`, or a channel name or names (prefixed with `#`) in `files_upload_v2`. Lookup by name is not supported by the Slack API, so this method invokes `conversations_list` to locate the channel ID. This invocation can have a cost if you have many Slack channels and is only recommended when you intend to list channels anyway.
190
187
 
191
- Note: This library includes a `files_upload` method that uses a deprecated endpoint `files.upload` that will [no longer be supported on 3/11/2025](https://api.slack.com/methods/files.upload#markdown).
192
-
193
- ```ruby
194
- client.files_upload(
195
- channels: '#general',
196
- as_user: true,
197
- file: Faraday::Multipart::FilePart.new('/path/to/avatar.jpg', 'image/jpeg'),
198
- title: 'My Avatar',
199
- filename: 'avatar.jpg',
200
- initial_comment: 'Attached a selfie.'
201
- )
202
- ```
188
+ Note: The generated `files_upload` method calls the [`files.upload`](https://docs.slack.dev/reference/methods/files.upload/) endpoint, which Slack sunset on November 12, 2025. Use `files_upload_v2` instead.
203
189
 
204
190
  ##### Get Channel Info
205
191
 
206
- You can use a channel ID or name (prefixed with `#`) in all functions that take a `:channel` argument. Lookup by name is not supported by the Slack API and the `channels_id` method called invokes `conversations_list` in order to locate the channel ID. This invocation can have a cost if you have many Slack channels. In this scenario, we encourage you to use channel id.
192
+ You can use a channel ID or name (prefixed with `#`) in all functions that take a `:channel` argument. Lookup by name is not supported by the Slack API, so the `channels_id` method invokes `conversations_list` to locate the channel ID. This invocation can have a cost if you have many Slack channels. In this scenario, we encourage you to use channel IDs.
207
193
 
208
194
  ```ruby
209
195
  client.conversations_info(channel: 'C04KB5X4D') # calls conversations_info
@@ -215,7 +201,7 @@ client.conversations_info(channel: '#general') # calls conversations_list follow
215
201
 
216
202
  ##### Get User Info
217
203
 
218
- You can use a user ID or name (prefixed with `@`) in all functions that take a `:user` argument. Lookup by name is not supported by the Slack API and the `users_id` method called invokes `users_list` in order to locate the user ID.
204
+ You can use a user ID or name (prefixed with `@`) in all functions that take a `:user` argument. Lookup by name is not supported by the Slack API, so the `users_id` method invokes `users_list` to locate the user ID.
219
205
 
220
206
  ```ruby
221
207
  client.users_info(user: 'U092BDCLV') # calls users_info
@@ -235,25 +221,25 @@ client.users_search(user: 'dblock')
235
221
 
236
222
  ##### Other
237
223
 
238
- Refer to the [Slack Web API Method Reference](https://api.slack.com/methods) for the list of all available functions.
224
+ Refer to the [Slack Web API method reference](https://docs.slack.dev/reference/methods/) for the list of all available functions.
239
225
 
240
226
  #### JSON Arguments
241
227
 
242
- The Web API expects certain arguments to be sent as JSON-encoded strings. With the client you can pass these args as ruby hashes or arrays and they will be converted automatically to JSON, or you can provide the JSON directly.
228
+ The Web API expects certain arguments to be sent as JSON-encoded strings. With the client you can pass these arguments as Ruby hashes or arrays and they will be converted automatically to JSON, or you can provide the JSON directly.
243
229
 
244
230
  ```ruby
245
- # As ruby objects
231
+ # As Ruby objects
246
232
  client.chat_postMessage(
247
233
  channel: 'C123456',
248
234
  text: 'Hello World',
249
- blocks: [{type: 'section', text: {type: 'mrkdwn', text: 'Hello World'}}]
235
+ blocks: [{ type: 'section', text: { type: 'mrkdwn', text: 'Hello World' } }]
250
236
  )
251
237
 
252
238
  # As a JSON string
253
239
  client.chat_postMessage(
254
240
  channel: 'C123456',
255
241
  text: 'Hello World',
256
- blocks: JSON.dump([{type: 'section', text: {type: 'mrkdwn', text: 'Hello World'}}])
242
+ blocks: JSON.dump([{ type: 'section', text: { type: 'mrkdwn', text: 'Hello World' } }])
257
243
  )
258
244
  client.chat_postMessage(
259
245
  channel: 'C123456',
@@ -278,22 +264,22 @@ client = Slack::Web::Client.new(user_agent: 'Slack Ruby Client/3.0')
278
264
 
279
265
  The following settings are supported.
280
266
 
281
- setting | description
282
- -----------------------------|-------------------------------------------------------------------------------------------------
283
- token | Slack API token.
284
- user_agent | User-agent, defaults to _Slack Ruby Client/version_.
285
- proxy | Optional HTTP proxy.
286
- ca_path | Optional SSL certificates path.
287
- ca_file | Optional SSL certificates file.
288
- endpoint | Slack endpoint, default is _https://slack.com/api_.
289
- logger | Optional `Logger` instance that logs HTTP requests.
290
- timeout | Optional open/read timeout in seconds.
291
- open_timeout | Optional connection open timeout in seconds.
292
- default_page_size | Optional page size for paginated requests, default is _100_.
293
- conversations_id_page_size | Optional page size for conversations_list requests made when calculating conversation id from a conversation name, default is _nil_, which will use the default_page_size.
294
- users_id_page_size | Optional page size for users_list requests made when calculating user id from a user name, default is _nil_, which will use the default_page_size.
295
- default_max_retries | Optional number of retries for paginated requests, default is _100_.
296
- adapter | Optional HTTP adapter to use, defaults to `Faraday.default_adapter`.
267
+ setting | description
268
+ ----------------------------- | -------------------------------------------------------------------------------------------------
269
+ token | Slack API token.
270
+ user_agent | User-agent, defaults to _Slack Ruby Client/version_.
271
+ proxy | Optional HTTP proxy.
272
+ ca_path | Optional SSL certificates path.
273
+ ca_file | Optional SSL certificates file.
274
+ endpoint | Slack endpoint, default is _https://slack.com/api_.
275
+ logger | Optional `Logger` instance that logs HTTP requests.
276
+ timeout | Optional open/read timeout in seconds.
277
+ open_timeout | Optional connection open timeout in seconds.
278
+ default_page_size | Optional page size for paginated requests, default is _100_.
279
+ conversations_id_page_size | Optional page size for conversations_list requests made when calculating conversation id from a conversation name, default is _nil_, which will use the default_page_size.
280
+ users_id_page_size | Optional page size for users_list requests made when calculating user id from a user name, default is _nil_, which will use the default_page_size.
281
+ default_max_retries | Optional number of retries for paginated requests, default is _100_.
282
+ adapter | Optional HTTP adapter to use, defaults to `Faraday.default_adapter`.
297
283
 
298
284
  You can also pass request options, including `timeout` and `open_timeout` into individual calls.
299
285
 
@@ -336,13 +322,13 @@ observed_client.auth_test
336
322
 
337
323
  Error callbacks receive the exception and then it is re-raised unchanged. They run for every failed HTTP attempt, including failures that pagination subsequently retries. Successful calls and exceptions from request or response callbacks do not trigger them. If an error callback raises, its exception propagates instead and later callbacks are not invoked. As with other callbacks, these methods return a configured copy and can be chained.
338
324
 
339
- You can control what proxy options are used by modifying the `http_proxy` environment variable per [Net::HTTP's documentation](https://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html#class-Net::HTTP-label-Proxies).
325
+ You can control what proxy options are used by modifying the `http_proxy` environment variable per the [Net::HTTP documentation](https://docs.ruby-lang.org/en/master/Net/HTTP.html#class-Net::HTTP-label-Proxies).
340
326
 
341
- Note that Docker on OSX seems to incorrectly set the proxy, causing `Faraday::ConnectionFailed, ERROR -- : Failed to open TCP connection to : (getaddrinfo: Name or service not known)`. You might need to manually unset `http_proxy` in that case, eg. `http_proxy="" bundle exec ruby ./my_bot.rb`.
327
+ Note that Docker on macOS seems to incorrectly set the proxy, causing `Faraday::ConnectionFailed, ERROR -- : Failed to open TCP connection to : (getaddrinfo: Name or service not known)`. You might need to manually unset `http_proxy` in that case, e.g. `http_proxy="" bundle exec ruby ./my_bot.rb`.
342
328
 
343
329
  #### Pagination Support
344
330
 
345
- The Web client natively supports [cursor pagination](https://api.slack.com/docs/pagination#cursors) for methods that allow it, such as `users_list`. Supply a block and the client will make repeated requests adjusting the value of `cursor` with every response. The default limit is set to 100 and can be adjusted via `Slack::Web::Client.config.default_page_size` or by passing it directly into the API call.
331
+ The Web client natively supports [cursor pagination](https://docs.slack.dev/apis/web-api/pagination/) for methods that allow it, such as `users_list`. Supply a block and the client will make repeated requests adjusting the value of `cursor` with every response. The default limit is set to 100 and can be adjusted via `Slack::Web::Client.config.default_page_size` or by passing it directly into the API call.
346
332
 
347
333
  ```ruby
348
334
  all_members = []
@@ -373,7 +359,7 @@ Note that Slack expects `text` to be UTF-8 encoded. If your messages appear with
373
359
  ```ruby
374
360
  text = 'characters such as "Ñ", "Á", "É"'
375
361
  text.encoding
376
- => #<Encoding:UTF-8>
362
+ # => #<Encoding:UTF-8>
377
363
  client.chat_postMessage(channel: '#general', text: text, as_user: true)
378
364
  # renders 'characters such as "Ñ", "Á", "É"' in Slack
379
365
 
@@ -391,6 +377,8 @@ client.chat_postMessage(channel: '#general', text: text, as_user: true)
391
377
  If Slack returns an error for the request, then an error will be raised. The error class is specific to the type of error that Slack returns. For instance if Slack returns `account_inactive` then the error will be `Slack::Web::Api::Errors::AccountInactive`. This allows you to handle certain types of errors as needed:
392
378
 
393
379
  ```ruby
380
+ begin
381
+ client.auth_test
394
382
  rescue Slack::Web::Api::Errors::AccountInactive => e
395
383
  # deal with inactive account
396
384
  end
@@ -399,6 +387,8 @@ end
399
387
  All of these errors inherit from `Slack::Web::Api::Errors::SlackError`, so you can handle or silence all errors if necessary:
400
388
 
401
389
  ```ruby
390
+ begin
391
+ client.auth_test
402
392
  rescue Slack::Web::Api::Errors::SlackError => e
403
393
  # capture all Slack errors
404
394
  end
@@ -410,19 +400,19 @@ In all of these cases the error message contains the error code, which is also a
410
400
 
411
401
  ##### Rate Limiting
412
402
 
413
- If you exceed [Slack’s rate limits](https://api.slack.com/docs/rate-limits), a `Slack::Web::Api::Errors::TooManyRequestsError` will be raised instead. (This does not inherit from `Slack::Web::Api::Errors::SlackError`.)
403
+ If you exceed [Slack's rate limits](https://docs.slack.dev/apis/web-api/rate-limits/), a `Slack::Web::Api::Errors::TooManyRequestsError` will be raised instead. (This does not inherit from `Slack::Web::Api::Errors::SlackError`.)
414
404
 
415
405
  ##### Other Errors
416
406
 
417
- When Slack is temporarily unavailable a subclass of `Slack::Web::Api::Errors::ServerError` will be raised and the original `Faraday::Error` will be accesible via `exception.cause`. (Starting with 0.18.0 this is no longer a subclass of `Slack::Web::Api::Errors::SlackError`.)
407
+ When Slack is temporarily unavailable a subclass of `Slack::Web::Api::Errors::ServerError` will be raised and the original `Faraday::Error` will be accessible via `exception.cause`. (Starting with 0.18.0 this is no longer a subclass of `Slack::Web::Api::Errors::SlackError`.)
418
408
 
419
- Specifically `Slack::Web::Api::Errors::ParsingError` will be raised on non-json response (i.e. 200 OK with `Slack unavailable` HTML page) and `Slack::Web::Api::Errors::HttpRequestError` subclasses for connection failures (`Slack::Web::Api::Errors::TimeoutError` for read/open timeouts & `Slack::Web::Api::Errors::UnavailableError` for 5xx HTTP responses).
409
+ Specifically `Slack::Web::Api::Errors::ParsingError` will be raised on a non-JSON response (i.e. 200 OK with `Slack unavailable` HTML page) and `Slack::Web::Api::Errors::HttpRequestError` subclasses for connection failures (`Slack::Web::Api::Errors::TimeoutError` for read/open timeouts & `Slack::Web::Api::Errors::UnavailableError` for 5xx HTTP responses).
420
410
 
421
411
  In any other case, a `Faraday::ClientError` will be raised.
422
412
 
423
413
  ### Events API
424
414
 
425
- This library provides limited support for the [Slack Events API](https://api.slack.com/events-api).
415
+ This library provides limited support for the [Slack Events API](https://docs.slack.dev/apis/events-api/).
426
416
 
427
417
  #### Configuring Slack::Events
428
418
 
@@ -436,10 +426,10 @@ end
436
426
 
437
427
  The following settings are supported.
438
428
 
439
- setting | description
440
- ----------------------|---------------------------------------------------------------------------------------------------
441
- signing_secret | Slack signing secret, defaults is `ENV['SLACK_SIGNING_SECRET']`.
442
- signature_expires_in | Signature expiration window in seconds, default is `300`.
429
+ setting | description
430
+ ---------------------- | ---------------------------------------------------------------------------------------------------
431
+ signing_secret | Slack signing secret, default is `ENV['SLACK_SIGNING_SECRET']`.
432
+ signature_expires_in | Signature expiration window in seconds, default is `300`.
443
433
 
444
434
  #### Verifying the Request Signature
445
435
 
@@ -451,6 +441,7 @@ slack_request.verify!
451
441
  ```
452
442
 
453
443
  To specify secrets on a per-request basis:
444
+
454
445
  ```ruby
455
446
  Slack::Events::Request.new(
456
447
  http_request,
@@ -467,7 +458,7 @@ Verify the signature before middleware or application code reads a non-rewindabl
467
458
 
468
459
  ### Message Handling
469
460
 
470
- All text in Slack uses the same [system of formatting and escaping](https://api.slack.com/docs/formatting): chat messages, direct messages, file comments, etc. [Slack::Messages::Formatting](lib/slack/messages/formatting.rb) provides convenience methods to format and parse messages.
461
+ All text in Slack uses the same [system of formatting and escaping](https://docs.slack.dev/messaging/formatting-message-text/): chat messages, direct messages, file comments, etc. [Slack::Messages::Formatting](lib/slack/messages/formatting.rb) provides convenience methods to format and parse messages.
471
462
 
472
463
  #### Formatting Messages
473
464
 
@@ -485,13 +476,13 @@ Slack::Messages::Formatting.date(date)
485
476
  # => "<!date^1688150386^{date_num} {time_secs}|2023-06-30 18:39:46 +0000>"
486
477
 
487
478
  # Specify a different format
488
- # See https://api.slack.com/reference/surfaces/formatting#date-formatting for supported formats
479
+ # See https://docs.slack.dev/messaging/formatting-message-text/ for supported formats
489
480
  Slack::Messages::Formatting.date(date, format: 'date_long_pretty')
490
481
  # => "<!date^1688150386^date_long_pretty|2023-06-30 18:39:46 +0000>"
491
482
 
492
483
  # Link your timestamp to a fully qualified URL
493
- Slack::Messages::Formatting.date(date, link: 'https://media.giphy.com/media/AcfTF7tyikWyroP0x7/giphy.gif')
494
- # => "<!date^1688150386^{date_num} {time_secs}^https://media.giphy.com/media/AcfTF7tyikWyroP0x7/giphy.gif|2023-06-30 18:39:46 +0000>"
484
+ Slack::Messages::Formatting.date(date, link: 'https://example.com/party')
485
+ # => "<!date^1688150386^{date_num} {time_secs}^https://example.com/party|2023-06-30 18:39:46 +0000>"
495
486
 
496
487
  # Specify custom fallback text to use if the client is unable to process the date
497
488
  Slack::Messages::Formatting.date(date, text: 'party time!')
@@ -541,31 +532,30 @@ Slack::Messages::Formatting.url_link(text, url)
541
532
 
542
533
  ##### Markdown Formatting
543
534
 
544
- Slack uses a mishmash of regular markdown formatting with its own syntax. Some features like headings aren't supported and will be left as-is, but others like bold, strikethrough, and links are converted.
535
+ Slack uses a mishmash of regular Markdown formatting with its own syntax. Some features like headings aren't supported and will be left as-is, but others like bold, strikethrough, and links are converted.
545
536
 
546
537
  ```ruby
547
- text = """
548
- ## A heading
549
- **Bold text**
550
- ~~Strikethrough text~~
551
- _Italic text_
552
- [A link](https://example.com)
553
- `code`
554
- """
538
+ text = <<~MARKDOWN
539
+ ## A heading
540
+ **Bold text**
541
+ ~~Strikethrough text~~
542
+ _Italic text_
543
+ [A link](https://example.com)
544
+ `code`
545
+ MARKDOWN
546
+
555
547
  Slack::Messages::Formatting.markdown(text)
556
- # => """
557
- # ## A heading
558
- # *Bold text*
559
- # ~Strikethrough text~
560
- # _Italic text_
561
- # <https://example.com|A link>
562
- # `code`
563
- # """
548
+ # ## A heading
549
+ # *Bold text*
550
+ # ~Strikethrough text~
551
+ # _Italic text_
552
+ # <https://example.com|A link>
553
+ # `code`
564
554
  ```
565
555
 
566
556
  #### Parsing Messages
567
557
 
568
- `Slack::Messages::Formatting` also provides ways to escape or unescape messages. This comes handy, for example, you want to treat all input to a real time bot as plain text.
558
+ `Slack::Messages::Formatting` also provides ways to escape or unescape messages. This comes in handy, for example, when you want to treat all input to a bot as plain text.
569
559
 
570
560
  ##### Unescaping Message Content
571
561
 
@@ -603,7 +593,7 @@ Slack::Messages::Formatting.escape('Hello & <world>')
603
593
 
604
594
  The slack command-line client returns JSON data from the Slack API. It uses [GLI](https://github.com/davetron5000/gli), which is not a dependency of slack-ruby-client, so install it alongside the client.
605
595
 
606
- ```
596
+ ```bash
607
597
  gem install gli
608
598
  ```
609
599
 
@@ -611,14 +601,14 @@ Or add `gem 'gli'` to your Gemfile.
611
601
 
612
602
  #### Authenticate with Slack
613
603
 
614
- ```
604
+ ```console
615
605
  $ slack --slack-api-token=[token] auth test
616
606
  {"ok":true,"url":"...","team":"...","user":"...","team_id":"...","user_id":"..."}
617
607
  ```
618
608
 
619
609
  #### Send a Message
620
610
 
621
- ```
611
+ ```console
622
612
  export SLACK_API_TOKEN=...
623
613
  $ slack chat postMessage --text="hello world" --channel="#general"
624
614
  {"ok":true,"channel":"...","ts":"...","message":{"text":"hello world","username":"bot","type":"message","subtype":"bot_message","ts":"..."}}
@@ -626,16 +616,16 @@ $ slack chat postMessage --text="hello world" --channel="#general"
626
616
 
627
617
  #### Get Channel Info
628
618
 
629
- ```
619
+ ```console
630
620
  $ slack conversations info --channel=#general
631
621
  {"ok":true,"channel":{"id":"C04KB5X4D","name":"general", ...}}
632
622
  ```
633
623
 
634
624
  #### List Users
635
625
 
636
- Combine with [jq](http://stedolan.github.io/jq), a command-line JSON parser.
626
+ Combine with [jq](https://jqlang.org/), a command-line JSON processor.
637
627
 
638
- ```
628
+ ```console
639
629
  $ slack users list | jq '.members | map({(.id): .name})'
640
630
  [
641
631
  {
@@ -653,11 +643,11 @@ See `slack help` for a complete command-line reference.
653
643
 
654
644
  This library was created and has been maintained for a decade by [@dblock](https://github.com/dblock). Please consider [a sponsorship](https://github.com/sponsors/dblock).
655
645
 
656
- Enterprise Support is available as part of a Tidelift Subscription. Click [here](https://tidelift.com/subscription/request-a-demo?utm_source=rubygems-slack-ruby-client&utm_medium=referral&utm_campaign=enterprise) for more details.
646
+ Enterprise Support is available as part of a [Tidelift Subscription](https://tidelift.com/subscription/request-a-demo?utm_source=rubygems-slack-ruby-client&utm_medium=referral&utm_campaign=enterprise).
657
647
 
658
648
  ## History
659
649
 
660
- This gem is based on [slack-ruby-gem](https://github.com/aki017/slack-ruby-gem), but it more clearly separates the Web and RTM APIs, is more thoroughly tested and is in active development.
650
+ This gem is based on [slack-ruby-gem](https://github.com/aki017/slack-ruby-gem), but it more clearly separates the Web and Events APIs, is more thoroughly tested, and is in active development. The RealTime (RTM) client was removed in 2.0.0, see [UPGRADING](UPGRADING.md).
661
651
 
662
652
  ## Security
663
653
 
@@ -669,6 +659,6 @@ See [CONTRIBUTING](CONTRIBUTING.md).
669
659
 
670
660
  ## Copyright and License
671
661
 
672
- Copyright (c) 2015-2025, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
662
+ Copyright (c) 2015-2026, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
673
663
 
674
664
  This project is licensed under the [MIT License](LICENSE.md).
data/RELEASING.md CHANGED
@@ -1,77 +1,39 @@
1
1
  # Releasing Slack-Ruby-Client
2
2
 
3
- There're no hard rules about when to release slack-ruby-client. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
3
+ There are no hard rules about when to release slack-ruby-client. Release bug fixes frequently, features not so frequently, and breaking API changes rarely.
4
4
 
5
- ### Release
5
+ Releases use [ruby-gem-release](https://github.com/dblock/ruby-gem-release) 0.9.0 through a manually dispatched [Release workflow](.github/workflows/release.yml). Keep the `ruby-gem-release` gem in [Gemfile](Gemfile) and the reusable workflow in `release.yml` pinned to the same version. The workflow publishes through RubyGems Trusted Publishing, so no RubyGems API key or one-time password is needed. It only runs from `master` in `slack-ruby/slack-ruby-client`. The local Bundler `rake release`, `release:rubygem_push`, and `release:source_control_push` tasks are disabled.
6
6
 
7
- Run tests, check that all tests succeed locally.
7
+ ## One-Time Setup
8
8
 
9
- ```
10
- bundle install
11
- rake
12
- ```
13
-
14
- Check that the last build succeeded in [GitHub Actions](https://github.com/slack-ruby/slack-ruby-client/actions) for all supported platforms.
15
-
16
- Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
17
-
18
- ```
19
- ### 0.2.2 (2015/07/10)
20
- ```
21
-
22
- Remove the line with "Your contribution here.", since there will be no more contributions to this release.
23
-
24
- In the "Stable Release" section of the README, change `**next**` to `**stable**` and add the version number so users know that they are reading the documentation for a released version.
25
-
26
- ```
27
- ## Stable Release
28
-
29
- You're reading the documentation for the **stable** release of slack-ruby-client, 0.2.2. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
30
- ```
31
-
32
- Commit your changes.
33
-
34
- ```
35
- git add README.md CHANGELOG.md
36
- git commit -m "Preparing for release, 0.2.2."
37
- git push origin master
38
- ```
9
+ Before the first automated release, a maintainer must:
39
10
 
40
- Release.
11
+ 1. Create the GitHub environment `release` in `slack-ruby/slack-ruby-client`, for example with `gh api --method PUT repos/slack-ruby/slack-ruby-client/environments/release`, and restrict its deployment branches to `master`. Add required reviewers to require maintainer approval before publication.
12
+ 2. At [slack-ruby-client's trusted publishers](https://rubygems.org/gems/slack-ruby-client/trusted_publishers), add a GitHub Actions publisher with repository owner `slack-ruby`, repository `slack-ruby-client`, workflow filename `release.yml`, environment `release`, and the separate workflow repository owner `dblock` and repository `ruby-gem-release`.
13
+ 3. Allow GitHub Actions to push release commits and `v*` tags to `master`. See the upstream [setup and permissions guidance](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/RELEASING.md#one-time-setup).
41
14
 
42
- ```
43
- $ rake release
15
+ Verify the setup without publishing with a [dry run](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#dry-run), which never edits files, builds, pushes, or publishes:
44
16
 
45
- slack-ruby-client 0.2.2 built to pkg/slack-ruby-client-0.2.2.gem.
46
- Tagged v0.2.2.
47
- Pushed git commits and release tag.
48
- Pushed slack-ruby-client 0.2.2 to rubygems.org.
17
+ ```bash
18
+ gh workflow run release.yml --repo slack-ruby/slack-ruby-client --ref master -f dry-run=true
49
19
  ```
50
20
 
51
- ### Prepare for the Next Version
21
+ ## Prepare
52
22
 
53
- Add the next release to [CHANGELOG.md](CHANGELOG.md).
23
+ Start with a clean, up-to-date `master` and verify that the latest [CI checks](https://github.com/slack-ruby/slack-ruby-client/actions) pass on all supported Ruby versions. Follow semantic versioning: patch for fixes, minor for backward-compatible features, major for breaking changes. Check `VERSION` in [lib/slack/version.rb](lib/slack/version.rb) and the matching `(Next)` heading in [CHANGELOG.md](CHANGELOG.md), and change both in a pull request if needed, or pass a `version` override when dispatching. Document breaking changes in [UPGRADING.md](UPGRADING.md).
54
24
 
55
- ```
56
- ### 0.2.3 (Next)
57
-
58
- * Your contribution here.
59
- ```
25
+ The workflow dates the `(Next)` heading using `YYYY/MM/DD` and removes the `* Your contribution here.` placeholder; a section without notes cannot be released. It also rewrites the "Stable Release" paragraph in [README.md](README.md) to point at the released version, and restores the next-release wording afterwards.
60
26
 
61
- Increment the third version number in [lib/slack/version.rb](lib/slack/version.rb).
27
+ Release automation requires MRI Ruby 3.3 or newer; the release dependency and tasks are skipped on older Ruby versions and JRuby. Release specs in [spec/release](spec/release) run the actual release tasks against a local fixture with the [ruby-gem-release RSpec helpers](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/testing.md), without contacting RubyGems or GitHub.
62
28
 
63
- Undo your change in README about the stable release.
29
+ ## Publish
64
30
 
31
+ ```bash
32
+ gh workflow run release.yml --repo slack-ruby/slack-ruby-client --ref master
65
33
  ```
66
- ## Stable Release
67
34
 
68
- You're reading the documentation for the **next** release of slack-ruby-client. Please see the documentation for the [last stable release, v0.2.2](https://github.com/slack-ruby/slack-ruby-client/blob/v0.2.2/README.md) unless you're integrating with HEAD. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
69
- ```
35
+ Pass `-f version=x.y.z` to release a different version. Dispatching starts a real release; do not merge into `master` while it runs. The workflow prepares the release commit, runs lint and specs on Ruby 3.3, builds the gem, preserves recovery artifacts, publishes to RubyGems, pushes the release commit and `v` tag, and creates a GitHub Release with the changelog notes and the gem attached. It then increments the patch version, adds a new `(Next)` section, and pushes the next development commit. Verify the published version on [RubyGems](https://rubygems.org/gems/slack-ruby-client), the tag, the [GitHub Release](https://github.com/slack-ruby/slack-ruby-client/releases), and the next development commit.
70
36
 
71
- Commit your changes.
37
+ ## Recover a Partial Release
72
38
 
73
- ```
74
- git add README.md CHANGELOG.md lib/slack/version.rb
75
- git commit -m "Preparing for next development iteration, 0.2.3."
76
- git push origin master
77
- ```
39
+ Inspect the failed run, RubyGems, remote commits and tags, and the GitHub Release before retrying. Publication may have succeeded even if a later step failed. Never move a published tag or republish a version with different contents. Use the run's retained recovery artifacts and the upstream [recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#recovery-artifacts).
data/Rakefile CHANGED
@@ -5,6 +5,18 @@ require 'bundler/gem_tasks'
5
5
 
6
6
  Bundler.setup :default, :development
7
7
 
8
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
9
+ Gem.loaded_specs.key?('ruby-gem-release')
10
+ require_relative 'script/release'
11
+ SlackRubyClientRelease.workflow.install_tasks
12
+
13
+ %w[release release:rubygem_push release:source_control_push].each do |name|
14
+ Rake::Task[name].clear
15
+ desc 'Disabled; releases run through GitHub Actions, see RELEASING.md'
16
+ task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
17
+ end
18
+ end
19
+
8
20
  require 'rspec/core'
9
21
  require 'rspec/core/rake_task'
10
22
 
@@ -19,8 +31,18 @@ task :rubocop do
19
31
  sh 'bundle exec rubocop'
20
32
  end
21
33
 
34
+ desc 'Lint Ruby, Markdown, YAML, and spelling (Ruby 3.2+).'
35
+ task lint: :rubocop
36
+
22
37
  task default: :spec
23
38
 
39
+ desc 'Run the benchmarks in benchmarks/.'
40
+ task :benchmark do
41
+ FileList['benchmarks/*.rb'].exclude('benchmarks/support.rb').each do |file|
42
+ ruby file
43
+ end
44
+ end
45
+
24
46
  load 'tasks/git.rake'
25
47
  load 'tasks/web.rake'
26
48
  load 'tasks/update.rake'
data/SECURITY.md CHANGED
@@ -6,4 +6,4 @@ Version 2.0 or newer is currently supported.
6
6
 
7
7
  ## Reporting a Vulnerability
8
8
 
9
- Tidelift acts as the security contact for this open-source project. To make a report, please email the security team at [security@tidelift.com](mailto:security@tidelift.com). Please do not create a public GitHub issue. See [tidelift.com/security](https://tidelift.com/security) for details and more options.
9
+ Tidelift acts as the security contact for this open-source project. To make a report, please email the security team at [security@tidelift.com](mailto:security@tidelift.com). Please do not create a public GitHub issue. See [tidelift.com/security](https://tidelift.com/security) for details and more options.