-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow command handlers to match regexes #846
Conversation
Codecov Report
@@ Coverage Diff @@
## main #846 +/- ##
==========================================
+ Coverage 65.89% 65.98% +0.08%
==========================================
Files 13 13
Lines 1173 1176 +3
Branches 343 344 +1
==========================================
+ Hits 773 776 +3
Misses 334 334
Partials 66 66
Continue to review full report at Codecov.
|
@itowlson You're so quick! Thanks a lot for taking the time to make this pull request 🙇
The added tests cover all the possible patterns. Perfect 👍
This is intended behavior in Bolt for JS. Thanks for clarifying this.
The changes look good to me. In the future, we may want to improve the duplication but we can do it separately. If you don't mind, could you send another pull request for the document changes? Merging document changes updates the live website immediately. We would like to merge the document updates right after releasing a new version including your change. Once you move the doc changes to another PR, we will merge the code changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this pull request does not include the document changes, we can merge this PR 👍
Sorry about that @seratch, I noticed some remarks about documentation in the contributor's guide but I overlooked them when it came to doing the PR. I'll back those out and create a new one for them. |
529e82f
to
cf298c9
Compare
cf298c9
to
385cc5f
Compare
Docs backed out and moved to #847. |
@itowlson Thanks again for your prompt work 👍 I'm sure this is great and already ready for merge but, just in case, I will wait for other maintainers for one business day before merging it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work @itowlson! 🎉 Thanks a lot for contribution!
Summary
The
App#command
method currently only subscribes to a specific slash command identified by exact name. In a few cases it is useful to have more flexibility - for example, a gateway that transforms commands into messages for another system might need to be agnostic about which specific commands the user wants to use it with. This PR adds a RegExp option to theApp#command
signature, which enables this and related behaviours.Fixes #841.
Notes to reviewers
app.command(/h*/)
andapp.command(/he*/)
. I followed the behaviour ofshortcut
here, where if it runs the listener for all matching regexes. This may be surprising/unwelcome but it is at least consistent. I documented theshortcut
behaviour as part of this; but it may be that you prefer to leave this undefined or say it's unsupported so people don't take a dependency on the current behaviour. Note this is distinct from Issue 281 message array support #761 where the regexes could be passed in an array in a singlemessage
call (and therefore were looped over within a single piece of middleware). Again I'd welcome feedback or guidance on this!Requirements (place an
x
in each[ ]
)