Read the command
rambo1986 opened this issue · 2 comments
rambo1986 commented
Hi, and thanks for the fantastic bot code. I need to send a massage on a channel with an inline button that contains a url like: tg://resolve?Domain=mybot&start=onecommand
I would need to read the "onecommand" as i have to process it depending on its content. How can i do that?
What should i change to make the bot read "onecommand" as a command even if it doesn't start with "/"?
Thanks in advance
jcomas commented
@rambo1986 Could you paste here more code of your project?
noplanman commented
Using deeplinking, the /start
command gets called, passing the value as the text parameter.
So basically, you can create a custom StartCommand
and get the input in the execute()
method, something like this:
public function execute(): ServerResponse
{
// Get the command from the text ("onecommand" in your example):
$command = $this->getText(true);
// Maybe you want to check if the command is valid, and then you can execute the appropriate command like thusly:
return $this->getTelegram()->executeCommand($command);
}