import { cfg, read } from './inc/cfg.js'; import { wrapper, clients } from './inc/wrapper.js'; const safeEval = require('safe-eval'); read().then(() => { let bot = new wrapper(); bot.on('message', e => { //if(e.type === "tg") // clients[0].client.send(`PRIVMSG #kbot-dev ${e.user.nick}: ${e.message}`); if(e.type === "irc") { if (e.message.match(/^\.js /)) { // JS-Sandbox let args = e.message.substring(3); var context = { e: e } try { var output = safeEval(args, context); if (typeof output !== undefined && output !== 'undefined' && output) { let blah = JSON.stringify(output); if (blah != "Converting circular structure to JSON") e.reply(blah.length > 250 ? `holy fuck, Ausgabe wäre viel zu lang! (${blah.length} Zeichen :DDDDDD)` : blah); } } catch (err) { e.reply(err.message); } } } }); });