jclg / php-slack-bot

Slack bot user written in PHP
MIT License
169 stars 61 forks source link

Case-insensitive command #28

Closed vleonov closed 6 years ago

vleonov commented 7 years ago

Current implemenation of Command is case-sensitive. E.g. if I register a command help, I should send exact command help, but not Help or HELP. It's unusual.

So, why don't make it case-insensitive by adding modifier i inside getCommand method?

This $find = '/^'.preg_quote($commandName).'/'; Change to this $find = '/^'.preg_quote($commandName).'/i';

jclg commented 7 years ago

I don't think it's unusual but maybe we can make it optional. Inside the configure() method for a given command, we can set this option. By default, it's still case-sensitive.

    protected function configure() {
        $this->setName('help');
        $this->setCaseInsensitive(true); // Now it works with help, Help and HELP
    }

What do you think ?

vleonov commented 7 years ago

Well, why not? This solution would work fine.