botanalytics 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/botanalytics/slack.rb +18 -27
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bee5ffb6479f0573f57057fd11213b806d1327e6e7cfb727446b72a56582660
4
- data.tar.gz: 1a3c8c1f3a54d7a3efbed7e74017c4715eb6e3ff0684aba8fd355332ab3ae03d
3
+ metadata.gz: 99c86d03b641ad6da98606746413f322edd74473723c8f4c55f049f78fb55789
4
+ data.tar.gz: cd1d92032c5b36eb036ec38ea6c83a0d526395bee7acedb9bb700842e71774e8
5
5
  SHA512:
6
- metadata.gz: 9867be496c3613629527567381fd052bd101b4fb3de4ef0cdeff5457c95bdcbc4771c413b12437e344826a951dbe90c3dacf84de818f4539c0eb739eb9fb24f5
7
- data.tar.gz: 109ff13e50417e683026dad780436e384d93f4c9ae35a692050e06fdc02aa2126f543c4c97c3a4beb292eba298548fbb075f807fea43f9bb25c83a0e677964d3
6
+ metadata.gz: 23ead521e1740c101490341e3d7ffeb4521f1c237a996bb0e245a076a1eb9608a9769d4b757684b784020b05e2c552dd8bc4e6b04642fc9f739d581af6615b04
7
+ data.tar.gz: f3140bca7c1ccc9470db1ba2169c877e8bc9a23199bd2eb461e4e7ad5d1dd9d8649cf511f5740e200b20562e89a3753de02fd22dee72c1f49e85fce03e2758f6
@@ -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('team and bot'), 'Not initialized yet...')
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('team and bot'), 'Not initialized yet...')
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
- if @active_team.nil? or @active_user.nil?
269
- fails(Exception.new('team and bot'), 'Not initialized yet...')
270
- else
271
- validation = validate(payload)
272
- if validation[:ok]
273
- if @accepted_types.include?(payload['type'])
274
- informs('Logging message...')
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
- fails(
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(validation[:err], validation[:reason], payload)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: botanalytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beyhan Esen