I want to use several telegram-bots with the same 'vendor' folder. Each bot needs his own different /start command. I can't create /start as user command.
When I create custom /start command and put code to custom folder - nothing happens, only system /start command has been called. I checked paths and code, but it didn't help:
$commands_folder = __DIR__.'/AnotherBotCommands/';
$telegram->addCommandsPath($commands_folder);
I tried set 'enabled' property to 'false' in system start command class - it didn't help. Also, I tried to delete StartCommand.php file from 'SystemCommands' folder, but it also didn't help.
So question is how to create custom user /start command and switch off system /start command?
There is no need to edit any commands in the vendor folder!
Simply copy the Commands/SystemCommands/StartCommand.php file and put it into your custom commands folder AnotherBotCommands.
Then you can edit the functionality in the execute() method, which will effectively override the default one.
@noplanman Yes, I tried this firstly, but it didn't help. Only system start command executing.
Here is my /hook.php: http://pastebin.com/FgR2BApN
Here is my /AnotherBotCommands/StartCommand.php: http://pastebin.com/8XvAX3ci
I checked file permissions, etc — everything is ok.
@noplanman gotcha. To create custom start command I must copy 'System' start command, not 'User' start command. Now everything works. Thank you!
Exactly!
This way, you can override "all" commands to your custom needs 😃
How can I override /start command to transform it in /start phoneNumber command? This in order to send the start command together client's phone number. Java language. Thanks
@robyx87 This is a PHP library. Search for a Java one online.
Also, you'll need to look into deep-linking for what you're trying to achieve. 👌
Most helpful comment
There is no need to edit any commands in the vendor folder!
Simply copy the
Commands/SystemCommands/StartCommand.phpfile and put it into your custom commands folderAnotherBotCommands.Then you can edit the functionality in the
execute()method, which will effectively override the default one.