Listening for multiple command variations using a single hears()
- Dominant language
- PHP
- Stars
- 51
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
**Version**: ^2.1
Is it possible to listen for multiple variations of a command using `hears()`? For example, I'd like to be able to listen for:
`mycommand action (.*)`
and
`action (.*)`
Using `|` to separate the commands seems to allow execution, though when using regex in both of the commands, the text doesn't seem to come through as expected.
**Example Code**
```
$botman->hears('command action (.*)|action (.*)', function ( $botman, $message ) {
$uid = $botman->getUser()->getId();
$botman->reply(
'<@' . $uid . '> You said: ' . $message
);
});
```
When the bot hears `command action [message]`, `$message` comes through without any issues. When the bot hears `action [message]`, `$message` is empty.
As long as there's not regex, both command variants work, though I need regex in 99% of the commands in use. Perhaps I'm just doing it wrong :).
Contributor guide
Assessment
This issue has not been assessed yet.