slack_bot-events 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77da24b43ab5d9941684e5a5b02b55089c623dbd0e04c169a3f369d163723201
4
- data.tar.gz: fa617a08d0c79e5067613143f33763cf2603083b53cd855a18617c937323b106
3
+ metadata.gz: 26e9e0a0edd93455cbc0cff5043f9a5e9a93a1bdb1a6ace9107df71cabd01856
4
+ data.tar.gz: 4eb9d15cc14f868f8e1f8bab0ccaaca876e256899a84d2b53cf5939df2496205
5
5
  SHA512:
6
- metadata.gz: 67a0f94912390776300171104e17fb58b53c4cb694e536acbe45fc69fcb243fc1878bd4a90d1d86c8ac3b2235c6c70387aad96493e39ecfbc7c5a2faf0996396
7
- data.tar.gz: 85055e2261e1f8cc24b6b45069b5f2907b15c05a6d9e40af6712390d13f5d10241cd802950d851faee1c8aa6005e58d84a6eee7e1ebb5e50082c1fde5990b05e
6
+ metadata.gz: 44891a0644cd45f3b8c22a8256f48e509933b7a35a4504f9ac046d8b761fcd5a8bee09d2ecefa89d85616953e7a70e18b7fc84a1a5435a97f4d5dc4eb2fbcef2
7
+ data.tar.gz: 8af558314cab90d174ac1555f590eaeaab3bd87530928da99eea571486c962ef2926f41d82ff030107fc4ad4d615a7835030579b5497970bfd65a3653ec8991d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack_bot-events (0.4.0)
4
+ slack_bot-events (0.4.2)
5
5
  class_composer (~> 1.0)
6
6
  faraday
7
7
  faye-websocket
@@ -20,7 +20,7 @@ module SlackBot
20
20
  process_message(socket_event: socket_event) do |listener:, parsed_data:, schema: nil|
21
21
  case parsed_data["type"]
22
22
  when "events_api"
23
- events_api(handler: listener[:handler], schema: schema, parsed_data: parsed_data)
23
+ events_api(handler: listener&.dig(:handler), schema: schema, parsed_data: parsed_data)
24
24
  end
25
25
  end
26
26
  end
@@ -19,9 +19,12 @@ module SlackBot
19
19
  attr_reader :type
20
20
 
21
21
  DEFAULT_ENTRIES = {
22
- message: [Middleware::EventTracer, Middleware::MessageHandler],
23
- open: [Middleware::EventTracer],
24
- close: [Middleware::EventTracer],
22
+ message: {
23
+ base: [Middleware::EventTracer, Middleware::MessageHandler],
24
+ immutable: [Middleware::MessageHandler]
25
+ },
26
+ open: { base: [Middleware::EventTracer] },
27
+ close: { base: [Middleware::EventTracer] },
25
28
  }
26
29
 
27
30
  def initialize(type:)
@@ -29,7 +32,7 @@ module SlackBot
29
32
  end
30
33
 
31
34
  def self.default_entry(type)
32
- DEFAULT_ENTRIES[type].map { Entry.new(_1) }
35
+ DEFAULT_ENTRIES[type][:base].map { Entry.new(_1) }
33
36
  end
34
37
 
35
38
  def entries
@@ -37,7 +40,7 @@ module SlackBot
37
40
  end
38
41
 
39
42
  def remove(klass)
40
- raise ArgumentError, "Unable to remove default Middleware #{klass}" if self.class.default_entry.map(:klass).include?(klass)
43
+ raise ArgumentError, "Unable to remove default Middleware #{klass}" if Array(DEFAULT_ENTRIES[@type][:immutable]).include?(klass)
41
44
 
42
45
  entries.delete_if { |entry| entry.klass == klass }
43
46
  end
@@ -11,21 +11,23 @@ module SlackBot
11
11
  when :close
12
12
  additional_info = "code: #{socket_event.code} reason:#{socket_event.reason}"
13
13
  when :message
14
- accurate_type = parsed_data.dig("payload","event","subtype") || parsed_data.dig("payload","event","type")
15
- p_type = [
16
- parsed_data.dig("type"),
17
- accurate_type
18
- ].compact.join(":")
19
- case p_type
14
+
15
+ case parsed_data.dig("type")
20
16
  when "app_rate_limited"
21
17
  # https://api.slack.com/apis/rate-limits#events
22
18
  # Total allowed workspace events are 30,000 per hour
23
19
  # This message type is received once you have gone beyond that
24
- temp_type += ":#{p_type}"
20
+ temp_type += ":#{parsed_data.dig("type")}"
25
21
  additional_info = "minute_rate_limited:#{parsed_data["minute_rate_limited"]} " \
26
22
  "team_id:#{parsed_data["team_id"]} " \
27
23
  "api_app_id:#{parsed_data["api_app_id"]}"
28
24
  else
25
+ accurate_type = parsed_data.dig("payload","event","subtype") || parsed_data.dig("payload","event","type")
26
+ p_type = [
27
+ parsed_data.dig("type"),
28
+ accurate_type
29
+ ].compact.join(":")
30
+
29
31
  # Expected other types are `events_api` and `hello`
30
32
  temp_type += ":#{p_type}"
31
33
  end
@@ -17,8 +17,6 @@ module SlackBot
17
17
  acknowledge!(websocket: websocket, schema: schema)
18
18
  end
19
19
  rescue StandardError => error
20
- puts error.message
21
- puts error.backtrace
22
20
  Events.logger.error do
23
21
  "#{listener[:handler]} returned #{error.class} => #{error.message}. #{error.backtrace[0...10]}"
24
22
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SlackBot
4
4
  module Events
5
- VERSION = "0.4.1"
5
+ VERSION = "0.4.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack_bot-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Taylor