This commit is contained in:
Flummi 2016-10-29 05:21:35 +02:00
parent 2912006129
commit 8fb995309a

View File

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