slack-ruby-client-bhe 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +17 -0
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +78 -0
- data/.travis.yml +26 -0
- data/CHANGELOG.md +79 -0
- data/CONTRIBUTING.md +157 -0
- data/Gemfile +5 -0
- data/LICENSE.md +22 -0
- data/README.md +385 -0
- data/RELEASING.md +69 -0
- data/Rakefile +19 -0
- data/UPGRADING.md +26 -0
- data/bin/commands.rb +21 -0
- data/bin/commands/api.rb +14 -0
- data/bin/commands/auth.rb +12 -0
- data/bin/commands/channels.rb +149 -0
- data/bin/commands/chat.rb +47 -0
- data/bin/commands/dnd.rb +47 -0
- data/bin/commands/emoji.rb +12 -0
- data/bin/commands/files.rb +72 -0
- data/bin/commands/groups.rb +167 -0
- data/bin/commands/im.rb +53 -0
- data/bin/commands/mpim.rb +53 -0
- data/bin/commands/oauth.rb +16 -0
- data/bin/commands/pins.rb +37 -0
- data/bin/commands/reactions.rb +53 -0
- data/bin/commands/rtm.rb +15 -0
- data/bin/commands/search.rb +40 -0
- data/bin/commands/stars.rb +37 -0
- data/bin/commands/team.rb +32 -0
- data/bin/commands/usergroups.rb +73 -0
- data/bin/commands/users.rb +57 -0
- data/bin/slack +50 -0
- data/examples/hi_real_time/Gemfile +5 -0
- data/examples/hi_real_time/hi.gif +0 -0
- data/examples/hi_real_time/hi.rb +32 -0
- data/examples/hi_real_time_and_web/Gemfile +5 -0
- data/examples/hi_real_time_and_web/hi.gif +0 -0
- data/examples/hi_real_time_and_web/hi.rb +24 -0
- data/examples/hi_real_time_async/Gemfile +5 -0
- data/examples/hi_real_time_async/hi.rb +29 -0
- data/examples/hi_web/Gemfile +3 -0
- data/examples/hi_web/hi.gif +0 -0
- data/examples/hi_web/hi.rb +12 -0
- data/examples/new_ticket/Gemfile +3 -0
- data/examples/new_ticket/new_ticket.rb +25 -0
- data/lib/slack-ruby-client.rb +29 -0
- data/lib/slack.rb +1 -0
- data/lib/slack/config.rb +21 -0
- data/lib/slack/messages/formatting.rb +30 -0
- data/lib/slack/real_time/api/message.rb +20 -0
- data/lib/slack/real_time/api/message_id.rb +14 -0
- data/lib/slack/real_time/api/ping.rb +16 -0
- data/lib/slack/real_time/api/typing.rb +17 -0
- data/lib/slack/real_time/client.rb +152 -0
- data/lib/slack/real_time/concurrency.rb +8 -0
- data/lib/slack/real_time/concurrency/celluloid.rb +93 -0
- data/lib/slack/real_time/concurrency/eventmachine.rb +39 -0
- data/lib/slack/real_time/config.rb +55 -0
- data/lib/slack/real_time/socket.rb +81 -0
- data/lib/slack/version.rb +3 -0
- data/lib/slack/web/api/endpoints.rb +53 -0
- data/lib/slack/web/api/endpoints/api.rb +24 -0
- data/lib/slack/web/api/endpoints/auth.rb +20 -0
- data/lib/slack/web/api/endpoints/channels.rb +220 -0
- data/lib/slack/web/api/endpoints/chat.rb +91 -0
- data/lib/slack/web/api/endpoints/dnd.rb +64 -0
- data/lib/slack/web/api/endpoints/emoji.rb +20 -0
- data/lib/slack/web/api/endpoints/files.rb +108 -0
- data/lib/slack/web/api/endpoints/groups.rb +247 -0
- data/lib/slack/web/api/endpoints/im.rb +85 -0
- data/lib/slack/web/api/endpoints/mpim.rb +84 -0
- data/lib/slack/web/api/endpoints/oauth.rb +32 -0
- data/lib/slack/web/api/endpoints/pins.rb +64 -0
- data/lib/slack/web/api/endpoints/presence.rb +23 -0
- data/lib/slack/web/api/endpoints/reactions.rb +89 -0
- data/lib/slack/web/api/endpoints/rtm.rb +27 -0
- data/lib/slack/web/api/endpoints/search.rb +65 -0
- data/lib/slack/web/api/endpoints/stars.rb +61 -0
- data/lib/slack/web/api/endpoints/team.rb +47 -0
- data/lib/slack/web/api/endpoints/usergroups.rb +113 -0
- data/lib/slack/web/api/endpoints/users.rb +73 -0
- data/lib/slack/web/api/error.rb +14 -0
- data/lib/slack/web/api/mixins.rb +3 -0
- data/lib/slack/web/api/mixins/channels.id.json +20 -0
- data/lib/slack/web/api/mixins/channels.id.rb +26 -0
- data/lib/slack/web/api/mixins/groups.id.json +20 -0
- data/lib/slack/web/api/mixins/groups.id.rb +26 -0
- data/lib/slack/web/api/mixins/users.id.json +20 -0
- data/lib/slack/web/api/mixins/users.id.rb +26 -0
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +13 -0
- data/lib/slack/web/api/patches/chat.2.attachments-json.patch +17 -0
- data/lib/slack/web/api/schema/group.json +14 -0
- data/lib/slack/web/api/schema/method.json +45 -0
- data/lib/slack/web/api/tasks/generate.rake +61 -0
- data/lib/slack/web/api/templates/command.erb +34 -0
- data/lib/slack/web/api/templates/commands.erb +5 -0
- data/lib/slack/web/api/templates/endpoints.erb +21 -0
- data/lib/slack/web/api/templates/method.erb +49 -0
- data/lib/slack/web/client.rb +28 -0
- data/lib/slack/web/config.rb +41 -0
- data/lib/slack/web/faraday/connection.rb +29 -0
- data/lib/slack/web/faraday/request.rb +39 -0
- data/lib/slack/web/faraday/response/raise_error.rb +15 -0
- data/lib/slack_ruby_client.rb +1 -0
- data/screenshots/register-bot.png +0 -0
- data/slack-ruby-client.gemspec +31 -0
- data/slack.png +0 -0
- data/spec/fixtures/slack/web/429_error.yml +83 -0
- data/spec/fixtures/slack/web/auth_test_error.yml +48 -0
- data/spec/fixtures/slack/web/auth_test_success.yml +57 -0
- data/spec/fixtures/slack/web/channels_info.yml +46 -0
- data/spec/fixtures/slack/web/groups_info.yml +43 -0
- data/spec/fixtures/slack/web/rtm_start.yml +73 -0
- data/spec/fixtures/slack/web/users_info.yml +130 -0
- data/spec/fixtures/slack/web/users_list.yml +72 -0
- data/spec/integration/integration_spec.rb +107 -0
- data/spec/slack/config_spec.rb +14 -0
- data/spec/slack/messages/formatting_spec.rb +43 -0
- data/spec/slack/real_time/api/message_spec.rb +15 -0
- data/spec/slack/real_time/api/ping_spec.rb +15 -0
- data/spec/slack/real_time/api/typing_spec.rb +15 -0
- data/spec/slack/real_time/client_spec.rb +198 -0
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +58 -0
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +49 -0
- data/spec/slack/slack_spec.rb +58 -0
- data/spec/slack/version_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/auth_spec.rb +20 -0
- data/spec/slack/web/api/endpoints/channels_spec.rb +11 -0
- data/spec/slack/web/api/endpoints/chat_spec.rb +33 -0
- data/spec/slack/web/api/endpoints/groups_spec.rb +11 -0
- data/spec/slack/web/api/endpoints/users_spec.rb +17 -0
- data/spec/slack/web/api/error_spec.rb +14 -0
- data/spec/slack/web/api/mixins/channels_spec.rb +31 -0
- data/spec/slack/web/api/mixins/groups_spec.rb +31 -0
- data/spec/slack/web/api/mixins/users_spec.rb +31 -0
- data/spec/slack/web/client_spec.rb +134 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/queue_with_timeout.rb +34 -0
- data/spec/support/real_time/concurrency/mock.rb +31 -0
- data/spec/support/real_time/connected_client.rb +16 -0
- data/spec/support/token.rb +10 -0
- data/spec/support/vcr.rb +8 -0
- metadata +392 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# This file was auto-generated by lib/slack/web/api/tasks/generate.rake
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module Web
|
|
5
|
+
module Api
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Team
|
|
8
|
+
#
|
|
9
|
+
# This method is used to get the access logs for users on a team.
|
|
10
|
+
#
|
|
11
|
+
# @see https://api.slack.com/methods/team.accessLogs
|
|
12
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.accessLogs.json
|
|
13
|
+
def team_accessLogs(options = {})
|
|
14
|
+
post('team.accessLogs', options)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
# This method provides information about your team.
|
|
19
|
+
#
|
|
20
|
+
# @see https://api.slack.com/methods/team.info
|
|
21
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.info.json
|
|
22
|
+
def team_info(options = {})
|
|
23
|
+
post('team.info', options)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# 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.
|
|
28
|
+
#
|
|
29
|
+
# @option options [Object] :service_id
|
|
30
|
+
# Filter logs to this service. Defaults to all logs.
|
|
31
|
+
# @option options [Object] :app_id
|
|
32
|
+
# Filter logs to this Slack app. Defaults to all logs.
|
|
33
|
+
# @option options [user] :user
|
|
34
|
+
# Filter logs generated by this user's actions. Defaults to all logs.
|
|
35
|
+
# @option options [Object] :change_type
|
|
36
|
+
# Filter logs with this change type. Defaults to all logs.
|
|
37
|
+
# @see https://api.slack.com/methods/team.integrationLogs
|
|
38
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.integrationLogs.json
|
|
39
|
+
def team_integrationLogs(options = {})
|
|
40
|
+
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
|
|
41
|
+
post('team.integrationLogs', options)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# This file was auto-generated by lib/slack/web/api/tasks/generate.rake
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module Web
|
|
5
|
+
module Api
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Usergroups
|
|
8
|
+
#
|
|
9
|
+
# This method is used to create a user group.
|
|
10
|
+
#
|
|
11
|
+
# @option options [Object] :name
|
|
12
|
+
# A name for the user group. Must be unique among user groups.
|
|
13
|
+
# @option options [Object] :handle
|
|
14
|
+
# A mention handle. Must be unique among channels, users and user groups.
|
|
15
|
+
# @option options [Object] :description
|
|
16
|
+
# A short description of the user group.
|
|
17
|
+
# @option options [Object] :channels
|
|
18
|
+
# A comma separated string of encoded channel IDs for which the user group uses as a default.
|
|
19
|
+
# @option options [Object] :include_count
|
|
20
|
+
# Include the number of users in each user group.
|
|
21
|
+
# @see https://api.slack.com/methods/usergroups.create
|
|
22
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.create.json
|
|
23
|
+
def usergroups_create(options = {})
|
|
24
|
+
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
|
|
25
|
+
post('usergroups.create', options)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
#
|
|
29
|
+
# This method disables an existing user group.
|
|
30
|
+
#
|
|
31
|
+
# @option options [Object] :usergroup
|
|
32
|
+
# The encoded ID of the user group to disable.
|
|
33
|
+
# @option options [Object] :include_count
|
|
34
|
+
# Include the number of users in the user group.
|
|
35
|
+
# @see https://api.slack.com/methods/usergroups.disable
|
|
36
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.disable.json
|
|
37
|
+
def usergroups_disable(options = {})
|
|
38
|
+
throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
|
|
39
|
+
post('usergroups.disable', options)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# This method enables a user group which was previously disabled.
|
|
44
|
+
#
|
|
45
|
+
# @option options [Object] :usergroup
|
|
46
|
+
# The encoded ID of the user group to enable.
|
|
47
|
+
# @option options [Object] :include_count
|
|
48
|
+
# Include the number of users in the user group.
|
|
49
|
+
# @see https://api.slack.com/methods/usergroups.enable
|
|
50
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.enable.json
|
|
51
|
+
def usergroups_enable(options = {})
|
|
52
|
+
throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
|
|
53
|
+
post('usergroups.enable', options)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# This method returns a list of all user groups in the team. This can optionally include disabled user groups.
|
|
58
|
+
#
|
|
59
|
+
# @option options [Object] :include_disabled
|
|
60
|
+
# Include disabled user groups.
|
|
61
|
+
# @option options [Object] :include_count
|
|
62
|
+
# Include the number of users in each user group.
|
|
63
|
+
# @option options [Object] :include_users
|
|
64
|
+
# Include the list of users for each user group.
|
|
65
|
+
# @see https://api.slack.com/methods/usergroups.list
|
|
66
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.list.json
|
|
67
|
+
def usergroups_list(options = {})
|
|
68
|
+
post('usergroups.list', options)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# This method updates the properties of an existing user group.
|
|
73
|
+
#
|
|
74
|
+
# @option options [Object] :usergroup
|
|
75
|
+
# The encoded ID of the user group to update.
|
|
76
|
+
# @option options [Object] :name
|
|
77
|
+
# A name for the user group. Must be unique among user groups.
|
|
78
|
+
# @option options [Object] :handle
|
|
79
|
+
# A mention handle. Must be unique among channels, users and user groups.
|
|
80
|
+
# @option options [Object] :description
|
|
81
|
+
# A short description of the user group.
|
|
82
|
+
# @option options [Object] :channels
|
|
83
|
+
# A comma separated string of encoded channel IDs for which the user group uses as a default.
|
|
84
|
+
# @option options [Object] :include_count
|
|
85
|
+
# Include the number of users in the user group.
|
|
86
|
+
# @see https://api.slack.com/methods/usergroups.update
|
|
87
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.update.json
|
|
88
|
+
def usergroups_update(options = {})
|
|
89
|
+
throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
|
|
90
|
+
post('usergroups.update', options)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
#
|
|
94
|
+
# 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.
|
|
95
|
+
#
|
|
96
|
+
# @option options [Object] :usergroup
|
|
97
|
+
# The encoded ID of the user group to update.
|
|
98
|
+
# @option options [Object] :users
|
|
99
|
+
# A comma separated string of encoded user IDs that represent the entire list of users for the user group.
|
|
100
|
+
# @option options [Object] :include_count
|
|
101
|
+
# Include the number of users in the user group.
|
|
102
|
+
# @see https://api.slack.com/methods/usergroups.users
|
|
103
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.users.json
|
|
104
|
+
def usergroups_users(options = {})
|
|
105
|
+
throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
|
|
106
|
+
throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
|
|
107
|
+
post('usergroups.users', options)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# This file was auto-generated by lib/slack/web/api/tasks/generate.rake
|
|
2
|
+
|
|
3
|
+
module Slack
|
|
4
|
+
module Web
|
|
5
|
+
module Api
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Users
|
|
8
|
+
#
|
|
9
|
+
# This method lets you find out information about a user's presence.
|
|
10
|
+
# Consult the presence documentation for more details.
|
|
11
|
+
#
|
|
12
|
+
# @option options [user] :user
|
|
13
|
+
# User to get presence info on. Defaults to the authed user.
|
|
14
|
+
# @see https://api.slack.com/methods/users.getPresence
|
|
15
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.getPresence.json
|
|
16
|
+
def users_getPresence(options = {})
|
|
17
|
+
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
|
|
18
|
+
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
|
|
19
|
+
post('users.getPresence', options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#
|
|
23
|
+
# This method returns information about a team member.
|
|
24
|
+
#
|
|
25
|
+
# @option options [user] :user
|
|
26
|
+
# User to get info on.
|
|
27
|
+
# @see https://api.slack.com/methods/users.info
|
|
28
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.info.json
|
|
29
|
+
def users_info(options = {})
|
|
30
|
+
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
|
|
31
|
+
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
|
|
32
|
+
post('users.info', options)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
# This method returns a list of all users in the team. This includes deleted/deactivated users.
|
|
37
|
+
#
|
|
38
|
+
# @option options [Object] :presence
|
|
39
|
+
# Whether to include presence data in the output.
|
|
40
|
+
# @see https://api.slack.com/methods/users.list
|
|
41
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.list.json
|
|
42
|
+
def users_list(options = {})
|
|
43
|
+
post('users.list', options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# This method lets the slack messaging server know that the authenticated user
|
|
48
|
+
# is currently active. Consult the presence documentation for
|
|
49
|
+
# more details.
|
|
50
|
+
#
|
|
51
|
+
# @see https://api.slack.com/methods/users.setActive
|
|
52
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.setActive.json
|
|
53
|
+
def users_setActive(options = {})
|
|
54
|
+
post('users.setActive', options)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
# This method lets you set the calling user's manual presence.
|
|
59
|
+
# Consult the presence documentation for more details.
|
|
60
|
+
#
|
|
61
|
+
# @option options [Object] :presence
|
|
62
|
+
# Either auto or away.
|
|
63
|
+
# @see https://api.slack.com/methods/users.setPresence
|
|
64
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.setPresence.json
|
|
65
|
+
def users_setPresence(options = {})
|
|
66
|
+
throw ArgumentError.new('Required arguments :presence missing') if options[:presence].nil?
|
|
67
|
+
post('users.setPresence', options)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mixin": true,
|
|
3
|
+
"group": "channels",
|
|
4
|
+
"name": "channels.id",
|
|
5
|
+
"desc": "This method returns the ID of a team channel.",
|
|
6
|
+
"args": {
|
|
7
|
+
"channel": {
|
|
8
|
+
"required": true,
|
|
9
|
+
"example": "#general",
|
|
10
|
+
"desc": "Channel to get ID for, prefixed with #.",
|
|
11
|
+
"type": "channel"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"errors": {
|
|
15
|
+
"channel_not_found": "Value passed for channel was invalid.",
|
|
16
|
+
"not_authed": "No authentication token provided.",
|
|
17
|
+
"invalid_auth": "Invalid authentication token.",
|
|
18
|
+
"account_inactive": "Authentication token is for a deleted user or team."
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Slack
|
|
2
|
+
module Web
|
|
3
|
+
module Api
|
|
4
|
+
module Mixins
|
|
5
|
+
module Channels
|
|
6
|
+
#
|
|
7
|
+
# This method returns a channel ID given a channel name.
|
|
8
|
+
#
|
|
9
|
+
# @option options [channel] :channel
|
|
10
|
+
# Channel to get ID for, prefixed with #.
|
|
11
|
+
def channels_id(options = {})
|
|
12
|
+
name = options[:channel]
|
|
13
|
+
throw ArgumentError.new('Required arguments :channel missing') if name.nil?
|
|
14
|
+
return { 'ok' => true, 'channel' => { 'id' => name } } unless name[0] == '#'
|
|
15
|
+
channels_list.tap do |list|
|
|
16
|
+
list['channels'].each do |channel|
|
|
17
|
+
return { 'ok' => true, 'channel' => { 'id' => channel['id'] } } if channel['name'] == name[1..-1]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
fail Slack::Web::Api::Error, 'channel_not_found'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mixin": true,
|
|
3
|
+
"group": "groups",
|
|
4
|
+
"name": "groups.id",
|
|
5
|
+
"desc": "This method returns the ID of a group.",
|
|
6
|
+
"args": {
|
|
7
|
+
"channel": {
|
|
8
|
+
"required": true,
|
|
9
|
+
"example": "#general",
|
|
10
|
+
"desc": "Group channel to get ID for, prefixed with #.",
|
|
11
|
+
"type": "group"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"errors": {
|
|
15
|
+
"channel_not_found": "Value passed for group was invalid.",
|
|
16
|
+
"not_authed": "No authentication token provided.",
|
|
17
|
+
"invalid_auth": "Invalid authentication token.",
|
|
18
|
+
"account_inactive": "Authentication token is for a deleted user or team."
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Slack
|
|
2
|
+
module Web
|
|
3
|
+
module Api
|
|
4
|
+
module Mixins
|
|
5
|
+
module Groups
|
|
6
|
+
#
|
|
7
|
+
# This method returns a group ID given a group name.
|
|
8
|
+
#
|
|
9
|
+
# @option options [channel] :channel
|
|
10
|
+
# Group channel to get ID for, prefixed with #.
|
|
11
|
+
def groups_id(options = {})
|
|
12
|
+
name = options[:channel]
|
|
13
|
+
throw ArgumentError.new('Required arguments :channel missing') if name.nil?
|
|
14
|
+
return { 'ok' => true, 'group' => { 'id' => name } } unless name[0] == '#'
|
|
15
|
+
groups_list.tap do |list|
|
|
16
|
+
list['groups'].each do |group|
|
|
17
|
+
return { 'ok' => true, 'group' => { 'id' => group['id'] } } if group['name'] == name[1..-1]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
fail Slack::Web::Api::Error, 'channel_not_found'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mixin": true,
|
|
3
|
+
"group": "users",
|
|
4
|
+
"name": "users.id",
|
|
5
|
+
"desc": "This method returns the ID of a team user.",
|
|
6
|
+
"args": {
|
|
7
|
+
"user": {
|
|
8
|
+
"required": true,
|
|
9
|
+
"example": "#general",
|
|
10
|
+
"desc": "User to get ID for, prefixed with @.",
|
|
11
|
+
"type": "user"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"errors": {
|
|
15
|
+
"user_not_found": "Value passed for user was invalid.",
|
|
16
|
+
"not_authed": "No authentication token provided.",
|
|
17
|
+
"invalid_auth": "Invalid authentication token.",
|
|
18
|
+
"account_inactive": "Authentication token is for a deleted user or team."
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Slack
|
|
2
|
+
module Web
|
|
3
|
+
module Api
|
|
4
|
+
module Mixins
|
|
5
|
+
module Users
|
|
6
|
+
#
|
|
7
|
+
# This method returns a user ID given a user name.
|
|
8
|
+
#
|
|
9
|
+
# @option options [user] :user
|
|
10
|
+
# User to get ID for, prefixed with '@'.
|
|
11
|
+
def users_id(options = {})
|
|
12
|
+
name = options[:user]
|
|
13
|
+
throw ArgumentError.new('Required arguments :user missing') if name.nil?
|
|
14
|
+
return { 'ok' => true, 'user' => { 'id' => name } } unless name[0] == '@'
|
|
15
|
+
users_list.tap do |list|
|
|
16
|
+
list['members'].each do |user|
|
|
17
|
+
return { 'ok' => true, 'user' => { 'id' => user['id'] } } if user['name'] == name[1..-1]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
fail Slack::Web::Api::Error, 'user_not_found'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
|
|
2
|
+
index 1f7a8d7..2ec4bed 100644
|
|
3
|
+
--- a/lib/slack/web/api/endpoints/chat.rb
|
|
4
|
+
+++ b/lib/slack/web/api/endpoints/chat.rb
|
|
5
|
+
@@ -49,7 +49,7 @@ module Slack
|
|
6
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat.postMessage.json
|
|
7
|
+
def chat_postMessage(options = {})
|
|
8
|
+
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
|
9
|
+
- throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
|
|
10
|
+
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
|
|
11
|
+
post('chat.postMessage', options)
|
|
12
|
+
end
|
|
13
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
|
|
2
|
+
index 1f7a8d7..89b1562 100644
|
|
3
|
+
--- a/lib/slack/web/api/endpoints/chat.rb
|
|
4
|
+
+++ b/lib/slack/web/api/endpoints/chat.rb
|
|
5
|
+
@@ -50,6 +50,12 @@ module Slack
|
|
6
|
+
def chat_postMessage(options = {})
|
|
7
|
+
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
|
|
8
|
+
throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
|
|
9
|
+
+ # attachments must be passed as an encoded JSON string
|
|
10
|
+
+ if options.key?(:attachments)
|
|
11
|
+
+ attachments = options[:attachments]
|
|
12
|
+
+ attachments = JSON.dump(attachments) unless attachments.is_a?(String)
|
|
13
|
+
+ options = options.merge(attachments: attachments)
|
|
14
|
+
+ end
|
|
15
|
+
post('chat.postMessage', options)
|
|
16
|
+
end
|
|
17
|
+
|