Some misc changes

This commit is contained in:
Lucas Gabriel 2025-01-10 12:27:55 -03:00
parent ef63ae439c
commit b465ba29dd
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985
2 changed files with 14 additions and 20 deletions

View File

@ -7,7 +7,7 @@ require('./plugins/ytdlp-wrapper.js');
// require('./plugins/termlogger.js'); // require('./plugins/termlogger.js');
const bot = new Telegraf(process.env.botToken); const bot = new Telegraf(process.env.botToken);
const MAX_RETRIES = 5; const maxRetries = process.env.maxRetries || 5;
let restartCount = 0; let restartCount = 0;
const loadCommands = () => { const loadCommands = () => {
@ -38,7 +38,7 @@ const startBot = async () => {
restartCount = 0; restartCount = 0;
} catch (error) { } catch (error) {
console.error('Failed to start bot:', error.message); console.error('Failed to start bot:', error.message);
if (restartCount < MAX_RETRIES) { if (restartCount < maxRetries) {
restartCount++; restartCount++;
console.log(`Retrying to start bot... Attempt ${restartCount}`); console.log(`Retrying to start bot... Attempt ${restartCount}`);
setTimeout(startBot, 5000); setTimeout(startBot, 5000);

View File

@ -129,23 +129,12 @@ module.exports = (bot) => {
source: mp4File }, { source: mp4File }, {
caption: message, caption: message,
parse_mode: 'Markdown', parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id,
}); });
if (approxSizeInMB >= 50) {
await ctx.telegram.editMessageText(
ctx.chat.id,
downloadingMessage.message_id,
null,
Strings.ytDownload.sizeLimitWarn, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id,
},
);
}
fs.unlinkSync(mp4File); fs.unlinkSync(mp4File);
} catch (error) { } catch (error) {
if (error.includes("Request Entity Too Large")) { if (toString(error).includes("Request Entity Too Large")) {
await ctx.telegram.editMessageText( await ctx.telegram.editMessageText(
ctx.chat.id, ctx.chat.id,
downloadingMessage.message_id, downloadingMessage.message_id,
@ -188,10 +177,15 @@ module.exports = (bot) => {
} }
} catch (error) { } catch (error) {
console.error(error); console.error(error);
await ctx.reply(Strings.ytDownload.uploadErr, { await ctx.telegram.editMessageText(
parse_mode: 'Markdown', ctx.chat.id,
reply_to_message_id: ctx.message.message_id, downloadingMessage.message_id,
}); null,
Strings.ytDownload.uploadErr, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id,
},
);
} }
}); });
}; };