refactor: [YT] Reply downloading or uploading status

This commit is contained in:
GiovaniFZ 2024-09-27 15:30:14 -03:00
parent 452aed5fd3
commit 9749f8a685
No known key found for this signature in database
GPG Key ID: 63DD92181B575322
3 changed files with 13 additions and 10 deletions

View File

@ -1,5 +1,6 @@
var exec = require('child_process').exec;
const fs = require('fs');
const { getStrings } = require('../plugins/checklang');
async function DownloadFromYoutube(command) {
return new Promise((resolve, reject) => {
@ -16,19 +17,17 @@ async function DownloadFromYoutube(command) {
module.exports = (bot) => {
bot.command('yt', async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
const args = ctx.message.text.split(' ').slice(1).join(' ');
const ytCommand = 'yt-dlp ' + args + ' -o video.mp4';
ctx.reply(Strings.downloading);
await DownloadFromYoutube(ytCommand);
try {
ctx.reply(Strings.uploading);
await ctx.replyWithVideo({ source: 'video.mp4' });
} catch (error) {
console.log(error);
ctx.reply('Error!')
}
try {
fs.unlinkSync('video.mp4');
} catch (error) {
console.log(error)
}
}
)
})
}

View File

@ -57,5 +57,7 @@
"interactiveEmojisDesc": "*Interactive emojis*\n\n- /dice: Roll a dice\n- /idice: Infinitely roll a colored dice\n- /slot: Try to combine the figures!\n- /ball: Try to kick the ball into the goal!\n- /bowling: Try to hit the pins!\n- /dart: Try to hit the target!",
"goBack": "Back",
"maInvalidModule": "Please provide a valid module ID from The Mod Archive.\nExample: `/modarchive 81574`",
"maDownloadError": "Error downloading the file. Check the module ID and try again."
"maDownloadError": "Error downloading the file. Check the module ID and try again.",
"downloading": "Downloading...",
"uploading": "Uploading. Please, hold on..."
}

View File

@ -57,5 +57,7 @@
"interactiveEmojisDesc": "*Emojis interativos*\n\n- /dice: Jogue um dado\n- /idice: Role infinitamente um dado colorido\n- /slot: Tente combinar as figuras!\n- /ball: Tente chutar a bola no gol!\n- /bowling: Tente derrubar os pinos!\n- /dart: Tente acertar o alvo!",
"goBack": "Voltar",
"maInvalidModule": "Por favor, forneça um ID de módulo válido do The Mod Archive.\nExemplo: `/modarchive 81574`",
"maDownloadError": "Erro ao baixar o arquivo. Verifique o ID do módulo e tente novamente."
"maDownloadError": "Erro ao baixar o arquivo. Verifique o ID do módulo e tente novamente.",
"downloading": "Fazendo download...",
"uploading": "Fazendo upload. Por favor, aguarde um momento..."
}