mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
refactor: [YT] Reply downloading or uploading status
This commit is contained in:
parent
452aed5fd3
commit
9749f8a685
@ -1,5 +1,6 @@
|
|||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const { getStrings } = require('../plugins/checklang');
|
||||||
|
|
||||||
async function DownloadFromYoutube(command) {
|
async function DownloadFromYoutube(command) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -16,19 +17,17 @@ async function DownloadFromYoutube(command) {
|
|||||||
|
|
||||||
module.exports = (bot) => {
|
module.exports = (bot) => {
|
||||||
bot.command('yt', async (ctx) => {
|
bot.command('yt', async (ctx) => {
|
||||||
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
const args = ctx.message.text.split(' ').slice(1).join(' ');
|
const args = ctx.message.text.split(' ').slice(1).join(' ');
|
||||||
const ytCommand = 'yt-dlp ' + args + ' -o video.mp4';
|
const ytCommand = 'yt-dlp ' + args + ' -o video.mp4';
|
||||||
|
ctx.reply(Strings.downloading);
|
||||||
await DownloadFromYoutube(ytCommand);
|
await DownloadFromYoutube(ytCommand);
|
||||||
try {
|
try {
|
||||||
|
ctx.reply(Strings.uploading);
|
||||||
await ctx.replyWithVideo({ source: 'video.mp4' });
|
await ctx.replyWithVideo({ source: 'video.mp4' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
ctx.reply('Error!')
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
fs.unlinkSync('video.mp4');
|
fs.unlinkSync('video.mp4');
|
||||||
} catch (error) {
|
})
|
||||||
console.log(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
@ -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!",
|
"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",
|
"goBack": "Back",
|
||||||
"maInvalidModule": "Please provide a valid module ID from The Mod Archive.\nExample: `/modarchive 81574`",
|
"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..."
|
||||||
}
|
}
|
@ -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!",
|
"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",
|
"goBack": "Voltar",
|
||||||
"maInvalidModule": "Por favor, forneça um ID de módulo válido do The Mod Archive.\nExemplo: `/modarchive 81574`",
|
"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..."
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user