slack-ruby-client 3.2.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.
- checksums.yaml +4 -4
- data/.coveralls.yml +0 -0
- data/.github/FUNDING.yml +0 -0
- data/.github/dependabot.yml +0 -0
- data/.github/prompts/changelog-entries.prompt.yml +32 -0
- data/.github/workflows/danger-comment.yml +11 -2
- data/.github/workflows/danger.yml +10 -2
- data/.github/workflows/lint.yml +21 -6
- data/.github/workflows/release.yml +27 -0
- data/.github/workflows/test.yml +0 -0
- data/.github/workflows/update_api.yml +86 -6
- data/.gitignore +1 -0
- data/.gitmodules +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +94 -1
- data/.rubocop_todo.yml +13 -2
- data/.ruby-version +0 -0
- data/.spellcheck.txt +256 -0
- data/AGENTS.md +12 -0
- data/CHANGELOG.md +50 -0
- data/CONTRIBUTING.md +59 -59
- data/Dangerfile +0 -0
- data/Gemfile +33 -5
- data/LICENSE.md +1 -1
- data/README.md +139 -104
- data/RELEASING.md +20 -58
- data/Rakefile +29 -3
- data/SECURITY.md +1 -1
- data/UPGRADING.md +48 -40
- data/benchmarks/events.rb +26 -0
- data/benchmarks/formatting.rb +17 -0
- data/benchmarks/support.rb +67 -0
- data/benchmarks/web_client.rb +28 -0
- data/bin/commands/admin_analytics.rb +0 -0
- data/bin/commands/admin_analytics_members.rb +39 -0
- data/bin/commands/admin_analytics_messages.rb +4 -4
- data/bin/commands/admin_analytics_slackbot.rb +33 -0
- data/bin/commands/admin_apps.rb +0 -0
- data/bin/commands/admin_apps_activities.rb +0 -0
- data/bin/commands/admin_apps_approved.rb +0 -0
- data/bin/commands/admin_apps_config.rb +0 -0
- data/bin/commands/admin_apps_mcp_servers.rb +21 -0
- data/bin/commands/admin_apps_mcp_servers_permissions.rb +33 -0
- data/bin/commands/admin_apps_permissions.rb +58 -0
- data/bin/commands/admin_apps_requests.rb +0 -0
- data/bin/commands/admin_apps_restricted.rb +0 -0
- data/bin/commands/admin_audit_anomaly_allow.rb +0 -0
- data/bin/commands/admin_auth_policy.rb +0 -0
- data/bin/commands/admin_barriers.rb +0 -0
- data/bin/commands/admin_conversations.rb +23 -3
- data/bin/commands/admin_conversations_ekm.rb +0 -0
- data/bin/commands/admin_conversations_restrictAccess.rb +0 -0
- data/bin/commands/admin_emoji.rb +0 -0
- data/bin/commands/admin_functions.rb +1 -1
- data/bin/commands/admin_functions_permissions.rb +0 -0
- data/bin/commands/admin_inviteRequests.rb +0 -0
- data/bin/commands/admin_inviteRequests_approved.rb +0 -0
- data/bin/commands/admin_inviteRequests_denied.rb +0 -0
- data/bin/commands/admin_roles.rb +0 -0
- data/bin/commands/admin_slackbot_skills.rb +56 -0
- data/bin/commands/admin_teams.rb +0 -0
- data/bin/commands/admin_teams_admins.rb +0 -0
- data/bin/commands/admin_teams_owners.rb +0 -0
- data/bin/commands/admin_teams_settings.rb +0 -0
- data/bin/commands/admin_usergroups.rb +74 -0
- data/bin/commands/admin_users.rb +11 -2
- data/bin/commands/admin_users_access.rb +31 -0
- data/bin/commands/admin_users_session.rb +0 -1
- data/bin/commands/admin_users_unsupportedVersions.rb +0 -0
- data/bin/commands/admin_workflows.rb +0 -0
- data/bin/commands/admin_workflows_collaborators.rb +0 -0
- data/bin/commands/admin_workflows_permissions.rb +0 -0
- data/bin/commands/admin_workflows_triggers_types_permissions.rb +0 -0
- data/bin/commands/agents_conversations.rb +122 -0
- data/bin/commands/agents_sessions.rb +38 -0
- data/bin/commands/api.rb +0 -0
- data/bin/commands/apps.rb +0 -0
- data/bin/commands/apps_activities.rb +0 -0
- data/bin/commands/apps_auth_external.rb +0 -0
- data/bin/commands/apps_connections.rb +0 -0
- data/bin/commands/apps_datastore.rb +0 -0
- data/bin/commands/apps_event_authorizations.rb +0 -0
- data/bin/commands/apps_icon.rb +0 -0
- data/bin/commands/apps_managed_permissions.rb +21 -0
- data/bin/commands/apps_manifest.rb +0 -0
- data/bin/commands/apps_user_connection.rb +0 -0
- data/bin/commands/assistant_search.rb +0 -0
- data/bin/commands/assistant_threads.rb +1 -1
- data/bin/commands/auth.rb +0 -0
- data/bin/commands/auth_teams.rb +0 -0
- data/bin/commands/blocks.rb +0 -0
- data/bin/commands/bookmarks.rb +0 -0
- data/bin/commands/bots.rb +0 -0
- data/bin/commands/calls.rb +0 -0
- data/bin/commands/calls_participants.rb +0 -0
- data/bin/commands/canvases.rb +12 -2
- data/bin/commands/canvases_access.rb +0 -0
- data/bin/commands/canvases_sections.rb +0 -0
- data/bin/commands/chat.rb +10 -7
- data/bin/commands/chat_scheduledMessages.rb +0 -0
- data/bin/commands/conversations.rb +1 -1
- data/bin/commands/conversations_canvases.rb +1 -1
- data/bin/commands/conversations_externalInvitePermissions.rb +0 -0
- data/bin/commands/conversations_requestSharedInvite.rb +0 -0
- data/bin/commands/dialog.rb +0 -0
- data/bin/commands/dnd.rb +0 -0
- data/bin/commands/emoji.rb +0 -0
- data/bin/commands/entity.rb +27 -0
- data/bin/commands/files.rb +3 -0
- data/bin/commands/files_comments.rb +0 -0
- data/bin/commands/files_remote.rb +0 -0
- data/bin/commands/functions.rb +0 -0
- data/bin/commands/functions_distributions_permissions.rb +0 -0
- data/bin/commands/functions_workflows_steps.rb +0 -0
- data/bin/commands/functions_workflows_steps_responses.rb +0 -0
- data/bin/commands/migration.rb +0 -0
- data/bin/commands/oauth.rb +0 -0
- data/bin/commands/oauth_v2.rb +21 -0
- data/bin/commands/oauth_v2_user.rb +0 -0
- data/bin/commands/openid_connect.rb +0 -0
- data/bin/commands/pins.rb +1 -1
- data/bin/commands/reactions.rb +0 -0
- data/bin/commands/reminders.rb +0 -0
- data/bin/commands/rtm.rb +0 -0
- data/bin/commands/search.rb +0 -0
- data/bin/commands/slackLists.rb +0 -0
- data/bin/commands/slackLists_access.rb +0 -0
- data/bin/commands/slackLists_download.rb +7 -0
- data/bin/commands/slackLists_items.rb +2 -1
- data/bin/commands/slackbot_skills.rb +71 -0
- data/bin/commands/slackbot_skills_library.rb +29 -0
- data/bin/commands/stars.rb +0 -0
- data/bin/commands/team.rb +1 -0
- data/bin/commands/team_billing.rb +0 -0
- data/bin/commands/team_externalTeams.rb +1 -1
- data/bin/commands/team_preferences.rb +0 -0
- data/bin/commands/team_profile.rb +0 -0
- data/bin/commands/tooling_tokens.rb +0 -0
- data/bin/commands/usergroups.rb +0 -0
- data/bin/commands/usergroups_users.rb +0 -0
- data/bin/commands/users.rb +1 -0
- data/bin/commands/users_admin.rb +0 -0
- data/bin/commands/users_discoverableContacts.rb +0 -0
- data/bin/commands/users_prefs.rb +0 -0
- data/bin/commands/users_profile.rb +0 -0
- data/bin/commands/views.rb +0 -0
- data/bin/commands/workflows_featured.rb +0 -0
- data/bin/commands/workflows_triggers_permissions.rb +0 -0
- data/bin/slack +5 -1
- data/examples/files_upload_v2/.env.example +0 -0
- data/examples/files_upload_v2/Gemfile +0 -0
- data/examples/files_upload_v2/README.md +4 -3
- data/examples/files_upload_v2/files_upload_v2.rb +1 -1
- data/examples/hi_web/Gemfile +0 -0
- data/examples/hi_web/hi.gif +0 -0
- data/examples/hi_web/hi.rb +1 -1
- data/examples/new_ticket/Gemfile +0 -0
- data/examples/new_ticket/new_ticket.rb +1 -1
- data/examples/oauth_v2/.env.example +0 -0
- data/examples/oauth_v2/Gemfile +0 -0
- data/examples/oauth_v2/README.md +5 -4
- data/examples/oauth_v2/oauth_v2.rb +6 -6
- data/lib/slack/config.rb +0 -0
- data/lib/slack/events/config.rb +1 -1
- data/lib/slack/events/request.rb +2 -2
- data/lib/slack/logger.rb +0 -0
- data/lib/slack/messages/formatting.rb +29 -20
- data/lib/slack/messages/message.rb +0 -0
- data/lib/slack/utils/security.rb +0 -0
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_analytics.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_analytics_members.rb +66 -0
- data/lib/slack/web/api/endpoints/admin_analytics_messages.rb +3 -3
- data/lib/slack/web/api/endpoints/admin_analytics_slackbot.rb +54 -0
- data/lib/slack/web/api/endpoints/admin_apps.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_apps_activities.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_apps_config.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_apps_mcp_servers.rb +31 -0
- data/lib/slack/web/api/endpoints/admin_apps_mcp_servers_permissions.rb +46 -0
- data/lib/slack/web/api/endpoints/admin_apps_permissions.rb +83 -0
- data/lib/slack/web/api/endpoints/admin_apps_requests.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_audit_anomaly_allow.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_auth_policy.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_barriers.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +32 -2
- data/lib/slack/web/api/endpoints/admin_conversations_ekm.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_emoji.rb +0 -1
- data/lib/slack/web/api/endpoints/admin_functions.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_functions_permissions.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_roles.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_slackbot_skills.rb +84 -0
- data/lib/slack/web/api/endpoints/admin_teams.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_teams_admins.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_teams_owners.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_teams_settings.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_usergroups.rb +111 -0
- data/lib/slack/web/api/endpoints/admin_users.rb +14 -1
- data/lib/slack/web/api/endpoints/admin_users_access.rb +40 -0
- data/lib/slack/web/api/endpoints/admin_users_session.rb +0 -2
- data/lib/slack/web/api/endpoints/admin_users_unsupportedVersions.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_workflows.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_workflows_collaborators.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_workflows_permissions.rb +0 -0
- data/lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb +0 -0
- data/lib/slack/web/api/endpoints/agents_conversations.rb +186 -0
- data/lib/slack/web/api/endpoints/agents_sessions.rb +54 -0
- data/lib/slack/web/api/endpoints/api.rb +0 -0
- data/lib/slack/web/api/endpoints/apps.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_activities.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_auth_external.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_connections.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_datastore.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_event_authorizations.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_icon.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_managed_permissions.rb +27 -0
- data/lib/slack/web/api/endpoints/apps_manifest.rb +0 -0
- data/lib/slack/web/api/endpoints/apps_user_connection.rb +0 -0
- data/lib/slack/web/api/endpoints/assistant_search.rb +0 -0
- data/lib/slack/web/api/endpoints/assistant_threads.rb +1 -1
- data/lib/slack/web/api/endpoints/auth.rb +0 -0
- data/lib/slack/web/api/endpoints/auth_teams.rb +0 -0
- data/lib/slack/web/api/endpoints/blocks.rb +0 -0
- data/lib/slack/web/api/endpoints/bookmarks.rb +0 -0
- data/lib/slack/web/api/endpoints/bots.rb +0 -0
- data/lib/slack/web/api/endpoints/calls.rb +0 -0
- data/lib/slack/web/api/endpoints/calls_participants.rb +0 -0
- data/lib/slack/web/api/endpoints/canvases.rb +16 -2
- data/lib/slack/web/api/endpoints/canvases_access.rb +0 -0
- data/lib/slack/web/api/endpoints/canvases_sections.rb +0 -0
- data/lib/slack/web/api/endpoints/chat.rb +14 -10
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +0 -0
- data/lib/slack/web/api/endpoints/conversations.rb +1 -1
- data/lib/slack/web/api/endpoints/conversations_canvases.rb +1 -1
- data/lib/slack/web/api/endpoints/conversations_externalInvitePermissions.rb +0 -0
- data/lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb +0 -0
- data/lib/slack/web/api/endpoints/dialog.rb +0 -0
- data/lib/slack/web/api/endpoints/dnd.rb +0 -0
- data/lib/slack/web/api/endpoints/emoji.rb +0 -0
- data/lib/slack/web/api/endpoints/entity.rb +48 -0
- data/lib/slack/web/api/endpoints/files.rb +7 -0
- data/lib/slack/web/api/endpoints/files_comments.rb +0 -0
- data/lib/slack/web/api/endpoints/files_remote.rb +0 -0
- data/lib/slack/web/api/endpoints/functions.rb +0 -0
- data/lib/slack/web/api/endpoints/functions_distributions_permissions.rb +0 -0
- data/lib/slack/web/api/endpoints/functions_workflows_steps.rb +0 -0
- data/lib/slack/web/api/endpoints/functions_workflows_steps_responses.rb +0 -0
- data/lib/slack/web/api/endpoints/migration.rb +0 -0
- data/lib/slack/web/api/endpoints/oauth.rb +0 -0
- data/lib/slack/web/api/endpoints/oauth_v2.rb +33 -0
- data/lib/slack/web/api/endpoints/oauth_v2_user.rb +0 -0
- data/lib/slack/web/api/endpoints/openid_connect.rb +0 -0
- data/lib/slack/web/api/endpoints/pins.rb +1 -1
- data/lib/slack/web/api/endpoints/reactions.rb +0 -0
- data/lib/slack/web/api/endpoints/reminders.rb +0 -0
- data/lib/slack/web/api/endpoints/rtm.rb +0 -0
- data/lib/slack/web/api/endpoints/search.rb +0 -0
- data/lib/slack/web/api/endpoints/slackLists.rb +0 -0
- data/lib/slack/web/api/endpoints/slackLists_access.rb +0 -0
- data/lib/slack/web/api/endpoints/slackLists_download.rb +14 -0
- data/lib/slack/web/api/endpoints/slackLists_items.rb +3 -1
- data/lib/slack/web/api/endpoints/slackbot_skills.rb +107 -0
- data/lib/slack/web/api/endpoints/slackbot_skills_library.rb +36 -0
- data/lib/slack/web/api/endpoints/stars.rb +0 -0
- data/lib/slack/web/api/endpoints/team.rb +2 -0
- data/lib/slack/web/api/endpoints/team_billing.rb +0 -0
- data/lib/slack/web/api/endpoints/team_externalTeams.rb +1 -1
- data/lib/slack/web/api/endpoints/team_preferences.rb +0 -0
- data/lib/slack/web/api/endpoints/team_profile.rb +0 -0
- data/lib/slack/web/api/endpoints/tooling_tokens.rb +0 -0
- data/lib/slack/web/api/endpoints/usergroups.rb +0 -0
- data/lib/slack/web/api/endpoints/usergroups_users.rb +0 -0
- data/lib/slack/web/api/endpoints/users.rb +2 -1
- data/lib/slack/web/api/endpoints/users_admin.rb +0 -0
- data/lib/slack/web/api/endpoints/users_discoverableContacts.rb +0 -0
- data/lib/slack/web/api/endpoints/users_prefs.rb +0 -0
- data/lib/slack/web/api/endpoints/users_profile.rb +0 -0
- data/lib/slack/web/api/endpoints/views.rb +0 -0
- data/lib/slack/web/api/endpoints/workflows_featured.rb +0 -0
- data/lib/slack/web/api/endpoints/workflows_triggers_permissions.rb +0 -0
- data/lib/slack/web/api/endpoints.rb +24 -0
- data/lib/slack/web/api/error.rb +0 -0
- data/lib/slack/web/api/errors/server_error.rb +1 -1
- data/lib/slack/web/api/errors/slack_error.rb +1 -1
- data/lib/slack/web/api/errors/too_many_requests_error.rb +1 -1
- data/lib/slack/web/api/errors.rb +384 -10
- data/lib/slack/web/api/helpers/files.rb +2 -2
- data/lib/slack/web/api/helpers.rb +0 -0
- data/lib/slack/web/api/mixins/conversations.id.rb +2 -1
- data/lib/slack/web/api/mixins/ids.id.rb +2 -1
- data/lib/slack/web/api/mixins/users.id.json +0 -0
- data/lib/slack/web/api/mixins/users.id.rb +2 -1
- data/lib/slack/web/api/mixins/users.search.json +0 -0
- data/lib/slack/web/api/mixins/users.search.rb +1 -1
- data/lib/slack/web/api/mixins.rb +0 -0
- data/lib/slack/web/api/options.rb +0 -0
- data/lib/slack/web/api/patches/.gitkeep +0 -0
- data/lib/slack/web/api/patches/files.default-filename.patch +12 -0
- data/lib/slack/web/api/schema/group.json +0 -0
- data/lib/slack/web/api/schema/method.json +0 -0
- data/lib/slack/web/api/templates/command.erb +0 -0
- data/lib/slack/web/api/templates/endpoints.erb +0 -0
- data/lib/slack/web/api/templates/errors.erb +0 -0
- data/lib/slack/web/api/templates/method.erb +0 -0
- data/lib/slack/web/api/templates/method_spec.erb +0 -0
- data/lib/slack/web/client.rb +29 -0
- data/lib/slack/web/config.rb +0 -0
- data/lib/slack/web/faraday/connection.rb +0 -0
- data/lib/slack/web/faraday/options.rb +0 -0
- data/lib/slack/web/faraday/request.rb +22 -2
- data/lib/slack/web/faraday/response/raise_error.rb +0 -0
- data/lib/slack/web/faraday/response/wrap_error.rb +0 -0
- data/lib/slack/web/pagination/cursor.rb +0 -0
- data/lib/slack-ruby-client.rb +0 -0
- data/lib/slack.rb +0 -0
- data/lib/slack_ruby_client.rb +0 -0
- data/lib/tasks/git.rake +0 -0
- data/lib/tasks/update.rake +0 -0
- data/lib/tasks/web.rake +0 -0
- data/script/release.rb +33 -0
- data/slack-ruby-client.gemspec +1 -3
- data/slack.png +0 -0
- metadata +41 -17
data/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
Slack Ruby Client
|
|
2
|
-
=================
|
|
1
|
+
# Slack Ruby Client
|
|
3
2
|
|
|
4
|
-
[](http://badge.fury.io/rb/slack-ruby-client)
|
|
5
|
-
[](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml)
|
|
6
|
-
[](https://coveralls.io/github/slack-ruby/slack-ruby-client?branch=master)
|
|
3
|
+
[](http://badge.fury.io/rb/slack-ruby-client) [](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml) [](https://coveralls.io/github/slack-ruby/slack-ruby-client?branch=master)
|
|
7
4
|
|
|
8
|
-
A Ruby client for the Slack [Web](https://
|
|
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
|
-

|
|
7
|
+

|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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.
|
|
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
|
|
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://
|
|
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
|
|
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
|
|
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
|
|
112
|
-
|
|
113
|
-
token
|
|
114
|
-
logger
|
|
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 [
|
|
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
|
-

|
|
138
|
+

|
|
142
139
|
|
|
143
140
|
##### List Channels
|
|
144
141
|
|
|
145
|
-
List channels with [conversations_list](https://
|
|
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://
|
|
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: [
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
282
|
-
|
|
283
|
-
token
|
|
284
|
-
user_agent
|
|
285
|
-
proxy
|
|
286
|
-
ca_path
|
|
287
|
-
ca_file
|
|
288
|
-
endpoint
|
|
289
|
-
logger
|
|
290
|
-
timeout
|
|
291
|
-
open_timeout
|
|
292
|
-
default_page_size
|
|
293
|
-
conversations_id_page_size
|
|
294
|
-
users_id_page_size
|
|
295
|
-
default_max_retries
|
|
296
|
-
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
|
|
|
@@ -301,13 +287,48 @@ You can also pass request options, including `timeout` and `open_timeout` into i
|
|
|
301
287
|
client.conversations_list(request: { timeout: 180 })
|
|
302
288
|
```
|
|
303
289
|
|
|
304
|
-
|
|
290
|
+
Use `with_request` and `with_response` to create a configured client copy with HTTP callbacks, without changing the original client or parsed-body return values:
|
|
291
|
+
|
|
292
|
+
```ruby
|
|
293
|
+
scopes = nil
|
|
294
|
+
observed_client = client.with_request do |request|
|
|
295
|
+
request.headers['X-Custom'] = 'value'
|
|
296
|
+
end.with_response do |response|
|
|
297
|
+
scopes = response.headers['x-oauth-scopes']&.split(',')&.map(&:strip)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
result = observed_client.auth_test
|
|
301
|
+
observed_client.users_list do |page|
|
|
302
|
+
puts page.members
|
|
303
|
+
end
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Request callbacks receive a `Faraday::Request` after authentication and request options are configured, before dispatch. They can change headers, body, and options. Response callbacks receive a `Faraday::Response` with the parsed body, headers, and status after successful completion; they do not run when Slack or transport errors are raised. Callbacks apply to each HTTP call, including pagination pages and requests made by helpers. Endpoint blocks retain their existing meaning.
|
|
307
|
+
|
|
308
|
+
Chaining registers callbacks in order. Copies preserve client configuration but use independent connections and callback lists; the original client is unchanged. Callback exceptions propagate and request callback failures prevent dispatch. Callbacks are synchronous; avoid storing sensitive authorization headers, and synchronize any shared state if using a client concurrently.
|
|
309
|
+
|
|
310
|
+
Use `with_error` to observe Slack and transport errors without recovering from them:
|
|
311
|
+
|
|
312
|
+
```ruby
|
|
313
|
+
observed_client = client.with_error do |error|
|
|
314
|
+
logger.warn(
|
|
315
|
+
message: error.message,
|
|
316
|
+
errors: error.respond_to?(:errors) && error.response ? error.errors : nil,
|
|
317
|
+
response_metadata: error.respond_to?(:response_metadata) && error.response ? error.response_metadata : nil
|
|
318
|
+
)
|
|
319
|
+
end
|
|
320
|
+
observed_client.auth_test
|
|
321
|
+
```
|
|
322
|
+
|
|
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.
|
|
305
324
|
|
|
306
|
-
|
|
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).
|
|
326
|
+
|
|
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`.
|
|
307
328
|
|
|
308
329
|
#### Pagination Support
|
|
309
330
|
|
|
310
|
-
The Web client natively supports [cursor pagination](https://
|
|
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.
|
|
311
332
|
|
|
312
333
|
```ruby
|
|
313
334
|
all_members = []
|
|
@@ -338,7 +359,7 @@ Note that Slack expects `text` to be UTF-8 encoded. If your messages appear with
|
|
|
338
359
|
```ruby
|
|
339
360
|
text = 'characters such as "Ñ", "Á", "É"'
|
|
340
361
|
text.encoding
|
|
341
|
-
=> #<Encoding:UTF-8>
|
|
362
|
+
# => #<Encoding:UTF-8>
|
|
342
363
|
client.chat_postMessage(channel: '#general', text: text, as_user: true)
|
|
343
364
|
# renders 'characters such as "Ñ", "Á", "É"' in Slack
|
|
344
365
|
|
|
@@ -356,6 +377,8 @@ client.chat_postMessage(channel: '#general', text: text, as_user: true)
|
|
|
356
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:
|
|
357
378
|
|
|
358
379
|
```ruby
|
|
380
|
+
begin
|
|
381
|
+
client.auth_test
|
|
359
382
|
rescue Slack::Web::Api::Errors::AccountInactive => e
|
|
360
383
|
# deal with inactive account
|
|
361
384
|
end
|
|
@@ -364,6 +387,8 @@ end
|
|
|
364
387
|
All of these errors inherit from `Slack::Web::Api::Errors::SlackError`, so you can handle or silence all errors if necessary:
|
|
365
388
|
|
|
366
389
|
```ruby
|
|
390
|
+
begin
|
|
391
|
+
client.auth_test
|
|
367
392
|
rescue Slack::Web::Api::Errors::SlackError => e
|
|
368
393
|
# capture all Slack errors
|
|
369
394
|
end
|
|
@@ -375,19 +400,19 @@ In all of these cases the error message contains the error code, which is also a
|
|
|
375
400
|
|
|
376
401
|
##### Rate Limiting
|
|
377
402
|
|
|
378
|
-
If you exceed [Slack
|
|
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`.)
|
|
379
404
|
|
|
380
405
|
##### Other Errors
|
|
381
406
|
|
|
382
|
-
When Slack is temporarily unavailable a subclass of `Slack::Web::Api::Errors::ServerError` will be raised and the original `Faraday::Error` will be
|
|
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`.)
|
|
383
408
|
|
|
384
|
-
Specifically `Slack::Web::Api::Errors::ParsingError` will be raised on non-
|
|
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).
|
|
385
410
|
|
|
386
411
|
In any other case, a `Faraday::ClientError` will be raised.
|
|
387
412
|
|
|
388
413
|
### Events API
|
|
389
414
|
|
|
390
|
-
This library provides limited support for the [Slack Events API](https://
|
|
415
|
+
This library provides limited support for the [Slack Events API](https://docs.slack.dev/apis/events-api/).
|
|
391
416
|
|
|
392
417
|
#### Configuring Slack::Events
|
|
393
418
|
|
|
@@ -401,10 +426,10 @@ end
|
|
|
401
426
|
|
|
402
427
|
The following settings are supported.
|
|
403
428
|
|
|
404
|
-
setting
|
|
405
|
-
|
|
406
|
-
signing_secret
|
|
407
|
-
signature_expires_in
|
|
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`.
|
|
408
433
|
|
|
409
434
|
#### Verifying the Request Signature
|
|
410
435
|
|
|
@@ -416,6 +441,7 @@ slack_request.verify!
|
|
|
416
441
|
```
|
|
417
442
|
|
|
418
443
|
To specify secrets on a per-request basis:
|
|
444
|
+
|
|
419
445
|
```ruby
|
|
420
446
|
Slack::Events::Request.new(
|
|
421
447
|
http_request,
|
|
@@ -426,9 +452,13 @@ Slack::Events::Request.new(
|
|
|
426
452
|
|
|
427
453
|
The `verify!` call may raise `Slack::Events::Request::MissingSigningSecret`, `Slack::Events::Request::InvalidSignature` or `Slack::Events::Request::TimestampExpired` errors.
|
|
428
454
|
|
|
455
|
+
Both rewindable request bodies and non-rewindable streams permitted by Rack 3 are supported. `Slack::Events::Request#body` caches the raw body. Rewindable inputs are rewound before and after reading, preserving access for other consumers. Non-rewindable inputs are consumed once; use `slack_request.body` for subsequent access to the raw body.
|
|
456
|
+
|
|
457
|
+
Verify the signature before middleware or application code reads a non-rewindable input. Bytes already consumed from a one-shot stream cannot be recovered, and verification will fail. If multiple consumers need to read `rack.input`, install `Rack::RewindableInput::Middleware` (Rack 3) before any body-reading middleware to buffer the input.
|
|
458
|
+
|
|
429
459
|
### Message Handling
|
|
430
460
|
|
|
431
|
-
All text in Slack uses the same [system of formatting and escaping](https://
|
|
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.
|
|
432
462
|
|
|
433
463
|
#### Formatting Messages
|
|
434
464
|
|
|
@@ -446,13 +476,13 @@ Slack::Messages::Formatting.date(date)
|
|
|
446
476
|
# => "<!date^1688150386^{date_num} {time_secs}|2023-06-30 18:39:46 +0000>"
|
|
447
477
|
|
|
448
478
|
# Specify a different format
|
|
449
|
-
# See https://
|
|
479
|
+
# See https://docs.slack.dev/messaging/formatting-message-text/ for supported formats
|
|
450
480
|
Slack::Messages::Formatting.date(date, format: 'date_long_pretty')
|
|
451
481
|
# => "<!date^1688150386^date_long_pretty|2023-06-30 18:39:46 +0000>"
|
|
452
482
|
|
|
453
483
|
# Link your timestamp to a fully qualified URL
|
|
454
|
-
Slack::Messages::Formatting.date(date, link: 'https://
|
|
455
|
-
# => "<!date^1688150386^{date_num} {time_secs}^https://
|
|
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>"
|
|
456
486
|
|
|
457
487
|
# Specify custom fallback text to use if the client is unable to process the date
|
|
458
488
|
Slack::Messages::Formatting.date(date, text: 'party time!')
|
|
@@ -502,31 +532,30 @@ Slack::Messages::Formatting.url_link(text, url)
|
|
|
502
532
|
|
|
503
533
|
##### Markdown Formatting
|
|
504
534
|
|
|
505
|
-
Slack uses a mishmash of regular
|
|
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.
|
|
506
536
|
|
|
507
537
|
```ruby
|
|
508
|
-
text =
|
|
509
|
-
## A heading
|
|
510
|
-
**Bold text**
|
|
511
|
-
~~Strikethrough text~~
|
|
512
|
-
_Italic text_
|
|
513
|
-
[A link](https://example.com)
|
|
514
|
-
`code`
|
|
515
|
-
|
|
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
|
+
|
|
516
547
|
Slack::Messages::Formatting.markdown(text)
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
# `code`
|
|
524
|
-
# """
|
|
548
|
+
# ## A heading
|
|
549
|
+
# *Bold text*
|
|
550
|
+
# ~Strikethrough text~
|
|
551
|
+
# _Italic text_
|
|
552
|
+
# <https://example.com|A link>
|
|
553
|
+
# `code`
|
|
525
554
|
```
|
|
526
555
|
|
|
527
556
|
#### Parsing Messages
|
|
528
557
|
|
|
529
|
-
`Slack::Messages::Formatting` also provides ways to escape or unescape messages. This comes handy, for example, you want to treat all input to a
|
|
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.
|
|
530
559
|
|
|
531
560
|
##### Unescaping Message Content
|
|
532
561
|
|
|
@@ -562,18 +591,24 @@ Slack::Messages::Formatting.escape('Hello & <world>')
|
|
|
562
591
|
|
|
563
592
|
### Command-Line Client
|
|
564
593
|
|
|
565
|
-
The slack command-line client returns JSON data from the Slack API.
|
|
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.
|
|
595
|
+
|
|
596
|
+
```bash
|
|
597
|
+
gem install gli
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
Or add `gem 'gli'` to your Gemfile.
|
|
566
601
|
|
|
567
602
|
#### Authenticate with Slack
|
|
568
603
|
|
|
569
|
-
```
|
|
604
|
+
```console
|
|
570
605
|
$ slack --slack-api-token=[token] auth test
|
|
571
606
|
{"ok":true,"url":"...","team":"...","user":"...","team_id":"...","user_id":"..."}
|
|
572
607
|
```
|
|
573
608
|
|
|
574
609
|
#### Send a Message
|
|
575
610
|
|
|
576
|
-
```
|
|
611
|
+
```console
|
|
577
612
|
export SLACK_API_TOKEN=...
|
|
578
613
|
$ slack chat postMessage --text="hello world" --channel="#general"
|
|
579
614
|
{"ok":true,"channel":"...","ts":"...","message":{"text":"hello world","username":"bot","type":"message","subtype":"bot_message","ts":"..."}}
|
|
@@ -581,16 +616,16 @@ $ slack chat postMessage --text="hello world" --channel="#general"
|
|
|
581
616
|
|
|
582
617
|
#### Get Channel Info
|
|
583
618
|
|
|
584
|
-
```
|
|
619
|
+
```console
|
|
585
620
|
$ slack conversations info --channel=#general
|
|
586
621
|
{"ok":true,"channel":{"id":"C04KB5X4D","name":"general", ...}}
|
|
587
622
|
```
|
|
588
623
|
|
|
589
624
|
#### List Users
|
|
590
625
|
|
|
591
|
-
Combine with [jq](
|
|
626
|
+
Combine with [jq](https://jqlang.org/), a command-line JSON processor.
|
|
592
627
|
|
|
593
|
-
```
|
|
628
|
+
```console
|
|
594
629
|
$ slack users list | jq '.members | map({(.id): .name})'
|
|
595
630
|
[
|
|
596
631
|
{
|
|
@@ -608,11 +643,11 @@ See `slack help` for a complete command-line reference.
|
|
|
608
643
|
|
|
609
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).
|
|
610
645
|
|
|
611
|
-
Enterprise Support is available as part of a Tidelift Subscription
|
|
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).
|
|
612
647
|
|
|
613
648
|
## History
|
|
614
649
|
|
|
615
|
-
This gem is based on [slack-ruby-gem](https://github.com/aki017/slack-ruby-gem), but it more clearly separates the Web and
|
|
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).
|
|
616
651
|
|
|
617
652
|
## Security
|
|
618
653
|
|
|
@@ -624,6 +659,6 @@ See [CONTRIBUTING](CONTRIBUTING.md).
|
|
|
624
659
|
|
|
625
660
|
## Copyright and License
|
|
626
661
|
|
|
627
|
-
Copyright (c) 2015-
|
|
662
|
+
Copyright (c) 2015-2026, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
|
|
628
663
|
|
|
629
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
|
|
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
|
-
|
|
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
|
-
|
|
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 (7/10/2015)
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
Pushed git commits and tags.
|
|
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
|
-
|
|
21
|
+
## Prepare
|
|
52
22
|
|
|
53
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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).
|