From 9d73a1d03f130ec56a705e78415d3a87224e43c6 Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Date: Sat, 28 Sep 2024 23:43:16 -0300 Subject: [PATCH] Run command to remote shell --- commands/crew.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/commands/crew.js b/commands/crew.js index 9a91c30..6181819 100644 --- a/commands/crew.js +++ b/commands/crew.js @@ -165,4 +165,32 @@ module.exports = (bot) => { } }, '', Strings.fileError); }); + + bot.command('run', (ctx) => { + const command = ctx.message.text.split(' ').slice(1).join(' '); + handleAdminCommand(ctx, async () => { + if (!command) { + return ctx.reply('Por favor, forneça um comando para executar.'); + } + + exec(command, (error, stdout, stderr) => { + if (error) { + return ctx.reply(`\`${error.message}\``, { + parse_mode: 'Markdown', + reply_to_message_id: ctx.message.message_id + }); + } + if (stderr) { + return ctx.reply(`\`${stderr}\``, { + parse_mode: 'Markdown', + reply_to_message_id: ctx.message.message_id + }); + } + ctx.reply(`\`${stdout}\``, { + parse_mode: 'Markdown', + reply_to_message_id: ctx.message.message_id + }); + }); + }, '', "Nope!"); + }); };