slack-ruby-client 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +3 -0
  4. data/.rubocop_todo.yml +40 -39
  5. data/.travis.yml +1 -9
  6. data/CHANGELOG.md +24 -0
  7. data/CONTRIBUTING.md +2 -2
  8. data/Gemfile +3 -1
  9. data/README.md +40 -12
  10. data/Rakefile +1 -1
  11. data/UPGRADING.md +1 -1
  12. data/bin/commands/api.rb +2 -2
  13. data/bin/commands/apps_permissions.rb +22 -0
  14. data/bin/commands/auth.rb +4 -4
  15. data/bin/commands/bots.rb +2 -2
  16. data/bin/commands/channels.rb +52 -40
  17. data/bin/commands/chat.rb +63 -25
  18. data/bin/commands/conversations.rb +178 -0
  19. data/bin/commands/dialog.rb +14 -0
  20. data/bin/commands/dnd.rb +8 -8
  21. data/bin/commands/emoji.rb +2 -2
  22. data/bin/commands/files.rb +38 -17
  23. data/bin/commands/files_comments.rb +6 -6
  24. data/bin/commands/groups.rb +44 -51
  25. data/bin/commands/im.rb +16 -13
  26. data/bin/commands/migration.rb +14 -0
  27. data/bin/commands/mpim.rb +11 -11
  28. data/bin/commands/oauth.rb +15 -2
  29. data/bin/commands/pins.rb +6 -6
  30. data/bin/commands/reactions.rb +13 -13
  31. data/bin/commands/reminders.rb +10 -10
  32. data/bin/commands/rtm.rb +9 -6
  33. data/bin/commands/search.rb +9 -9
  34. data/bin/commands/stars.rb +8 -8
  35. data/bin/commands/team.rb +10 -10
  36. data/bin/commands/team_profile.rb +2 -2
  37. data/bin/commands/usergroups.rb +16 -16
  38. data/bin/commands/usergroups_users.rb +4 -4
  39. data/bin/commands/users.rb +40 -36
  40. data/bin/commands/users_admin.rb +28 -0
  41. data/bin/commands/users_prefs.rb +12 -0
  42. data/bin/commands/users_profile.rb +7 -7
  43. data/bin/commands.rb +7 -1
  44. data/bin/slack +1 -1
  45. data/examples/hi_real_time/hi.rb +1 -1
  46. data/examples/hi_real_time_and_web/hi.rb +1 -1
  47. data/examples/hi_real_time_async_celluloid/hi.rb +1 -1
  48. data/examples/hi_real_time_async_eventmachine/hi.rb +1 -1
  49. data/examples/hi_web/hi.rb +1 -1
  50. data/examples/new_ticket/new_ticket.rb +1 -1
  51. data/lib/slack/messages/formatting.rb +4 -4
  52. data/lib/slack/messages/message.rb +1 -2
  53. data/lib/slack/real_time/api/templates/event_handler.erb +1 -1
  54. data/lib/slack/real_time/client.rb +11 -10
  55. data/lib/slack/real_time/concurrency/celluloid.rb +6 -2
  56. data/lib/slack/real_time/config.rb +11 -11
  57. data/lib/slack/real_time/models/base.rb +1 -2
  58. data/lib/slack/real_time/socket.rb +2 -2
  59. data/lib/slack/real_time/stores/base.rb +1 -2
  60. data/lib/slack/real_time/stores/starter.rb +92 -72
  61. data/lib/slack/real_time/stores/store.rb +120 -90
  62. data/lib/slack/version.rb +1 -1
  63. data/lib/slack/web/api/endpoints/api.rb +2 -2
  64. data/lib/slack/web/api/endpoints/apps_permissions.rb +35 -0
  65. data/lib/slack/web/api/endpoints/auth.rb +4 -4
  66. data/lib/slack/web/api/endpoints/bots.rb +2 -2
  67. data/lib/slack/web/api/endpoints/channels.rb +57 -34
  68. data/lib/slack/web/api/endpoints/chat.rb +107 -37
  69. data/lib/slack/web/api/endpoints/conversations.rb +301 -0
  70. data/lib/slack/web/api/endpoints/dialog.rb +32 -0
  71. data/lib/slack/web/api/endpoints/dnd.rb +9 -9
  72. data/lib/slack/web/api/endpoints/emoji.rb +2 -2
  73. data/lib/slack/web/api/endpoints/files.rb +53 -23
  74. data/lib/slack/web/api/endpoints/files_comments.rb +11 -11
  75. data/lib/slack/web/api/endpoints/groups.rb +38 -50
  76. data/lib/slack/web/api/endpoints/im.rb +27 -17
  77. data/lib/slack/web/api/endpoints/migration.rb +25 -0
  78. data/lib/slack/web/api/endpoints/mpim.rb +13 -15
  79. data/lib/slack/web/api/endpoints/oauth.rb +24 -3
  80. data/lib/slack/web/api/endpoints/pins.rb +6 -8
  81. data/lib/slack/web/api/endpoints/presence.rb +1 -1
  82. data/lib/slack/web/api/endpoints/reactions.rb +18 -20
  83. data/lib/slack/web/api/endpoints/reminders.rb +10 -10
  84. data/lib/slack/web/api/endpoints/rtm.rb +14 -8
  85. data/lib/slack/web/api/endpoints/search.rb +12 -12
  86. data/lib/slack/web/api/endpoints/stars.rb +10 -12
  87. data/lib/slack/web/api/endpoints/team.rb +12 -13
  88. data/lib/slack/web/api/endpoints/team_profile.rb +2 -2
  89. data/lib/slack/web/api/endpoints/usergroups.rb +22 -22
  90. data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -4
  91. data/lib/slack/web/api/endpoints/users.rb +34 -24
  92. data/lib/slack/web/api/endpoints/users_admin.rb +46 -0
  93. data/lib/slack/web/api/endpoints/users_prefs.rb +19 -0
  94. data/lib/slack/web/api/endpoints/users_profile.rb +10 -10
  95. data/lib/slack/web/api/endpoints.rb +14 -2
  96. data/lib/slack/web/api/mixins/ids.id.rb +1 -1
  97. data/lib/slack/web/api/mixins/users.search.rb +38 -36
  98. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +1 -1
  99. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +4 -3
  100. data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +17 -0
  101. data/lib/slack/web/api/patches/dialog.1.open-json-support.patch +17 -0
  102. data/lib/slack/web/api/templates/command.erb +4 -3
  103. data/lib/slack/web/api/templates/commands.erb +1 -1
  104. data/lib/slack/web/api/templates/endpoints.erb +2 -2
  105. data/lib/slack/web/api/templates/method.erb +18 -3
  106. data/lib/slack/web/api/templates/method_spec.erb +1 -1
  107. data/lib/slack/web/config.rb +16 -12
  108. data/lib/slack/web/faraday/connection.rb +1 -1
  109. data/lib/slack/web/faraday/response/raise_error.rb +3 -3
  110. data/lib/slack/web/pagination/cursor.rb +48 -0
  111. data/lib/slack-ruby-client.rb +6 -0
  112. data/lib/tasks/git.rake +1 -1
  113. data/lib/tasks/real_time.rake +1 -1
  114. data/lib/tasks/web.rake +4 -1
  115. data/slack-ruby-client.gemspec +2 -3
  116. data/spec/fixtures/slack/web/paginated_users_list.yml +181 -0
  117. data/spec/integration/integration_spec.rb +1 -1
  118. data/spec/slack/messages/formatting_spec.rb +1 -1
  119. data/spec/slack/real_time/client_spec.rb +62 -63
  120. data/spec/slack/real_time/concurrency/celluloid_spec.rb +41 -31
  121. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +1 -1
  122. data/spec/slack/real_time/event_handlers/bot_spec.rb +4 -2
  123. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +1 -1
  124. data/spec/slack/real_time/event_handlers/user_spec.rb +4 -2
  125. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +15 -0
  126. data/spec/slack/web/api/endpoints/conversations_spec.rb +100 -0
  127. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +37 -1
  128. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +28 -0
  129. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +16 -6
  130. data/spec/slack/web/api/endpoints/files_comments_spec.rb +8 -8
  131. data/spec/slack/web/api/endpoints/files_spec.rb +16 -5
  132. data/spec/slack/web/api/endpoints/migration_spec.rb +12 -0
  133. data/spec/slack/web/api/endpoints/oauth_spec.rb +11 -0
  134. data/spec/slack/web/api/endpoints/users_admin_spec.rb +17 -0
  135. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +7 -0
  136. data/spec/slack/web/api/error_spec.rb +1 -1
  137. data/spec/slack/web/api/errors/slack_error_spec.rb +1 -1
  138. data/spec/slack/web/api/mixins/users_spec.rb +6 -4
  139. data/spec/slack/web/api/pagination/cursor_spec.rb +70 -0
  140. data/spec/support/queue_with_timeout.rb +1 -1
  141. data/spec/support/real_time/concurrency/mock.rb +1 -2
  142. metadata +47 -30
