Skip to content

Add support for params in commands

Compare
Choose a tag to compare
@Mateodioev Mateodioev released this 25 Jun 21:12
· 85 commits to main since this release

Now you can format you commands with regex pattern

Example:

use Mateodioev\Bots\Telegram\Api;
use Mateodioev\TgHandler\Context;
use Mateodioev\TgHandler\Commands\MessageCommand;

class Start extends MessageCommand {
    protected string $name = 'info';
    protected string $params = '{w:id}';
    
    public function handle(Api $bot, Context $context, array $args = []) {
        $id = $this->param('id', 'default id'); // get the param
    }
}

// This command now only works with this format: "/info myId"

Full Changelog: v3.4.04...v3.5.0