grape-slack-bot 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +24 -0
- data/lib/slack_bot/callback.rb +1 -1
- data/lib/slack_bot/config.rb +3 -1
- data/lib/slack_bot/errors.rb +10 -0
- data/lib/slack_bot.rb +1 -1
- 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: 953075c11d83ecf06161ba1ffdda403a08c673c87a598a5d924443a8bf7bb587
|
4
|
+
data.tar.gz: c99d95f100f8e067e19502c2d144454b9d8416534b2e8ef930d31136d1b13ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f184bf86ddce2dacaecce93f8377ef62b562b8ba5cf010993903bac8910af115b5659be794fb9e7961c2ab51d3f48f46622705a595d79aadff089a909c4fce2
|
7
|
+
data.tar.gz: 6e821e2e1aea7494d01ece594de33ba5264ed6ff9e3ab6937ad44a4fb65ddfda1ff44bd717358c3fc4c0ff5a6bf8368988085e277677086d8dffdc5417d6ed7a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -292,6 +292,30 @@ module MySlackBot::Game
|
|
292
292
|
end
|
293
293
|
```
|
294
294
|
|
295
|
+
App home interaction example:
|
296
|
+
|
297
|
+
```ruby
|
298
|
+
module MySlackBot
|
299
|
+
class AppHomeInteraction < SlackBot::Event
|
300
|
+
view MySlackBot::AppHomeView
|
301
|
+
|
302
|
+
def call
|
303
|
+
action_id = payload.dig("actions", 0, "action_id")
|
304
|
+
case action_id
|
305
|
+
when "add_game"
|
306
|
+
add_game
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
private
|
311
|
+
|
312
|
+
def add_game
|
313
|
+
open_modal :add_game_modal
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
```
|
318
|
+
|
295
319
|
## View example
|
296
320
|
|
297
321
|
Modal view example:
|
data/lib/slack_bot/callback.rb
CHANGED
@@ -107,7 +107,7 @@ module SlackBot
|
|
107
107
|
|
108
108
|
def handler_class=(handler_class)
|
109
109
|
new_class_name = handler_class&.name
|
110
|
-
|
110
|
+
config.find_handler_class(class_name)
|
111
111
|
|
112
112
|
self.class_name = new_class_name
|
113
113
|
end
|
data/lib/slack_bot/config.rb
CHANGED
@@ -72,7 +72,9 @@ module SlackBot
|
|
72
72
|
|
73
73
|
def find_handler_class(class_name)
|
74
74
|
@handler_classes ||= {}
|
75
|
-
@handler_classes
|
75
|
+
@handler_classes.fetch(class_name.to_sym)
|
76
|
+
rescue KeyError
|
77
|
+
raise SlackBot::Errors::HandlerClassNotFound.new(class_name, handler_classes: @handler_classes)
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
data/lib/slack_bot/errors.rb
CHANGED
@@ -21,6 +21,16 @@ module SlackBot
|
|
21
21
|
class CallbackNotFound < SlackBot::Error
|
22
22
|
end
|
23
23
|
|
24
|
+
class HandlerClassNotFound < SlackBot::Error
|
25
|
+
attr_reader :class_name, :handler_classes
|
26
|
+
def initialize(class_name, handler_classes:)
|
27
|
+
@class_name = class_name
|
28
|
+
@handler_classes = handler_classes
|
29
|
+
|
30
|
+
super("Handler class not found for #{class_name}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
class SlackResponseError < SlackBot::Error
|
25
35
|
attr_reader :error, :data, :payload
|
26
36
|
def initialize(error, data: nil, payload: nil)
|
data/lib/slack_bot.rb
CHANGED