From e09b4b2ad7d4550e1a15caa21962b0acedbab872 Mon Sep 17 00:00:00 2001 From: mysubcult Date: Mon, 3 Aug 2026 17:14:22 +0400 Subject: [PATCH] Send Telegram chat files by URL --- bootstrap/bootstrap.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bootstrap/bootstrap.php b/bootstrap/bootstrap.php index 20d3c3a..a8194ad 100644 --- a/bootstrap/bootstrap.php +++ b/bootstrap/bootstrap.php @@ -472,7 +472,7 @@ private function sendTelegramChatFile($tchat, $fileData, $caption, $disableNotif 'chat_id' => $tchat->bot->group_chat_id, 'message_thread_id' => $tchat->tchat_id, 'parse_mode' => 'HTML', - $field => Longman\TelegramBot\Request::encodeFile($file->file_path_server) + $field => $this->getTelegramChatFileUrl($file) ); if ($caption !== '') { @@ -517,6 +517,20 @@ private function sendTelegramChatFile($tchat, $fileData, $caption, $disableNotif return true; } + + private function getTelegramChatFileUrl($file) + { + $URLHash = ''; + + if ($file->chat_id > 0) { + $tsHash = time(); + $temporaryHash = sha1($file->id . '_' . $file->hash . '_' . $tsHash . '_' . erConfigClassLhConfig::getInstance()->getSetting('site', 'secrethash')); + $URLHash = "/(vhash)/{$temporaryHash}/(vts)/{$tsHash}"; + } + + return erLhcoreClassSystem::getHost() . erLhcoreClassDesign::baseurldirect('file/downloadfile') . "/{$file->id}/{$file->security_hash}{$URLHash}"; + } + public function messageAdded($params) { $chat = $params['chat'];