mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Run command to remote shell
This commit is contained in:
parent
18e7a77176
commit
9d73a1d03f
@ -165,4 +165,32 @@ module.exports = (bot) => {
|
|||||||
}
|
}
|
||||||
}, '', Strings.fileError);
|
}, '', 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!");
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user