Run command to remote shell

This commit is contained in:
Lucas Gabriel 2024-09-28 23:43:16 -03:00
parent 18e7a77176
commit 9d73a1d03f
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985

View File

@ -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!");
});
};