Skip to content

Unable to define commands containing underscore #1364

Closed
@mlocati

Description

@mlocati

🐞 Bug Report

Required Information

? !
Operating system n/a
PHP Telegram Bot version 0.79.0
PHP version 7.4.32
MySQL version none
Update Method Webhook
Self-signed certificate no
RAW update (if available) n/a

Summary

The specs says this:

Commands can use latin letters, numbers and underscores

But it's not possible to define a command that contains underscores.

For example, let's assume that we'd like to define the command /foo_bar.

If we define it in a file named FooBarCommand.php, at this line we have that $command has a value of Foobar, and $command_name will be foobar.

If we define it in a file named Foo_BarCommand.php, at this line we have that $command has a value of FooBar, and $command_name will still be foobar.

Current behaviour

It's impossible to define a command containing underscores.

How to reproduce

Create a command like this one

<?php

class FooBarCommand extends UserCommand
{
    protected $name = 'foo_bar';
}

It won't be executed with /foo_bar.

Expected behaviour

Invoking /foo_bar should execute a command defined in a file named FooBarCommand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions