mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
Add /eval for bot admins
This commit is contained in:
parent
98e83f85b9
commit
911c0d41bb
@ -167,7 +167,7 @@ module.exports = (bot) => {
|
||||
}, '', Strings.fileError);
|
||||
});
|
||||
|
||||
bot.command('run', (ctx) => {
|
||||
bot.command('run', spamwatchMiddleware, async (ctx) => {
|
||||
const command = ctx.message.text.split(' ').slice(1).join(' ');
|
||||
handleAdminCommand(ctx, async () => {
|
||||
if (!command) {
|
||||
@ -195,7 +195,27 @@ module.exports = (bot) => {
|
||||
}, '', "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 () => {
|
||||
ctx.reply(null);
|
||||
}, '', "Nope!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user