slack-ruby-client 0.11.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (392) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/danger.yml +19 -0
  4. data/.github/workflows/integtest.yml +25 -0
  5. data/.github/workflows/rubocop.yml +13 -0
  6. data/.github/workflows/test.yml +34 -0
  7. data/.gitignore +6 -3
  8. data/.rubocop.yml +36 -2
  9. data/.rubocop_todo.yml +186 -54
  10. data/CHANGELOG.md +156 -31
  11. data/CONTRIBUTING.md +20 -9
  12. data/Dangerfile +2 -0
  13. data/Gemfile +27 -6
  14. data/Gemfile.danger +6 -0
  15. data/LICENSE.md +1 -1
  16. data/README.md +199 -52
  17. data/RELEASING.md +2 -2
  18. data/Rakefile +2 -1
  19. data/UPGRADING.md +89 -3
  20. data/bin/commands/admin_analytics.rb +16 -0
  21. data/bin/commands/admin_apps.rb +51 -0
  22. data/bin/commands/admin_apps_approved.rb +17 -0
  23. data/bin/commands/admin_apps_requests.rb +28 -0
  24. data/bin/commands/admin_apps_restricted.rb +17 -0
  25. data/bin/commands/admin_auth_policy.rb +39 -0
  26. data/bin/commands/admin_barriers.rb +47 -0
  27. data/bin/commands/admin_conversations.rb +170 -0
  28. data/bin/commands/admin_conversations_ekm.rb +17 -0
  29. data/bin/commands/admin_conversations_restrictAccess.rb +37 -0
  30. data/bin/commands/admin_conversations_whitelist.rb +37 -0
  31. data/bin/commands/admin_emoji.rb +54 -0
  32. data/bin/commands/admin_inviteRequests.rb +36 -0
  33. data/bin/commands/admin_inviteRequests_approved.rb +16 -0
  34. data/bin/commands/admin_inviteRequests_denied.rb +16 -0
  35. data/bin/commands/admin_teams.rb +27 -0
  36. data/bin/commands/admin_teams_admins.rb +16 -0
  37. data/bin/commands/admin_teams_owners.rb +16 -0
  38. data/bin/commands/admin_teams_settings.rb +64 -0
  39. data/bin/commands/admin_usergroups.rb +48 -0
  40. data/bin/commands/admin_users.rb +98 -0
  41. data/bin/commands/admin_users_session.rb +78 -0
  42. data/bin/commands/admin_users_unsupportedVersions.rb +15 -0
  43. data/bin/commands/api.rb +1 -1
  44. data/bin/commands/apps.rb +15 -0
  45. data/bin/commands/apps_connections.rb +13 -0
  46. data/bin/commands/apps_event_authorizations.rb +16 -0
  47. data/bin/commands/apps_manifest.rb +52 -0
  48. data/bin/commands/apps_permissions.rb +1 -0
  49. data/bin/commands/apps_permissions_resources.rb +15 -0
  50. data/bin/commands/apps_permissions_scopes.rb +13 -0
  51. data/bin/commands/apps_permissions_users.rb +26 -0
  52. data/bin/commands/auth.rb +1 -0
  53. data/bin/commands/auth_teams.rb +16 -0
  54. data/bin/commands/bookmarks.rb +52 -0
  55. data/bin/commands/bots.rb +2 -0
  56. data/bin/commands/calls.rb +52 -0
  57. data/bin/commands/calls_participants.rb +25 -0
  58. data/bin/commands/channels.rb +1 -153
  59. data/bin/commands/chat.rb +57 -12
  60. data/bin/commands/chat_scheduledMessages.rb +19 -0
  61. data/bin/commands/conversations.rb +75 -4
  62. data/bin/commands/dialog.rb +1 -0
  63. data/bin/commands/dnd.rb +6 -3
  64. data/bin/commands/emoji.rb +1 -0
  65. data/bin/commands/files.rb +14 -19
  66. data/bin/commands/files_comments.rb +1 -21
  67. data/bin/commands/files_remote.rb +78 -0
  68. data/bin/commands/groups.rb +1 -159
  69. data/bin/commands/im.rb +1 -62
  70. data/bin/commands/migration.rb +2 -0
  71. data/bin/commands/mpim.rb +1 -58
  72. data/bin/commands/oauth.rb +4 -15
  73. data/bin/commands/oauth_v2.rb +29 -0
  74. data/bin/commands/openid_connect.rb +27 -0
  75. data/bin/commands/pins.rb +3 -6
  76. data/bin/commands/reactions.rb +5 -3
  77. data/bin/commands/reminders.rb +7 -0
  78. data/bin/commands/rtm.rb +7 -4
  79. data/bin/commands/search.rb +8 -3
  80. data/bin/commands/stars.rb +10 -6
  81. data/bin/commands/team.rb +6 -0
  82. data/bin/commands/team_billing.rb +13 -0
  83. data/bin/commands/team_preferences.rb +13 -0
  84. data/bin/commands/team_profile.rb +1 -0
  85. data/bin/commands/tooling_tokens.rb +14 -0
  86. data/bin/commands/usergroups.rb +7 -1
  87. data/bin/commands/usergroups_users.rb +3 -0
  88. data/bin/commands/users.rb +21 -6
  89. data/bin/commands/users_admin.rb +1 -0
  90. data/bin/commands/users_prefs.rb +1 -0
  91. data/bin/commands/users_profile.rb +7 -6
  92. data/bin/commands/views.rb +48 -0
  93. data/bin/commands/workflows.rb +38 -0
  94. data/bin/commands.rb +40 -5
  95. data/bin/slack +2 -3
  96. data/examples/hi_real_time_and_web/Gemfile +1 -0
  97. data/examples/hi_real_time_and_web/hi.rb +7 -3
  98. data/examples/{hi_real_time_async_eventmachine → hi_real_time_async_async}/Gemfile +2 -1
  99. data/examples/{hi_real_time_async_celluloid → hi_real_time_async_async}/Procfile +0 -0
  100. data/examples/{hi_real_time_async_celluloid → hi_real_time_async_async}/hi.rb +12 -7
  101. data/examples/hi_web/Gemfile +1 -0
  102. data/examples/hi_web/hi.rb +1 -0
  103. data/examples/new_ticket/Gemfile +1 -0
  104. data/examples/new_ticket/new_ticket.rb +1 -0
  105. data/lib/slack/config.rb +2 -2
  106. data/lib/slack/events/config.rb +32 -0
  107. data/lib/slack/events/request.rb +72 -0
  108. data/lib/slack/logger.rb +6 -5
  109. data/lib/slack/messages/formatting.rb +1 -1
  110. data/lib/slack/messages/message.rb +1 -4
  111. data/lib/slack/real_time/api/message.rb +3 -1
  112. data/lib/slack/real_time/api/message_id.rb +1 -0
  113. data/lib/slack/real_time/api/ping.rb +5 -2
  114. data/lib/slack/real_time/api/typing.rb +3 -1
  115. data/lib/slack/real_time/client.rb +103 -34
  116. data/lib/slack/real_time/concurrency/async.rb +138 -0
  117. data/lib/slack/real_time/concurrency.rb +2 -2
  118. data/lib/slack/real_time/config.rb +6 -10
  119. data/lib/slack/real_time/models/base.rb +1 -4
  120. data/lib/slack/real_time/models/bot.rb +1 -0
  121. data/lib/slack/real_time/models/channel.rb +1 -0
  122. data/lib/slack/real_time/models/group.rb +1 -0
  123. data/lib/slack/real_time/models/im.rb +1 -0
  124. data/lib/slack/real_time/models/team.rb +1 -0
  125. data/lib/slack/real_time/models/user.rb +1 -0
  126. data/lib/slack/real_time/models.rb +1 -0
  127. data/lib/slack/real_time/socket.rb +45 -17
  128. data/lib/slack/real_time/stores/base.rb +5 -7
  129. data/lib/slack/real_time/stores/starter.rb +27 -3
  130. data/lib/slack/real_time/stores/store.rb +43 -25
  131. data/lib/slack/real_time/stores.rb +1 -0
  132. data/lib/slack/version.rb +2 -1
  133. data/lib/slack/web/api/endpoints/admin_analytics.rb +28 -0
  134. data/lib/slack/web/api/endpoints/admin_apps.rb +78 -0
  135. data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
  136. data/lib/slack/web/api/endpoints/admin_apps_requests.rb +51 -0
  137. data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
  138. data/lib/slack/web/api/endpoints/admin_auth_policy.rb +72 -0
  139. data/lib/slack/web/api/endpoints/admin_barriers.rb +82 -0
  140. data/lib/slack/web/api/endpoints/admin_conversations.rb +262 -0
  141. data/lib/slack/web/api/endpoints/admin_conversations_ekm.rb +35 -0
  142. data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +61 -0
  143. data/lib/slack/web/api/endpoints/admin_conversations_whitelist.rb +64 -0
  144. data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -0
  145. data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +61 -0
  146. data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
  147. data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
  148. data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
  149. data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
  150. data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
  151. data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
  152. data/lib/slack/web/api/endpoints/admin_usergroups.rb +77 -0
  153. data/lib/slack/web/api/endpoints/admin_users.rb +163 -0
  154. data/lib/slack/web/api/endpoints/admin_users_session.rb +122 -0
  155. data/lib/slack/web/api/endpoints/admin_users_unsupportedVersions.rb +25 -0
  156. data/lib/slack/web/api/endpoints/api.rb +2 -3
  157. data/lib/slack/web/api/endpoints/apps.rb +27 -0
  158. data/lib/slack/web/api/endpoints/apps_connections.rb +21 -0
  159. data/lib/slack/web/api/endpoints/apps_event_authorizations.rb +34 -0
  160. data/lib/slack/web/api/endpoints/apps_manifest.rb +77 -0
  161. data/lib/slack/web/api/endpoints/apps_permissions.rb +1 -0
  162. data/lib/slack/web/api/endpoints/apps_permissions_resources.rb +31 -0
  163. data/lib/slack/web/api/endpoints/apps_permissions_scopes.rb +21 -0
  164. data/lib/slack/web/api/endpoints/apps_permissions_users.rb +50 -0
  165. data/lib/slack/web/api/endpoints/auth.rb +2 -1
  166. data/lib/slack/web/api/endpoints/auth_teams.rb +33 -0
  167. data/lib/slack/web/api/endpoints/bookmarks.rb +86 -0
  168. data/lib/slack/web/api/endpoints/bots.rb +4 -1
  169. data/lib/slack/web/api/endpoints/calls.rb +83 -0
  170. data/lib/slack/web/api/endpoints/calls_participants.rb +42 -0
  171. data/lib/slack/web/api/endpoints/channels.rb +2 -243
  172. data/lib/slack/web/api/endpoints/chat.rb +145 -46
  173. data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +40 -0
  174. data/lib/slack/web/api/endpoints/conversations.rb +152 -39
  175. data/lib/slack/web/api/endpoints/dialog.rb +3 -2
  176. data/lib/slack/web/api/endpoints/dnd.rb +9 -4
  177. data/lib/slack/web/api/endpoints/emoji.rb +1 -0
  178. data/lib/slack/web/api/endpoints/files.rb +35 -28
  179. data/lib/slack/web/api/endpoints/files_comments.rb +2 -34
  180. data/lib/slack/web/api/endpoints/files_remote.rb +127 -0
  181. data/lib/slack/web/api/endpoints/groups.rb +1 -243
  182. data/lib/slack/web/api/endpoints/im.rb +1 -101
  183. data/lib/slack/web/api/endpoints/migration.rb +5 -2
  184. data/lib/slack/web/api/endpoints/mpim.rb +1 -86
  185. data/lib/slack/web/api/endpoints/oauth.rb +8 -30
  186. data/lib/slack/web/api/endpoints/oauth_v2.rb +48 -0
  187. data/lib/slack/web/api/endpoints/openid_connect.rb +42 -0
  188. data/lib/slack/web/api/endpoints/pins.rb +8 -15
  189. data/lib/slack/web/api/endpoints/reactions.rb +29 -18
  190. data/lib/slack/web/api/endpoints/reminders.rb +18 -5
  191. data/lib/slack/web/api/endpoints/rtm.rb +14 -9
  192. data/lib/slack/web/api/endpoints/search.rb +30 -15
  193. data/lib/slack/web/api/endpoints/stars.rb +23 -10
  194. data/lib/slack/web/api/endpoints/team.rb +15 -4
  195. data/lib/slack/web/api/endpoints/team_billing.rb +21 -0
  196. data/lib/slack/web/api/endpoints/team_preferences.rb +21 -0
  197. data/lib/slack/web/api/endpoints/team_profile.rb +2 -1
  198. data/lib/slack/web/api/endpoints/tooling_tokens.rb +24 -0
  199. data/lib/slack/web/api/endpoints/usergroups.rb +27 -16
  200. data/lib/slack/web/api/endpoints/usergroups_users.rb +10 -5
  201. data/lib/slack/web/api/endpoints/users.rb +44 -17
  202. data/lib/slack/web/api/endpoints/users_admin.rb +1 -0
  203. data/lib/slack/web/api/endpoints/users_prefs.rb +1 -0
  204. data/lib/slack/web/api/endpoints/users_profile.rb +9 -8
  205. data/lib/slack/web/api/endpoints/views.rb +97 -0
  206. data/lib/slack/web/api/endpoints/workflows.rb +61 -0
  207. data/lib/slack/web/api/endpoints.rb +80 -12
  208. data/lib/slack/web/api/error.rb +1 -0
  209. data/lib/slack/web/api/errors/server_error.rb +37 -0
  210. data/lib/slack/web/api/errors/slack_error.rb +14 -1
  211. data/lib/slack/web/api/errors/too_many_requests_error.rb +2 -4
  212. data/lib/slack/web/api/errors.rb +1066 -0
  213. data/lib/slack/web/api/mixins/{channels.id.rb → conversations.id.rb} +4 -5
  214. data/lib/slack/web/api/mixins/ids.id.rb +3 -2
  215. data/lib/slack/web/api/mixins/users.id.rb +2 -3
  216. data/lib/slack/web/api/mixins/users.search.rb +1 -0
  217. data/lib/slack/web/api/mixins.rb +2 -2
  218. data/lib/slack/web/api/patches/chat.1.patch +70 -0
  219. data/lib/slack/web/api/patches/views.1.view-json.patch +40 -0
  220. data/lib/slack/web/api/patches/views.1.views-published.patch +16 -0
  221. data/lib/slack/web/api/templates/command.erb +1 -0
  222. data/lib/slack/web/api/templates/commands.erb +1 -0
  223. data/lib/slack/web/api/templates/endpoints.erb +2 -2
  224. data/lib/slack/web/api/templates/errors.erb +20 -0
  225. data/lib/slack/web/api/templates/method.erb +5 -1
  226. data/lib/slack/web/api/templates/method_spec.erb +2 -1
  227. data/lib/slack/web/client.rb +2 -1
  228. data/lib/slack/web/config.rb +3 -0
  229. data/lib/slack/web/faraday/connection.rb +24 -20
  230. data/lib/slack/web/faraday/request.rb +5 -1
  231. data/lib/slack/web/faraday/response/raise_error.rb +14 -7
  232. data/lib/slack/web/faraday/response/wrap_error.rb +24 -0
  233. data/lib/slack/web/pagination/cursor.rb +7 -7
  234. data/lib/slack-ruby-client.rb +12 -5
  235. data/lib/slack.rb +1 -0
  236. data/lib/slack_ruby_client.rb +1 -0
  237. data/lib/tasks/git.rake +1 -0
  238. data/lib/tasks/real_time.rake +16 -8
  239. data/lib/tasks/update.rake +1 -0
  240. data/lib/tasks/web.rake +39 -10
  241. data/screenshots/create-app.png +0 -0
  242. data/slack-ruby-client.gemspec +7 -12
  243. data/spec/fixtures/slack/web/429_error.yml +50 -54
  244. data/spec/fixtures/slack/web/auth_test_error.yml +51 -18
  245. data/spec/fixtures/slack/web/auth_test_success.yml +50 -26
  246. data/spec/fixtures/slack/web/conversations_info.yml +167 -0
  247. data/spec/fixtures/slack/web/conversations_setTopic.yml +84 -0
  248. data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +172 -0
  249. data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +253 -0
  250. data/spec/fixtures/slack/web/paginated_users_list.yml +501 -69
  251. data/spec/fixtures/slack/web/rtm_connect.yml +267 -30
  252. data/spec/fixtures/slack/web/rtm_start.yml +771 -60
  253. data/spec/fixtures/slack/web/users_info.yml +153 -69
  254. data/spec/fixtures/slack/web/users_list.yml +102 -41
  255. data/spec/fixtures/slack/web/views_open_error.yml +83 -0
  256. data/spec/integration/integration_spec.rb +116 -48
  257. data/spec/slack/config_spec.rb +2 -0
  258. data/spec/slack/events/config_spec.rb +33 -0
  259. data/spec/slack/events/request_spec.rb +184 -0
  260. data/spec/slack/messages/formatting_spec.rb +25 -14
  261. data/spec/slack/real_time/api/message_spec.rb +6 -1
  262. data/spec/slack/real_time/api/ping_spec.rb +2 -0
  263. data/spec/slack/real_time/api/typing_spec.rb +5 -1
  264. data/spec/slack/real_time/client_spec.rb +258 -62
  265. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +2 -0
  266. data/spec/slack/real_time/concurrency/with_concurrency_spec.rb +10 -0
  267. data/spec/slack/real_time/concurrency/without_concurrency_spec.rb +10 -0
  268. data/spec/slack/real_time/event_handlers/bot_spec.rb +3 -2
  269. data/spec/slack/real_time/event_handlers/channel_spec.rb +14 -11
  270. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +2 -1
  271. data/spec/slack/real_time/event_handlers/group_spec.rb +6 -5
  272. data/spec/slack/real_time/event_handlers/im_spec.rb +10 -9
  273. data/spec/slack/real_time/event_handlers/team_spec.rb +3 -1
  274. data/spec/slack/real_time/event_handlers/user_spec.rb +3 -2
  275. data/spec/slack/real_time/rtm_connect_spec.rb +2 -1
  276. data/spec/slack/real_time/rtm_start_spec.rb +2 -1
  277. data/spec/slack/real_time/store_spec.rb +4 -3
  278. data/spec/slack/slack_spec.rb +42 -8
  279. data/spec/slack/version_spec.rb +2 -1
  280. data/spec/slack/web/api/endpoints/admin_analytics_spec.rb +13 -0
  281. data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +8 -0
  282. data/spec/slack/web/api/endpoints/admin_apps_requests_spec.rb +13 -0
  283. data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
  284. data/spec/slack/web/api/endpoints/admin_apps_spec.rb +18 -0
  285. data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +35 -0
  286. data/spec/slack/web/api/endpoints/admin_barriers_spec.rb +38 -0
  287. data/spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb +8 -0
  288. data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +32 -0
  289. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +98 -0
  290. data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +37 -0
  291. data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +8 -0
  292. data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +8 -0
  293. data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +18 -0
  294. data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +13 -0
  295. data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +13 -0
  296. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +53 -0
  297. data/spec/slack/web/api/endpoints/admin_teams_spec.rb +16 -0
  298. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +37 -0
  299. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +41 -0
  300. data/spec/slack/web/api/endpoints/admin_users_spec.rb +67 -0
  301. data/spec/slack/web/api/endpoints/admin_users_unsupportedVersions_spec.rb +8 -0
  302. data/spec/slack/web/api/endpoints/api_spec.rb +1 -0
  303. data/spec/slack/web/api/endpoints/apps_connections_spec.rb +8 -0
  304. data/spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb +13 -0
  305. data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +36 -0
  306. data/spec/slack/web/api/endpoints/apps_spec.rb +16 -0
  307. data/spec/slack/web/api/endpoints/auth_teams_spec.rb +8 -0
  308. data/spec/slack/web/api/endpoints/bookmarks_spec.rb +40 -0
  309. data/spec/slack/web/api/endpoints/bots_spec.rb +1 -0
  310. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +24 -0
  311. data/spec/slack/web/api/endpoints/calls_spec.rb +31 -0
  312. data/spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb +8 -0
  313. data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +9 -7
  314. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +131 -39
  315. data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +13 -0
  316. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +16 -6
  317. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +8 -3
  318. data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +103 -0
  319. data/spec/slack/web/api/endpoints/dnd_spec.rb +4 -3
  320. data/spec/slack/web/api/endpoints/emoji_spec.rb +1 -0
  321. data/spec/slack/web/api/endpoints/files_comments_spec.rb +3 -21
  322. data/spec/slack/web/api/endpoints/files_remote_spec.rb +24 -0
  323. data/spec/slack/web/api/endpoints/files_spec.rb +5 -4
  324. data/spec/slack/web/api/endpoints/migration_spec.rb +1 -0
  325. data/spec/slack/web/api/endpoints/oauth_spec.rb +1 -22
  326. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +16 -0
  327. data/spec/slack/web/api/endpoints/openid_connect_spec.rb +8 -0
  328. data/spec/slack/web/api/endpoints/pins_spec.rb +1 -0
  329. data/spec/slack/web/api/endpoints/reactions_spec.rb +8 -1
  330. data/spec/slack/web/api/endpoints/reminders_spec.rb +3 -2
  331. data/spec/slack/web/api/endpoints/rtm_spec.rb +1 -0
  332. data/spec/slack/web/api/endpoints/search_spec.rb +1 -0
  333. data/spec/slack/web/api/endpoints/stars_spec.rb +1 -0
  334. data/spec/slack/web/api/endpoints/team_billing_spec.rb +8 -0
  335. data/spec/slack/web/api/endpoints/team_preferences_spec.rb +8 -0
  336. data/spec/slack/web/api/endpoints/team_profile_spec.rb +1 -0
  337. data/spec/slack/web/api/endpoints/team_spec.rb +1 -0
  338. data/spec/slack/web/api/endpoints/tooling_tokens_spec.rb +13 -0
  339. data/spec/slack/web/api/endpoints/usergroups_spec.rb +1 -0
  340. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +3 -2
  341. data/spec/slack/web/api/endpoints/users_admin_spec.rb +1 -0
  342. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +1 -0
  343. data/spec/slack/web/api/endpoints/users_profile_spec.rb +1 -0
  344. data/spec/slack/web/api/endpoints/workflows_spec.rb +26 -0
  345. data/spec/slack/web/api/error_spec.rb +7 -7
  346. data/spec/slack/web/api/errors/slack_error_spec.rb +26 -7
  347. data/spec/slack/web/api/mixins/conversations_list_spec.rb +21 -0
  348. data/spec/slack/web/api/mixins/conversations_spec.rb +43 -0
  349. data/spec/slack/web/api/mixins/users_spec.rb +25 -14
  350. data/spec/slack/web/api/pagination/cursor_spec.rb +43 -15
  351. data/spec/slack/web/client_spec.rb +186 -19
  352. data/spec/slack/web/faraday/request_spec.rb +80 -0
  353. data/spec/slack/web/faraday/response/raise_error_spec.rb +48 -12
  354. data/spec/spec_helper.rb +9 -2
  355. data/spec/support/queue_with_timeout.rb +5 -4
  356. data/spec/support/real_time/concurrency/mock.rb +1 -0
  357. data/spec/support/real_time/connected_client.rb +6 -6
  358. data/spec/support/real_time/event.rb +1 -0
  359. data/spec/support/token.rb +1 -0
  360. data/spec/support/vcr.rb +37 -1
  361. metadata +177 -231
  362. data/.travis.yml +0 -30
  363. data/examples/hi_real_time/Gemfile +0 -5
  364. data/examples/hi_real_time/hi.gif +0 -0
  365. data/examples/hi_real_time/hi.rb +0 -37
  366. data/examples/hi_real_time_async_celluloid/Gemfile +0 -6
  367. data/examples/hi_real_time_async_eventmachine/Procfile +0 -2
  368. data/examples/hi_real_time_async_eventmachine/hi.rb +0 -36
  369. data/lib/slack/real_time/concurrency/celluloid.rb +0 -117
  370. data/lib/slack/real_time/concurrency/eventmachine.rb +0 -60
  371. data/lib/slack/web/api/mixins/channels.id.json +0 -20
  372. data/lib/slack/web/api/mixins/groups.id.json +0 -20
  373. data/lib/slack/web/api/mixins/groups.id.rb +0 -26
  374. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +0 -13
  375. data/lib/slack/web/api/patches/chat.2.attachments-json.patch +0 -17
  376. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +0 -21
  377. data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +0 -17
  378. data/screenshots/register-bot.png +0 -0
  379. data/spec/fixtures/slack/web/503_error.yml +0 -14
  380. data/spec/fixtures/slack/web/channels_info.yml +0 -46
  381. data/spec/fixtures/slack/web/groups_info.yml +0 -43
  382. data/spec/slack/real_time/concurrency/celluloid_spec.rb +0 -62
  383. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +0 -47
  384. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +0 -15
  385. data/spec/slack/web/api/endpoints/conversations_spec.rb +0 -100
  386. data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +0 -11
  387. data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +0 -11
  388. data/spec/slack/web/api/endpoints/im_spec.rb +0 -38
  389. data/spec/slack/web/api/endpoints/mpim_spec.rb +0 -38
  390. data/spec/slack/web/api/errors/service_unavailable_spec.rb +0 -14
  391. data/spec/slack/web/api/mixins/channels_spec.rb +0 -31
  392. data/spec/slack/web/api/mixins/groups_spec.rb +0 -31
