From ae8be193f53f75f247c8d90fea18bb43dcbdd6d7 Mon Sep 17 00:00:00 2001 From: Luquinhas Date: Fri, 10 Jan 2025 09:54:38 -0300 Subject: [PATCH] Better error handling when sending a too large video --- src/commands/youtube.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/commands/youtube.js b/src/commands/youtube.js index cd19963..fc5b844 100644 --- a/src/commands/youtube.js +++ b/src/commands/youtube.js @@ -145,10 +145,27 @@ module.exports = (bot) => { fs.unlinkSync(mp4File); } catch (error) { - await ctx.reply(Strings.ytFileError, { - parse_mode: 'Markdown', - reply_to_message_id: ctx.message.message_id, - }); + if (error.includes("Request Entity Too Large")) { + await ctx.telegram.editMessageText( + ctx.chat.id, + downloadingMessage.message_id, + null, + Strings.ytUploadLimit, { + parse_mode: 'Markdown', + reply_to_message_id: ctx.message.message_id, + }, + ); + } else { + await ctx.telegram.editMessageText( + ctx.chat.id, + downloadingMessage.message_id, + null, + Strings.ytFileError, { + parse_mode: 'Markdown', + reply_to_message_id: ctx.message.message_id, + }, + ); + }; fs.unlinkSync(mp4File); }