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