data/README.md CHANGED
@@ -2,23 +2,76 @@ Slack Ruby Client
2
2
  =================
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/slack-ruby-client.svg)](http://badge.fury.io/rb/slack-ruby-client)
5
- [![Build Status](https://travis-ci.org/slack-ruby/slack-ruby-client.svg?branch=master)](https://travis-ci.org/slack-ruby/slack-ruby-client)
5
+ [![Integration Tests](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/integtest.yml/badge.svg?branch=master)](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/integtest.yml)
6
+ [![Tests](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml)
6
7
  [![Code Climate](https://codeclimate.com/github/slack-ruby/slack-ruby-client/badges/gpa.svg)](https://codeclimate.com/github/slack-ruby/slack-ruby-client)
7
8
 
8
- A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messaging](https://api.slack.com/rtm) 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
+ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messaging](https://api.slack.com/rtm) and [Events](https://api.slack.com/events-api) APIs. Comes with a handy command-line client, too. If you are not familiar with these concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
9
10
 
10
11
  ![](slack.png)
11
12
 
13
+ # Table of Contents
14
+
15
+ - [Useful to Me?](#useful-to-me)
16
+ - [Stable Release](#stable-release)
17
+ - [Installation](#installation)
18
+ - [Usage](#usage)
19
+ - [Create a New Bot Integration](#create-a-new-bot-integration)
20
+ - [OAuth Code Grant](#oauth-code-grant)
21
+ - [Using the Legacy API Token](#using-the-legacy-api-token)
22
+ - [Global Settings](#global-settings)
23
+ - [Web Client](#web-client)
24
+ - [Web Client Examples](#web-client-examples)
25
+ - [Test Auth](#test-auth)
26
+ - [Send Messages](#send-messages)
27
+ - [List Channels](#list-channels)
28
+ - [Upload a File](#upload-a-file)
29
+ - [Get Channel Info](#get-channel-info)
30
+ - [Get User Info](#get-user-info)
31
+ - [Search for a User](#search-for-a-user)
32
+ - [Other](#other)
33
+ - [Web Client Options](#web-client-options)
34
+ - [Pagination Support](#pagination-support)
35
+ - [Character Encoding](#character-encoding)
36
+ - [Error Handling](#error-handling)
37
+ - [Slack Errors](#slack-errors)
38
+ - [Rate Limiting](#rate-limiting)
39
+ - [Other Errors](#other-errors)
40
+ - [RealTime Client](#realtime-client)
41
+ - [Slack::RealTime::Stores::Store](#slackrealtimestoresstore)
42
+ - [Slack::RealTime::Stores::Starter](#slackrealtimestoresstarter)
43
+ - [Configuring Slack::RealTime::Client](#configuring-slackrealtimeclient)
44
+ - [Caveats](#caveats)
45
+ - [websocket_ping](#websocket_ping)
46
+ - [Connection Methods](#connection-methods)
47
+ - [Combining RealTime and Web Clients](#combining-realtime-and-web-clients)
48
+ - [Large Team Considerations](#large-team-considerations)
49
+ - [Concurrency](#concurrency)
50
+ - [Async](#async)
51
+ - [Events API](#events-api)
52
+ - [Configuring Slack::Events](#configuring-slackevents)
53
+ - [Verifying the Request Signature](#verifying-the-request-signature)
54
+ - [Message Parsing](#message-parsing)
55
+ - [Command-Line Client](#command-line-client)
56
+ - [Authenticate with Slack](#authenticate-with-slack)
57
+ - [Send a Message](#send-a-message)
58
+ - [Get Channel Id](#get-channel-id)
59
+ - [Get Channel Info](#get-channel-info-1)
60
+ - [List Users](#list-users)
61
+ - [History](#history)
62
+ - [Contributing](#contributing)
63
+ - [Copyright and License](#copyright-and-license)
64
+
12
65
  ## Useful to Me?
13
66
 
14
- * This piece of the puzzle will help you send messages to Slack via the Web API and send and receive messages via the Real Time API.
15
- * If you're trying to respond to slash commands, just write a basic web application and use this library to call the Slack Web API.
16
- * If you're trying to build a Real Time bot, use [slack-ruby-bot](https://github.com/dblock/slack-ruby-bot), which uses this library.
17
- * If you're trying to roll out a full service with Slack button integration to multiple teams, check out [slack-ruby-bot-server](https://github.com/dblock/slack-ruby-bot-server), which is built on top of slack-ruby-bot, which uses this library.
67
+ * 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.
68
+ * 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.
69
+ * 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.
70
+ * 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.
18
71
 
19
72
  ## Stable Release
20
73
 
21
- You're reading the documentation for the **next** release of slack-ruby-client. Please see the documentation for the [last stable release, v0.11.1](https://github.com/slack-ruby/slack-ruby-client/blob/v0.11.1/README.md) unless you're integrating with HEAD. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
74
+ You're reading the documentation for the **stable** release of slack-ruby-client, 1.1.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
22
75
 
23
76
  ## Installation
24
77
 
@@ -28,11 +81,10 @@ Add to Gemfile.
28
81
  gem 'slack-ruby-client'
29
82
  ```
30
83
 
31
- If you're going to be using the RealTime client, add either `eventmachine` and `faye-websocket` or `celluloid-io`. See below for more information about concurrency.
84
+ If you're going to be using the RealTime client, add `async-websocket`. See below for more information about concurrency.
32
85
 
33
86
  ```
34
- gem 'eventmachine'
35
- gem 'faye-websocket'
87
+ gem 'async-websocket', '~> 0.8.0'
36
88
  ```
37
89
 
38
90
  Run `bundle install`.
@@ -41,11 +93,17 @@ Run `bundle install`.
41
93
 
42
94
  ### Create a New Bot Integration
43
95
 
44
- This is something done in Slack, under [integrations](https://my.slack.com/services). Create a [new bot](https://my.slack.com/services/new/bot), and note its API token.
96
+ To integrate your bot with Slack, you must first create a new [Slack App](https://api.slack.com/apps).
97
+
98
+ ![](screenshots/create-app.png)
99
+
100
+ ### OAuth Code Grant
45
101
 
46
- ![](screenshots/register-bot.png)
102
+ 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).
47
103
 
48
- ### Use the API Token
104
+ ### Using the Legacy API Token
105
+
106
+ 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.
49
107
 
50
108
  ```ruby
51
109
  Slack.configure do |config|
@@ -68,14 +126,18 @@ logger | An optional logger, defaults to `::Logger.new(STDOUT)` at `Logger
68
126
 
69
127
  The Slack Web API allows you to build applications that interact with Slack.
70
128
 
71
- #### Test Auth
129
+ #### Web Client Examples
130
+
131
+ Here are some examples of how to use the web client with the Web API.
132
+
133
+ ##### Test Auth
72
134
 
73
135
  ```ruby
74
136
  client = Slack::Web::Client.new
75
137
  client.auth_test
76
138
  ```
77
139
 
78
- #### Send Messages
140
+ ##### Send Messages
79
141
 
80
142
  Send messages with [chat_PostMessage](https://api.slack.com/methods/chat.postMessage).
81
143
 
@@ -87,17 +149,17 @@ See a fully working example in [examples/hi_web](examples/hi_web/hi.rb).
87
149
 
88
150
  ![](examples/hi_web/hi.gif)
89
151
 
90
- #### List Channels
152
+ ##### List Channels
91
153
 
92
- List channels with [channels_list](https://api.slack.com/methods/channels.list).
154
+ List channels with [conversations_list](https://api.slack.com/methods/conversations.list).
93
155
 
94
156
  ```ruby
95
- channels = client.channels_list.channels
157
+ channels = client.conversations_list.channels
96
158
 
97
159
  general_channel = channels.detect { |c| c.name == 'general' }
98
160
  ```
99
161
 
100
- #### Upload a File
162
+ ##### Upload a File
101
163
 
102
164
  Upload a file with [files_upload](https://api.slack.com/methods/files.upload).
103
165
 
@@ -112,19 +174,19 @@ client.files_upload(
112
174
  )
113
175
  ```
114
176
 
115
- ### Get Channel Info
177
+ ##### Get Channel Info
116
178
 
117
- 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.
179
+ You can use a channel ID or name (prefixed with `#`) in all functions that take a `:channel` argument. Lookup by name is not supported by the Slack API and the `channels_id` method called invokes `conversations_list` in order to locate the channel ID.
118
180
 
119
181
  ```ruby
120
- client.channels_info(channel: 'C04KB5X4D') # calls channels_info
182
+ client.conversations_info(channel: 'C04KB5X4D') # calls conversations_info
121
183
  ```
122
184
 
123
185
  ```ruby
124
- client.channels_info(channel: '#general') # calls channels_list followed by channels_info
186
+ client.conversations_info(channel: '#general') # calls conversations_list followed by conversations_info
125
187
  ```
126
188
 
127
- ### Get User Info
189
+ ##### Get User Info
128
190
 
129
191
  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.
130
192
 
@@ -136,7 +198,7 @@ client.users_info(user: 'U092BDCLV') # calls users_info
136
198
  client.users_info(user: '@dblock') # calls users_list followed by users_info
137
199
  ```
138
200
 
139
- ### Search for a User
201
+ ##### Search for a User
140
202
 
141
203
  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.
142
204
 
@@ -144,7 +206,7 @@ Constructs an in-memory index of users and searches it. If you want to use this
144
206
  client.users_search(user: 'dblock')
145
207
  ```
146
208
 
147
- #### Other
209
+ ##### Other
148
210
 
149
211
  Refer to the [Slack Web API Method Reference](https://api.slack.com/methods) for the list of all available functions.
150
212
 
@@ -153,7 +215,7 @@ Refer to the [Slack Web API Method Reference](https://api.slack.com/methods) for
153
215
  You can configure the Web client either globally or via the initializer.
154
216
 
155
217
  ```ruby
156
- Slack::Web::Client.config do |config|
218
+ Slack::Web::Client.configure do |config|
157
219
  config.user_agent = 'Slack Ruby Client/1.0'
158
220
  end
159
221
  ```
@@ -177,11 +239,12 @@ timeout | Optional open/read timeout in seconds.
177
239
  open_timeout | Optional connection open timeout in seconds.
178
240
  default_page_size | Optional page size for paginated requests, default is _100_.
179
241
  default_max_retries | Optional number of retries for paginated requests, default is _100_.
242
+ adapter | Optional HTTP adapter to use, defaults to `Faraday.default_adapter`.
180
243
 
181
244
  You can also pass request options, including `timeout` and `open_timeout` into individual calls.
182
245
 
183
246
  ```ruby
184
- client.channels_list(request: { timeout: 180 })
247
+ client.conversations_list(request: { timeout: 180 })
185
248
  ```
186
249
 
187
250
  You can also control what proxy options are used by modifying the `http_proxy` environment variable per [Net::HTTP's documentation](https://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html#class-Net::HTTP-label-Proxies).
@@ -214,13 +277,59 @@ end
214
277
  all_members # many thousands of team members retrieved 10 at a time
215
278
  ```
216
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
+
217
298
  #### Error Handling
218
299
 
219
- If a request fails, a `Slack::Web::Api::Errors::SlackError` will be raised. The error message contains the error code. In case of multiple errors, the error codes are separated by commas. The original response is also accessible using the `response` attribute.
300
+ ##### Slack Errors
301
+
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).)
220
319
 
221
- If you exceed [Slack’s rate limits](https://api.slack.com/docs/rate-limits), a `Slack::Web::Api::Errors::TooManyRequestsError` will be raised instead.
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`.
222
321
 
223
- In any other case, a `Faraday::ClientError` will be raised. This may be the case if Slack is temporarily unavailable, for example.
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
327
+
328
+ When Slack is temporarily unavailable a subclass of `Slack::Web::Api::Errors::ServerError` will be raised and the original `Faraday::Error` will be accesible via `exception.cause`. (Starting with 0.18.0 this is no longer a subclass of `Slack::Web::Api::Errors::SlackError`.)
329
+
330
+ Specifically `Slack::Web::Api::Errors::ParsingError` will be raised on non-json response (i.e. 200 OK with `Slack unavailable` HTML page) and `Slack::Web::Api::Errors::HttpRequestError` subclasses for connection failures (`Slack::Web::Api::Errors::TimeoutError` for read/open timeouts & `Slack::Web::Api::Errors::UnavailableError` for 5xx HTTP responses).
331
+
332
+ In any other case, a `Faraday::ClientError` will be raised.
224
333
 
225
334
  ### RealTime Client
226
335
 
@@ -236,9 +345,9 @@ end
236
345
  client.on :message do |data|
237
346
  case data.text
238
347
  when 'bot hi' then
239
- client.message channel: data.channel, text: "Hi <@#{data.user}>!"
348
+ client.message(channel: data.channel, text: "Hi <@#{data.user}>!")
240
349
  when /^bot/ then
241
- client.message channel: data.channel, text: "Sorry <@#{data.user}>, what?"
350
+ client.message(channel: data.channel, text: "Sorry <@#{data.user}>, what?")
242
351
  end
243
352
  end
244
353
 
@@ -295,7 +404,7 @@ A smaller store that only stores and tracks information about the bot user, but
295
404
  You can configure the RealTime client either globally or via the initializer.
296
405
 
297
406
  ```ruby
298
- Slack::RealTime::Client.config do |config|
407
+ Slack::RealTime::Client.configure do |config|
299
408
  config.websocket_ping = 42
300
409
  end
301
410
  ```
@@ -309,7 +418,7 @@ The following settings are supported.
309
418
  setting | description
310
419
  ----------------|-----------------------------------------------------------------------------------------------------
311
420
  token | Slack API token.
312
- websocket_ping | The number of seconds that indicates how often the WebSocket should send ping frames, default is 30.
421
+ websocket_ping | How long the socket can be idle before sending a ping message to confirm it's still connected, default is 30.
313
422
  websocket_proxy | Connect via proxy, include `:origin` and `:headers`.
314
423
  store_class | Local store class name, default is an in-memory `Slack::RealTime::Stores::Store`.
315
424
  start_method | Optional start method, either `:rtm_start` or `:rtm_connect`.
@@ -322,12 +431,23 @@ See a fully working example in [examples/hi_real_time](examples/hi_real_time/hi.
322
431
 
323
432
  ![](examples/hi_real_time/hi.gif)
324
433
 
434
+ #### Caveats
435
+
436
+ ##### `websocket_ping`
437
+ This setting determines how long the socket can be idle before sending a ping message to confirm it's still connected.
438
+
439
+ 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.
440
+
441
+ 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.
442
+
443
+ To disable this feature set `websocket_ping` to 0.
444
+
325
445
  ### Connection Methods
326
446
 
327
447
  The RealTime client uses either [rtm.start](https://api.slack.com/methods/rtm.start) or [rtm.connect](https://api.slack.com/methods/rtm.connect) to open a connection. The former retrieves a lot of team information while the latter only serves connection purposes and is preferred. You should let the library choose the right method for you based on the `store_class` used and override this behavior with `start_method` when necessary.
328
448
 
329
449
  ```ruby
330
- Slack::RealTime::Client.config do |config|
450
+ Slack::RealTime::Client.configure do |config|
331
451
  config.start_method = :rtm_start
332
452
  end
333
453
  ```
@@ -342,9 +462,9 @@ client = Slack::RealTime::Client.new
342
462
  client.on :message do |data|
343
463
  case data.text
344
464
  when 'bot hi' then
345
- client.web_client.chat_postMessage channel: data.channel, text: "Hi <@#{data.user}>!"
465
+ client.web_client.chat_postMessage(channel: data.channel, text: "Hi <@#{data.user}>!")
346
466
  when /^bot/ then
347
- client.web_client.chat_postMessage channel: data.channel, text: "Sorry <@#{data.user}>, what?"
467
+ client.web_client.chat_postMessage(channel: data.channel, text: "Sorry <@#{data.user}>, what?")
348
468
  end
349
469
  end
350
470
 
@@ -360,7 +480,7 @@ See a fully working example in [examples/hi_real_time_and_web](examples/hi_real_
360
480
  The `rtm.start` call downloads a large amount of data. For large teams, consider reducing the amount of unnecessary data downloaded with `start_options`. You may also want to increase the default timeout of 180 seconds.
361
481
 
362
482
  ```ruby
363
- Slack::RealTime::Client.config do |config|
483
+ Slack::RealTime::Client.configure do |config|
364
484
  # Return timestamp only for latest message object of each channel.
365
485
  config.start_options[:simple_latest] = true
366
486
  # Skip unread counts for each channel.
@@ -374,15 +494,15 @@ See [#134](https://github.com/slack-ruby/slack-ruby-client/issues/134) for a dis
374
494
 
375
495
  #### Concurrency
376
496
 
377
- `Slack::RealTime::Client` needs help from a concurrency library and supports [Faye::WebSocket](https://github.com/faye/faye-websocket-ruby) with [Eventmachine](https://github.com/eventmachine/eventmachine) and [Celluloid](https://github.com/celluloid/celluloid). It will auto-detect one or the other depending on the gems in your Gemfile, but you can also set concurrency explicitly.
497
+ `Slack::RealTime::Client` needs help from a concurrency library and supports [Async](https://github.com/socketry/async).
378
498
 
379
499
  ```ruby
380
500
  Slack::RealTime.configure do |config|
381
- config.concurrency = Slack::RealTime::Concurrency::Eventmachine
501
+ config.concurrency = Slack::RealTime::Concurrency::Async
382
502
  end
383
503
  ```
384
504
 
385
- Use `client.start_async` instead of `client.start!`. A good example of such application is [slack-bot-server](https://github.com/dblock/slack-bot-server).
505
+ 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).
386
506
 
387
507
  ```ruby
388
508
  client = Slack::RealTime::Client.new
@@ -390,27 +510,54 @@ client = Slack::RealTime::Client.new
390
510
  client.start_async
391
511
  ```
392
512
 
393
- ##### Faye::Websocket with Eventmachine
513
+ ##### Async
394
514
 
395
- Add the following to your Gemfile.
515
+ Add `async-websocket` to your Gemfile.
396
516
 
397
517
  ```
398
- gem 'faye-websocket'
518
+ gem 'async-websocket'
399
519
  ```
400
520
 
401
- See a fully working example in [examples/hi_real_time_async_eventmachine](examples/hi_real_time_async_eventmachine/hi.rb).
521
+ See a fully working example in [examples/hi_real_time_async_async](examples/hi_real_time_async_async/hi.rb).
522
+
523
+ ### Events API
524
+
525
+ This library provides limited support for the [Slack Events API](https://api.slack.com/events-api).
402
526
 
403
- ##### Celluloid
527
+ #### Configuring Slack::Events
404
528
 
405
- Add the following to your Gemfile.
529
+ You can configure Events support globally.
406
530
 
531
+ ```ruby
532
+ Slack::Events.configure do |config|
533
+ config.signing_secret = 'secret'
534
+ end
407
535
  ```
408
- gem 'celluloid-io', require: ['celluloid/current', 'celluloid/io']
536
+
537
+ The following settings are supported.
538
+
539
+ setting | description
540
+ ----------------------|---------------------------------------------------------------------------------------------------
541
+ signing_secret | Slack signing secret, defaults is `ENV['SLACK_SIGNING_SECRET']`.
542
+ signature_expires_in | Signature expiration window in seconds, default is `300`.
543
+
544
+ #### Verifying the Request Signature
545
+
546
+ Slack signs its requests using a secret that's unique to your app. Verify incoming HTTP requests as follows.
547
+
548
+ ```ruby
549
+ slack_request = Slack::Events::Request.new(http_request)
550
+ slack_request.verify!
409
551
  ```
410
552
 
411
- See a fully working example in [examples/hi_real_time_async_celluloid](examples/hi_real_time_async_celluloid/hi.rb).
553
+ To specify secrets on a per-request basis:
554
+ ```ruby
555
+ Slack::Events::Request.new(http_request,
556
+ signing_secret: signing_secret,
557
+ signature_expires_in: signature_expires_in)
558
+ ```
412
559
 
413
- Require
560
+ The `verify!` call may raise `Slack::Events::Request::MissingSigningSecret`, `Slack::Events::Request::InvalidSignature` or `Slack::Events::Request::TimestampExpired` errors.
414
561
 
415
562
  ### Message Parsing
416
563
 
@@ -500,6 +647,6 @@ See [CONTRIBUTING](CONTRIBUTING.md).
500
647
 
501
648
  ## Copyright and License
502
649
 
503
- Copyright (c) 2015-2016, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
650
+ Copyright (c) 2015-2021, [Daniel Doubrovkine](https://twitter.com/dblockdotorg), [Artsy](https://www.artsy.net) and [Contributors](CHANGELOG.md).
504
651
 
505
652
  This project is licensed under the [MIT License](LICENSE.md).
data/RELEASING.md CHANGED
@@ -11,7 +11,7 @@ bundle install
11
11
  rake
12
12
  ```
13
13
 
14
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/slack-ruby/slack-ruby-client) for all supported platforms.
14
+ Check that the last build succeeded in [GitHub Actions](https://github.com/slack-ruby/slack-ruby-client/actions) for all supported platforms.
15
15
 
16
16
  Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
17
17
 
@@ -21,7 +21,7 @@ Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
21
21
 
22
22
  Remove the line with "Your contribution here.", since there will be no more contributions to this release.
23
23
 
24
- Change `**next**` in the "Stable Release" section in README that warns users that they are reading the documentation for an unreleased version with `**stable**`.
24
+ In the "Stable Release" section of the README, change `**next**` to `**stable**` so users know that they are reading the documentation for a released version.
25
25
 
26
26
  ```
27
27
  ## Stable Release
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rubygems'
2
3
  require 'bundler'
3
4
  require 'bundler/gem_tasks'
@@ -14,7 +15,7 @@ end
14
15
  require 'rubocop/rake_task'
15
16
  RuboCop::RakeTask.new
16
17
 
17
- task default: %i[rubocop spec]
18
+ task default: %i[spec rubocop]
18
19
 
19
20
  load 'tasks/git.rake'
20
21
  load 'tasks/web.rake'
data/UPGRADING.md CHANGED
@@ -1,6 +1,94 @@
1
1
  Upgrading Slack-Ruby-Client
2
2
  ===========================
3
3
 
4
+ ### Upgrading to >= 1.0.0
5
+
6
+ #### Deprecated Methods
7
+
8
+ Slack has deprecated all `channel` and `group` methods, which have been removed from the library.
9
+
10
+ See [this announcement from Slack](https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api) for details.
11
+
12
+ #### Error Handling
13
+
14
+ As of 1.0.0 `Slack::Web::Api::Errors::ServerError` and its subclasses (introduced in 0.16.0) no longer extend `Slack::Web::Api::Errors::InternalError` or its parent `Slack::Web::Api::Errors::SlackError`. If you are rescuing `SlackError` or `InternalError` with the intention of including `ServerError` and its subclasses you should adjust your code to explicitly rescue `Slack::Web::Api::Errors::ServerError`.
15
+
16
+ ```ruby
17
+ # Before
18
+ begin
19
+ client.auth_test
20
+ rescue Slack::Web::Api::Errors::SlackError
21
+ # Includes all server errors
22
+ end
23
+
24
+ # After
25
+ begin
26
+ client.auth_test
27
+ rescue Slack::Web::Api::Errors::SlackError, Slack::Web::Api::Errors::ServerError
28
+ # Need to rescue the server errors separately from SlackError
29
+ end
30
+ ```
31
+
32
+ Additionally the `initialize` method for `ParsingError`, `TimeoutError`, and `UnavailableError` have changed from `new(message, response)` to `new(response)`. The `message` is now built into the definition of these classes. If you are instantiating or raising these errors in your code (perhaps in tests) you will need to update your code.
33
+
34
+ ```ruby
35
+ # Before
36
+ error = Slack::Web::Api::Errors::TimeoutError.new('timeout_error', response)
37
+ error.message
38
+ # => 'timeout_error'
39
+
40
+ # After
41
+ error = Slack::Web::Api::Errors::TimeoutError.new(response)
42
+ error.message
43
+ # => 'timeout_error'
44
+ ```
45
+
46
+ ### Upgrading to >= 0.16.0
47
+
48
+ #### Removed Celluloid and Faye-Websocket Concurrency Support
49
+
50
+ Concurrency support for `celluloid-io` and `faye-websocket` has been removed. If you are running a RealTime bot on Celluloid or Faye, you must upgrade to `async-websocket`. Please note that RealTime bots are deprecated by Slack, and we generally recommend you [migrate your classic, RealTime bot, to granular permissions](https://code.dblock.org/2020/11/30/migrating-classic-slack-ruby-bots-to-granular-permissions.html).
51
+
52
+ See [#338](https://github.com/slack-ruby/slack-ruby-client/issues/338) for more information.
53
+
54
+ #### Error Handling
55
+
56
+ As of 0.16.0 `Faraday::Error` exceptions sans `Faraday::ClientError` are wrapped into `Slack::Web::Api::Errors::ServerError`, so if you're rescuing `Faraday::Error` — you should adjust your code to use `Slack::Web::Api::Errors::ServerError` and use `exception.cause` if underlying `Faraday::Error` is needed.
57
+
58
+ See [README#other-errors](README.md#other-errors) and [#350](https://github.com/slack-ruby/slack-ruby-client/pull/350) for more information.
59
+
60
+ ### Upgrading to >= 0.15.0
61
+
62
+ As of 0.15.0, `activesupport` is no longer required. Add `gem 'activesupport'` to your Gemfile if you required ActiveSupport via this library.
63
+
64
+ See [#325](https://github.com/slack-ruby/slack-ruby-client/pull/325) for more information.
65
+
66
+ ### Upgrading to >= 0.14.0
67
+
68
+ If you are using async-websocket, lock down its version to 0.8.0 as newer versions are currently incompatible.
69
+
70
+ ```
71
+ gem 'async-websocket', '~> 0.8.0'
72
+ ```
73
+
74
+ See [#282](https://github.com/slack-ruby/slack-ruby-client/issues/282) for more information.
75
+
76
+ ### Upgrading to >= 0.13.0
77
+
78
+ #### Recommended Async Library
79
+
80
+ The RealTime client now supports [async-websocket](https://github.com/socketry/async-websocket), which is actively maintained and is now the recommended library.
81
+
82
+ See [#219](https://github.com/slack-ruby/slack-ruby-client/pull/219) for implementation details.
83
+
84
+ #### Async Library Threading and Reactor Changes
85
+
86
+ The RealTime celluloid-io implementation now uses a `Thread` per client. Previous versions used an `Actor`.
87
+
88
+ The faye-websocket implementation with EventMachine will attempt to shutdown EventMachine via `EventMachine.stop` upon shutdown if a reactor wasn't already running.
89
+
90
+ See [#224](https://github.com/slack-ruby/slack-ruby-client/pull/224) for more information.
91
+
4
92
  ### Upgrading to >= 0.9.0
5
93
 
6
94
  #### Changes in How the RTM Client Connects
@@ -37,7 +125,7 @@ Slack::RealTime::Client.config do |config|
37
125
  end
38
126
  ```
39
127
 
40
- See [#136](https://github.com/slack-ruby/slack-ruby-client/pull/136) for more details.
128
+ See [#136](https://github.com/slack-ruby/slack-ruby-client/pull/136) for more information.
41
129
 
42
130
  ### Upgrading to >= 0.6.0
43
131
 
@@ -98,5 +186,3 @@ gem 'celluloid-io'
98
186
  When in doubt, use `faye-websocket`.
99
187
 
100
188
  See [#5](https://github.com/slack-ruby/slack-ruby-client/issues/5) for more information.
101
-
102
-
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ desc 'AdminAnalytics methods.'
5
+ command 'admin_analytics' do |g|
6
+ g.desc 'Retrieve analytics data for a given date, presented as a compressed JSON file'
7
+ g.long_desc %( Retrieve analytics data for a given date, presented as a compressed JSON file )
8
+ g.command 'getFile' do |c|
9
+ c.flag 'type', desc: 'The type of analytics to retrieve. The options are currently limited to member (for grid member analytics) and public_channel (for public channel analytics).'
10
+ c.flag 'date', desc: 'Date to retrieve the analytics data for, expressed as YYYY-MM-DD in UTC.'
11
+ c.flag 'metadata_only', desc: 'Retrieve metadata for the type of analytics indicated. Can be used only with type set to public_channel analytics. See detail below. Omit the date parameter when using this argument.'
12
+ c.action do |_global_options, options, _args|
13
+ puts JSON.dump($client.admin_analytics_getFile(options))
14
+ end
15
+ end
16
+ end