Open
Description
🐞 Bug Report
If the forwarded message comes from a deleted chat, it seems that an error will be reported.
Now forward the message to the save message of telegram, delete the original channel or chat of the message, and then forward the message from the save message to the robot, it seems that an error will be reported.
Error: Call to a member function getId() on null in /var/www/html/vendor/longman/telegram-bot/src/DB.php:1301
Stack trace:
#0 /var/www/html/vendor/longman/telegram-bot/src/DB.php(583): Longman\TelegramBot\DB::insertMessageRequest(Object(Longman\TelegramBot\Entities\Message))
#1 /var/www/html/vendor/longman/telegram-bot/src/Telegram.php(655): Longman\TelegramBot\DB::insertRequest(Object(Longman\TelegramBot\Entities\Update))
#2 /var/www/html/vendor/longman/telegram-bot/src/Telegram.php(527): Longman\TelegramBot\Telegram->processUpdate(Object(Longman\TelegramBot\Entities\Update))
I simply changed the code and the program ran normally, but it may need more sanity considerations.
if ($forward_origin = $message->getForwardOrigin()) {
$forward_date = self::getTimestamp($forward_origin->getDate());
if ($forward_origin instanceof MessageOriginUser) {
self::insertUser($forward_origin->getSenderUser());
$forward_from = $forward_origin->getSenderUser()->getId();
} elseif ($forward_origin instanceof MessageOriginHiddenUser) {
$forward_sender_name = $forward_origin->getSenderUserName();
} elseif ($forward_origin instanceof MessageOriginChat) {
if(!empty($forward_origin->getChat())){
self::insertChat($forward_origin->getChat());
$forward_from_chat = $forward_origin->getChat()->getId();
$forward_signature = $forward_origin->getAuthorSignature();
}
} elseif ($forward_origin instanceof MessageOriginChannel) {
self::insertChat($forward_origin->getChat());
$forward_from_chat = $forward_origin->getChat()->getId();
$forward_from_message_id = $forward_origin->getMessageId();
$forward_signature = $forward_origin->getAuthorSignature();
}
}
Required Information
? | ! |
---|---|
Operating system | debian |
PHP Telegram Bot version | docker php:8.1.29-fpm-bullseye |
PHP version | x.y.z |