Closed Stajor closed 4 years ago
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
also have this problem, maybe it because all new methods tested with only getUpdates
without webhook
I'm rolled back to ^2.0 ver or "dev-master" is last
UP @irazasyed why is this happening? can it be solved?
It happens because CommandBus is trying to parse command in update->message->text using message entity bot_command. In callback query there is no entities, so it gives error. I resolved this problem very simple, but it is not best practice, just temporary fix.
In file scr/Commands/Command.php
add if (!$this->update->isType('callback_query'))
on line 183
for method make
, like this:
public function make(Api $telegram, Update $update, array $entity)
{
$this->telegram = $telegram;
$this->update = $update;
$this->entity = $entity;
if (!$this->update->isType('callback_query'))
$this->arguments = $this->parseCommandArguments();
return call_user_func_array([$this, 'handle'], $this->getArguments());
}
and now you can call triggerCommand for callback queries, but without command arguments (i resolved it by sending callback data as json, i.e. command=start, parameters=[param1=val1...])
It happens because CommandBus is trying to parse command in update->message->text using message entity bot_command. In callback query there is no entities, so it gives error. I resolved this problem very simple, but it is not best practice, just temporary fix.
In file
scr/Commands/Command.php
addif (!$this->update->isType('callback_query'))
on line183
for methodmake
, like this:public function make(Api $telegram, Update $update, array $entity) { $this->telegram = $telegram; $this->update = $update; $this->entity = $entity; if (!$this->update->isType('callback_query')) $this->arguments = $this->parseCommandArguments(); return call_user_func_array([$this, 'handle'], $this->getArguments()); }
and now you can call triggerCommand for callback queries, but without command arguments (i resolved it by sending callback data as json, i.e. command=start, parameters=[param1=val1...])
That's exactly it! Thank you!
These kinda cases have been taken care in upcoming version which will be released in sometime.
How can I call command outside
composer.json
Webhook controller
Stack trace: