3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 22:39:26 +01:00
dbot/modules/js.js

30 lines
645 B
JavaScript

var vm = require('vm');
var js = function(dbot) {
var dbot = dbot;
var commands = {
'~js': function(data, params) {
var q = data.message.valMatch(/^~js (.*)/, 2);
dbot.say(data.channel, vm.runInNewContext(q[1]));
},
'~ajs': function(data, params) {
var q = data.message.valMatch(/^~ajs (.*)/, 2);
if(data.user == dbot.admin) {
dbot.say(data.channel, eval(q[1]));
}
}
};
return {
'onLoad': function() {
return commands;
}
};
};
exports.fetch = function(dbot) {
return js(dbot);
};