Hi
I use this package (dev version) with laravel 5.5 and i find out that if i use start command name after that use sthstart command name command handler cannot match sthstart command and trigger help command.
it may be a bug or may i dont know something about this.
please check it.
regard.
Please, help us, i've got the same problem with Laravel 5.5. Dunno how to solve that.
The point is:
There is a commands array in the telegram.php file and when we register new command in the array in laravel 5.5, the package mixes up the commands. And when a user send a message that starts with a slash '/', the package thinks that the user typed last command in the commands array (usually it's Telegram\Bot\Commands\HelpCommand::class), so the package thinks he typed /help, but actually he could type anything else, for example /lol /hi /god etc. If i put an other command in the commands array first, it always performs instead help in all cases.
Unfortunately, the bug spoils every commands, because only the first command in the commands array will be performed in laravel 5.5, and it doesn't matter what the user has typed. I think the bug is located within the commandsHandler function...
P.S
And another little problem, when a command performs for example /help, code lines that go after Telegram::commandsHandler performs as well, for example:
$update = Telegram::commandsHandler(true);
$response = Telegram::sendMessage([
'chat_id' => 432423342,
'text' => 'You said:"'.$text.'" :)'
]);
the message will be sent. I fixed it, by killing the script in the command file, just typed "die;" but
i think that's not an adequate behaviour ...
I really appreciate your work, you've done a good job :) that's amazing! But please, check the problem...
That's a weird issue but will look into it soon.
cc: @jonnywilliamson You might wanna check this, please!
@Slava-Nik ok a lot of points to cover here.
I'm using the command system extensively for a while now, I've never come across these issues so far.
1) Are you using the master branch or the develop branch? (v2 is master). Please type composer info in your code folder and tell me what version you have. It'll look like this:

2) Please copy your telegram.php config file here - remove any sensitive info - so that we can see your commands list.
I have 20+ commands in my config file and they all get detected fine, so something isn't just right with your setup.
3) The latest version of the sdk uses the entity data in every inbound update to match exactly where in the message the command is. Because of this, I don't know how it could be detecting another command name.
I have tests to show its able to extract commands anywhere in a message precisely.
https://github.com/irazasyed/telegram-bot-sdk/blob/develop/tests/Unit/Commands/CommandBusTest.php#L151-L174
4) As for your last query, you said:
And another little problem, when a command performs for example /help, code lines that go after Telegram::commandsHandler performs as well, for example:
$update = Telegram::commandsHandler(true);
$response = Telegram::sendMessage([
'chat_id' => 432423342,
'text' => 'You said:"'.$text.'" :)'
]);
In this case the code is performing EXACTLY as it should.
The inbound update is passed to the commandHandler. This processes the update and detects if there were any commands in it. If there were, it executes the command THEN RETURNS the update object for you the user to do whatever you want to with it.
In your case, you are sending the update object to the command handler to be processed and then sending a message with the message "You said $text"
If you don't want that message sent...don't put that code there after the commandHandler has been called.
Hope that helps
Hello, thanks that you've paid attention on the problem.

That's my telegram.php config file
```return [
'bot_token' => env('TELEGRAM_BOT_TOKEN', 'myToken'),
'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', false),
'http_client_handler' => null,
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
App\Http\Commands\StartCommand::class
],
];
Actually it has 2 commands, the default HelpCommand and my custom StartCommand. But unfortunately, Always a wrong command performs, even i just type '/lol'
4. I need the message for one case, in order to aware a user, that there are no such commands, that he typed. For example:
$update = Telegram::commandsHandler(true);
//if there are no such commands, the message will be sent
$update = Telegram::getWebhookUpdates();
$chatId = $update['message']['chat']['id'];
$text = $update['message']['text'];
$response = Telegram::sendMessage([
'chat_id' => $chatId,
'text' => 'Sorry, write an existing command, i understand only them'
]);
``
Now, i just typedie;` in command file (helpCommand or startCommand) it works
@Slava-Nik In your first photo you show you are using version v2.2.0 of this SDK.
The command system is now completely updated and changed for v3 - which isn't officially released, but is pretty stable at the moment (I'm using it for months now).
Perhaps give that a go composer require irazasyed/telegram-bot-sdk dev-develop
Please note however that the command class has been changed slightly. So have a look at the code itself until we manage to get documentation done.
I don't know why, but i've installed the fresh Laravel, i've installed the third version of the SDK with the command composer require irazasyed/telegram-bot-sdk dev-develop. But it still has the same problem.
That's my new telegram config :
'bots' => [
'mybot' => [
'username' => 'TelegramBot',
'token' => env('TELEGRAM_BOT_TOKEN', 'myToken'),
'certificate_path' => env('TELEGRAM_CERTIFICATE_PATH', 'https://9605d1f9.ngrok.io'),
'webhook_url' => env('TELEGRAM_WEBHOOK_URL', '/myToken/webhook'),
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
App\Http\Commands\StartCommand::class
],
],
],
'default' => 'mybot',
'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', false),
'http_client_handler' => null,
'resolve_command_dependencies' => true,
/*
|--------------------------------------------------------------------------
| Register Telegram Global Commands [Optional]
|--------------------------------------------------------------------------
'commands' => [
],
'command_groups' => [
],
'shared_commands' => [
],
];
And again, in all cases, when a user types a message that starts with slash '/', the SDK performs the last command in the commands array. Even if i write '/help', the StartCommand will be performed, instead HelpCommand, because the startCommand is located in the array in the last place.
I wonder why you have no the bug(