f0ckv1/src/trigger/bot.js

27 lines
605 B
JavaScript
Raw Normal View History

2016-10-29 05:16:37 +02:00
const util = require('util');
const vm = require('vm');
module.exports = (lib) => {
const sandbox = {
2016-10-29 05:21:35 +02:00
bot: lib.bot,
output: "nothing"
2016-10-29 05:16:37 +02:00
};
lib.trigger.add({
name: 'bot debug',
call: /^!bot (.*)/i,
level: 100,
active: 1,
func: (e) => {
var args = e.message.trim().match(/^!bot (.*?)/i)[1];
2016-10-29 05:21:35 +02:00
e.reply(args);
2016-10-29 05:16:37 +02:00
const script = new vm.Script(args);
const context = new vm.createContext(sandbox);
2016-10-29 05:21:35 +02:00
2016-10-29 05:16:37 +02:00
script.runInContext(context);
2016-10-29 05:21:35 +02:00
e.reply(util.inspect(sandbox.output));
2016-10-29 05:16:37 +02:00
},
desc: 'bot debug'
});
};