slack-ruby-client 0.14.2 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.rubocop.yml +23 -7
- data/.rubocop_todo.yml +103 -43
- data/.travis.yml +0 -1
- data/CHANGELOG.md +39 -2
- data/CONTRIBUTING.md +24 -6
- data/Dangerfile +2 -1
- data/Gemfile +10 -3
- data/README.md +90 -30
- data/Rakefile +1 -0
- data/UPGRADING.md +16 -0
- data/bin/commands.rb +24 -0
- data/bin/commands/admin_apps.rb +27 -0
- data/bin/commands/admin_apps_approved.rb +17 -0
- data/bin/commands/admin_apps_requests.rb +16 -0
- data/bin/commands/admin_apps_restricted.rb +17 -0
- data/bin/commands/admin_conversations.rb +17 -0
- data/bin/commands/admin_conversations_restrictAccess.rb +37 -0
- data/bin/commands/admin_conversations_whitelist.rb +37 -0
- data/bin/commands/admin_emoji.rb +54 -0
- data/bin/commands/admin_inviteRequests.rb +36 -0
- data/bin/commands/admin_inviteRequests_approved.rb +16 -0
- data/bin/commands/admin_inviteRequests_denied.rb +16 -0
- data/bin/commands/admin_teams.rb +27 -0
- data/bin/commands/admin_teams_admins.rb +16 -0
- data/bin/commands/admin_teams_owners.rb +16 -0
- data/bin/commands/admin_teams_settings.rb +64 -0
- data/bin/commands/admin_usergroups.rb +48 -0
- data/bin/commands/admin_users.rb +97 -0
- data/bin/commands/admin_users_session.rb +16 -0
- data/bin/commands/api.rb +3 -2
- data/bin/commands/apps.rb +3 -2
- data/bin/commands/apps_permissions.rb +5 -4
- data/bin/commands/apps_permissions_resources.rb +3 -2
- data/bin/commands/apps_permissions_scopes.rb +3 -2
- data/bin/commands/apps_permissions_users.rb +5 -4
- data/bin/commands/auth.rb +5 -4
- data/bin/commands/bots.rb +3 -2
- data/bin/commands/calls.rb +52 -0
- data/bin/commands/calls_participants.rb +25 -0
- data/bin/commands/channels.rb +31 -30
- data/bin/commands/chat.rb +36 -32
- data/bin/commands/chat_scheduledMessages.rb +3 -2
- data/bin/commands/conversations.rb +36 -36
- data/bin/commands/dialog.rb +3 -2
- data/bin/commands/dnd.rb +9 -8
- data/bin/commands/emoji.rb +3 -2
- data/bin/commands/files.rb +14 -12
- data/bin/commands/files_comments.rb +3 -2
- data/bin/commands/files_remote.rb +78 -0
- data/bin/commands/groups.rb +33 -32
- data/bin/commands/im.rb +13 -12
- data/bin/commands/migration.rb +3 -2
- data/bin/commands/mpim.rb +11 -10
- data/bin/commands/oauth.rb +6 -5
- data/bin/commands/oauth_v2.rb +17 -0
- data/bin/commands/pins.rb +7 -8
- data/bin/commands/reactions.rb +10 -11
- data/bin/commands/reminders.rb +11 -10
- data/bin/commands/rtm.rb +5 -4
- data/bin/commands/search.rb +7 -6
- data/bin/commands/stars.rb +7 -6
- data/bin/commands/team.rb +10 -8
- data/bin/commands/team_profile.rb +3 -2
- data/bin/commands/usergroups.rb +11 -10
- data/bin/commands/usergroups_users.rb +5 -4
- data/bin/commands/users.rb +21 -20
- data/bin/commands/users_admin.rb +1 -0
- data/bin/commands/users_prefs.rb +1 -0
- data/bin/commands/users_profile.rb +5 -4
- data/bin/commands/views.rb +48 -0
- data/bin/slack +1 -2
- data/examples/hi_real_time/Gemfile +1 -0
- data/examples/hi_real_time/hi.rb +7 -3
- data/examples/hi_real_time_and_web/Gemfile +1 -0
- data/examples/hi_real_time_and_web/hi.rb +7 -3
- data/examples/hi_real_time_async_async/Gemfile +1 -0
- data/examples/hi_real_time_async_async/hi.rb +6 -2
- data/examples/hi_real_time_async_celluloid/Gemfile +1 -0
- data/examples/hi_real_time_async_celluloid/hi.rb +7 -3
- data/examples/hi_real_time_async_eventmachine/Gemfile +1 -0
- data/examples/hi_real_time_async_eventmachine/hi.rb +7 -3
- data/examples/hi_web/Gemfile +1 -0
- data/examples/hi_web/hi.rb +1 -0
- data/examples/new_ticket/Gemfile +1 -0
- data/examples/new_ticket/new_ticket.rb +1 -0
- data/lib/slack-ruby-client.rb +4 -4
- data/lib/slack.rb +1 -0
- data/lib/slack/config.rb +1 -0
- data/lib/slack/events/config.rb +1 -0
- data/lib/slack/events/request.rb +3 -1
- data/lib/slack/logger.rb +6 -5
- data/lib/slack/messages/formatting.rb +1 -0
- data/lib/slack/messages/message.rb +1 -4
- data/lib/slack/real_time/api/message.rb +3 -1
- data/lib/slack/real_time/api/message_id.rb +1 -0
- data/lib/slack/real_time/api/ping.rb +5 -2
- data/lib/slack/real_time/api/typing.rb +3 -1
- data/lib/slack/real_time/client.rb +46 -22
- data/lib/slack/real_time/concurrency.rb +1 -0
- data/lib/slack/real_time/concurrency/async.rb +18 -9
- data/lib/slack/real_time/concurrency/celluloid.rb +10 -4
- data/lib/slack/real_time/concurrency/eventmachine.rb +9 -6
- data/lib/slack/real_time/config.rb +6 -1
- data/lib/slack/real_time/models.rb +1 -0
- data/lib/slack/real_time/models/base.rb +1 -4
- data/lib/slack/real_time/models/bot.rb +1 -0
- data/lib/slack/real_time/models/channel.rb +1 -0
- data/lib/slack/real_time/models/group.rb +1 -0
- data/lib/slack/real_time/models/im.rb +1 -0
- data/lib/slack/real_time/models/team.rb +1 -0
- data/lib/slack/real_time/models/user.rb +1 -0
- data/lib/slack/real_time/socket.rb +16 -13
- data/lib/slack/real_time/stores.rb +1 -0
- data/lib/slack/real_time/stores/base.rb +4 -1
- data/lib/slack/real_time/stores/starter.rb +11 -0
- data/lib/slack/real_time/stores/store.rb +26 -25
- data/lib/slack/version.rb +2 -1
- data/lib/slack/web/api/endpoints.rb +48 -0
- data/lib/slack/web/api/endpoints/admin_apps.rb +42 -0
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_apps_requests.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +30 -0
- data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_conversations_whitelist.rb +64 -0
- data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
- data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
- data/lib/slack/web/api/endpoints/admin_usergroups.rb +77 -0
- data/lib/slack/web/api/endpoints/admin_users.rb +163 -0
- data/lib/slack/web/api/endpoints/admin_users_session.rb +28 -0
- data/lib/slack/web/api/endpoints/api.rb +2 -1
- data/lib/slack/web/api/endpoints/apps.rb +2 -1
- data/lib/slack/web/api/endpoints/apps_permissions.rb +3 -2
- data/lib/slack/web/api/endpoints/apps_permissions_resources.rb +2 -1
- data/lib/slack/web/api/endpoints/apps_permissions_scopes.rb +2 -1
- data/lib/slack/web/api/endpoints/apps_permissions_users.rb +3 -2
- data/lib/slack/web/api/endpoints/auth.rb +3 -2
- data/lib/slack/web/api/endpoints/bots.rb +2 -1
- data/lib/slack/web/api/endpoints/calls.rb +83 -0
- data/lib/slack/web/api/endpoints/calls_participants.rb +42 -0
- data/lib/slack/web/api/endpoints/channels.rb +44 -29
- data/lib/slack/web/api/endpoints/chat.rb +38 -31
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +3 -2
- data/lib/slack/web/api/endpoints/conversations.rb +34 -35
- data/lib/slack/web/api/endpoints/dialog.rb +2 -1
- data/lib/slack/web/api/endpoints/dnd.rb +6 -4
- data/lib/slack/web/api/endpoints/emoji.rb +2 -1
- data/lib/slack/web/api/endpoints/files.rb +11 -8
- data/lib/slack/web/api/endpoints/files_comments.rb +2 -1
- data/lib/slack/web/api/endpoints/files_remote.rb +127 -0
- data/lib/slack/web/api/endpoints/groups.rb +33 -18
- data/lib/slack/web/api/endpoints/im.rb +17 -12
- data/lib/slack/web/api/endpoints/migration.rb +2 -1
- data/lib/slack/web/api/endpoints/mpim.rb +16 -11
- data/lib/slack/web/api/endpoints/oauth.rb +4 -6
- data/lib/slack/web/api/endpoints/oauth_v2.rb +30 -0
- data/lib/slack/web/api/endpoints/pins.rb +8 -12
- data/lib/slack/web/api/endpoints/reactions.rb +12 -15
- data/lib/slack/web/api/endpoints/reminders.rb +6 -5
- data/lib/slack/web/api/endpoints/rtm.rb +3 -2
- data/lib/slack/web/api/endpoints/search.rb +4 -3
- data/lib/slack/web/api/endpoints/stars.rb +6 -7
- data/lib/slack/web/api/endpoints/team.rb +7 -5
- data/lib/slack/web/api/endpoints/team_profile.rb +2 -1
- data/lib/slack/web/api/endpoints/usergroups.rb +6 -5
- data/lib/slack/web/api/endpoints/usergroups_users.rb +3 -2
- data/lib/slack/web/api/endpoints/users.rb +11 -12
- data/lib/slack/web/api/endpoints/users_admin.rb +1 -0
- data/lib/slack/web/api/endpoints/users_prefs.rb +1 -0
- data/lib/slack/web/api/endpoints/users_profile.rb +3 -2
- data/lib/slack/web/api/endpoints/views.rb +97 -0
- data/lib/slack/web/api/error.rb +1 -0
- data/lib/slack/web/api/errors.rb +656 -0
- data/lib/slack/web/api/errors/slack_error.rb +14 -1
- data/lib/slack/web/api/errors/too_many_requests_error.rb +1 -0
- data/lib/slack/web/api/mixins.rb +2 -0
- data/lib/slack/web/api/mixins/channels.id.rb +1 -0
- data/lib/slack/web/api/mixins/conversations.id.rb +27 -0
- data/lib/slack/web/api/mixins/groups.id.rb +1 -0
- data/lib/slack/web/api/mixins/ids.id.rb +1 -0
- data/lib/slack/web/api/mixins/users.id.rb +1 -0
- data/lib/slack/web/api/mixins/users.search.rb +1 -0
- data/lib/slack/web/api/patches/{chat.6.block-kit-support.patch → chat.1.patch} +29 -26
- data/lib/slack/web/api/patches/views.1.view-json.patch +40 -0
- data/lib/slack/web/api/patches/views.1.views-published.patch +16 -0
- data/lib/slack/web/api/templates/command.erb +1 -0
- data/lib/slack/web/api/templates/commands.erb +1 -0
- data/lib/slack/web/api/templates/endpoints.erb +1 -0
- data/lib/slack/web/api/templates/errors.erb +20 -0
- data/lib/slack/web/api/templates/method.erb +5 -1
- data/lib/slack/web/api/templates/method_spec.erb +1 -0
- data/lib/slack/web/client.rb +2 -1
- data/lib/slack/web/config.rb +1 -0
- data/lib/slack/web/faraday/connection.rb +24 -20
- data/lib/slack/web/faraday/request.rb +1 -0
- data/lib/slack/web/faraday/response/raise_error.rb +10 -6
- data/lib/slack/web/pagination/cursor.rb +3 -2
- data/lib/slack_ruby_client.rb +1 -0
- data/lib/tasks/git.rake +1 -0
- data/lib/tasks/real_time.rake +13 -5
- data/lib/tasks/update.rake +1 -0
- data/lib/tasks/web.rake +27 -7
- data/screenshots/create-app.png +0 -0
- data/slack-ruby-client.gemspec +6 -3
- data/spec/fixtures/slack/web/channels_info.yml +108 -15
- data/spec/fixtures/slack/web/views_open_error.yml +76 -0
- data/spec/integration/integration_spec.rb +26 -23
- data/spec/slack/config_spec.rb +2 -0
- data/spec/slack/events/config_spec.rb +8 -4
- data/spec/slack/events/request_spec.rb +67 -37
- data/spec/slack/messages/formatting_spec.rb +25 -13
- data/spec/slack/real_time/api/message_spec.rb +6 -1
- data/spec/slack/real_time/api/ping_spec.rb +2 -0
- data/spec/slack/real_time/api/typing_spec.rb +5 -1
- data/spec/slack/real_time/client_spec.rb +178 -32
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +11 -6
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +9 -1
- data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +2 -0
- data/spec/slack/real_time/event_handlers/bot_spec.rb +2 -1
- data/spec/slack/real_time/event_handlers/channel_spec.rb +9 -6
- data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +2 -1
- data/spec/slack/real_time/event_handlers/group_spec.rb +5 -4
- data/spec/slack/real_time/event_handlers/im_spec.rb +4 -3
- data/spec/slack/real_time/event_handlers/team_spec.rb +3 -1
- data/spec/slack/real_time/event_handlers/user_spec.rb +1 -0
- data/spec/slack/real_time/rtm_connect_spec.rb +1 -0
- data/spec/slack/real_time/rtm_start_spec.rb +1 -0
- data/spec/slack/real_time/store_spec.rb +2 -1
- data/spec/slack/slack_spec.rb +37 -5
- data/spec/slack/version_spec.rb +2 -1
- data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_requests_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +32 -0
- data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_conversations_whitelist_spec.rb +32 -0
- data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +37 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +53 -0
- data/spec/slack/web/api/endpoints/admin_teams_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +37 -0
- data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_users_spec.rb +75 -0
- data/spec/slack/web/api/endpoints/api_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/apps_permissions_resources_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/apps_permissions_scopes_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +3 -2
- data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +4 -3
- data/spec/slack/web/api/endpoints/apps_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/bots_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/calls_participants_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/calls_spec.rb +31 -0
- data/spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/conversations_spec.rb +2 -1
- data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +5 -1
- data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +5 -3
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +80 -25
- data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +12 -4
- data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +2 -0
- data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +6 -1
- data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +95 -0
- data/spec/slack/web/api/endpoints/dnd_spec.rb +6 -0
- data/spec/slack/web/api/endpoints/emoji_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/files_remote_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/files_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/im_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/migration_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/mpim_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/oauth_spec.rb +1 -11
- data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/pins_spec.rb +5 -1
- data/spec/slack/web/api/endpoints/reactions_spec.rb +8 -1
- data/spec/slack/web/api/endpoints/reminders_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/rtm_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/search_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/stars_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/team_profile_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/team_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/usergroups_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/users_admin_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/users_prefs_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/users_profile_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/views_spec.rb +29 -0
- data/spec/slack/web/api/error_spec.rb +4 -2
- data/spec/slack/web/api/errors/service_unavailable_spec.rb +8 -5
- data/spec/slack/web/api/errors/slack_error_spec.rb +26 -2
- data/spec/slack/web/api/mixins/channels_spec.rb +17 -7
- data/spec/slack/web/api/mixins/conversations_spec.rb +41 -0
- data/spec/slack/web/api/mixins/groups_spec.rb +17 -7
- data/spec/slack/web/api/mixins/users_spec.rb +17 -8
- data/spec/slack/web/api/pagination/cursor_spec.rb +40 -10
- data/spec/slack/web/client_spec.rb +71 -18
- data/spec/slack/web/faraday/response/raise_error_spec.rb +41 -7
- data/spec/spec_helper.rb +2 -1
- data/spec/support/queue_with_timeout.rb +1 -0
- data/spec/support/real_time/concurrency/mock.rb +1 -0
- data/spec/support/real_time/connected_client.rb +9 -3
- data/spec/support/real_time/event.rb +1 -0
- data/spec/support/token.rb +1 -0
- data/spec/support/vcr.rb +1 -0
- metadata +156 -30
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +0 -13
- data/lib/slack/web/api/patches/chat.2.attachments-json.patch +0 -17
- data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +0 -21
- data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +0 -17
- data/lib/slack/web/api/patches/chat.5.postEphemeral-text-or-attachments.patch +0 -13
- data/screenshots/register-bot.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c889cedf29a72dd4c60c2d8c1338538c2f35ed7be9d42defa10f04866466997a
|
4
|
+
data.tar.gz: f23223bf65696509321856a536f60411db15c3fe34db3c42f2284672fbc99f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1c55f1840dbb1604294e83e922188467aa63a8aa04c2d38c744e6e96287db2ba961b33f408ee83c68dae70f9554d362e1fb1278c36dc45b1e1a5190e6b3189f
|
7
|
+
data.tar.gz: 582c4f3d190b998521b5c7e358188c0662d1e3c2c43021cf9e93345e7ca162c027e0d170364c87367ba548132aeb4c0ab989d08c01bc4e5eec4f8312dbaf8ea6
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: [dblock]
|
data/.rubocop.yml
CHANGED
@@ -1,21 +1,37 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
require:
|
4
|
+
- rubocop-performance
|
5
|
+
- rubocop-rspec
|
6
|
+
|
1
7
|
AllCops:
|
8
|
+
DisplayCopNames: true
|
2
9
|
Exclude:
|
10
|
+
- bin/**/*
|
3
11
|
- vendor/**/*
|
4
12
|
- lib/slack/web/api/slack-api-ref/**/*
|
13
|
+
- lib/slack/web/api/endpoints/* # Auto-generated
|
14
|
+
- lib/slack/web/api/errors.rb # Auto-generated
|
15
|
+
- spec/slack/web/api/endpoints/* # Auto-generated
|
5
16
|
|
6
|
-
|
17
|
+
Layout/EmptyLineAfterMagicComment:
|
7
18
|
Enabled: false
|
8
19
|
|
9
|
-
Metrics/
|
10
|
-
Max:
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Max: 250
|
11
22
|
|
12
|
-
|
13
|
-
|
23
|
+
Metrics/ClassLength:
|
24
|
+
Max: 250
|
14
25
|
|
15
|
-
|
26
|
+
Layout/LineLength:
|
27
|
+
Max: 128
|
28
|
+
|
29
|
+
Style/Documentation:
|
16
30
|
Enabled: false
|
17
31
|
|
18
32
|
Style/ModuleFunction:
|
19
33
|
Enabled: false
|
20
34
|
|
21
|
-
|
35
|
+
Naming/FileName:
|
36
|
+
Exclude:
|
37
|
+
- lib/slack-ruby-client.rb # Required to match gemspec name
|
data/.rubocop_todo.yml
CHANGED
@@ -1,74 +1,134 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2020-06-29 08:44:31 -0400 using RuboCop version 0.82.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
#
|
11
|
-
Lint/
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
Lint/NonDeterministicRequireOrder:
|
12
12
|
Exclude:
|
13
|
-
- '
|
14
|
-
- 'lib/slack/real_time/socket.rb'
|
13
|
+
- 'spec/spec_helper.rb'
|
15
14
|
|
16
|
-
# Offense count:
|
17
|
-
|
15
|
+
# Offense count: 2
|
16
|
+
# Cop supports --auto-correct.
|
17
|
+
Lint/RedundantCopDisableDirective:
|
18
18
|
Exclude:
|
19
19
|
- 'lib/slack-ruby-client.rb'
|
20
|
+
|
21
|
+
# Offense count: 2
|
22
|
+
# Configuration parameters: AllowComments.
|
23
|
+
Lint/SuppressedException:
|
24
|
+
Exclude:
|
20
25
|
- 'spec/slack/real_time/concurrency/celluloid_spec.rb'
|
21
26
|
- 'spec/slack/real_time/concurrency/eventmachine_spec.rb'
|
22
27
|
|
23
|
-
# Offense count:
|
24
|
-
# Configuration parameters:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
# Offense count: 11
|
29
|
+
# Configuration parameters: IgnoredMethods.
|
30
|
+
Metrics/AbcSize:
|
31
|
+
Max: 39
|
32
|
+
|
33
|
+
# Offense count: 2
|
34
|
+
# Configuration parameters: IgnoredMethods.
|
35
|
+
Metrics/CyclomaticComplexity:
|
36
|
+
Max: 9
|
37
|
+
|
38
|
+
# Offense count: 14
|
39
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
40
|
+
Metrics/MethodLength:
|
41
|
+
Max: 32
|
32
42
|
|
33
43
|
# Offense count: 1
|
34
|
-
# Configuration parameters:
|
35
|
-
|
36
|
-
|
44
|
+
# Configuration parameters: IgnoredMethods.
|
45
|
+
Metrics/PerceivedComplexity:
|
46
|
+
Max: 9
|
47
|
+
|
48
|
+
# Offense count: 2
|
49
|
+
# Cop supports --auto-correct.
|
50
|
+
Performance/RegexpMatch:
|
37
51
|
Exclude:
|
38
|
-
- 'lib/
|
52
|
+
- 'lib/tasks/web.rake'
|
39
53
|
|
40
54
|
# Offense count: 1
|
41
|
-
|
55
|
+
RSpec/AnyInstance:
|
42
56
|
Exclude:
|
43
|
-
- '
|
57
|
+
- 'spec/slack/real_time/concurrency/celluloid_spec.rb'
|
44
58
|
|
45
|
-
# Offense count:
|
46
|
-
#
|
47
|
-
|
48
|
-
Style/AccessModifierDeclarations:
|
59
|
+
# Offense count: 5
|
60
|
+
# Cop supports --auto-correct.
|
61
|
+
RSpec/ContextMethod:
|
49
62
|
Exclude:
|
50
|
-
- '
|
51
|
-
- '
|
63
|
+
- 'spec/slack/messages/formatting_spec.rb'
|
64
|
+
- 'spec/slack/web/api/mixins/channels_spec.rb'
|
65
|
+
- 'spec/slack/web/api/mixins/groups_spec.rb'
|
66
|
+
- 'spec/slack/web/api/mixins/users_spec.rb'
|
52
67
|
|
53
|
-
# Offense count:
|
54
|
-
# Configuration parameters:
|
55
|
-
|
68
|
+
# Offense count: 71
|
69
|
+
# Configuration parameters: Prefixes.
|
70
|
+
# Prefixes: when, with, without
|
71
|
+
RSpec/ContextWording:
|
56
72
|
Enabled: false
|
57
73
|
|
58
|
-
# Offense count:
|
59
|
-
#
|
60
|
-
|
74
|
+
# Offense count: 129
|
75
|
+
# Cop supports --auto-correct.
|
76
|
+
# Configuration parameters: AllowConsecutiveOneLiners.
|
77
|
+
RSpec/EmptyLineAfterExample:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
# Offense count: 66
|
81
|
+
# Configuration parameters: Max.
|
82
|
+
RSpec/ExampleLength:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
# Offense count: 17
|
86
|
+
# Configuration parameters: CustomTransform, IgnoreMethods.
|
87
|
+
RSpec/FilePath:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
# Offense count: 13
|
91
|
+
# Configuration parameters: AssignmentOnly.
|
92
|
+
RSpec/InstanceVariable:
|
61
93
|
Exclude:
|
62
|
-
- '
|
63
|
-
- '
|
64
|
-
- '
|
94
|
+
- 'spec/integration/integration_spec.rb'
|
95
|
+
- 'spec/slack/real_time/client_spec.rb'
|
96
|
+
- 'spec/slack/slack_spec.rb'
|
65
97
|
|
66
|
-
# Offense count:
|
67
|
-
|
98
|
+
# Offense count: 77
|
99
|
+
# Configuration parameters: .
|
100
|
+
# SupportedStyles: have_received, receive
|
101
|
+
RSpec/MessageSpies:
|
102
|
+
EnforcedStyle: receive
|
103
|
+
|
104
|
+
# Offense count: 95
|
105
|
+
RSpec/MultipleExpectations:
|
106
|
+
Max: 5
|
107
|
+
|
108
|
+
# Offense count: 35
|
109
|
+
RSpec/NestedGroups:
|
110
|
+
Max: 6
|
111
|
+
|
112
|
+
# Offense count: 3
|
113
|
+
RSpec/SubjectStub:
|
68
114
|
Exclude:
|
69
|
-
- '
|
115
|
+
- 'spec/slack/web/api/mixins/channels_spec.rb'
|
116
|
+
- 'spec/slack/web/api/mixins/groups_spec.rb'
|
117
|
+
- 'spec/slack/web/api/mixins/users_spec.rb'
|
70
118
|
|
71
|
-
# Offense count:
|
72
|
-
|
119
|
+
# Offense count: 16
|
120
|
+
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
121
|
+
RSpec/VerifiedDoubles:
|
73
122
|
Exclude:
|
123
|
+
- 'spec/slack/events/request_spec.rb'
|
124
|
+
- 'spec/slack/real_time/client_spec.rb'
|
125
|
+
- 'spec/slack/real_time/concurrency/celluloid_spec.rb'
|
126
|
+
- 'spec/slack/real_time/concurrency/eventmachine_spec.rb'
|
127
|
+
- 'spec/slack/web/faraday/response/raise_error_spec.rb'
|
74
128
|
- 'spec/support/real_time/connected_client.rb'
|
129
|
+
|
130
|
+
# Offense count: 4
|
131
|
+
# Configuration parameters: .
|
132
|
+
# SupportedStyles: annotated, template, unannotated
|
133
|
+
Style/FormatStringToken:
|
134
|
+
EnforcedStyle: unannotated
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,40 @@
|
|
1
|
+
### 0.15.0 (2020/7/26)
|
2
|
+
|
3
|
+
* [#322](https://github.com/slack-ruby/slack-ruby-client/pull/322): Cache `Faraday::Connection` for persistent adapters - [@drbrain](https://github.com/drbrain).
|
4
|
+
* [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Require Faraday >= 1.0 - [@dblock](https://github.com/dblock).
|
5
|
+
* [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Upgrade slack-ruby-danger, rubocop, rubocop-rspec and rubocop-performance - [@dblock](https://github.com/dblock).
|
6
|
+
* [#327](https://github.com/slack-ruby/slack-ruby-client/pull/327), [#326](https://github.com/slack-ruby/slack-ruby-client/pull/326): Added `admin_conversations_whitelist`, `admin_usergroups`, `calls` and `calls_participants` endpoints - [@wasabigeek](https://github.com/wasabigeek).
|
7
|
+
* [#329](https://github.com/slack-ruby/slack-ruby-client/pull/329): Log when methods are deprecated - [@wasabigeek](https://github.com/wasabigeek).
|
8
|
+
* [#325](https://github.com/slack-ruby/slack-ruby-client/pull/325): Remove activesupport dependency - [@ianks](https://github.com/ianks).
|
9
|
+
* [#331](https://github.com/slack-ruby/slack-ruby-client/pull/331): Use `conversations_list` instead of deprecated `channels_list`. Added `admin_conversations_restrictAccess_addGroup`, `admin_conversations_restrictAccess_listGroups` and `admin_conversations_restrictAccess_removeGroup` endpoints - [@wasabigeek](https://github.com/wasabigeek).
|
10
|
+
|
11
|
+
### 0.14.6 (2020/3/28)
|
12
|
+
|
13
|
+
* [#305](https://github.com/slack-ruby/slack-ruby-client/pull/305): Added `admin_inviteRequests_approve`, `admin_inviteRequests_deny`, `admin_inviteRequests_list`, `admin_inviteRequests_approved_list`, `admin_inviteRequests_denied_list`, `admin_teams_create`, `admin_teams_list`, `admin_teams_admins_list`, `admin_teams_owners_list`, `admin_teams_settings`, `admin_teams_settings_setIcon`, `admin_teams_settings_setName`, `admin_teams_settings_setDescription`, `admin_users_assign`, `admin_users_invite`, `admin_users_remove`, `admin_users_setAdmin`, `admin_users_setOwner` and `admin_users_setRegular` endpoints - [@manuelmeurer](https://github.com/manuelmeurer).
|
14
|
+
* [#311](https://github.com/slack-ruby/slack-ruby-client/pull/311): Made Web API `response_metadata` more accessible in errors - [@jmanian](https://github.com/jmanian).
|
15
|
+
* [#312](https://github.com/slack-ruby/slack-ruby-client/pull/312): Added specific error classes for Web API - [@jmanian](https://github.com/jmanian).
|
16
|
+
* [#313](https://github.com/slack-ruby/slack-ruby-client/pull/313): Added `admin_teams_settings_info`, `admin_users_list`, `admin_users_setExpiration`, `admin_apps_approved_list`, `admin_apps_restricted_list`, `admin_conversations_setTeams`, `admin_emoji_add`, `admin_emoji_addAlias`, `admin_emoji_list`, `admin_emoji_remove` and `admin_emoji_rename` endpoints - [@dblock](https://github.com/dblock).
|
17
|
+
|
18
|
+
### 0.14.5 (2019/12/23)
|
19
|
+
|
20
|
+
* [#293](https://github.com/slack-ruby/slack-ruby-client/pull/293): Rubocop auto-correct and comprehensive todo - [@jcraigk](https://github.com/jcraigk).
|
21
|
+
* [#297](https://github.com/slack-ruby/slack-ruby-client/pull/297): Various Rubocop fixes - [@jcraigk](https://github.com/jcraigk).
|
22
|
+
* [#298](https://github.com/slack-ruby/slack-ruby-client/pull/298): Added `admin_apps`, `admin_app_requests` and `views` endpoints - [@jmanian](https://github.com/jmanian).
|
23
|
+
* [#303](https://github.com/slack-ruby/slack-ruby-client/pull/303): Added `oauth_v2_access` and `views_publish` endpoints - [@jwright](https://github.com/jwright).
|
24
|
+
* [#309](https://github.com/slack-ruby/slack-ruby-client/pull/309): Stop ping on `inactive_account` and `invalid_auth` - [@dblock](https://github.com/dblock).
|
25
|
+
|
26
|
+
### 0.14.4 (2019/7/28)
|
27
|
+
|
28
|
+
* [#289](https://github.com/slack-ruby/slack-ruby-client/pull/289): Fix reconnects when ping timers under/overshoot - [@georgyangelov](https://github.com/georgyangelov).
|
29
|
+
* [#290](https://github.com/slack-ruby/slack-ruby-client/pull/290): Expose Slack::RealTime::Client.logger accessor publicly - [@jcraigk](https://github.com/jcraigk).
|
30
|
+
|
31
|
+
### 0.14.3 (2019/7/23)
|
32
|
+
|
33
|
+
* [#279](https://github.com/slack-ruby/slack-ruby-client/pull/279): Prevent ping worker from dying on unexpected errors - [@dblock](https://github.com/dblock).
|
34
|
+
* [#281](https://github.com/slack-ruby/slack-ruby-client/pull/281): Added `admin_users_session_reset` to Web API - [@dblock](https://github.com/dblock).
|
35
|
+
* [#283](https://github.com/slack-ruby/slack-ruby-client/pull/283): Fail when used with incompatible async-websocket > 0.8.0 - [@dblock](https://github.com/dblock).
|
36
|
+
* [#284](https://github.com/slack-ruby/slack-ruby-client/pull/284): Include team id, name and domain in log output - [@dblock](https://github.com/dblock).
|
37
|
+
|
1
38
|
### 0.14.2 (2019/4/12)
|
2
39
|
|
3
40
|
* [#256](https://github.com/slack-ruby/slack-ruby-client/pull/256): Added support for specifying signing secrets on a per-request basis via optional parameters to the `Slack::Events::Request` constructor - [@gabrielmdeal](https://github.com/gabrielmdeal).
|
@@ -147,8 +184,8 @@
|
|
147
184
|
### 0.7.1 (2016/5/2)
|
148
185
|
|
149
186
|
* [#82](https://github.com/slack-ruby/slack-ruby-client/pull/82): Fix `usergroups.users.{list,update}` and `files.comments.{add,edit,delete}` APIs - [@masatomo](https://github.com/masatomo).
|
150
|
-
* [#73](https://github.com/slack-ruby/slack-ruby-client/issues/73):
|
151
|
-
* [#69](https://github.com/slack-ruby/slack-ruby-client/issues/69):
|
187
|
+
* [#73](https://github.com/slack-ruby/slack-ruby-client/issues/73): Added a `closed` event - [@rkadyb](https://github.com/rkadyb).
|
188
|
+
* [#69](https://github.com/slack-ruby/slack-ruby-client/issues/69): Added attachments support for `Slack::Web::Api::Endpoints::Chat.chat_update` - [@nicka](https://github.com/nicka).
|
152
189
|
* [#85](https://github.com/slack-ruby/slack-ruby-client/issues/85): Compatibility with WebMock 2.0 - [@dblock](https://github.com/dblock).
|
153
190
|
* Added `as_user` to `chat_delete` Web API - [@dblock](https://github.com/dblock).
|
154
191
|
* Added `reminders_add`, `reminders_complete`, `reminders_delete`, `reminders_info` and `reminders_list` to Web API - [@dblock](https://github.com/dblock).
|
data/CONTRIBUTING.md
CHANGED
@@ -75,13 +75,31 @@ rake slack:api:update
|
|
75
75
|
|
76
76
|
Sometimes it's necessary to patch auto-generated Slack Web API methods. For example, we want to help clients with calling `to_json` on the `attachments` parameter sent to `chat_postMessage`. See [#20](https://github.com/slack-ruby/slack-ruby-client/issues/20).
|
77
77
|
|
78
|
-
|
78
|
+
The broad steps are:
|
79
|
+
1. Run `rake slack:api:update` to check that existing patches are still valid.
|
80
|
+
- If you run into a `failed to apply patch` error, the auto-generated methods likely drifted from the last patch. Follow the steps [below](#resolving-patch-errors).
|
81
|
+
- This may add new methods if the API has updated, please split them up into multiple PRs if so.
|
82
|
+
2. Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat.rb`.
|
83
|
+
3. Generate a patch:
|
84
|
+
```
|
85
|
+
git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
|
86
|
+
```
|
87
|
+
4. Run `rake slack:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
|
88
|
+
|
89
|
+
##### Resolving Patch Errors
|
90
|
+
|
91
|
+
The auto-generated method files may drift overtime e.g. new arguments may be added or descriptions changed. Since previous patches were based on the older auto-generated files, git may be unable to apply them to the new files. Resolving them requires some good ol' splicing:
|
92
|
+
1. Comment out the patching code in `lib/tasks/web.rake`:
|
93
|
+
```ruby
|
94
|
+
# Dir.glob("lib/slack/web/api/patches/#{group}*.patch").sort.each do |patch|
|
95
|
+
# puts "- patching #{patch}"
|
96
|
+
# system("git apply #{patch}") || raise('failed to apply patch')
|
97
|
+
# end
|
98
|
+
```
|
99
|
+
2. Run `rake slack:api:update` to create the raw auto-generated files. Commit the files that you are updating, so we can run `git diff` later.
|
100
|
+
3. Go through the old patches for the files (e.g. in `lib/slack/web/api/patches/chat.1.patch`), copying code into the new files.
|
101
|
+
4. Continue with Step 2 [above](#patching-slack-web-api).
|
79
102
|
|
80
|
-
```
|
81
|
-
git diff --no-color HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
|
82
|
-
```
|
83
|
-
|
84
|
-
Run `rake slack:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
|
85
103
|
|
86
104
|
### Write Documentation
|
87
105
|
|
data/Dangerfile
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
source 'http://rubygems.org'
|
2
3
|
|
3
4
|
gemspec
|
4
5
|
|
5
|
-
|
6
|
+
if ENV.key?('CONCURRENCY')
|
7
|
+
case ENV['CONCURRENCY']
|
8
|
+
when 'async-websocket'
|
9
|
+
gem 'async-websocket', '~> 0.8.0', require: false
|
10
|
+
else
|
11
|
+
gem ENV['CONCURRENCY'], require: false
|
12
|
+
end
|
13
|
+
end
|
6
14
|
|
7
15
|
group :test do
|
8
|
-
gem 'danger
|
9
|
-
gem 'slack-ruby-danger', '~> 0.1.0', require: false
|
16
|
+
gem 'slack-ruby-danger', '~> 0.2.0', require: false
|
10
17
|
end
|
data/README.md
CHANGED
@@ -16,20 +16,26 @@ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messagin
|
|
16
16
|
- [Installation](#installation)
|
17
17
|
- [Usage](#usage)
|
18
18
|
- [Create a New Bot Integration](#create-a-new-bot-integration)
|
19
|
-
- [
|
19
|
+
- [OAuth Code Grant](#oauth-code-grant)
|
20
|
+
- [Using the Legacy API Token](#using-the-legacy-api-token)
|
20
21
|
- [Global Settings](#global-settings)
|
21
22
|
- [Web Client](#web-client)
|
22
|
-
- [
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
- [Web Client Examples](#web-client-examples)
|
24
|
+
- [Test Auth](#test-auth)
|
25
|
+
- [Send Messages](#send-messages)
|
26
|
+
- [List Channels](#list-channels)
|
27
|
+
- [Upload a File](#upload-a-file)
|
28
|
+
- [Get Channel Info](#get-channel-info)
|
29
|
+
- [Get User Info](#get-user-info)
|
30
|
+
- [Search for a User](#search-for-a-user)
|
31
|
+
- [Other](#other)
|
30
32
|
- [Web Client Options](#web-client-options)
|
31
33
|
- [Pagination Support](#pagination-support)
|
34
|
+
- [Character Encoding](#character-encoding)
|
32
35
|
- [Error Handling](#error-handling)
|
36
|
+
- [Slack Errors](#slack-errors)
|
37
|
+
- [Rate Limiting](#rate-limiting)
|
38
|
+
- [Other Errors](#other-errors)
|
33
39
|
- [RealTime Client](#realtime-client)
|
34
40
|
- [Slack::RealTime::Stores::Store](#slackrealtimestoresstore)
|
35
41
|
- [Slack::RealTime::Stores::Starter](#slackrealtimestoresstarter)
|
@@ -61,12 +67,12 @@ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messagin
|
|
61
67
|
|
62
68
|
* This library will let you send messages to Slack via the Web API, send and receive messages via the Real Time Messaging API and facilitate integration with the Events API.
|
63
69
|
* To respond to slash commands, interactive components or events, 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
|
-
* To build a bot using the Real Time Messaging API, use [slack-ruby-bot](https://github.com/
|
65
|
-
* To roll out a complete service using the Real Time Messaging API with Slack button integration to multiple teams, check out [slack-ruby-bot-server](https://github.com/
|
70
|
+
* To build a bot using the Real Time Messaging API, use [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot), which uses this library.
|
71
|
+
* To roll out a complete service using the Real Time Messaging API with Slack button integration to multiple teams, check out [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server), which is built on top of slack-ruby-bot, which uses this library.
|
66
72
|
|
67
73
|
## Stable Release
|
68
74
|
|
69
|
-
You're reading the documentation for the **
|
75
|
+
You're reading the documentation for the **stale** release of slack-ruby-client, v0.15.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
70
76
|
|
71
77
|
## Installation
|
72
78
|
|
@@ -79,7 +85,7 @@ gem 'slack-ruby-client'
|
|
79
85
|
If you're going to be using the RealTime client, add either `async-websocket`, `eventmachine` and `faye-websocket` or `celluloid-io`. See below for more information about concurrency. We recommend you use `async-websocket`.
|
80
86
|
|
81
87
|
```
|
82
|
-
gem 'async-websocket'
|
88
|
+
gem 'async-websocket', '~> 0.8.0'
|
83
89
|
```
|
84
90
|
|
85
91
|
Run `bundle install`.
|
@@ -88,11 +94,17 @@ Run `bundle install`.
|
|
88
94
|
|
89
95
|
### Create a New Bot Integration
|
90
96
|
|
91
|
-
|
97
|
+
To integrate your bot with Slack, you must first create a new [Slack App](https://api.slack.com/apps).
|
98
|
+
|
99
|
+
![](screenshots/create-app.png)
|
100
|
+
|
101
|
+
### OAuth Code Grant
|
102
|
+
|
103
|
+
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 code grant flow](https://api.slack.com/docs/oauth#flow) as described at [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server).
|
92
104
|
|
93
|
-
|
105
|
+
### Using the Legacy API Token
|
94
106
|
|
95
|
-
|
107
|
+
Although OAuth is recommended, you can still [generate a legacy API token](https://api.slack.com/custom-integrations/legacy-tokens) for your app and use it for some interactions.
|
96
108
|
|
97
109
|
```ruby
|
98
110
|
Slack.configure do |config|
|
@@ -115,14 +127,18 @@ logger | An optional logger, defaults to `::Logger.new(STDOUT)` at `Logger
|
|
115
127
|
|
116
128
|
The Slack Web API allows you to build applications that interact with Slack.
|
117
129
|
|
118
|
-
####
|
130
|
+
#### Web Client Examples
|
131
|
+
|
132
|
+
Here are some examples of how to use the web client with the Web API.
|
133
|
+
|
134
|
+
##### Test Auth
|
119
135
|
|
120
136
|
```ruby
|
121
137
|
client = Slack::Web::Client.new
|
122
138
|
client.auth_test
|
123
139
|
```
|
124
140
|
|
125
|
-
|
141
|
+
##### Send Messages
|
126
142
|
|
127
143
|
Send messages with [chat_PostMessage](https://api.slack.com/methods/chat.postMessage).
|
128
144
|
|
@@ -134,7 +150,7 @@ See a fully working example in [examples/hi_web](examples/hi_web/hi.rb).
|
|
134
150
|
|
135
151
|
![](examples/hi_web/hi.gif)
|
136
152
|
|
137
|
-
|
153
|
+
##### List Channels
|
138
154
|
|
139
155
|
List channels with [channels_list](https://api.slack.com/methods/channels.list).
|
140
156
|
|
@@ -144,7 +160,7 @@ channels = client.channels_list.channels
|
|
144
160
|
general_channel = channels.detect { |c| c.name == 'general' }
|
145
161
|
```
|
146
162
|
|
147
|
-
|
163
|
+
##### Upload a File
|
148
164
|
|
149
165
|
Upload a file with [files_upload](https://api.slack.com/methods/files.upload).
|
150
166
|
|
@@ -159,7 +175,7 @@ client.files_upload(
|
|
159
175
|
)
|
160
176
|
```
|
161
177
|
|
162
|
-
|
178
|
+
##### Get Channel Info
|
163
179
|
|
164
180
|
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 `channels_list` in order to locate the channel ID.
|
165
181
|
|
@@ -171,7 +187,7 @@ client.channels_info(channel: 'C04KB5X4D') # calls channels_info
|
|
171
187
|
client.channels_info(channel: '#general') # calls channels_list followed by channels_info
|
172
188
|
```
|
173
189
|
|
174
|
-
|
190
|
+
##### Get User Info
|
175
191
|
|
176
192
|
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.
|
177
193
|
|
@@ -183,7 +199,7 @@ client.users_info(user: 'U092BDCLV') # calls users_info
|
|
183
199
|
client.users_info(user: '@dblock') # calls users_list followed by users_info
|
184
200
|
```
|
185
201
|
|
186
|
-
|
202
|
+
##### Search for a User
|
187
203
|
|
188
204
|
Constructs an in-memory index of users and searches it. If you want to use this functionality, add the [picky](https://github.com/floere/picky) gem to your project's Gemfile.
|
189
205
|
|
@@ -191,7 +207,7 @@ Constructs an in-memory index of users and searches it. If you want to use this
|
|
191
207
|
client.users_search(user: 'dblock')
|
192
208
|
```
|
193
209
|
|
194
|
-
|
210
|
+
##### Other
|
195
211
|
|
196
212
|
Refer to the [Slack Web API Method Reference](https://api.slack.com/methods) for the list of all available functions.
|
197
213
|
|
@@ -261,11 +277,53 @@ end
|
|
261
277
|
all_members # many thousands of team members retrieved 10 at a time
|
262
278
|
```
|
263
279
|
|
280
|
+
#### Character Encoding
|
281
|
+
|
282
|
+
Note that Slack expects `text` to be UTF-8 encoded. If your messages appear with text such as `BAD+11` in Slack, check `text.encoding` and `.encode(Encoding::UTF_8)` your messages before sending them to Slack.
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
text = 'characters such as "Ñ", "Á", "É"'
|
286
|
+
text.encoding
|
287
|
+
=> #<Encoding:UTF-8>
|
288
|
+
client.chat_postMessage(channel: '#general', text: text, as_user: true)
|
289
|
+
# renders 'characters such as "Ñ", "Á", "É"' in Slack
|
290
|
+
|
291
|
+
text = text.encode(Encoding::ISO_8859_1)
|
292
|
+
text.encoding
|
293
|
+
# => #<Encoding:ISO-8859-1>
|
294
|
+
client.chat_postMessage(channel: '#general', text: text, as_user: true)
|
295
|
+
# renders 'characters such as "BAD+11", "", "BAD+9"' in Slack
|
296
|
+
```
|
297
|
+
|
264
298
|
#### Error Handling
|
265
299
|
|
266
|
-
|
300
|
+
##### Slack Errors
|
267
301
|
|
268
|
-
If
|
302
|
+
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:
|
303
|
+
|
304
|
+
```ruby
|
305
|
+
rescue Slack::Web::Api::Errors::AccountInactive => e
|
306
|
+
# deal with inactive account
|
307
|
+
end
|
308
|
+
```
|
309
|
+
|
310
|
+
All of these errors inherit from `Slack::Web::Api::Errors::SlackError`, so you can handle or silence all errors if necessary:
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
rescue Slack::Web::Api::Errors::SlackError => e
|
314
|
+
# capture all Slack errors
|
315
|
+
end
|
316
|
+
```
|
317
|
+
|
318
|
+
If there's a new error type that is not yet known by this library, then it will raise `Slack::Web::Api::Errors::SlackError`. (Update the Web API if you find that errors are missing — see [CONTRIBUTING](CONTRIBUTING.md).)
|
319
|
+
|
320
|
+
In all of these cases the error message contains the error code, which is also accessible with `slack_error.error`. In case of multiple errors, the error message contains the error codes separated by commas, or they are accessible as an array with `slack_error.errors`. The original response is also accessible using the `response` attribute. The `response_metadata` is accessible with `slack_error.response_metadata`.
|
321
|
+
|
322
|
+
##### Rate Limiting
|
323
|
+
|
324
|
+
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`.)
|
325
|
+
|
326
|
+
##### Other Errors
|
269
327
|
|
270
328
|
In any other case, a `Faraday::ClientError` will be raised. This may be the case if Slack is temporarily unavailable, for example.
|
271
329
|
|
@@ -374,9 +432,11 @@ See a fully working example in [examples/hi_real_time](examples/hi_real_time/hi.
|
|
374
432
|
##### `websocket_ping`
|
375
433
|
This setting determines how long the socket can be idle before sending a ping message to confirm it's still connected.
|
376
434
|
|
377
|
-
It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping
|
435
|
+
It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping` the client will attempt to reestablish it's connection to the message server.
|
436
|
+
|
437
|
+
Note that the ping may take between `websocket_ping` and `websocket_ping * 3/2` seconds to actually trigger when there is no activity on the socket. This is because the timer that checks whether to ping is triggered at every `websocket_ping / 2` interval.
|
378
438
|
|
379
|
-
To disable this feature
|
439
|
+
To disable this feature set `websocket_ping` to 0.
|
380
440
|
|
381
441
|
### Connection Methods
|
382
442
|
|
@@ -438,7 +498,7 @@ Slack::RealTime.configure do |config|
|
|
438
498
|
end
|
439
499
|
```
|
440
500
|
|
441
|
-
Use `client.start_async` instead of `client.start!`. A good example of such application is [slack-bot-server](https://github.com/
|
501
|
+
Use `client.start_async` instead of `client.start!`. A good example of such application is [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server).
|
442
502
|
|
443
503
|
```ruby
|
444
504
|
client = Slack::RealTime::Client.new
|
@@ -513,7 +573,7 @@ Slack::Events::Request.new(http_request,
|
|
513
573
|
signature_expires_in: signature_expires_in)
|
514
574
|
```
|
515
575
|
|
516
|
-
The `verify!` call may raise `Slack::Events::MissingSigningSecret`, `Slack::Events::InvalidSignature` or `Slack::Events::TimestampExpired` errors.
|
576
|
+
The `verify!` call may raise `Slack::Events::Request::MissingSigningSecret`, `Slack::Events::Request::InvalidSignature` or `Slack::Events::Request::TimestampExpired` errors.
|
517
577
|
|
518
578
|
### Message Parsing
|
519
579
|
|