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,
});
}
});
};
};