From aae5926db933ed57f1be6fe85051160a5c051326 Mon Sep 17 00:00:00 2001 From: Manuel Hettich <17690367+ManuelHettich@users.noreply.github.com> Date: Tue, 6 Jan 2026 08:45:07 +0000 Subject: [PATCH] fix(telegram): notify user when media exceeds size limit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a file exceeds mediaMaxMb, send a friendly error message instead of silently dropping the upload. --- 🤖 Authored by Jarvis (AI assistant) --- src/telegram/bot.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index 79b14da48..f6b7317f5 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -483,12 +483,30 @@ export function createTelegramBot(opts: TelegramBotOptions) { return; } - const media = await resolveMedia( - ctx, - mediaMaxBytes, - opts.token, - opts.proxyFetch, - ); + let media: Awaited> = null; + try { + media = await resolveMedia( + ctx, + mediaMaxBytes, + opts.token, + opts.proxyFetch, + ); + } catch (mediaErr) { + const errMsg = String(mediaErr); + if (errMsg.includes("exceeds") && errMsg.includes("MB limit")) { + const limitMb = Math.round(mediaMaxBytes / (1024 * 1024)); + await bot.api + .sendMessage( + chatId, + `⚠️ File too large. Maximum size is ${limitMb}MB.`, + { reply_to_message_id: msg.message_id }, + ) + .catch(() => {}); + logger.warn({ chatId, error: errMsg }, "media exceeds size limit"); + return; + } + throw mediaErr; + } const allMedia = media ? [{ path: media.path, contentType: media.contentType }] : [];