This commit is contained in:
Flummi 2016-10-29 05:59:05 +02:00
parent c303a1040d
commit 680230abc1

View File

@ -1,12 +1,13 @@
const util = require('util');
const vm = require('vm');
//const util = require('util');
//const vm = require('vm');
var safeEval = require('safe-eval');
module.exports = (lib) => {
var sandbox = {
bot: lib.bot,
output: undefined,
e: null
};
//var sandbox = {
// bot: lib.bot,
// output: undefined,
// e: null
//};
lib.trigger.add({
name: 'bot debug',
@ -15,13 +16,18 @@ module.exports = (lib) => {
active: 1,
func: (e) => {
var args = e.message.match(/^\!bot (.*)/i)[1];
sandbox.e = e;
vm.runInNewContext('this.output = '+args, sandbox);
var context = {
bot: lib.bot,
e: e
}
e.reply( safeEval(args, context) );
var output = util.inspect(sandbox.output);
if(typeof(output) !== undefined)
e.reply(output);
//sandbox.e = e;
//vm.runInNewContext('this.output = '+args, sandbox);
//var output = util.inspect(sandbox.output);
//if(typeof(output) !== undefined)
// e.reply(output);
},
desc: 'bot debug'
});