slack-ruby-client 0.6.0 → 0.7.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 +19 -17
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +24 -4
- data/bin/commands/chat.rb +10 -9
- data/bin/commands/files.rb +19 -1
- data/examples/hi_real_time/hi.rb +2 -0
- data/lib/slack-ruby-client.rb +4 -2
- data/lib/slack/config.rb +4 -0
- data/lib/slack/logger.rb +13 -0
- data/lib/slack/messages/message.rb +6 -0
- data/lib/slack/real_time/api/schema/event.json +1 -0
- data/lib/slack/real_time/api/templates/event_handler.erb +4 -18
- data/lib/slack/real_time/client.rb +29 -5
- data/lib/slack/real_time/concurrency/celluloid.rb +6 -0
- data/lib/slack/real_time/concurrency/eventmachine.rb +22 -1
- data/lib/slack/real_time/config.rb +5 -1
- data/lib/slack/real_time/socket.rb +5 -0
- data/lib/slack/real_time/stores.rb +10 -0
- data/lib/slack/real_time/stores/base.rb +34 -0
- data/lib/slack/real_time/stores/starter.rb +361 -0
- data/lib/slack/real_time/stores/store.rb +479 -0
- data/lib/slack/version.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 +14 -14
- data/lib/slack/web/api/endpoints/chat.rb +15 -13
- data/lib/slack/web/api/endpoints/dnd.rb +5 -5
- data/lib/slack/web/api/endpoints/emoji.rb +1 -1
- data/lib/slack/web/api/endpoints/files.rb +30 -6
- data/lib/slack/web/api/endpoints/groups.rb +16 -16
- data/lib/slack/web/api/endpoints/im.rb +5 -5
- data/lib/slack/web/api/endpoints/mpim.rb +5 -5
- data/lib/slack/web/api/endpoints/oauth.rb +1 -1
- data/lib/slack/web/api/endpoints/pins.rb +3 -3
- data/lib/slack/web/api/endpoints/reactions.rb +4 -4
- data/lib/slack/web/api/endpoints/rtm.rb +1 -1
- data/lib/slack/web/api/endpoints/search.rb +3 -3
- data/lib/slack/web/api/endpoints/stars.rb +3 -3
- data/lib/slack/web/api/endpoints/team.rb +3 -3
- data/lib/slack/web/api/endpoints/usergroups.rb +6 -6
- data/lib/slack/web/api/endpoints/users.rb +5 -5
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +1 -1
- data/lib/slack/web/api/templates/method.erb +1 -1
- data/lib/slack/web/client.rb +1 -0
- data/lib/tasks/real_time.rake +27 -21
- data/slack-ruby-client.gemspec +1 -0
- data/spec/integration/integration_spec.rb +13 -1
- data/spec/slack/real_time/client_spec.rb +40 -5
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +2 -1
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +3 -2
- data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +15 -0
- data/spec/slack/real_time/event_handlers/team_spec.rb +54 -52
- data/spec/slack/web/api/endpoints/files_spec.rb +10 -0
- data/spec/slack/web/client_spec.rb +1 -1
- data/spec/support/real_time/connected_client.rb +3 -3
- metadata +23 -71
- data/lib/slack/real_time/api/templates/event_handlers.erb +0 -5
- data/lib/slack/real_time/event_handlers.rb +0 -66
- data/lib/slack/real_time/event_handlers/accounts_changed.rb +0 -18
- data/lib/slack/real_time/event_handlers/bot_added.rb +0 -16
- data/lib/slack/real_time/event_handlers/bot_changed.rb +0 -17
- data/lib/slack/real_time/event_handlers/channel_archive.rb +0 -17
- data/lib/slack/real_time/event_handlers/channel_created.rb +0 -17
- data/lib/slack/real_time/event_handlers/channel_deleted.rb +0 -16
- data/lib/slack/real_time/event_handlers/channel_history_changed.rb +0 -18
- data/lib/slack/real_time/event_handlers/channel_joined.rb +0 -22
- data/lib/slack/real_time/event_handlers/channel_left.rb +0 -17
- data/lib/slack/real_time/event_handlers/channel_marked.rb +0 -18
- data/lib/slack/real_time/event_handlers/channel_rename.rb +0 -17
- data/lib/slack/real_time/event_handlers/channel_unarchive.rb +0 -17
- data/lib/slack/real_time/event_handlers/commands_changed.rb +0 -18
- data/lib/slack/real_time/event_handlers/dnd_updated.rb +0 -18
- data/lib/slack/real_time/event_handlers/dnd_updated_user.rb +0 -18
- data/lib/slack/real_time/event_handlers/email_domain_changed.rb +0 -16
- data/lib/slack/real_time/event_handlers/emoji_changed.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_change.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_comment_added.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_comment_deleted.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_comment_edited.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_created.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_deleted.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_private.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_public.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_shared.rb +0 -18
- data/lib/slack/real_time/event_handlers/file_unshared.rb +0 -18
- data/lib/slack/real_time/event_handlers/group_archive.rb +0 -17
- data/lib/slack/real_time/event_handlers/group_close.rb +0 -16
- data/lib/slack/real_time/event_handlers/group_history_changed.rb +0 -18
- data/lib/slack/real_time/event_handlers/group_joined.rb +0 -16
- data/lib/slack/real_time/event_handlers/group_left.rb +0 -17
- data/lib/slack/real_time/event_handlers/group_marked.rb +0 -18
- data/lib/slack/real_time/event_handlers/group_open.rb +0 -16
- data/lib/slack/real_time/event_handlers/group_rename.rb +0 -17
- data/lib/slack/real_time/event_handlers/group_unarchive.rb +0 -17
- data/lib/slack/real_time/event_handlers/im_close.rb +0 -16
- data/lib/slack/real_time/event_handlers/im_created.rb +0 -16
- data/lib/slack/real_time/event_handlers/im_history_changed.rb +0 -18
- data/lib/slack/real_time/event_handlers/im_marked.rb +0 -18
- data/lib/slack/real_time/event_handlers/im_open.rb +0 -16
- data/lib/slack/real_time/event_handlers/manual_presence_change.rb +0 -16
- data/lib/slack/real_time/event_handlers/pin_added.rb +0 -18
- data/lib/slack/real_time/event_handlers/pin_removed.rb +0 -18
- data/lib/slack/real_time/event_handlers/pref_change.rb +0 -16
- data/lib/slack/real_time/event_handlers/presence_change.rb +0 -17
- data/lib/slack/real_time/event_handlers/reaction_added.rb +0 -18
- data/lib/slack/real_time/event_handlers/reaction_removed.rb +0 -18
- data/lib/slack/real_time/event_handlers/reconnect_url.rb +0 -18
- data/lib/slack/real_time/event_handlers/star_added.rb +0 -18
- data/lib/slack/real_time/event_handlers/star_removed.rb +0 -18
- data/lib/slack/real_time/event_handlers/subteam_created.rb +0 -18
- data/lib/slack/real_time/event_handlers/subteam_self_added.rb +0 -18
- data/lib/slack/real_time/event_handlers/subteam_self_removed.rb +0 -18
- data/lib/slack/real_time/event_handlers/subteam_updated.rb +0 -18
- data/lib/slack/real_time/event_handlers/team_domain_change.rb +0 -17
- data/lib/slack/real_time/event_handlers/team_join.rb +0 -16
- data/lib/slack/real_time/event_handlers/team_migration_started.rb +0 -18
- data/lib/slack/real_time/event_handlers/team_plan_change.rb +0 -16
- data/lib/slack/real_time/event_handlers/team_pref_change.rb +0 -16
- data/lib/slack/real_time/event_handlers/team_profile_change.rb +0 -18
- data/lib/slack/real_time/event_handlers/team_profile_delete.rb +0 -18
- data/lib/slack/real_time/event_handlers/team_profile_reorder.rb +0 -18
- data/lib/slack/real_time/event_handlers/team_rename.rb +0 -16
- data/lib/slack/real_time/event_handlers/user_change.rb +0 -16
- data/lib/slack/real_time/event_handlers/user_typing.rb +0 -18
- data/lib/slack/real_time/store.rb +0 -47
@@ -0,0 +1,479 @@
|
|
1
|
+
module Slack
|
2
|
+
module RealTime
|
3
|
+
module Stores
|
4
|
+
# Stores everything.
|
5
|
+
class Store < Base
|
6
|
+
def self
|
7
|
+
users[@self_id]
|
8
|
+
end
|
9
|
+
|
10
|
+
def team
|
11
|
+
teams[@team_id]
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(attrs)
|
15
|
+
if attrs.team
|
16
|
+
@team_id = attrs.team.id
|
17
|
+
@teams = { @team_id => Slack::RealTime::Models::Team.new(attrs.team) }
|
18
|
+
else
|
19
|
+
@teams = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
if attrs.self
|
23
|
+
@self_id = attrs.self.id
|
24
|
+
@users = { @self_id => Slack::RealTime::Models::User.new(attrs.self) }
|
25
|
+
else
|
26
|
+
@users = {}
|
27
|
+
end
|
28
|
+
|
29
|
+
attrs.users.each do |data|
|
30
|
+
user = Models::User.new(data)
|
31
|
+
@users[data.id] = @users.key?(data.id) ? @users[data.id].merge(user) : user
|
32
|
+
end if attrs.users
|
33
|
+
|
34
|
+
@channels = {}
|
35
|
+
attrs.channels.each do |data|
|
36
|
+
@channels[data.id] = Models::Channel.new(data)
|
37
|
+
end if attrs.channels
|
38
|
+
|
39
|
+
@bots = {}
|
40
|
+
attrs.bots.each do |data|
|
41
|
+
@bots[data.id] = Models::Bot.new(data)
|
42
|
+
end if attrs.bots
|
43
|
+
|
44
|
+
@groups = {}
|
45
|
+
attrs.groups.each do |data|
|
46
|
+
@groups[data.id] = Models::Group.new(data)
|
47
|
+
end if attrs.groups
|
48
|
+
|
49
|
+
@ims = {}
|
50
|
+
attrs.ims.each do |data|
|
51
|
+
@ims[data.id] = Models::Im.new(data)
|
52
|
+
end if attrs.ims
|
53
|
+
end
|
54
|
+
|
55
|
+
### RealTime Events
|
56
|
+
|
57
|
+
# A direct message read marker was updated.
|
58
|
+
# @see https://api.slack.com/events/im_marked
|
59
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/im_marked.json
|
60
|
+
# on :im_marked do |data|
|
61
|
+
|
62
|
+
# Bulk updates were made to a DM channel's history.
|
63
|
+
# @see https://api.slack.com/events/im_history_changed
|
64
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/im_history_changed.json
|
65
|
+
# on :im_history_changed do |data|
|
66
|
+
|
67
|
+
# The list of accounts a user is signed into has changed.
|
68
|
+
# @see https://api.slack.com/events/accounts_changed
|
69
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/accounts_changed.json
|
70
|
+
# on :accounts_changed do |data|
|
71
|
+
|
72
|
+
# An integration bot was added.
|
73
|
+
# @see https://api.slack.com/events/bot_added
|
74
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/bot_added.json
|
75
|
+
on :bot_added do |data|
|
76
|
+
bots[data.bot.id] = Models::Bot.new(data.bot)
|
77
|
+
end
|
78
|
+
|
79
|
+
# An integration bot was changed.
|
80
|
+
# @see https://api.slack.com/events/bot_changed
|
81
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/bot_changed.json
|
82
|
+
on :bot_changed do |data|
|
83
|
+
bot = bots[data.bot.id]
|
84
|
+
bot.merge!(data.bot) if bot
|
85
|
+
end
|
86
|
+
|
87
|
+
# A team channel was archived.
|
88
|
+
# @see https://api.slack.com/events/channel_archive
|
89
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_archive.json
|
90
|
+
on :channel_archive do |data|
|
91
|
+
channel = channels[data.channel]
|
92
|
+
channel.is_archived = true if channel
|
93
|
+
end
|
94
|
+
|
95
|
+
# A team channel was created.
|
96
|
+
# @see https://api.slack.com/events/channel_created
|
97
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_created.json
|
98
|
+
on :channel_created do |data|
|
99
|
+
channel = Models::Channel.new(data.channel)
|
100
|
+
channels[channel.id] = channel
|
101
|
+
end
|
102
|
+
|
103
|
+
# A team channel was deleted.
|
104
|
+
# @see https://api.slack.com/events/channel_deleted
|
105
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_deleted.json
|
106
|
+
on :channel_deleted do |data|
|
107
|
+
channels.delete(data.channel)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Bulk updates were made to a channel's history.
|
111
|
+
# @see https://api.slack.com/events/channel_history_changed
|
112
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_history_changed.json
|
113
|
+
# on :channel_history_changed do |data|
|
114
|
+
|
115
|
+
# You joined a channel.
|
116
|
+
# @see https://api.slack.com/events/channel_joined
|
117
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_joined.json
|
118
|
+
on :channel_joined do |data|
|
119
|
+
channel_id = data.channel.id
|
120
|
+
channel = channels[channel_id]
|
121
|
+
if channel
|
122
|
+
channel.merge!(data.channel)
|
123
|
+
else
|
124
|
+
channels[channel_id] = Models::Channel.new(data.channel)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# You left a channel.
|
129
|
+
# @see https://api.slack.com/events/channel_left
|
130
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_left.json
|
131
|
+
on :channel_left do |data|
|
132
|
+
channel = channels[data.channel]
|
133
|
+
channel.members.delete(self.self.id) if channel.key? :members
|
134
|
+
end
|
135
|
+
|
136
|
+
# Your channel read marker was updated.
|
137
|
+
# @see https://api.slack.com/events/channel_marked
|
138
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_marked.json
|
139
|
+
# on :channel_marked do |data|
|
140
|
+
|
141
|
+
# A team channel was renamed.
|
142
|
+
# @see https://api.slack.com/events/channel_rename
|
143
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_rename.json
|
144
|
+
on :channel_rename do |data|
|
145
|
+
channel = channels[data.channel.id]
|
146
|
+
channel.name = data.channel.name if channel
|
147
|
+
end
|
148
|
+
|
149
|
+
# A team channel was unarchived.
|
150
|
+
# @see https://api.slack.com/events/channel_unarchive
|
151
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/channel_unarchive.json
|
152
|
+
on :channel_unarchive do |data|
|
153
|
+
channel = channels[data.channel]
|
154
|
+
channel.is_archived = false if channel
|
155
|
+
end
|
156
|
+
|
157
|
+
# A team slash command has been added or changed.
|
158
|
+
# @see https://api.slack.com/events/commands_changed
|
159
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/commands_changed.json
|
160
|
+
# on :commands_changed do |data|
|
161
|
+
|
162
|
+
# Do not Disturb settings changed for the current user.
|
163
|
+
# @see https://api.slack.com/events/dnd_updated
|
164
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/dnd_updated.json
|
165
|
+
# on :dnd_updated do |data|
|
166
|
+
|
167
|
+
# Do not Disturb settings changed for a team member.
|
168
|
+
# @see https://api.slack.com/events/dnd_updated_user
|
169
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/dnd_updated_user.json
|
170
|
+
# on :dnd_updated_user do |data|
|
171
|
+
|
172
|
+
# The team email domain has changed.
|
173
|
+
# @see https://api.slack.com/events/email_domain_changed
|
174
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/email_domain_changed.json
|
175
|
+
on :email_domain_changed do |data|
|
176
|
+
team.email_domain = data.email_domain
|
177
|
+
end
|
178
|
+
|
179
|
+
# A team custom emoji has been added or changed.
|
180
|
+
# @see https://api.slack.com/events/emoji_changed
|
181
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/emoji_changed.json
|
182
|
+
# on :emoji_changed do |data|
|
183
|
+
|
184
|
+
# A file was changed.
|
185
|
+
# @see https://api.slack.com/events/file_change
|
186
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_change.json
|
187
|
+
# on :file_change do |data|
|
188
|
+
|
189
|
+
# A file comment was added.
|
190
|
+
# @see https://api.slack.com/events/file_comment_added
|
191
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_comment_added.json
|
192
|
+
# on :file_comment_added do |data| do
|
193
|
+
|
194
|
+
# A file comment was deleted.
|
195
|
+
# @see https://api.slack.com/events/file_comment_deleted
|
196
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_comment_deleted.json
|
197
|
+
# on :file_comment_deleted do |data|
|
198
|
+
|
199
|
+
# A file comment was edited.
|
200
|
+
# @see https://api.slack.com/events/file_comment_edited
|
201
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_comment_edited.json
|
202
|
+
# on :file_comment_edited do |data|
|
203
|
+
|
204
|
+
# A file was created.
|
205
|
+
# @see https://api.slack.com/events/file_created
|
206
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_created.json
|
207
|
+
# on :file_created do |data|
|
208
|
+
|
209
|
+
# A file was deleted.
|
210
|
+
# @see https://api.slack.com/events/file_deleted
|
211
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_deleted.json
|
212
|
+
# on :file_deleted do |data|
|
213
|
+
|
214
|
+
# A file was made private.
|
215
|
+
# @see https://api.slack.com/events/file_private
|
216
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_private.json
|
217
|
+
# on :file_private do |data|
|
218
|
+
|
219
|
+
# A file was made public.
|
220
|
+
# @see https://api.slack.com/events/file_public
|
221
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_public.json
|
222
|
+
# on :file_public do |data|
|
223
|
+
|
224
|
+
# A file was shared.
|
225
|
+
# @see https://api.slack.com/events/file_shared
|
226
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_shared.json
|
227
|
+
# on :file_shared do |data|
|
228
|
+
|
229
|
+
# A file was unshared.
|
230
|
+
# @see https://api.slack.com/events/file_unshared
|
231
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/file_unshared.json
|
232
|
+
# on :file_unshared do |data|
|
233
|
+
|
234
|
+
# A private group was archived.
|
235
|
+
# @see https://api.slack.com/events/group_archive
|
236
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_archive.json
|
237
|
+
on :group_archive do |data|
|
238
|
+
channel = groups[data.channel]
|
239
|
+
channel.is_archived = true if channel
|
240
|
+
end
|
241
|
+
|
242
|
+
# You closed a group channel.
|
243
|
+
# @see https://api.slack.com/events/group_close
|
244
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_close.json
|
245
|
+
on :group_close do |data|
|
246
|
+
groups[data.channel].is_open = false
|
247
|
+
end
|
248
|
+
|
249
|
+
# Bulk updates were made to a group's history.
|
250
|
+
# @see https://api.slack.com/events/group_history_changed
|
251
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_history_changed.json
|
252
|
+
# on :group_history_changed do |data|
|
253
|
+
|
254
|
+
# You joined a private group.
|
255
|
+
# @see https://api.slack.com/events/group_joined
|
256
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_joined.json
|
257
|
+
on :group_joined do |data|
|
258
|
+
groups[data.channel.id] = Models::Channel.new(data.channel)
|
259
|
+
end
|
260
|
+
|
261
|
+
# You left a private group.
|
262
|
+
# @see https://api.slack.com/events/group_left
|
263
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_left.json
|
264
|
+
on :group_left do |data|
|
265
|
+
channel = groups[data.channel]
|
266
|
+
channel.members.delete(self.self.id) if channel && channel.key?(:members)
|
267
|
+
end
|
268
|
+
|
269
|
+
# A private group read marker was updated.
|
270
|
+
# @see https://api.slack.com/events/group_marked
|
271
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_marked.json
|
272
|
+
# on :group_marked do |data|
|
273
|
+
|
274
|
+
# You opened a group channel.
|
275
|
+
# @see https://api.slack.com/events/group_open
|
276
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_open.json
|
277
|
+
on :group_open do |data|
|
278
|
+
groups[data.channel].is_open = true
|
279
|
+
end
|
280
|
+
|
281
|
+
# A private group was renamed.
|
282
|
+
# @see https://api.slack.com/events/group_rename
|
283
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_rename.json
|
284
|
+
on :group_rename do |data|
|
285
|
+
channel = groups[data.channel.id]
|
286
|
+
channel.name = data.channel.name if channel
|
287
|
+
end
|
288
|
+
|
289
|
+
# A private group was unarchived.
|
290
|
+
# @see https://api.slack.com/events/group_unarchive
|
291
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/group_unarchive.json
|
292
|
+
on :group_unarchive do |data|
|
293
|
+
channel = groups[data.channel]
|
294
|
+
channel.is_archived = false if channel
|
295
|
+
end
|
296
|
+
|
297
|
+
# You closed a direct message channel.
|
298
|
+
# @see https://api.slack.com/events/im_close
|
299
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/im_close.json
|
300
|
+
on :im_close do |data|
|
301
|
+
return unless ims && ims.key?(data.channel)
|
302
|
+
ims[data.channel].is_open = false
|
303
|
+
end
|
304
|
+
|
305
|
+
# A direct message channel was created.
|
306
|
+
# @see https://api.slack.com/events/im_created
|
307
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/im_created.json
|
308
|
+
on :im_created do |data|
|
309
|
+
ims[data.channel.id] = Models::Im.new(data.channel)
|
310
|
+
end
|
311
|
+
|
312
|
+
# Bulk updates were made to a DM channel's history.
|
313
|
+
# @see https://api.slack.com/events/im_history_changed
|
314
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/im_history_changed.json
|
315
|
+
# on :im_history_changed do |data|
|
316
|
+
|
317
|
+
# A direct message read marker was updated.
|
318
|
+
# @see https://api.slack.com/events/im_marked
|
319
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/im_marked.json
|
320
|
+
# on :im_marked do |data|
|
321
|
+
|
322
|
+
# You opened a direct message channel.
|
323
|
+
# @see https://api.slack.com/events/im_open
|
324
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/im_open.json
|
325
|
+
on :im_open do |data|
|
326
|
+
return unless ims && ims.key?(data.channel)
|
327
|
+
ims[data.channel].is_open = true
|
328
|
+
end
|
329
|
+
|
330
|
+
# You manually updated your presence.
|
331
|
+
# @see https://api.slack.com/events/manual_presence_change
|
332
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/manual_presence_change.json
|
333
|
+
on :manual_presence_change do |data|
|
334
|
+
self.self.presence = data.presence
|
335
|
+
end
|
336
|
+
|
337
|
+
# A pin was added to a channel.
|
338
|
+
# @see https://api.slack.com/events/pin_added
|
339
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/pin_added.json
|
340
|
+
# on :pin_added do |data|
|
341
|
+
|
342
|
+
# A pin was removed from a channel.
|
343
|
+
# @see https://api.slack.com/events/pin_removed
|
344
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/pin_removed.json
|
345
|
+
# on :pin_removed do |data|
|
346
|
+
|
347
|
+
# You have updated your preferences.
|
348
|
+
# @see https://api.slack.com/events/pref_change
|
349
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/pref_change.json
|
350
|
+
on :pref_change do |data|
|
351
|
+
self.self.prefs ||= {}
|
352
|
+
self.self.prefs[data.name] = data.value
|
353
|
+
end
|
354
|
+
|
355
|
+
# A team member's presence changed.
|
356
|
+
# @see https://api.slack.com/events/presence_change
|
357
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/presence_change.json
|
358
|
+
on :presence_change do |data|
|
359
|
+
user = users[data.user]
|
360
|
+
user.presence = data.presence if user
|
361
|
+
end
|
362
|
+
|
363
|
+
# A team member has added an emoji reaction to an item.
|
364
|
+
# @see https://api.slack.com/events/reaction_added
|
365
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/reaction_added.json
|
366
|
+
# on :reaction_added do |data|
|
367
|
+
|
368
|
+
# A team member removed an emoji reaction.
|
369
|
+
# @see https://api.slack.com/events/reaction_removed
|
370
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/reaction_removed.json
|
371
|
+
# on :reaction_removed do |data|
|
372
|
+
|
373
|
+
# Experimental.
|
374
|
+
# @see https://api.slack.com/events/reconnect_url
|
375
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/reconnect_url.json
|
376
|
+
# on :reconnect_url do |data|
|
377
|
+
|
378
|
+
# A team member has starred an item.
|
379
|
+
# @see https://api.slack.com/events/star_added
|
380
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/star_added.json
|
381
|
+
# on :star_added do |data|
|
382
|
+
|
383
|
+
# A team member removed a star.
|
384
|
+
# @see https://api.slack.com/events/star_removed
|
385
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/star_removed.json
|
386
|
+
# on :star_removed do |data|
|
387
|
+
|
388
|
+
# A user group has been added to the team.
|
389
|
+
# @see https://api.slack.com/events/subteam_created
|
390
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/subteam_created.json
|
391
|
+
# on :subteam_created do |data|
|
392
|
+
|
393
|
+
# You have been added to a user group.
|
394
|
+
# @see https://api.slack.com/events/subteam_self_added
|
395
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/subteam_self_added.json
|
396
|
+
# on :subteam_self_added do |data|
|
397
|
+
|
398
|
+
# You have been removed from a user group.
|
399
|
+
# @see https://api.slack.com/events/subteam_self_removed
|
400
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/subteam_self_removed.json
|
401
|
+
# on :subteam_self_removed do |data|
|
402
|
+
|
403
|
+
# An existing user group has been updated or its members changed.
|
404
|
+
# @see https://api.slack.com/events/subteam_updated
|
405
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/subteam_updated.json
|
406
|
+
# on :subteam_updated do |data|
|
407
|
+
|
408
|
+
# The team domain has changed.
|
409
|
+
# @see https://api.slack.com/events/team_domain_change
|
410
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_domain_change.json
|
411
|
+
on :team_domain_change do |data|
|
412
|
+
team.url = data.url
|
413
|
+
team.domain = data.domain
|
414
|
+
end
|
415
|
+
|
416
|
+
# A new team member has joined.
|
417
|
+
# @see https://api.slack.com/events/team_join
|
418
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_join.json
|
419
|
+
on :team_join do |data|
|
420
|
+
users[data.user.id] = Models::User.new(data.user)
|
421
|
+
end
|
422
|
+
|
423
|
+
# The team is being migrated between servers.
|
424
|
+
# @see https://api.slack.com/events/team_migration_started
|
425
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_migration_started.json
|
426
|
+
# on :team_migration_started do |data|
|
427
|
+
|
428
|
+
# The team billing plan has changed.
|
429
|
+
# @see https://api.slack.com/events/team_plan_change
|
430
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_plan_change.json
|
431
|
+
on :team_plan_change do |data|
|
432
|
+
team.plan = data.plan
|
433
|
+
end
|
434
|
+
|
435
|
+
# A team preference has been updated.
|
436
|
+
# @see https://api.slack.com/events/team_pref_change
|
437
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_pref_change.json
|
438
|
+
on :team_pref_change do |data|
|
439
|
+
team.prefs ||= {}
|
440
|
+
team.prefs[data.name] = data.value
|
441
|
+
end
|
442
|
+
|
443
|
+
# Team profile fields have been updated.
|
444
|
+
# @see https://api.slack.com/events/team_profile_change
|
445
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_profile_change.json
|
446
|
+
# on :team_profile_change do |data|
|
447
|
+
|
448
|
+
# Team profile fields have been deleted.
|
449
|
+
# @see https://api.slack.com/events/team_profile_delete
|
450
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_profile_delete.json
|
451
|
+
# on :team_profile_delete do |data|
|
452
|
+
|
453
|
+
# Team profile fields have been reordered.
|
454
|
+
# @see https://api.slack.com/events/team_profile_reorder
|
455
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_profile_reorder.json
|
456
|
+
# on :team_profile_reorder do |data|
|
457
|
+
|
458
|
+
# The team name has changed.
|
459
|
+
# @see https://api.slack.com/events/team_rename
|
460
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/team_rename.json
|
461
|
+
on :team_rename do |data|
|
462
|
+
team.name = data.name
|
463
|
+
end
|
464
|
+
|
465
|
+
# A team member's data has changed.
|
466
|
+
# @see https://api.slack.com/events/user_change
|
467
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/user_change.json
|
468
|
+
on :user_change do |data|
|
469
|
+
users[data.user.id] = Models::User.new(data.user)
|
470
|
+
end
|
471
|
+
|
472
|
+
# A channel member is typing a message.
|
473
|
+
# @see https://api.slack.com/events/user_typing
|
474
|
+
# @see https://github.com/dblock/slack-api-ref/blob/master/events/user_typing.json
|
475
|
+
# on :user_typing do |data|
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|