@@ -2,32 +2,32 @@
2
2
 
3
3
  desc 'Stars methods.'
4
4
  command 'stars' do |g|
5
- g.desc 'This method adds a star to an item (message, file, file comment, channel, private group, or DM) on behalf of the authenticated user.'
6
- g.long_desc %( This method adds a star to an item (message, file, file comment, channel, private group, or DM) on behalf of the authenticated user. One of file, file_comment, channel, or the combination of channel and timestamp must be specified. )
5
+ g.desc 'Adds a star to an item.'
6
+ g.long_desc %( Adds a star to an item. )
7
7
  g.command 'add' do |c|
8
+ c.flag 'channel', desc: 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp).'
8
9
  c.flag 'file', desc: 'File to add star to.'
9
10
  c.flag 'file_comment', desc: 'File comment to add star to.'
10
- c.flag 'channel', desc: 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp).'
11
11
  c.flag 'timestamp', desc: 'Timestamp of the message to add star to.'
12
12
  c.action do |_global_options, options, _args|
13
13
  puts JSON.dump($client.stars_add(options))
14
14
  end
15
15
  end
16
16
 
17
- g.desc 'This method lists the items starred by the authed user.'
18
- g.long_desc %( This method lists the items starred by the authed user. )
17
+ g.desc 'Lists stars for a user.'
18
+ g.long_desc %( Lists stars for a user. )
19
19
  g.command 'list' do |c|
