Add /eval for bot admins

This commit is contained in:
Lucas Gabriel 2024-10-14 13:16:15 -03:00
parent 98e83f85b9
commit 911c0d41bb
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985

View File

@ -167,7 +167,7 @@ module.exports = (bot) => {
}, '', Strings.fileError); }, '', Strings.fileError);
}); });
bot.command('run', (ctx) => { bot.command('run', spamwatchMiddleware, async (ctx) => {
const command = ctx.message.text.split(' ').slice(1).join(' '); const command = ctx.message.text.split(' ').slice(1).join(' ');
handleAdminCommand(ctx, async () => { handleAdminCommand(ctx, async () => {
if (!command) { if (!command) {
@ -195,7 +195,27 @@ module.exports = (bot) => {
}, '', "Nope!"); }, '', "Nope!");
}); });
bot.command('crash', (ctx) => { bot.command('eval', spamwatchMiddleware, async (ctx) => {
const code = ctx.message.text.split(' ').slice(1).join(' ');
if (!code) {
return ctx.reply('Por favor, forneça um código para avaliar.');
}
try {
const result = eval(code);
ctx.reply(`Result: ${result}`, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
} catch (error) {
ctx.reply(`Error: ${error.message}`, {
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id
});
}
});
bot.command('crash', spamwatchMiddleware, async (ctx) => {
handleAdminCommand(ctx, async () => { handleAdminCommand(ctx, async () => {
ctx.reply(null); ctx.reply(null);
}, '', "Nope!"); }, '', "Nope!");