telegram-bot-sdk
telegram-bot-sdk copied to clipboard
How to use $arguments in handle method?
public function make(Api $telegram, Update $update, array $entity)
{
$this->telegram = $telegram;
$this->update = $update;
$this->entity = $entity;
$this->arguments = $this->parseCommandArguments();
return call_user_func_array([$this, 'handle'], array_values($this->getArguments())); // here handle method should contain one array argument
}
/**
* {@inheritdoc}
*/
abstract public function handle(); // this method not contains $arguments arg
If you look at Telegram\Bot\Commands\Command;
abstract public function handle();
this method doesnt accept any argument,
I tried:
$this->getArguments() //this always return empty array
Use $commandWithArguments= $this->getUpdate()->message->text;
Example
public function handle() { $updates = $this->getUpdate(); $commandParts = explode(' ', $updates->message->text); $firstArgument = $commandParts[1] ?? 'default argument'; }