irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.

Home Page:https://telegram-bot-sdk.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Download this file (it contain one subtitle file in it)
    example.zip

  2. unzip it with php: (its important to unzip it with php)

$zip= new \ZipArchive();
$zip->open('example.zip');
$zip->extractTo('.');
  1. 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.