Temporary fix for 50MB issue

This commit is contained in:
Lucas Gabriel 2024-09-28 19:10:53 -03:00
parent 4ffb5c3972
commit 236bad0576
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985
3 changed files with 38 additions and 15 deletions

View File

@ -60,30 +60,51 @@ module.exports = (bot) => {
});
if (fs.existsSync(mp4File)) {
const userId = parseInt(ctx.match[2]);
const userName = ctx.from.first_name;
const message = strings.ytUploadDesc
.replace("{userId}", userId)
.replace("{userName}", userName);
.replace("{userName}", ctx.from.first_name);
await ctx.replyWithVideo({
source: mp4File,
caption: `${message}`,
parse_mode: 'Markdown'
fs.stat(mp4File, async (err, stats) => {
if (err) {
console.error(err);
return;
};
const mbSize = stats.size / (1024 * 1024);
if (mbSize > 50) {
await ctx.reply(strings.ytUploadLimit, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id,
});
fs.unlinkSync(mp4File);
} else {
try {
await ctx.replyWithVideo({
source: mp4File,
caption: `${message}`,
parse_mode: 'Markdown',
});
} catch (error) {
await ctx.reply(`\`${error}\``, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id,
});
};
};
});
fs.unlinkSync(mp4File);
}
} catch (error) {
};
} catch (downloadError) {
fs.unlinkSync(mp4File);
const message = strings.ytDownloadErr
.replace("{err}", error)
.replace("{userName}", ctx.from.first_name);
ctx.reply(message, {
await ctx.reply(message, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id,
});
}
});
};
};

View File

@ -61,5 +61,6 @@
"ytDownloading": "*Downloading video...*",
"ytUploading": "*Uploading video...*",
"ytUploadDesc": "*[{userName}](tg://user?id={userId}), there is your downloaded video.*",
"ytDownloadErr": "*Error during YT video download:*\n\n`{err}`"
"ytDownloadErr": "*Error during YT video download:*\n\n`{err}`",
"ytUploadLimit": "*You have reached the 50MB upload limit for the bot. Try another video. We're trying our best to increase the limit.*"
}

View File

@ -61,5 +61,6 @@
"ytDownloading": "*Baixando vídeo...*",
"ytUploading": "*Enviando video...*",
"ytUploadDesc": "*[{userName}](tg://user?id={userId}), aqui está o seu vídeo baixado.*",
"ytDownloadErr": "*Erro durante o download do vídeo do YT:*\n\n`{err}`"
"ytDownloadErr": "*Erro durante o download do vídeo do YT:*\n\n`{err}`",
"ytUploadLimit": "*Você atingiu o limite de upload de 50MB para o bot. Tente outro vídeo. Estamos tentando o máximo para aumentar o limite.*"
}