mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-30 04:19:13 +01:00
Media size limit option
This commit is contained in:
parent
38e8bef31d
commit
0a952cba3e
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user