20
20
  c.action do |_global_options, options, _args|
21
21
  puts JSON.dump($client.stars_list(options))
22
22
  end
23
23
  end
24
24
 
25
- g.desc 'This method removes a star from an item (message, file, file comment, channel, private group, or DM) on behalf of the authenticated user.'
26
- g.long_desc %( This method removes a star from an item (message, file, file comment, channel, private group, or DM) on behalf of the authenticated user. One of file, file_comment, channel, or the combination of channel and timestamp must be specified. )
25
+ g.desc 'Removes a star from an item.'
26
+ g.long_desc %( Removes a star from an item. )
27
27
  g.command 'remove' do |c|
28
+ c.flag 'channel', desc: 'Channel to remove star from, or channel where the message to remove star from was posted (used with timestamp).'
28
29
  c.flag 'file', desc: 'File to remove star from.'
29
30
  c.flag 'file_comment', desc: 'File comment to remove star from.'
30
- c.flag 'channel', desc: 'Channel to remove star from, or channel where the message to remove star from was posted (used with timestamp).'
31
31
  c.flag 'timestamp', desc: 'Timestamp of the message to remove star from.'
32
32
  c.action do |_global_options, options, _args|
33
33
  puts JSON.dump($client.stars_remove(options))
data/bin/commands/team.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  desc 'Team methods.'
4
4
  command 'team' do |g|
5
- g.desc 'This method is used to get the access logs for users on a team.'
6
- g.long_desc %( This method is used to get the access logs for users on a team. )
5
+ g.desc 'Gets the access logs for the current team.'
6
+ g.long_desc %( Gets the access logs for the current team. )
7
7
  g.command 'accessLogs' do |c|
8
8
  c.flag 'before', desc: 'End of time range of logs to include in results (inclusive).'
9
9
  c.action do |_global_options, options, _args|
@@ -11,8 +11,8 @@ command 'team' do |g|
11
11
  end
12
12
  end
13
13
 
