This commit is contained in:
Flummi 2016-10-29 05:26:24 +02:00
parent 8fb995309a
commit 995e9d9196

View File

@ -4,7 +4,8 @@ const vm = require('vm');
module.exports = (lib) => { module.exports = (lib) => {
const sandbox = { const sandbox = {
bot: lib.bot, bot: lib.bot,
output: "nothing" output: "nothing",
e: null
}; };
lib.trigger.add({ lib.trigger.add({
@ -13,14 +14,13 @@ module.exports = (lib) => {
level: 100, level: 100,
active: 1, active: 1,
func: (e) => { func: (e) => {
var args = e.message.trim().match(/^!bot (.*?)/i)[1]; var args = e.message.match(/^!bot (.*?)/i)[1];
e.reply(args); e.reply(args);
sandbox.e = e;
const script = new vm.Script(args); vm.runInNewContext(args, sandbox);
const context = new vm.createContext(sandbox);
script.runInContext(context); e.reply(util.inspect(sandbox['output']));
e.reply(util.inspect(sandbox.output));
}, },
desc: 'bot debug' desc: 'bot debug'
}); });