ruboty-slack_rtm 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruboty/adapters/slack_rtm.rb +40 -0
- data/lib/ruboty/slack_rtm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9630308dfdbf7041fdca0a1dc1a5386b051b3417
|
4
|
+
data.tar.gz: efa4af910759b1c3cf9c34a5717a8726163deffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f0e1420f9f50107be9f46a3bab49b25e526af045a807cf2b6801bd3b5b132e6b1f5d201dd4527a2d7efe4b25aeb398583965eaa5dd11e0da26458ff4a33af6f
|
7
|
+
data.tar.gz: 8c0cc313e1a2621853d709a0d11c3f4cdfd641c69c788886cf88993d14365c74160ff2dfbd31afea3c6d8cb562ea3ed1fc7a065571f61b6360845e562cd7ed00
|
@@ -40,11 +40,13 @@ module Ruboty
|
|
40
40
|
response = client.auth_test
|
41
41
|
@user_info_caches = {}
|
42
42
|
@channel_info_caches = {}
|
43
|
+
@usergroup_info_caches = {}
|
43
44
|
|
44
45
|
ENV['RUBOTY_NAME'] ||= response['user']
|
45
46
|
|
46
47
|
make_users_cache
|
47
48
|
make_channels_cache
|
49
|
+
make_usergroups_cache
|
48
50
|
end
|
49
51
|
|
50
52
|
def bind
|
@@ -151,6 +153,16 @@ module Ruboty
|
|
151
153
|
"@#{name}"
|
152
154
|
end
|
153
155
|
|
156
|
+
data['text'].gsub!(/\<!subteam\^(?<usergroup_id>[0-9A-Z]+)(?:\|(?<handle>[^>]+))?\>/) do |_|
|
157
|
+
handle = Regexp.last_match[:handle]
|
158
|
+
|
159
|
+
unless handle
|
160
|
+
handle = usergroup_info(Regexp.last_match[:usergroup_id])
|
161
|
+
end
|
162
|
+
|
163
|
+
"#{handle}"
|
164
|
+
end
|
165
|
+
|
154
166
|
data['text'].gsub!(/\<!(?<special>[^>|@]+)(\|\@[^>]+)?\>/) do |_|
|
155
167
|
"@#{Regexp.last_match[:special]}"
|
156
168
|
end
|
@@ -193,6 +205,18 @@ module Ruboty
|
|
193
205
|
"<!#{Regexp.last_match[:special]}>"
|
194
206
|
end
|
195
207
|
|
208
|
+
text.gsub!(/@(?<subteam_name>[0-9a-z._-]+)/) do |_|
|
209
|
+
subteam_name = Regexp.last_match[:subteam_name]
|
210
|
+
msg = "@#{subteam_name}"
|
211
|
+
|
212
|
+
@usergroup_info_caches.each_pair do |id, usergroup|
|
213
|
+
if usergroup && usergroup['handle'] == subteam_name
|
214
|
+
msg = "<!subteam^#{usergroup['id']}>"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
msg
|
218
|
+
end
|
219
|
+
|
196
220
|
text.gsub!(/\#(?<room_id>[a-z0-9_-]+)/) do |_|
|
197
221
|
room_id = Regexp.last_match[:room_id]
|
198
222
|
msg = "##{room_id}"
|
@@ -227,6 +251,15 @@ module Ruboty
|
|
227
251
|
end
|
228
252
|
end
|
229
253
|
|
254
|
+
def make_usergroups_cache
|
255
|
+
resp = client.get("usergroups.list")
|
256
|
+
if resp['ok']
|
257
|
+
resp['usergroups'].each do |usergroup|
|
258
|
+
@usergroup_info_caches[usergroup['id']] = usergroup
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
230
263
|
def user_info(user_id)
|
231
264
|
return {} if user_id.to_s.empty?
|
232
265
|
|
@@ -260,6 +293,13 @@ module Ruboty
|
|
260
293
|
end
|
261
294
|
return ret_id
|
262
295
|
end
|
296
|
+
|
297
|
+
def usergroup_info(usergroup_id)
|
298
|
+
@usergroup_info_caches[usergroup_id] || begin
|
299
|
+
make_usergroups_cache
|
300
|
+
@usergroup_info_caches[usergroup_id]
|
301
|
+
end
|
302
|
+
end
|
263
303
|
end
|
264
304
|
end
|
265
305
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-slack_rtm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Kusano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|