slack-ruby-client 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +17 -14
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +1 -0
- data/README.md +32 -18
- data/Rakefile +4 -1
- data/UPGRADING.md +41 -3
- data/bin/commands.rb +1 -1
- data/bin/commands/api.rb +1 -1
- data/bin/commands/auth.rb +1 -1
- data/bin/commands/channels.rb +3 -3
- data/bin/commands/chat.rb +1 -1
- data/bin/commands/dnd.rb +1 -1
- data/bin/commands/emoji.rb +1 -1
- data/bin/commands/files.rb +2 -1
- data/bin/commands/groups.rb +1 -1
- data/bin/commands/im.rb +1 -1
- data/bin/commands/mpim.rb +1 -1
- data/bin/commands/oauth.rb +1 -1
- data/bin/commands/pins.rb +1 -1
- data/bin/commands/reactions.rb +1 -1
- data/bin/commands/rtm.rb +1 -1
- data/bin/commands/search.rb +1 -1
- data/bin/commands/stars.rb +1 -1
- data/bin/commands/team.rb +1 -1
- data/bin/commands/usergroups.rb +1 -1
- data/bin/commands/users.rb +10 -1
- data/examples/hi_real_time/hi.rb +5 -5
- data/examples/hi_real_time_and_web/hi.rb +4 -4
- data/examples/hi_real_time_async/hi.rb +5 -5
- data/lib/slack-ruby-client.rb +10 -0
- data/lib/slack/messages/message.rb +9 -0
- data/lib/slack/real_time/api/schema/event.json +22 -0
- data/lib/slack/real_time/api/templates/event_handler.erb +18 -0
- data/lib/slack/real_time/api/templates/event_handlers.erb +5 -0
- data/lib/slack/real_time/client.rb +31 -9
- data/lib/slack/real_time/config.rb +3 -1
- data/lib/slack/real_time/event_handlers.rb +66 -0
- data/lib/slack/real_time/event_handlers/accounts_changed.rb +18 -0
- data/lib/slack/real_time/event_handlers/bot_added.rb +16 -0
- data/lib/slack/real_time/event_handlers/bot_changed.rb +17 -0
- data/lib/slack/real_time/event_handlers/channel_archive.rb +17 -0
- data/lib/slack/real_time/event_handlers/channel_created.rb +17 -0
- data/lib/slack/real_time/event_handlers/channel_deleted.rb +16 -0
- data/lib/slack/real_time/event_handlers/channel_history_changed.rb +18 -0
- data/lib/slack/real_time/event_handlers/channel_joined.rb +22 -0
- data/lib/slack/real_time/event_handlers/channel_left.rb +17 -0
- data/lib/slack/real_time/event_handlers/channel_marked.rb +18 -0
- data/lib/slack/real_time/event_handlers/channel_rename.rb +17 -0
- data/lib/slack/real_time/event_handlers/channel_unarchive.rb +17 -0
- data/lib/slack/real_time/event_handlers/commands_changed.rb +18 -0
- data/lib/slack/real_time/event_handlers/dnd_updated.rb +18 -0
- data/lib/slack/real_time/event_handlers/dnd_updated_user.rb +18 -0
- data/lib/slack/real_time/event_handlers/email_domain_changed.rb +16 -0
- data/lib/slack/real_time/event_handlers/emoji_changed.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_change.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_comment_added.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_comment_deleted.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_comment_edited.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_created.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_deleted.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_private.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_public.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_shared.rb +18 -0
- data/lib/slack/real_time/event_handlers/file_unshared.rb +18 -0
- data/lib/slack/real_time/event_handlers/group_archive.rb +17 -0
- data/lib/slack/real_time/event_handlers/group_close.rb +16 -0
- data/lib/slack/real_time/event_handlers/group_history_changed.rb +18 -0
- data/lib/slack/real_time/event_handlers/group_joined.rb +16 -0
- data/lib/slack/real_time/event_handlers/group_left.rb +17 -0
- data/lib/slack/real_time/event_handlers/group_marked.rb +18 -0
- data/lib/slack/real_time/event_handlers/group_open.rb +16 -0
- data/lib/slack/real_time/event_handlers/group_rename.rb +17 -0
- data/lib/slack/real_time/event_handlers/group_unarchive.rb +17 -0
- data/lib/slack/real_time/event_handlers/im_close.rb +16 -0
- data/lib/slack/real_time/event_handlers/im_created.rb +16 -0
- data/lib/slack/real_time/event_handlers/im_history_changed.rb +18 -0
- data/lib/slack/real_time/event_handlers/im_marked.rb +18 -0
- data/lib/slack/real_time/event_handlers/im_open.rb +16 -0
- data/lib/slack/real_time/event_handlers/manual_presence_change.rb +16 -0
- data/lib/slack/real_time/event_handlers/pin_added.rb +18 -0
- data/lib/slack/real_time/event_handlers/pin_removed.rb +18 -0
- data/lib/slack/real_time/event_handlers/pref_change.rb +16 -0
- data/lib/slack/real_time/event_handlers/presence_change.rb +17 -0
- data/lib/slack/real_time/event_handlers/reaction_added.rb +18 -0
- data/lib/slack/real_time/event_handlers/reaction_removed.rb +18 -0
- data/lib/slack/real_time/event_handlers/reconnect_url.rb +18 -0
- data/lib/slack/real_time/event_handlers/star_added.rb +18 -0
- data/lib/slack/real_time/event_handlers/star_removed.rb +18 -0
- data/lib/slack/real_time/event_handlers/subteam_created.rb +18 -0
- data/lib/slack/real_time/event_handlers/subteam_self_added.rb +18 -0
- data/lib/slack/real_time/event_handlers/subteam_self_removed.rb +18 -0
- data/lib/slack/real_time/event_handlers/subteam_updated.rb +18 -0
- data/lib/slack/real_time/event_handlers/team_domain_change.rb +17 -0
- data/lib/slack/real_time/event_handlers/team_join.rb +16 -0
- data/lib/slack/real_time/event_handlers/team_migration_started.rb +18 -0
- data/lib/slack/real_time/event_handlers/team_plan_change.rb +16 -0
- data/lib/slack/real_time/event_handlers/team_pref_change.rb +16 -0
- data/lib/slack/real_time/event_handlers/team_profile_change.rb +18 -0
- data/lib/slack/real_time/event_handlers/team_profile_delete.rb +18 -0
- data/lib/slack/real_time/event_handlers/team_profile_reorder.rb +18 -0
- data/lib/slack/real_time/event_handlers/team_rename.rb +16 -0
- data/lib/slack/real_time/event_handlers/user_change.rb +16 -0
- data/lib/slack/real_time/event_handlers/user_typing.rb +18 -0
- data/lib/slack/real_time/models.rb +7 -0
- data/lib/slack/real_time/models/base.rb +11 -0
- data/lib/slack/real_time/models/bot.rb +8 -0
- data/lib/slack/real_time/models/channel.rb +8 -0
- data/lib/slack/real_time/models/group.rb +8 -0
- data/lib/slack/real_time/models/im.rb +8 -0
- data/lib/slack/real_time/models/team.rb +8 -0
- data/lib/slack/real_time/models/user.rb +8 -0
- data/lib/slack/real_time/store.rb +47 -0
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/endpoints.rb +1 -1
- data/lib/slack/web/api/endpoints/api.rb +1 -1
- data/lib/slack/web/api/endpoints/auth.rb +1 -1
- data/lib/slack/web/api/endpoints/channels.rb +2 -4
- data/lib/slack/web/api/endpoints/chat.rb +1 -1
- data/lib/slack/web/api/endpoints/dnd.rb +1 -1
- data/lib/slack/web/api/endpoints/emoji.rb +1 -1
- data/lib/slack/web/api/endpoints/files.rb +4 -1
- data/lib/slack/web/api/endpoints/groups.rb +1 -1
- data/lib/slack/web/api/endpoints/im.rb +1 -1
- data/lib/slack/web/api/endpoints/mpim.rb +1 -1
- data/lib/slack/web/api/endpoints/oauth.rb +1 -1
- data/lib/slack/web/api/endpoints/pins.rb +1 -1
- data/lib/slack/web/api/endpoints/reactions.rb +1 -1
- data/lib/slack/web/api/endpoints/rtm.rb +1 -1
- data/lib/slack/web/api/endpoints/search.rb +1 -1
- data/lib/slack/web/api/endpoints/stars.rb +1 -1
- data/lib/slack/web/api/endpoints/team.rb +1 -1
- data/lib/slack/web/api/endpoints/usergroups.rb +1 -1
- data/lib/slack/web/api/endpoints/users.rb +1 -1
- data/lib/slack/web/api/mixins.rb +1 -0
- data/lib/slack/web/api/mixins/channels.id.rb +2 -2
- data/lib/slack/web/api/mixins/groups.id.rb +2 -2
- data/lib/slack/web/api/mixins/users.id.rb +2 -2
- data/lib/slack/web/api/mixins/users.search.json +19 -0
- data/lib/slack/web/api/mixins/users.search.rb +43 -0
- data/lib/slack/web/api/templates/command.erb +1 -1
- data/lib/slack/web/api/templates/commands.erb +1 -1
- data/lib/slack/web/api/templates/endpoints.erb +1 -1
- data/lib/slack/web/api/templates/method.erb +1 -1
- data/lib/slack/web/api/templates/method_spec.erb +20 -0
- data/lib/slack/web/faraday/connection.rb +1 -0
- data/lib/tasks/git.rake +7 -0
- data/lib/tasks/real_time.rake +45 -0
- data/lib/tasks/update.rake +9 -0
- data/lib/{slack/web/api/tasks/generate.rake → tasks/web.rake} +6 -6
- data/slack-ruby-client.gemspec +1 -0
- data/spec/fixtures/slack/web/rtm_start.yml +53 -22
- data/spec/integration/integration_spec.rb +5 -5
- data/spec/slack/real_time/client_spec.rb +72 -10
- data/spec/slack/real_time/event_handlers/bot_spec.rb +42 -0
- data/spec/slack/real_time/event_handlers/channel_spec.rb +116 -0
- data/spec/slack/real_time/event_handlers/group_spec.rb +90 -0
- data/spec/slack/real_time/event_handlers/im_spec.rb +47 -0
- data/spec/slack/real_time/event_handlers/team_spec.rb +58 -0
- data/spec/slack/real_time/event_handlers/user_spec.rb +61 -0
- data/spec/slack/real_time/rtm_start_spec.rb +13 -0
- data/spec/slack/real_time/store_spec.rb +11 -0
- data/spec/slack/slack_spec.rb +6 -6
- data/spec/slack/web/api/endpoints/api_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/{auth_spec.rb → custom_specs/auth_spec.rb} +0 -0
- data/spec/slack/web/api/endpoints/{channels_spec.rb → custom_specs/channels_spec.rb} +1 -1
- data/spec/slack/web/api/endpoints/{chat_spec.rb → custom_specs/chat_spec.rb} +0 -0
- data/spec/slack/web/api/endpoints/{groups_spec.rb → custom_specs/groups_spec.rb} +1 -1
- data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +23 -0
- data/spec/slack/web/api/endpoints/dnd_spec.rb +12 -0
- data/spec/slack/web/api/endpoints/emoji_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/files_spec.rb +36 -0
- data/spec/slack/web/api/endpoints/im_spec.rb +30 -0
- data/spec/slack/web/api/endpoints/mpim_spec.rb +30 -0
- data/spec/slack/web/api/endpoints/oauth_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/pins_spec.rb +22 -0
- data/spec/slack/web/api/endpoints/reactions_spec.rb +17 -0
- data/spec/slack/web/api/endpoints/rtm_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/search_spec.rb +22 -0
- data/spec/slack/web/api/endpoints/stars_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/team_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/usergroups_spec.rb +35 -0
- data/spec/slack/web/api/mixins/channels_spec.rb +6 -6
- data/spec/slack/web/api/mixins/groups_spec.rb +6 -6
- data/spec/slack/web/api/mixins/users_spec.rb +12 -6
- data/spec/support/real_time/event.rb +11 -0
- metadata +159 -13
- data/spec/slack/web/api/endpoints/users_spec.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b713ee1b5bbc32bbb54b434199c8245d1edcc528
|
4
|
+
data.tar.gz: 7122943dc5dabf15ccf656be06b3df08c24e39ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e9b7148626db6c19db75a8688f6f4233158ce7dc7162d084525516ceb8d458e14a8a2dca875d64ac88cad5913e60f3923b28038b54201de7bfa28bb625cb99d
|
7
|
+
data.tar.gz: 464204c4a4285827791b0c166d958f2fafe7cdadc38af68e40f3db8798e746fd78f70eed0dc5c649f93c8523a2fe8bdda6328ee75456d872cffa7201f1b7fc48
|
data/.rubocop_todo.yml
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2016-
|
3
|
+
# on 2016-02-02 17:03:58 -0500 using RuboCop version 0.35.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 4
|
10
10
|
Lint/HandleExceptions:
|
11
11
|
Exclude:
|
12
|
+
- 'lib/slack-ruby-client.rb'
|
12
13
|
- 'lib/slack/real_time/concurrency/celluloid.rb'
|
13
14
|
- 'spec/slack/real_time/concurrency/celluloid_spec.rb'
|
14
15
|
- 'spec/slack/real_time/concurrency/eventmachine_spec.rb'
|
@@ -20,30 +21,26 @@ Lint/UnusedBlockArgument:
|
|
20
21
|
Exclude:
|
21
22
|
- 'lib/slack/messages/formatting.rb'
|
22
23
|
|
23
|
-
# Offense count:
|
24
|
+
# Offense count: 12
|
24
25
|
Metrics/AbcSize:
|
25
|
-
Max:
|
26
|
+
Max: 31
|
26
27
|
|
27
28
|
# Offense count: 1
|
28
29
|
# Configuration parameters: CountComments.
|
29
30
|
Metrics/ClassLength:
|
30
|
-
Max:
|
31
|
-
|
32
|
-
# Offense count: 1
|
33
|
-
Metrics/CyclomaticComplexity:
|
34
|
-
Max: 7
|
31
|
+
Max: 131
|
35
32
|
|
36
|
-
# Offense count:
|
33
|
+
# Offense count: 586
|
37
34
|
# Configuration parameters: AllowURI, URISchemes.
|
38
35
|
Metrics/LineLength:
|
39
36
|
Max: 288
|
40
37
|
|
41
|
-
# Offense count:
|
38
|
+
# Offense count: 6
|
42
39
|
# Configuration parameters: CountComments.
|
43
40
|
Metrics/MethodLength:
|
44
|
-
Max:
|
41
|
+
Max: 24
|
45
42
|
|
46
|
-
# Offense count:
|
43
|
+
# Offense count: 80
|
47
44
|
# Configuration parameters: Exclude.
|
48
45
|
Style/Documentation:
|
49
46
|
Enabled: false
|
@@ -54,11 +51,17 @@ Style/FileName:
|
|
54
51
|
Exclude:
|
55
52
|
- 'lib/slack-ruby-client.rb'
|
56
53
|
|
57
|
-
# Offense count:
|
54
|
+
# Offense count: 90
|
58
55
|
# Configuration parameters: AllowedVariables.
|
59
56
|
Style/GlobalVars:
|
60
57
|
Enabled: false
|
61
58
|
|
59
|
+
# Offense count: 1
|
60
|
+
# Configuration parameters: MinBodyLength.
|
61
|
+
Style/GuardClause:
|
62
|
+
Exclude:
|
63
|
+
- 'lib/slack/real_time/store.rb'
|
64
|
+
|
62
65
|
# Offense count: 15
|
63
66
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
64
67
|
Style/MethodName:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 0.6.0 (2/4/2016)
|
2
|
+
|
3
|
+
* [#54](https://github.com/dblock/slack-ruby-client/issues/54): RealTime client maintains a local store of team data for `client.self`, `team`, `users`, `channels`, `groups`, `ims` and `bots` data - [@dblock](https://github.com/dblock).
|
4
|
+
* [#56](https://github.com/dblock/slack-ruby-client/issues/56): API responses in both Web and RealTime clients are now instances of [Slack::Messages::Message](lib/slack/messages/message), which provides method access to properties - [@dblock](https://github.com/dblock).
|
5
|
+
* [#57](https://github.com/dblock/slack-ruby-client/issues/57): Configure arguments to pass to `rtm.start` via `config.start_options` - [@dblock](https://github.com/dblock).
|
6
|
+
* [#52](https://github.com/dblock/slack-ruby-client/issues/52): Added `users_search` - [@dblock](https://github.com/dblock).
|
7
|
+
|
1
8
|
### 0.5.4 (1/23/2016)
|
2
9
|
|
3
10
|
* [#45](https://github.com/dblock/slack-ruby-client/issues/45): Added `channels_id`, `groups_id` and `users_id` - [@dblock](https://github.com/dblock).
|
data/CONTRIBUTING.md
CHANGED
@@ -68,7 +68,7 @@ Make sure that `bundle exec rake` completes without errors.
|
|
68
68
|
Slack Web API is updated from https://github.com/dblock/slack-api-ref, a maintained, machine-readable version of Slack API Docs, generated by scraping [api.slack.com](https://api.slack.com). To update the Web API from the latest definition run the following Rake task.
|
69
69
|
|
70
70
|
```
|
71
|
-
rake slack:
|
71
|
+
rake slack:api:update
|
72
72
|
```
|
73
73
|
|
74
74
|
#### Patching Slack Web API
|
@@ -81,7 +81,7 @@ Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat
|
|
81
81
|
git diff HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
|
82
82
|
```
|
83
83
|
|
84
|
-
Run `rake slack:
|
84
|
+
Run `rake slack:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
|
85
85
|
|
86
86
|
### Write Documentation
|
87
87
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messa
|
|
18
18
|
|
19
19
|
## Stable Release
|
20
20
|
|
21
|
-
You're reading the documentation for the **stable** release of slack-ruby-client, 0.
|
21
|
+
You're reading the documentation for the **stable** release of slack-ruby-client, 0.6.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
22
22
|
|
23
23
|
## Installation
|
24
24
|
|
@@ -83,9 +83,9 @@ See a fully working example in [examples/hi_web](examples/hi_web/hi.rb).
|
|
83
83
|
List channels with [channels_list](https://api.slack.com/methods/channels.list).
|
84
84
|
|
85
85
|
```ruby
|
86
|
-
channels = client.channels_list
|
86
|
+
channels = client.channels_list.channels
|
87
87
|
|
88
|
-
general_channel = channels.detect { |c| c
|
88
|
+
general_channel = channels.detect { |c| c.name == 'general' }
|
89
89
|
```
|
90
90
|
|
91
91
|
#### Upload a File
|
@@ -127,6 +127,14 @@ client.users_info(user: 'U092BDCLV') # calls users_info
|
|
127
127
|
client.users_info(user: '@dblock') # calls users_list followed by users_info
|
128
128
|
```
|
129
129
|
|
130
|
+
### Search for a User
|
131
|
+
|
132
|
+
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.
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
client.users_search(user: 'dblock')
|
136
|
+
```
|
137
|
+
|
130
138
|
#### Other
|
131
139
|
|
132
140
|
Refer to the [Slack Web API Method Reference](https://api.slack.com/methods) for the list of all available functions.
|
@@ -165,15 +173,15 @@ The Real Time Messaging API is a WebSocket-based API that allows you to receive
|
|
165
173
|
client = Slack::RealTime::Client.new
|
166
174
|
|
167
175
|
client.on :hello do
|
168
|
-
puts "Successfully connected, welcome '#{client.self
|
176
|
+
puts "Successfully connected, welcome '#{client.self.name}' to the '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
|
169
177
|
end
|
170
178
|
|
171
179
|
client.on :message do |data|
|
172
|
-
case data
|
180
|
+
case data.text
|
173
181
|
when 'bot hi' then
|
174
|
-
client.message channel: data
|
182
|
+
client.message channel: data.channel, text: "Hi <@#{data.user}>!"
|
175
183
|
when /^bot/ then
|
176
|
-
client.message channel: data
|
184
|
+
client.message channel: data.channel, text: "Sorry <@#{data.user}>, what?"
|
177
185
|
end
|
178
186
|
end
|
179
187
|
|
@@ -183,7 +191,7 @@ client.start!
|
|
183
191
|
You can send typing indicators with `typing`.
|
184
192
|
|
185
193
|
```ruby
|
186
|
-
client.typing channel: data
|
194
|
+
client.typing channel: data.channel
|
187
195
|
```
|
188
196
|
|
189
197
|
You can send a ping with `ping`.
|
@@ -192,19 +200,23 @@ You can send a ping with `ping`.
|
|
192
200
|
client.ping
|
193
201
|
```
|
194
202
|
|
195
|
-
|
203
|
+
By default, the RealTime client exposes and maintains a local store with the properties of [rtm.start](https://api.slack.com/methods/rtm.start) upon a successful connection.
|
196
204
|
|
197
205
|
property | description
|
198
206
|
---------|-------------------------------------------------------------------------------------------------
|
199
207
|
url | A WebSocket Message Server URL.
|
200
|
-
self |
|
208
|
+
self | The authenticated bot user.
|
201
209
|
team | Details on the authenticated user's team.
|
202
|
-
users | A
|
203
|
-
channels | A
|
204
|
-
groups | A
|
205
|
-
ims | A
|
210
|
+
users | A hash of user objects by user ID.
|
211
|
+
channels | A hash of channel objects, one for every channel visible to the authenticated user.
|
212
|
+
groups | A hash of group objects, one for every group the authenticated user is in.
|
213
|
+
ims | A hash of IM objects, one for every direct message channel visible to the authenticated user.
|
206
214
|
bots | Details of the integrations set up on this team.
|
207
215
|
|
216
|
+
It also tracks changes, such as users being renamed, added or deleted, therefore `client.users` is always up-to-date.
|
217
|
+
|
218
|
+
Tracking with a local store can be disabled with `Slack::RealTime::Client.new(store_class: nil)`
|
219
|
+
|
208
220
|
You can configure the RealTime client either globally or via the initializer.
|
209
221
|
|
210
222
|
```ruby
|
@@ -224,10 +236,12 @@ setting | description
|
|
224
236
|
token | Slack API token.
|
225
237
|
websocket_ping | The number of seconds that indicates how often the WebSocket should send ping frames, default is 30.
|
226
238
|
websocket_proxy | Connect via proxy, include `:origin` and `:headers`.
|
239
|
+
store_class | Local store class name, default is an in-memory `Slack::RealTime::Store`.
|
240
|
+
start_options | Options to pass into `rtm.start`, default is `{}`.
|
227
241
|
|
228
242
|
Note that the RealTime client uses a Web client to obtain the WebSocket URL via [rtm.start](https://api.slack.com/methods/rtm.start), configure Web client options via `Slack::Web::Client.configure` as described above.
|
229
243
|
|
230
|
-
See a
|
244
|
+
See a fully working example in [examples/hi_real_time](examples/hi_real_time/hi.rb).
|
231
245
|
|
232
246
|

|
233
247
|
|
@@ -239,11 +253,11 @@ Since the Web client is used to obtain the RealTime client's WebSocket URL, you
|
|
239
253
|
client = Slack::RealTime::Client.new
|
240
254
|
|
241
255
|
client.on :message do |data|
|
242
|
-
case data
|
256
|
+
case data.text
|
243
257
|
when 'bot hi' then
|
244
|
-
client.web_client.chat_postMessage channel: data
|
258
|
+
client.web_client.chat_postMessage channel: data.channel, text: "Hi <@#{data.user}>!"
|
245
259
|
when /^bot/ then
|
246
|
-
client.web_client.chat_postMessage channel: data
|
260
|
+
client.web_client.chat_postMessage channel: data.channel, text: "Sorry <@#{data.user}>, what?"
|
247
261
|
end
|
248
262
|
end
|
249
263
|
|
data/Rakefile
CHANGED
data/UPGRADING.md
CHANGED
@@ -1,16 +1,54 @@
|
|
1
1
|
Upgrading Slack-Ruby-Client
|
2
2
|
===========================
|
3
3
|
|
4
|
+
### Upgrading to >= 0.6.0
|
5
|
+
|
6
|
+
#### Changes to API Response Data
|
7
|
+
|
8
|
+
API responses in both Web and RealTime clients are now instances of [Slack::Messages::Message](lib/slack/messages/message.rb), which provides method access to properties.
|
9
|
+
|
10
|
+
Before:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
puts "Welcome '#{client.self['name']}' to the '#{client.team['name']}' team."
|
14
|
+
```
|
15
|
+
|
16
|
+
After:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
puts "Welcome #{client.self.name} to the #{client.team.name} team."
|
20
|
+
```
|
21
|
+
|
22
|
+
See [#56](https://github.com/dblock/slack-ruby-client/issues/56) for more information.
|
23
|
+
|
24
|
+
#### Changes to RealTime Local Store
|
25
|
+
|
26
|
+
Upon a successful `rtm.start` the RealTime client keeps a local cache of objects, including `self` or `users`. It will now also track changes to these objects. The following changes have been made to the data structures.
|
27
|
+
|
28
|
+
##### client.self
|
29
|
+
|
30
|
+
The `client.self` object is now a `Slack::RealTime::Models::User`, which is a child of `Hashie::Mash`, so no code changes should be required.
|
31
|
+
|
32
|
+
##### client.team
|
33
|
+
|
34
|
+
The `client.team` object is now a `Slack::RealTime::Models::Team`, which is a child of `Hashie::Mash`, so no code changes should be required.
|
35
|
+
|
36
|
+
##### client .users, .channels, .groups, .ims
|
37
|
+
|
38
|
+
The `client.users`, `.channels`, `.groups` and `.ims` collections have been changed from `Array` to `Hash`, with object ID as key. Replace any code iterating over the array, eg. `client.users.values.each` or `client.channels.each_pair { |id, channel| ... }`.
|
39
|
+
|
40
|
+
See [#55](https://github.com/dblock/slack-ruby-client/issues/55) for more information.
|
41
|
+
|
4
42
|
### Upgrading to >= 0.5.0
|
5
43
|
|
6
44
|
#### Changes to Real Time Concurrency
|
7
45
|
|
8
46
|
Since 0.5.0 `Slack::RealTime::Client` supports [Celluloid](https://github.com/celluloid/celluloid) and no longer defaults to [Faye::WebSocket](https://github.com/faye/faye-websocket-ruby) with [Eventmachine](https://github.com/eventmachine/eventmachine). It will auto-detect one or the other depending on the gems in your Gemfile, which means you may need to add one or the other to your Gemfile.
|
9
47
|
|
10
|
-
##### Faye::
|
48
|
+
##### Faye::WebSocket with Eventmachine
|
11
49
|
|
12
50
|
```
|
13
|
-
gem 'faye-
|
51
|
+
gem 'faye-websocket'
|
14
52
|
```
|
15
53
|
|
16
54
|
##### Celluloid
|
@@ -19,7 +57,7 @@ gem 'faye-webSocket'
|
|
19
57
|
gem 'celluloid-io'
|
20
58
|
```
|
21
59
|
|
22
|
-
When in doubt, use
|
60
|
+
When in doubt, use `faye-websocket`.
|
23
61
|
|
24
62
|
See [#5](https://github.com/dblock/slack-ruby-client/issues/5) for more information.
|
25
63
|
|
data/bin/commands.rb
CHANGED
data/bin/commands/api.rb
CHANGED
data/bin/commands/auth.rb
CHANGED
data/bin/commands/channels.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# This file was auto-generated by lib/
|
1
|
+
# This file was auto-generated by lib/tasks/web.rake
|
2
2
|
|
3
3
|
desc "Get info on your team's Slack channels, create or archive channels, invite users, set the topic and purpose, and mark a channel as read."
|
4
4
|
command 'channels' do |g|
|
@@ -20,8 +20,8 @@ command 'channels' do |g|
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
g.desc 'This method returns a portion of
|
24
|
-
g.long_desc %( This method returns a portion of
|
23
|
+
g.desc 'This method returns a portion of message events from the specified channel.'
|
24
|
+
g.long_desc %( This method returns a portion of message events from the specified channel. )
|
25
25
|
g.command 'history' do |c|
|
26
26
|
c.flag 'channel', desc: 'Channel to fetch history for.'
|
27
27
|
c.flag 'latest', desc: 'End of time range of messages to include in results.'
|
data/bin/commands/chat.rb
CHANGED
data/bin/commands/dnd.rb
CHANGED
data/bin/commands/emoji.rb
CHANGED
data/bin/commands/files.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# This file was auto-generated by lib/
|
1
|
+
# This file was auto-generated by lib/tasks/web.rake
|
2
2
|
|
3
3
|
desc 'Get info on files uploaded to Slack, upload new files to Slack.'
|
4
4
|
command 'files' do |g|
|
@@ -35,6 +35,7 @@ command 'files' do |g|
|
|
35
35
|
g.long_desc %( This method returns a list of files within the team. It can be filtered and sliced in various ways. )
|
36
36
|
g.command 'list' do |c|
|
37
37
|
c.flag 'user', desc: 'Filter files created by a single user.'
|
38
|
+
c.flag 'channel', desc: 'Filter files appearing in a specific channel, indicated by its ID.'
|
38
39
|
c.flag 'ts_from', desc: 'Filter files created after this timestamp (inclusive).'
|
39
40
|
c.flag 'ts_to', desc: 'Filter files created before this timestamp (inclusive).'
|
40
41
|
c.flag 'types', desc: 'Filter files by type:
|
data/bin/commands/groups.rb
CHANGED
data/bin/commands/im.rb
CHANGED
data/bin/commands/mpim.rb
CHANGED
data/bin/commands/oauth.rb
CHANGED
data/bin/commands/pins.rb
CHANGED
data/bin/commands/reactions.rb
CHANGED
data/bin/commands/rtm.rb
CHANGED
data/bin/commands/search.rb
CHANGED