3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 21:09:31 +01:00
dbot/modules/js.js

37 lines
851 B
JavaScript
Raw Normal View History

var vm = require('vm');
var sbox = require('sandbox');
2011-10-12 17:42:19 +02:00
var js = function(dbot) {
var dbot = dbot;
var s = new sbox();
2011-10-12 17:42:19 +02:00
var commands = {
'~js': function(data, params) {
2011-10-12 17:55:46 +02:00
var q = data.message.valMatch(/^~js (.*)/, 2);
s.run(q[1], function(output) {
dbot.say(data.channel, output.result);
});
},
'~ajs': function(data, params) {
var q = data.message.valMatch(/^~ajs (.*)/, 2);
if(dbot.admin.include(data.user) ) {
var ret = eval(q[1]);
if(ret != undefined) {
dbot.say(data.channel, ret);
}
}
2011-10-12 17:42:19 +02:00
}
};
2011-10-12 17:43:09 +02:00
return {
'onLoad': function() {
return commands;
}
};
};
exports.fetch = function(dbot) {
return js(dbot);
};