14
- g.desc 'This method lists billable information for each user on the team. Currently this consists solely of whether the user is'
15
- g.long_desc %( This method lists billable information for each user on the team. Currently this consists solely of whether the user is subject to billing per Slack's Fair Billing policy. )
14
+ g.desc 'Gets billable users information for the current team.'
15
+ g.long_desc %( Gets billable users information for the current team. )
16
16
  g.command 'billableInfo' do |c|
17
17
  c.flag 'user', desc: 'A user to retrieve the billable information for. Defaults to all users.'
18
18
  c.action do |_global_options, options, _args|
@@ -20,21 +20,21 @@ command 'team' do |g|
20
20
  end
21
21
  end
22
22
 
23
- g.desc 'This method provides information about your team.'
24
- g.long_desc %( This method provides information about your team. )
23
+ g.desc 'Gets information about the current team.'
24
+ g.long_desc %( Gets information about the current team. )
25
25
  g.command 'info' do |c|
26
26
  c.action do |_global_options, options, _args|
27
27
  puts JSON.dump($client.team_info(options))
28
28
  end
29
29
  end
30
30
 
31
- g.desc 'This method lists the integration activity logs for a team, including when integrations are added, modified and removed. This method can only be called by Admins.'
32
- g.long_desc %( This method lists the integration activity logs for a team, including when integrations are added, modified and removed. This method can only be called by Admins. )
31
+ g.desc 'Gets the integration logs for the current team.'
32
+ g.long_desc %( Gets the integration logs for the current team. )
33
33
  g.command 'integrationLogs' do |c|
34
- c.flag 'service_id', desc: 'Filter logs to this service. Defaults to all logs.'
35
34
  c.flag 'app_id', desc: 'Filter logs to this Slack app. Defaults to all logs.'
36
- c.flag 'user', desc: "Filter logs generated by this user's actions. Defaults to all logs."
37
35
  c.flag 'change_type', desc: 'Filter logs with this change type. Defaults to all logs.'
36
+ c.flag 'service_id', desc: 'Filter logs to this service. Defaults to all logs.'
37
+ c.flag 'user', desc: "Filter logs generated by this user's actions. Defaults to all logs."
38
38
  c.action do |_global_options, options, _args|
39
39
  puts JSON.dump($client.team_integrationLogs(options))
40
40
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  desc 'TeamProfile methods.'
4
4
  command 'team_profile' do |g|
5
- g.desc 'This method is used to get the profile field definitions for this team.'
6
- g.long_desc %( This method is used to get the profile field definitions for this team. )
5
+ g.desc "Retrieve a team's profile."
6
+ g.long_desc %( Retrieve a team's profile. )
7
7
  g.command 'get' do |c|
8
8
  c.flag 'visibility', desc: 'Filter by visibility.'
9
9
  c.action do |_global_options, options, _args|
@@ -2,21 +2,21 @@
2
2
 
3
3
  desc "Get info on your team's User Groups."
4
4
  command 'usergroups' do |g|
5
- g.desc 'This method is used to create a User Group.'
6
- g.long_desc %( This method is used to create a User Group. )
5
+ g.desc 'Create a User Group'
6
+ g.long_desc %( Create a User Group )
7
7
  g.command 'create' do |c|
8
8
  c.flag 'name', desc: 'A name for the User Group. Must be unique among User Groups.'
9
- c.flag 'handle', desc: 'A mention handle. Must be unique among channels, users and User Groups.'
10
- c.flag 'description', desc: 'A short description of the User Group.'
11
9
  c.flag 'channels', desc: 'A comma separated string of encoded channel IDs for which the User Group uses as a default.'
10
+ c.flag 'description', desc: 'A short description of the User Group.'
11
+ c.flag 'handle', desc: 'A mention handle. Must be unique among channels, users and User Groups.'
12
12
  c.flag 'include_count', desc: 'Include the number of users in each User Group.'
13
13
  c.action do |_global_options, options, _args|
14
14
  puts JSON.dump($client.usergroups_create(options))
15
15
  end
16
16
  end
17
17
 
18
- g.desc 'This method disables an existing User Group.'
19
- g.long_desc %( This method disables an existing User Group. )
18
+ g.desc 'Disable an existing User Group'
19
+ g.long_desc %( Disable an existing User Group )
20
20
  g.command 'disable' do |c|
21
21
  c.flag 'usergroup', desc: 'The encoded ID of the User Group to disable.'
22
22
  c.flag 'include_count', desc: 'Include the number of users in the User Group.'
@@ -25,8 +25,8 @@ command 'usergroups' do |g|
25
25
  end
26
26
  end
27
27
 
28
- g.desc 'This method enables a User Group which was previously disabled.'
29
- g.long_desc %( This method enables a User Group which was previously disabled. )
28
+ g.desc 'Enable a User Group'
29
+ g.long_desc %( Enable a User Group )
30
30
  g.command 'enable' do |c|
31
31
  c.flag 'usergroup', desc: 'The encoded ID of the User Group to enable.'
32
32
  c.flag 'include_count', desc: 'Include the number of users in the User Group.'
@@ -35,26 +35,26 @@ command 'usergroups' do |g|
35
35
  end
36
36
  end
37
37
 
38
- g.desc 'This method returns a list of all User Groups in the team. This can optionally include disabled User Groups.'
39
- g.long_desc %( This method returns a list of all User Groups in the team. This can optionally include disabled User Groups. )
38
+ g.desc 'List all User Groups for a team'
39
+ g.long_desc %( List all User Groups for a team )
40
40
  g.command 'list' do |c|
41
- c.flag 'include_disabled', desc: 'Include disabled User Groups.'
42
41
  c.flag 'include_count', desc: 'Include the number of users in each User Group.'
42
+ c.flag 'include_disabled', desc: 'Include disabled User Groups.'
43
43
  c.flag 'include_users', desc: 'Include the list of users for each User Group.'
44
44
  c.action do |_global_options, options, _args|
45
45
  puts JSON.dump($client.usergroups_list(options))
46
46
  end
47
47
  end
48
48
 
49
- g.desc 'This method updates the properties of an existing User Group.'
50
- g.long_desc %( This method updates the properties of an existing User Group. )
49
+ g.desc 'Update an existing User Group'
50
+ g.long_desc %( Update an existing User Group )
51
51
  g.command 'update' do |c|
52
52
  c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.'
53
- c.flag 'name', desc: 'A name for the User Group. Must be unique among User Groups.'
54
- c.flag 'handle', desc: 'A mention handle. Must be unique among channels, users and User Groups.'
55
- c.flag 'description', desc: 'A short description of the User Group.'
56
53
  c.flag 'channels', desc: 'A comma separated string of encoded channel IDs for which the User Group uses as a default.'
54
+ c.flag 'description', desc: 'A short description of the User Group.'
55
+ c.flag 'handle', desc: 'A mention handle. Must be unique among channels, users and User Groups.'
57
56
  c.flag 'include_count', desc: 'Include the number of users in the User Group.'
57
+ c.flag 'name', desc: 'A name for the User Group. Must be unique among User Groups.'
58
58
  c.action do |_global_options, options, _args|
59
59
  puts JSON.dump($client.usergroups_update(options))
60
60
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  desc 'UsergroupsUsers methods.'
4
4
  command 'usergroups_users' do |g|
5
- g.desc 'This method returns a list of all users within a User Group.'
6
- g.long_desc %( This method returns a list of all users within a User Group. )
5
+ g.desc 'List all users in a User Group'
6
+ g.long_desc %( List all users in a User Group )
7
7
  g.command 'list' do |c|
8
8
  c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.'
9
9
  c.flag 'include_disabled', desc: 'Allow results that involve disabled User Groups.'
@@ -12,8 +12,8 @@ command 'usergroups_users' do |g|
12
12
  end
13
13
  end
14
14
 
15
- g.desc 'This method updates the list of users that belong to a User Group. This method replaces all users in a User Group with the list of users provided in the users parameter.'
16
- g.long_desc %( This method updates the list of users that belong to a User Group. This method replaces all users in a User Group with the list of users provided in the users parameter. )
15
+ g.desc 'Update the list of users for a User Group'
16
+ g.long_desc %( Update the list of users for a User Group )
17
17
  g.command 'update' do |c|
18
18
  c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.'
19
19
  c.flag 'users', desc: 'A comma separated string of encoded user IDs that represent the entire list of users for the User Group.'
@@ -2,16 +2,16 @@
2
2
 
3
3
  desc 'Get info on members of your Slack team.'
4
4
  command 'users' do |g|
5
- g.desc 'This method allows the user to delete their profile image. It will clear whatever image is currently set.'
6
- g.long_desc %( This method allows the user to delete their profile image. It will clear whatever image is currently set. )
5
+ g.desc 'Delete the user profile photo'
6
+ g.long_desc %( Delete the user profile photo )
7
7
  g.command 'deletePhoto' do |c|
8
8
  c.action do |_global_options, options, _args|
9
9
  puts JSON.dump($client.users_deletePhoto(options))
10
10
  end
11
11
  end
12
12
 
13
- g.desc "This method lets you find out information about a user's presence."
14
- g.long_desc %( This method lets you find out information about a user's presence. Consult the presence documentation for more details. )
13
+ g.desc 'Gets user presence information.'
14
+ g.long_desc %( Gets user presence information. )
15
15
  g.command 'getPresence' do |c|
16
16
  c.flag 'user', desc: 'User to get presence info on. Defaults to the authed user.'
17
17
  c.action do |_global_options, options, _args|
@@ -19,76 +19,80 @@ command 'users' do |g|
19
19
  end
20
20
  end
21
21
 
22
- g.desc "After your Slack app is awarded an identity token through Sign in with Slack, use this method to retrieve a user's identity."
23
- g.long_desc %( After your Slack app is awarded an identity token through Sign in with Slack, use this method to retrieve a user's identity. )
22
+ g.desc 'This method returns the ID of a team user.'
23
+ g.long_desc %( This method returns the ID of a team user. )
24
+ g.command 'id' do |c|
25
+ c.flag 'user', desc: 'User to get ID for, prefixed with @.'
26
+ c.action do |_global_options, options, _args|
27
+ puts JSON.dump($client.users_id(options))
28
+ end
29
+ end
30
+
31
+ g.desc "Get a user's identity."
32
+ g.long_desc %( Get a user's identity. )
24
33
  g.command 'identity' do |c|
25
34
  c.action do |_global_options, options, _args|
26
35
  puts JSON.dump($client.users_identity(options))
27
36
  end
28
37
  end
29
38
 
30
- g.desc 'This method returns information about a team member.'
31
- g.long_desc %( This method returns information about a team member. )
39
+ g.desc 'Gets information about a user.'
40
+ g.long_desc %( Gets information about a user. )
32
41
  g.command 'info' do |c|
33
42
  c.flag 'user', desc: 'User to get info on.'
43
+ c.flag 'include_locale', desc: 'Set this to true to receive the locale for this user. Defaults to false.'
34
44
  c.action do |_global_options, options, _args|
35
45
  puts JSON.dump($client.users_info(options))
36
46
  end
37
47
  end
38
48
 
39
- g.desc 'This method returns a list of all users in the team. This includes deleted/deactivated users.'
40
- g.long_desc %( This method returns a list of all users in the team. This includes deleted/deactivated users. )
49
+ g.desc 'Lists all users in a Slack team.'
50
+ g.long_desc %( Lists all users in a Slack team. )
41
51
  g.command 'list' do |c|
42
- c.flag 'presence', desc: 'Whether to include presence data in the output.'
52
+ c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection. See pagination for more detail."
53
+ c.flag 'include_locale', desc: 'Set this to true to receive the locale for users. Defaults to false.'
54
+ c.flag 'limit', desc: "The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached."
55
+ c.flag 'presence', desc: 'Whether to include presence data in the output. Setting this to false improves performance, especially with large teams.'
43
56
  c.action do |_global_options, options, _args|
44
57
  puts JSON.dump($client.users_list(options))
45
58
  end
46
59
  end
47
60
 
48
- g.desc 'This method lets the slack messaging server know that the authenticated user'
49
- g.long_desc %( This method lets the slack messaging server know that the authenticated user is currently active. Consult the presence documentation for more details. )
61
+ g.desc 'This method searches for users.'
62
+ g.long_desc %( This method searches for users. )
63
+ g.command 'search' do |c|
64
+ c.flag 'user', desc: 'User to search for.'
65
+ c.action do |_global_options, options, _args|
66
+ puts JSON.dump($client.users_search(options))
67
+ end
68
+ end
69
+
70
+ g.desc 'Marks a user as active.'
71
+ g.long_desc %( Marks a user as active. )
50
72
  g.command 'setActive' do |c|
51
73
  c.action do |_global_options, options, _args|
52
74
  puts JSON.dump($client.users_setActive(options))
53
75
  end
54
76
  end
55
77
 
56
- g.desc 'This method allows the user to set their profile image. The caller can pass image data via image.'
57
- g.long_desc %( This method allows the user to set their profile image. The caller can pass image data via image. )
78
+ g.desc 'Set the user profile photo'
79
+ g.long_desc %( Set the user profile photo )
58
80
  g.command 'setPhoto' do |c|
59
81
  c.flag 'image', desc: 'File contents via multipart/form-data.'
82
+ c.flag 'crop_w', desc: 'Width/height of crop box (always square).'
60
83
  c.flag 'crop_x', desc: 'X coordinate of top-left corner of crop box.'
61
84
  c.flag 'crop_y', desc: 'Y coordinate of top-left corner of crop box.'
62
- c.flag 'crop_w', desc: 'Width/height of crop box (always square).'
63
85
  c.action do |_global_options, options, _args|
64
86
  puts JSON.dump($client.users_setPhoto(options))
65
87
  end
66
88
  end
67
89
 
68
- g.desc "This method lets you set the calling user's manual presence."
69
- g.long_desc %( This method lets you set the calling user's manual presence. Consult the presence documentation for more details. )
90
+ g.desc 'Manually sets user presence.'
91
+ g.long_desc %( Manually sets user presence. )
70
92
  g.command 'setPresence' do |c|
71
93
  c.flag 'presence', desc: 'Either auto or away.'
72
94
  c.action do |_global_options, options, _args|
73
95
  puts JSON.dump($client.users_setPresence(options))
74
96
  end
75
97
  end
76
-
77
- g.desc 'This method returns the ID of a team user.'
78
- g.long_desc %( This method returns the ID of a team user. )
79
- g.command 'id' do |c|
80
- c.flag 'user', desc: 'User to get ID for, prefixed with @.'
81
- c.action do |_global_options, options, _args|
82
- puts JSON.dump($client.users_id(options))
83
- end
84
- end
85
-
86
- g.desc 'This method searches for users.'
87
- g.long_desc %( This method searches for users. )
88
- g.command 'search' do |c|
89
- c.flag 'user', desc: 'User to search for.'
90
- c.action do |_global_options, options, _args|
91
- puts JSON.dump($client.users_search(options))
92
- end
93
- end
94
98
  end
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ desc 'UsersAdmin methods.'
4
+ command 'users_admin' do |g|
5
+ g.desc 'Send an invitation to a new user by email (undocumented)'
6
+ g.long_desc %( Send an invitation to a new user by email )
7
+ g.command 'invite' do |c|
8
+ c.flag 'email', desc: 'Email address of the new user'
9
+ c.flag 'channels', desc: 'Comma-separated list of IDs (not names!) for channels, which the new user will auto-join. Both channel IDs for public channels and group IDs for private chanels work.'
10
+ c.flag 'first_name', desc: 'Prefilled input for the "First name" field on the "new user registration" page.'
11
+ c.flag 'last_name', desc: 'Prefilled input for the "Last name" field on the "new user registration" page.'
12
+ c.flag 'resend', desc: 'Resend the invitation email if the user has already been invited and the email was sent some time ago.'
13
+ c.flag 'restricted', desc: 'Invite a guest that can use multiple channels'
14
+ c.flag 'ultra_restricted', desc: 'Invite a guest that can use one channel only'
15
+ c.action do |_global_options, options, _args|
16
+ puts JSON.dump($client.users_admin_invite(options))
17
+ end
18
+ end
19
+
20
+ g.desc 'Disable a user (undocumented)'
21
+ g.long_desc %( Disable a user )
22
+ g.command 'setInactive' do |c|
23
+ c.flag 'user', desc: 'User to disable'
24
+ c.action do |_global_options, options, _args|
25
+ puts JSON.dump($client.users_admin_setInactive(options))
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ # This file was auto-generated by lib/tasks/web.rake
2
+
3
+ desc 'UsersPrefs methods.'
4
+ command 'users_prefs' do |g|
5
+ g.desc "Returns the user's preferences (undocumented)"
6
+ g.long_desc %( Returns the user's preferences )
7
+ g.command 'get' do |c|
8
+ c.action do |_global_options, options, _args|
9
+ puts JSON.dump($client.users_prefs_get(options))
10
+ end
11
+ end
12
+ end
@@ -2,22 +2,22 @@
2
2
 
3
3
  desc 'UsersProfile methods.'
4
4
  command 'users_profile' do |g|
5
- g.desc "Use this method to retrieve a user's profile information."
6
- g.long_desc %( Use this method to retrieve a user's profile information. )
5
+ g.desc "Retrieves a user's profile information."
6
+ g.long_desc %( Retrieves a user's profile information. )
7
7
  g.command 'get' do |c|
8
- c.flag 'user', desc: 'User to retrieve profile info for.'
9
8
  c.flag 'include_labels', desc: 'Include labels for each ID in custom profile fields.'
9
+ c.flag 'user', desc: 'User to retrieve profile info for.'
10
10
  c.action do |_global_options, options, _args|
11
11
  puts JSON.dump($client.users_profile_get(options))
12
12
  end
13
13
  end
14
14
 
15
- g.desc "Use this method to set a user's profile information, including name, email, current status, and other attributes."
16
- g.long_desc %( Use this method to set a user's profile information, including name, email, current status, and other attributes. )
15
+ g.desc 'Set the profile information for a user.'
16
+ g.long_desc %( Set the profile information for a user. )
17
17
  g.command 'set' do |c|
18
- c.flag 'user', desc: 'ID of user to change. This argument may only be specified by team admins on paid teams.'
19
- c.flag 'profile', desc: 'Collection of key:value pairs presented as a URL-encoded JSON hash.'
20
18
  c.flag 'name', desc: 'Name of a single key to set. Usable only if profile is not passed.'
19
+ c.flag 'profile', desc: 'Collection of key:value pairs presented as a URL-encoded JSON hash.'
20
+ c.flag 'user', desc: 'ID of user to change. This argument may only be specified by team admins on paid teams.'
21
21
  c.flag 'value', desc: 'Value to set a single key to. Usable only if profile is not passed.'
22
22
  c.action do |_global_options, options, _args|
23
23
  puts JSON.dump($client.users_profile_set(options))
data/bin/commands.rb CHANGED
@@ -1,16 +1,20 @@
1
1
  # This file was auto-generated by lib/tasks/web.rake
2
2
 
3
3
  require 'commands/api'
4
+ require 'commands/apps_permissions'
4
5
  require 'commands/auth'
5
6
  require 'commands/bots'
6
7
  require 'commands/channels'
7
8
  require 'commands/chat'
9
+ require 'commands/conversations'
10
+ require 'commands/dialog'
8
11
  require 'commands/dnd'
9
12
  require 'commands/emoji'
10
- require 'commands/files_comments'
11
13
  require 'commands/files'
14
+ require 'commands/files_comments'
12
15
  require 'commands/groups'
13
16
  require 'commands/im'
17
+ require 'commands/migration'
14
18
  require 'commands/mpim'
15
19
  require 'commands/oauth'
16
20
  require 'commands/pins'
@@ -24,4 +28,6 @@ require 'commands/team_profile'
24
28
  require 'commands/usergroups'
25
29
  require 'commands/usergroups_users'
26
30
  require 'commands/users'
31
+ require 'commands/users_admin'
32
+ require 'commands/users_prefs'
27
33
  require 'commands/users_profile'
data/bin/slack CHANGED
@@ -9,7 +9,7 @@ program_desc 'Slack client.'
9
9
 
10
10
  default_command :help
11
11
 
12
- switch [:d, :debug], desc: 'Enable debug-level logging.', default_value: false
12
+ switch %i[d debug], desc: 'Enable debug-level logging.', default_value: false
13
13
  flag [:t, 'slack-api-token'], desc: 'Slack API token.', default_value: ENV['SLACK_API_TOKEN']
14
14
  flag ['vcr-cassette-name'], desc: 'Offline VCR cassette.'
15
15
 
@@ -4,7 +4,7 @@ Slack.configure do |config|
4
4
  config.token = ENV['SLACK_API_TOKEN']
5
5
  config.logger = Logger.new(STDOUT)
6
6
  config.logger.level = Logger::INFO
7
- fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
7
+ raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
8
8
  end
9
9
 
10
10
  client = Slack::RealTime::Client.new
@@ -2,7 +2,7 @@ require 'slack-ruby-client'
2
2
 
3
3
  Slack.configure do |config|
4
4
  config.token = ENV['SLACK_API_TOKEN']
5
- fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
5
+ raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
6
6
  end
7
7
 
8
8
  client = Slack::RealTime::Client.new
@@ -1,6 +1,6 @@
1
1
  require 'slack-ruby-client'
2
2
 
3
- fail 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')
3
+ raise 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')
4
4
 
5
5
  $stdout.sync = true
6
6
  logger = Logger.new($stdout)
@@ -1,6 +1,6 @@
1
1
  require 'slack-ruby-client'
2
2
 
3
- fail 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')
3
+ raise 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')
4
4
 
5
5
  $stdout.sync = true
6
6
  logger = Logger.new($stdout)
@@ -2,7 +2,7 @@ require 'slack-ruby-client'
2
2
 
3
3
  Slack.configure do |config|
4
4
  config.token = ENV['SLACK_API_TOKEN']
5
- fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
5
+ raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
6
6
  end
7
7
 
8
8
  client = Slack::Web::Client.new
@@ -2,7 +2,7 @@ require 'slack-ruby-client'
2
2
 
3
3
  Slack.configure do |config|
4
4
  config.token = ENV['SLACK_API_TOKEN']
5
- fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
5
+ raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
6
6
  end
7
7
 
8
8
  client = Slack::Web::Client.new
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+
2
2
  module Slack
3
3
  module Messages
4
4
  module Formatting
@@ -10,9 +10,9 @@ module Slack
10
10
  def unescape(message)
11
11
  CGI.unescapeHTML(message.gsub(/[“”]/, '"')
12
12
  .gsub(/[‘’]/, "'")
13
- .gsub(/<(?<sign>[?@#!]?)(?<dt>.*?)>/) do |match|
14
- sign = $~[:sign]
15
- dt = $~[:dt]
13
+ .gsub(/<(?<sign>[?@#!]?)(?<dt>.*?)>/) do
14
+ sign = Regexp.last_match[:sign]
15
+ dt = Regexp.last_match[:dt]
16
16
  rhs = dt.split('|', 2).last
17
17
  case sign
18
18
  when '@', '!'
@@ -14,8 +14,7 @@ module Slack
14
14
  private
15
15
 
16
16
  # see https://github.com/intridea/hashie/issues/394
17
- def log_built_in_message(*)
18
- end
17
+ def log_built_in_message(*); end
19
18
  end
20
19
  end
21
20
  end
@@ -1,4 +1,4 @@
1
1
  # <%= desc %>
2
2
  # @see https://api.slack.com/events/<%= name %>
3
- # @see https://github.com/dblock/slack-api-ref/blob/master/events/<%= name %>.json
3
+ # @see https://github.com/slack-ruby/slack-api-ref/blob/master/events/<%= name %>.json
4
4
  # on :<%= name %> do |data|
@@ -33,7 +33,7 @@ module Slack
33
33
  @web_client = Slack::Web::Client.new(token: token, logger: logger)
34
34
  end
35
35
 
36
- [:users, :self, :channels, :team, :teams, :groups, :ims, :bots].each do |store_method|
36
+ %i[users self channels team teams groups ims bots].each do |store_method|
37
37
  define_method store_method do
38
38
  store.send(store_method) if store
39
39
  end
@@ -60,7 +60,7 @@ module Slack
60
60
  end
61
61
 
62
62
  def stop!
63
- fail ClientNotStartedError unless started?
63
+ raise ClientNotStartedError unless started?
64
64
  @socket.disconnect! if @socket
65
65
  end
66
66
 
@@ -106,7 +106,7 @@ module Slack
106
106
 
107
107
  # @return [Slack::RealTime::Socket]
108
108
  def build_socket
109
- fail ClientAlreadyStartedError if started?
109
+ raise ClientAlreadyStartedError if started?
110
110
  start = web_client.send(rtm_start_method, start_options)
111
111
  data = Slack::Messages::Message.new(start)
112
112
  @url = data.url
@@ -117,7 +117,7 @@ module Slack
117
117
  def rtm_start_method
118
118
  if start_method
119
119
  start_method
120
- elsif @store_class == Slack::RealTime::Stores::Store
120
+ elsif @store_class && @store_class <= Slack::RealTime::Stores::Store
121
121
  :rtm_start
122
122
  else
123
123
  :rtm_connect
@@ -138,13 +138,12 @@ module Slack
138
138
  end
139
139
 
140
140
  def send_json(data)
141
- fail ClientNotStartedError unless started?
141
+ raise ClientNotStartedError unless started?
142
142
  logger.debug("#{self.class}##{__method__}") { data }
143
143
  @socket.send_data(data.to_json)
144
144
  end
145
145
 
146
- def open(_event)
147
- end
146
+ def open(_event); end
148
147
 
149
148
  def close(_event)
150
149
  socket = @socket
@@ -183,9 +182,11 @@ module Slack
183
182
 
184
183
  def run_handlers(type, data)
185
184
  handlers = store.class.events[type.to_s]
186
- handlers.each do |handler|
187
- store.instance_exec(data, &handler)
188
- end if handlers
185
+ if handlers
186
+ handlers.each do |handler|
187
+ store.instance_exec(data, &handler)
188
+ end
189
+ end
189
190
  rescue StandardError => e
190
191
  logger.error e
191
192
  false
@@ -34,11 +34,15 @@ module Slack
34
34
  @connected = @socket.connect
35
35
  driver.start
36
36
  loop { read } if socket
37
- rescue EOFError => e
37
+ rescue EOFError, Errno::EPIPE => e
38
38
  logger.debug("#{self.class}##{__method__}") { e }
39
39
  driver.emit(:close, WebSocket::Driver::CloseEvent.new(1001, 'server closed connection')) unless @closing
40
40
  ensure
41
- current_actor.terminate if current_actor.alive? rescue nil
41
+ begin
42
+ current_actor.terminate if current_actor.alive?
43
+ rescue
44
+ nil
45
+ end
42
46
  end
43
47
 
44
48
  def close