slack_bot-events 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/slack_bot/events/client.rb +2 -2
- data/lib/slack_bot/events/configuration.rb +0 -4
- data/lib/slack_bot/events/middleware/chain.rb +8 -5
- data/lib/slack_bot/events/middleware/event_tracer.rb +9 -7
- data/lib/slack_bot/events/middleware/message_handler.rb +0 -2
- data/lib/slack_bot/events/version.rb +1 -1
- data/lib/slack_bot/events.rb +0 -2
- 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: 26e9e0a0edd93455cbc0cff5043f9a5e9a93a1bdb1a6ace9107df71cabd01856
|
4
|
+
data.tar.gz: 4eb9d15cc14f868f8e1f8bab0ccaaca876e256899a84d2b53cf5939df2496205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44891a0644cd45f3b8c22a8256f48e509933b7a35a4504f9ac046d8b761fcd5a8bee09d2ecefa89d85616953e7a70e18b7fc84a1a5435a97f4d5dc4eb2fbcef2
|
7
|
+
data.tar.gz: 8af558314cab90d174ac1555f590eaeaab3bd87530928da99eea571486c962ef2926f41d82ff030107fc4ad4d615a7835030579b5497970bfd65a3653ec8991d
|
data/Gemfile.lock
CHANGED
@@ -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
|
23
|
+
events_api(handler: listener&.dig(:handler), schema: schema, parsed_data: parsed_data)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -52,7 +52,7 @@ module SlackBot
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def events_api(handler:, schema:, parsed_data:)
|
55
|
-
return if
|
55
|
+
return if handler.nil?
|
56
56
|
|
57
57
|
Events.logger.info { schema.tldr } if Events.config.print_tldr
|
58
58
|
|
@@ -15,11 +15,7 @@ module SlackBot
|
|
15
15
|
:on_receive,
|
16
16
|
]
|
17
17
|
|
18
|
-
add_composer :client_id, allowed: String, default: ENV["SLACK_CLIENT_ID"]
|
19
|
-
add_composer :client_secret, allowed: String, default: ENV["SLACK_CLIENT_SECRET"]
|
20
|
-
add_composer :client_signing_secret, allowed: String, default: ENV["SLACK_SIGNING_SECRET"]
|
21
18
|
add_composer :client_socket_token, allowed: String, default: ENV["SLACK_SOCKET_TOKEN"]
|
22
|
-
add_composer :client_verification_token, allowed: String, default: ENV["SLACK_VERIFICATION_TOKEN"]
|
23
19
|
add_composer :print_tldr, allowed: [true.class, false.class], default: true
|
24
20
|
add_composer :message_middleware, allowed: Middleware::Chain, default: Middleware::Chain.new(type: :message)
|
25
21
|
add_composer :open_middleware, allowed: Middleware::Chain, default: Middleware::Chain.new(type: :open)
|
@@ -19,9 +19,12 @@ module SlackBot
|
|
19
19
|
attr_reader :type
|
20
20
|
|
21
21
|
DEFAULT_ENTRIES = {
|
22
|
-
message:
|
23
|
-
|
24
|
-
|
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
|
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
|
-
|
15
|
-
|
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 += ":#{
|
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
|
data/lib/slack_bot/events.rb
CHANGED