php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.9k stars 953 forks source link

getChat() php fatal error #206

Closed ivanuz closed 8 years ago

ivanuz commented 8 years ago

[error] [client 173.245.53.24] PHP Notice: Undefined variable: command in /vendor/longman/telegram-bot/src/Telegram.php on line 477

[error] [client 173.245.53.24] PHP Fatal error: Call to a member function getChat() on a non-object in /vendor/longman/telegram-bot/src/Commands/GenericCommand.php on line 29

Bot worked very well last 4 month. But yesterday began errors. Nothing changed on server. Any suggestions?

longman/telegram-bot : 0.21.0

DB::insertRequest($update); $result = $this->executeCommand($command, $update); return $result;

jacklul commented 8 years ago

Very outdated library version.

If you do not want to update then you should check if object is valid before calling getChat() in GenericCommand, example:

$message -> $update->getMessage()

if ($message) {
       $chat_id = $message->getChat()->getId();
}

GenericCommand is used when unsupported update is called, .21.0 does not support API 2.0, things like callback query or edited_message will be redirected to it.

ivanuz commented 8 years ago

Your solution didn't help. Just updated for a new version and there is new error: PHP Fatal error: Call to a member function getFrom() on a non-object in /vendor/longman/telegram-bot/src/Commands/SystemCommands/GenericmessageCommand.php on line 51

$conversation = new Conversation( $this->getMessage()->getFrom()->getId(), $this->getMessage()->getChat()->getId() );

MBoretto commented 8 years ago

Would be useful to see the raw update

noplanman commented 8 years ago

@ivanuz Is this still a problem or has it been solved in the meantime? If it's still an issue, a raw update as @MBoretto suggested would really help, thanks!

noplanman commented 8 years ago

@ivanuz If this is still an issue for you, feel free to reopen.

khaninejad commented 7 years ago

version: 0.36.0 PHP Fatal error: Call to a member function getFrom() on null in ...public_html/telegram/vendor/longman/telegram-bot/src/Commands/SystemCommands/GenericmessageCommand.php on line 63