botanalytics 0.2.4 → 0.2.5
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 +4 -4
- data/lib/botanalytics/slack.rb +18 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c86d03b641ad6da98606746413f322edd74473723c8f4c55f049f78fb55789
|
4
|
+
data.tar.gz: cd1d92032c5b36eb036ec38ea6c83a0d526395bee7acedb9bb700842e71774e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ead521e1740c101490341e3d7ffeb4521f1c237a996bb0e245a076a1eb9608a9769d4b757684b784020b05e2c552dd8bc4e6b04642fc9f739d581af6615b04
|
7
|
+
data.tar.gz: f3140bca7c1ccc9470db1ba2169c877e8bc9a23199bd2eb461e4e7ad5d1dd9d8649cf511f5740e200b20562e89a3753de02fd22dee72c1f49e85fce03e2758f6
|
data/lib/botanalytics/slack.rb
CHANGED
@@ -90,7 +90,7 @@ class SlackRTMApi < Envoy
|
|
90
90
|
# @param payload Hash
|
91
91
|
def log_incoming(payload)
|
92
92
|
if @active_team.nil? or @active_user.nil?
|
93
|
-
fails(Exception.new('
|
93
|
+
fails(Exception.new('Team and Bot info is missing!'), 'Not initialized yet...')
|
94
94
|
else
|
95
95
|
validation = validate(payload)
|
96
96
|
if validation[:ok]
|
@@ -115,7 +115,7 @@ class SlackRTMApi < Envoy
|
|
115
115
|
#thread=None, reply_broadcast=None, msg_payload=None
|
116
116
|
|
117
117
|
if @active_team.nil? or @active_user.nil?
|
118
|
-
fails(Exception.new('
|
118
|
+
fails(Exception.new('Team and Bot info is missing!'), 'Not initialized yet...')
|
119
119
|
else
|
120
120
|
thread = params.fetch(:thread, nil)
|
121
121
|
reply_broadcast = params.fetch(:reply_broadcast, nil)
|
@@ -183,8 +183,6 @@ class SlackEventApi < Envoy
|
|
183
183
|
@path = 'messages/slack/event/'
|
184
184
|
@initialize_path = 'bots/slack/initialize/'
|
185
185
|
@interactive_path = 'messages/slack/interactive/'
|
186
|
-
@active_user = nil
|
187
|
-
@active_team = nil
|
188
186
|
@async = params.fetch(:async, false)
|
189
187
|
informs("Logging enabled for #{self.class.name}...")
|
190
188
|
if @async
|
@@ -219,10 +217,6 @@ class SlackEventApi < Envoy
|
|
219
217
|
when Net::HTTPSuccess
|
220
218
|
start_data = JSON.parse(response.body)
|
221
219
|
if start_data['ok']
|
222
|
-
|
223
|
-
@active_user = start_data['self']['id']
|
224
|
-
@active_team = start_data['team']['id']
|
225
|
-
|
226
220
|
if submits(start_data, @initialize_path, "Successfully updated bot '#{start_data['self']['name']}' info...")
|
227
221
|
informs("Botanalytics::#{self.class.name} initialized team info successfully...")
|
228
222
|
sleep update_interval
|
@@ -261,35 +255,32 @@ class SlackEventApi < Envoy
|
|
261
255
|
|
262
256
|
# @param payload Hash
|
263
257
|
def log(payload)
|
258
|
+
|
264
259
|
if payload.is_a?(Hash)
|
265
260
|
return unless payload['challenge'].nil?
|
266
261
|
end
|
267
262
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
if @
|
274
|
-
|
275
|
-
informs(payload)
|
276
|
-
if @async
|
277
|
-
@executor_service.post do
|
278
|
-
submits(payload, payload['type'] == 'event_callback' ? @path : @interactive_path)
|
279
|
-
end
|
280
|
-
else
|
263
|
+
validation = validate(payload)
|
264
|
+
if validation[:ok]
|
265
|
+
if @accepted_types.include?(payload['type'])
|
266
|
+
informs('Logging message...')
|
267
|
+
informs(payload)
|
268
|
+
if @async
|
269
|
+
@executor_service.post do
|
281
270
|
submits(payload, payload['type'] == 'event_callback' ? @path : @interactive_path)
|
282
271
|
end
|
283
272
|
else
|
284
|
-
|
285
|
-
Exception.new("Expected types, #{@accepted_types} but found #{payload['type']}"),
|
286
|
-
'If you are sure this is a new event type, contact us < tech@botanalytics.co >',
|
287
|
-
payload
|
288
|
-
)
|
273
|
+
submits(payload, payload['type'] == 'event_callback' ? @path : @interactive_path)
|
289
274
|
end
|
290
275
|
else
|
291
|
-
fails(
|
276
|
+
fails(
|
277
|
+
Exception.new("Expected types, #{@accepted_types} but found #{payload['type']}"),
|
278
|
+
'If you are sure this is a new event type, contact us < tech@botanalytics.co >',
|
279
|
+
payload
|
280
|
+
)
|
292
281
|
end
|
282
|
+
else
|
283
|
+
fails(validation[:err], validation[:reason], payload)
|
293
284
|
end
|
294
285
|
end
|
295
286
|
|