Closed sigaev-pro closed 8 years ago
At the moment there is no clean way to execute a subcommand. Seems like one of those obvious things that one should just be able to do, right?
The only thing that I can think of, is to extract the functionality from the /reply
command you're trying to call and execute it specifically.
If you need a more thorough explanation, let me know!
@akalongman @MBoretto @jacklul Am I just totally oblivious to the library actually being able to do this? The only way I found of doing this is the following, which is an ugly hack and I'm not exactly sure of all the things it might break:
// In the command's execute(), if we want to send "/echo testing".
// Note that we explicitly need to create the EchoCommand object!
$ud = clone $this->getUpdate();
\Tests\TestHelpers::setObjectProperty($ud->getMessage(), 'text', '/echo testing');
(new EchoCommand($this->telegram, $ud))->preExecute();
You can instead be sending /replyparameter command and then explode "" and execute first part then inside reply command extract the second part and use it as a parameter, thats how i did contact/reply system in my bots.
So I have a contact command that puts inline button under user message:
'text' => "Reply",
'callback_data' => 'reply_' . $message->getFrom()->getId()
then in callbackquerycommand I have this simple thing:
$data = $callback_query->getData();
$command = explode('_', $data);
$command = $command[0];
if ($this->getTelegram()->getCommandObject($command)) {
return $this->getTelegram()->executeCommand($command);
}
and then on top of my reply command i have:
$testtext = explode('reply_', $command);
$text = $testtext[1];
hope this helps
First of all thanks for great job!
I have created callbackquery command where I'm checking the callback_data for a string like "order:123". I need to start an other command such as
/reply 123
. But when I'm tryingI'm getting following exception:
Does it a way to do it?