Empty Message object return on some files
foremtehan opened this issue · comments
PHP version
8.1
irazasyed/telegram-bot-sdk version
3
Laravel version (if any)
10
Code To Reproduce the bug
-
Download this file (it contain one subtitle file in it)
example.zip -
unzip it with php: (its important to unzip it with php)
$zip= new \ZipArchive();
$zip->open('example.zip');
$zip->extractTo('.');
- Then send it:
$response = Telegram::sendDocument([
'chat_id' => CHAT_ID,
'document' => InputFile::create("The Other Two S02E08 - Pat Gets an Offer to Host \"Tic Tac Toe\".srt")
]);
//$response is an empty Message object!
I contacted the Telegram Bot API developer and they said that the request didn't even took place...
Problem:
The PHP unzip class extracts and renames the special characters in the filename to another valid character, Which is double quotations in this case. However, the character will still be converted to a double quotation mark, so you have to use quotation marks as I did in the example above.
It should throw an exception, but it silently returns an empty object.
You could use single quotes? Pre-process to a valid filename supported by Telegram? Not sure what the SDK could do here.