Media size limit option

This commit is contained in:
Alexander Pankratov 2019-02-24 19:18:47 +03:00
parent 38e8bef31d
commit 0a952cba3e

View File

@ -202,6 +202,7 @@ class Client {
'channel' =>'',
'id' => [0],
'message' => [],
'size_limit' => 0,
],$data);
@ -217,6 +218,15 @@ class Client {
}
$info = $this->MadelineProto->get_download_info($message);
if ($data['size_limit']) {
if ($info['size'] > $data['size_limit']) {
throw new \OutOfRangeException(
"Media exceeds size limit. Size: {$info['size']} bytes; limit: {$data['size_limit']} bytes"
);
}
}
$file = tempnam(sys_get_temp_dir(), 'telegram_media_');
$this->MadelineProto->download_to_file($message, $file);