grape-slack-bot 2.1.0 → 2.1.2
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/CHANGELOG.md +8 -0
- data/README.md +12 -0
- data/grape-slack-bot.gemspec +4 -3
- data/lib/slack_bot/grape_extension.rb +8 -4
- data/lib/slack_bot/grape_helpers/dispatch.rb +4 -4
- data/lib/slack_bot/grape_helpers/interactions.rb +4 -4
- data/lib/slack_bot.rb +1 -1
- data/sig/slack_bot.rbs +1 -0
- metadata +24 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45d672bb2de61c8d0d1335a0ddf37c9242dc97dd6db90ba630a1d70d7330436c
|
|
4
|
+
data.tar.gz: a42ebdc015514c1e66a38511d54ce21e718be36161d14ead247859e09bffbe87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e41c14e09be9c8687b6653ea29a102586e3fb2750f68533dc63aef9a914f8d4aa818e2af8d8a850f9b9ecaeefff1268d5315fa3f5b42405b9df7c0311f19968
|
|
7
|
+
data.tar.gz: c1e26e64aa95b0ff1ceef088a171888e508348e3afca8fb865eca5071841c052178daa015ce19f6ffee7a70850597fdf276f843ca78b4698c8cd7640afeff766
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 2.1.2 (2026-09-15)
|
|
4
|
+
|
|
5
|
+
- Allow grape 4.x by expanding the runtime dependency to `< 5.0`
|
|
6
|
+
|
|
7
|
+
## 2.1.1 (2026-09-07)
|
|
8
|
+
|
|
9
|
+
- Store SlackBot config in `@slack_bot_config` so Grape 3.3+ can keep `Endpoint::Options` in `@config`
|
|
10
|
+
|
|
3
11
|
## 2.1.0 (2026-07-10)
|
|
4
12
|
|
|
5
13
|
- Add `block_action` registration for message-level block action buttons outside modal callbacks
|
data/README.md
CHANGED
|
@@ -568,6 +568,18 @@ Or use the release script:
|
|
|
568
568
|
usr/bin/release.rb
|
|
569
569
|
```
|
|
570
570
|
|
|
571
|
+
## Links
|
|
572
|
+
|
|
573
|
+
- [GitHub](https://github.com/amkisko/grape-slack-bot.rb)
|
|
574
|
+
- [GitLab](https://gitlab.com/amkisko/grape-slack-bot.rb)
|
|
575
|
+
- [RubyGems](https://rubygems.org/gems/grape-slack-bot)
|
|
576
|
+
- [libraries.io](https://libraries.io/rubygems/grape-slack-bot)
|
|
577
|
+
- [Deps.dev](https://deps.dev/rubygems/grape-slack-bot)
|
|
578
|
+
- [SonarCloud](https://sonarcloud.io/project/overview?id=amkisko_grape-slack-bot.rb)
|
|
579
|
+
- [Snyk](https://snyk.io/test/github/amkisko/grape-slack-bot.rb)
|
|
580
|
+
- [Codecov](https://app.codecov.io/github/amkisko/grape-slack-bot.rb)
|
|
581
|
+
- [OpenSSF Scorecard](https://scorecard.dev/viewer/?uri=github.com/amkisko/grape-slack-bot.rb)
|
|
582
|
+
|
|
571
583
|
## License
|
|
572
584
|
|
|
573
585
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/grape-slack-bot.gemspec
CHANGED
|
@@ -29,12 +29,13 @@ Gem::Specification.new do |gem|
|
|
|
29
29
|
gem.require_paths = ["lib"]
|
|
30
30
|
|
|
31
31
|
gem.add_runtime_dependency "rack", "~> 3.0"
|
|
32
|
-
gem.add_runtime_dependency "grape", ">= 1.6", "<
|
|
32
|
+
gem.add_runtime_dependency "grape", ">= 1.6", "< 5.0"
|
|
33
33
|
gem.add_runtime_dependency "faraday", ">= 2.14.3", "< 3.0"
|
|
34
|
-
gem.add_runtime_dependency "activesupport", ">=
|
|
34
|
+
gem.add_runtime_dependency "activesupport", ">= 7.2.3.2", "< 9.0"
|
|
35
|
+
gem.add_runtime_dependency "ostruct", ">= 0.6"
|
|
35
36
|
|
|
36
37
|
gem.add_development_dependency "rspec", "~> 3"
|
|
37
|
-
gem.add_development_dependency "polyrun", "
|
|
38
|
+
gem.add_development_dependency "polyrun", ">= 2.2.0"
|
|
38
39
|
gem.add_development_dependency "webmock", "~> 3"
|
|
39
40
|
gem.add_development_dependency "rake", "~> 13"
|
|
40
41
|
gem.add_development_dependency "standard", "~> 1.52"
|
|
@@ -63,6 +63,10 @@ module SlackBot
|
|
|
63
63
|
raise SlackBot::Errors::UserAuthenticationError.new("User is not authorized")
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def slack_bot_config
|
|
67
|
+
@slack_bot_config ||= SlackBot::Config.current_instance
|
|
68
|
+
end
|
|
69
|
+
|
|
66
70
|
def slack_request_retry?
|
|
67
71
|
slack_request_header("x-slack-retry-num", "X-Slack-Retry-Num").present?
|
|
68
72
|
end
|
|
@@ -159,14 +163,14 @@ module SlackBot
|
|
|
159
163
|
def self.add_commands_resource!(base)
|
|
160
164
|
base.resource :commands do
|
|
161
165
|
post ":url_token" do
|
|
162
|
-
command_config =
|
|
166
|
+
command_config = slack_bot_config.find_slash_command_config(params[:url_token], params[:command], params[:text])
|
|
163
167
|
command_klass = command_config&.command_klass
|
|
164
168
|
raise SlackBot::Errors::SlashCommandNotImplemented.new if command_klass.blank?
|
|
165
169
|
|
|
166
170
|
args = params[:text].gsub(/^#{command_config.full_token}\s?/, "")
|
|
167
171
|
SlackBot::DevConsole.log_input "SlackApi::SlashCommands#post: #{command_config.url_token} | #{command_config.full_token} | #{args}"
|
|
168
172
|
|
|
169
|
-
action = command_klass.new(current_user: current_user, params: params, args: args, config:
|
|
173
|
+
action = command_klass.new(current_user: current_user, params: params, args: args, config: slack_bot_config)
|
|
170
174
|
verify_slack_team! if action.only_slack_team?
|
|
171
175
|
verify_direct_message_channel! if action.only_direct_message?
|
|
172
176
|
verify_current_user! if action.only_user?
|
|
@@ -222,10 +226,10 @@ module SlackBot
|
|
|
222
226
|
SlackBot::DevConsole.log_input "SlackApi::MenuOptions#get: #{params.inspect}"
|
|
223
227
|
|
|
224
228
|
verify_slack_team!
|
|
225
|
-
menu_options_klass =
|
|
229
|
+
menu_options_klass = slack_bot_config.find_menu_options(params[:action_id])
|
|
226
230
|
raise SlackBot::Errors::MenuOptionsNotImplemented.new if menu_options_klass.blank?
|
|
227
231
|
|
|
228
|
-
menu_options = menu_options_klass.new(current_user: current_user, params: params, config:
|
|
232
|
+
menu_options = menu_options_klass.new(current_user: current_user, params: params, config: slack_bot_config).call
|
|
229
233
|
return blank_slack_response! if menu_options.blank?
|
|
230
234
|
|
|
231
235
|
menu_options
|
|
@@ -18,7 +18,7 @@ module SlackBot
|
|
|
18
18
|
def resolve_user_session(team_id, user_id)
|
|
19
19
|
return if team_id.blank? || user_id.blank?
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
slack_bot_config.user_session_resolver!.call(team_id, user_id)
|
|
22
22
|
rescue SlackBot::Errors::ConfigurationError
|
|
23
23
|
nil
|
|
24
24
|
end
|
|
@@ -28,7 +28,7 @@ module SlackBot
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def dispatch_event(handler:, params:, current_user:)
|
|
31
|
-
|
|
31
|
+
slack_bot_config.event_dispatcher_method.call(handler: handler, params: params, current_user: current_user)
|
|
32
32
|
false
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -40,12 +40,12 @@ module SlackBot
|
|
|
40
40
|
|
|
41
41
|
def event_handler_for(params)
|
|
42
42
|
event_type = params[:event][:type] || params[:event]["type"]
|
|
43
|
-
|
|
43
|
+
slack_bot_config.find_event_handler(event_type.to_sym)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def run_event_handler(handler, params)
|
|
47
47
|
current_user = resolve_event_user(params)
|
|
48
|
-
return dispatch_event(handler: handler, params: params, current_user: current_user) if
|
|
48
|
+
return dispatch_event(handler: handler, params: params, current_user: current_user) if slack_bot_config.event_dispatcher_method
|
|
49
49
|
|
|
50
50
|
handler.new(params: params, current_user: current_user).call
|
|
51
51
|
end
|
|
@@ -20,10 +20,10 @@ module SlackBot
|
|
|
20
20
|
action_id = payload.dig("actions", 0, "action_id")
|
|
21
21
|
return false if action_id.blank?
|
|
22
22
|
|
|
23
|
-
interaction_klass =
|
|
23
|
+
interaction_klass = slack_bot_config.find_block_action(action_id)
|
|
24
24
|
raise SlackBot::Errors::BlockActionNotImplemented.new if interaction_klass.blank?
|
|
25
25
|
|
|
26
|
-
interaction_klass.new(current_user: user, params: params, config:
|
|
26
|
+
interaction_klass.new(current_user: user, params: params, config: slack_bot_config).call
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def validate_callback_user!(callback, user)
|
|
@@ -40,13 +40,13 @@ module SlackBot
|
|
|
40
40
|
interaction_klass = callback_interaction_klass(callback)
|
|
41
41
|
return false if interaction_klass.blank?
|
|
42
42
|
|
|
43
|
-
interaction_klass.new(current_user: user, params: params, callback: callback, config:
|
|
43
|
+
interaction_klass.new(current_user: user, params: params, callback: callback, config: slack_bot_config).call
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
private
|
|
47
47
|
|
|
48
48
|
def find_callback!(view:, user:)
|
|
49
|
-
callback = SlackBot::Callback.find(view&.dig("callback_id"), user: user, config:
|
|
49
|
+
callback = SlackBot::Callback.find(view&.dig("callback_id"), user: user, config: slack_bot_config)
|
|
50
50
|
raise SlackBot::Errors::CallbackNotFound.new if callback.blank?
|
|
51
51
|
|
|
52
52
|
callback
|
data/lib/slack_bot.rb
CHANGED
data/sig/slack_bot.rbs
CHANGED
|
@@ -327,6 +327,7 @@ module SlackBot
|
|
|
327
327
|
def verify_direct_message_channel!: () -> bool
|
|
328
328
|
def verify_current_user!: () -> bool
|
|
329
329
|
def slack_request_retry?: () -> bool
|
|
330
|
+
def slack_bot_config: () -> SlackBot::Config
|
|
330
331
|
def resolve_user_session: (String? team_id, String? user_id) -> untyped?
|
|
331
332
|
def resolve_event_user: (Hash[String, untyped] params) -> untyped?
|
|
332
333
|
def events_callback: (Hash[String, untyped] params) -> untyped
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: grape-slack-bot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrei Makarov
|
|
@@ -32,7 +32,7 @@ dependencies:
|
|
|
32
32
|
version: '1.6'
|
|
33
33
|
- - "<"
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: '
|
|
35
|
+
version: '5.0'
|
|
36
36
|
type: :runtime
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -42,7 +42,7 @@ dependencies:
|
|
|
42
42
|
version: '1.6'
|
|
43
43
|
- - "<"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '
|
|
45
|
+
version: '5.0'
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: faraday
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -69,7 +69,7 @@ dependencies:
|
|
|
69
69
|
requirements:
|
|
70
70
|
- - ">="
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
|
-
version:
|
|
72
|
+
version: 7.2.3.2
|
|
73
73
|
- - "<"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '9.0'
|
|
@@ -79,10 +79,24 @@ dependencies:
|
|
|
79
79
|
requirements:
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
82
|
+
version: 7.2.3.2
|
|
83
83
|
- - "<"
|
|
84
84
|
- !ruby/object:Gem::Version
|
|
85
85
|
version: '9.0'
|
|
86
|
+
- !ruby/object:Gem::Dependency
|
|
87
|
+
name: ostruct
|
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0.6'
|
|
93
|
+
type: :runtime
|
|
94
|
+
prerelease: false
|
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0.6'
|
|
86
100
|
- !ruby/object:Gem::Dependency
|
|
87
101
|
name: rspec
|
|
88
102
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -101,16 +115,16 @@ dependencies:
|
|
|
101
115
|
name: polyrun
|
|
102
116
|
requirement: !ruby/object:Gem::Requirement
|
|
103
117
|
requirements:
|
|
104
|
-
- - "
|
|
118
|
+
- - ">="
|
|
105
119
|
- !ruby/object:Gem::Version
|
|
106
|
-
version:
|
|
120
|
+
version: 2.2.0
|
|
107
121
|
type: :development
|
|
108
122
|
prerelease: false
|
|
109
123
|
version_requirements: !ruby/object:Gem::Requirement
|
|
110
124
|
requirements:
|
|
111
|
-
- - "
|
|
125
|
+
- - ">="
|
|
112
126
|
- !ruby/object:Gem::Version
|
|
113
|
-
version:
|
|
127
|
+
version: 2.2.0
|
|
114
128
|
- !ruby/object:Gem::Dependency
|
|
115
129
|
name: webmock
|
|
116
130
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -350,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
350
364
|
- !ruby/object:Gem::Version
|
|
351
365
|
version: '0'
|
|
352
366
|
requirements: []
|
|
353
|
-
rubygems_version:
|
|
367
|
+
rubygems_version: 4.0.6
|
|
354
368
|
specification_version: 4
|
|
355
369
|
summary: Slack bot implementation for ruby-grape
|
|
356
370
|
test_files: []
|