2012-02-13 20:56:04 +01:00
|
|
|
var vm = require('vm');
|
2012-02-13 21:21:57 +01:00
|
|
|
var sbox = require('sandbox');
|
2012-02-13 20:56:04 +01:00
|
|
|
|
2011-10-12 17:42:19 +02:00
|
|
|
var js = function(dbot) {
|
|
|
|
var dbot = dbot;
|
2012-02-13 21:21:57 +01:00
|
|
|
var s = new sbox();
|
2011-10-12 17:42:19 +02:00
|
|
|
|
|
|
|
var commands = {
|
2012-05-19 20:14:07 +02:00
|
|
|
'~js': function(event) {
|
|
|
|
console.log('hello');
|
|
|
|
var q = event.message.valMatch(/^~js (.*)/, 2);
|
2012-02-13 21:11:51 +01:00
|
|
|
s.run(q[1], function(output) {
|
2012-05-19 20:14:07 +02:00
|
|
|
event.reply(output.result);
|
|
|
|
}.bind(this));
|
2012-02-13 21:01:22 +01:00
|
|
|
},
|
|
|
|
|
2012-05-19 20:14:07 +02:00
|
|
|
'~ajs': function(event) {
|
2012-02-13 21:01:22 +01:00
|
|
|
var q = data.message.valMatch(/^~ajs (.*)/, 2);
|
2012-03-10 15:56:06 +01:00
|
|
|
if(dbot.admin.include(data.user) ) {
|
|
|
|
var ret = eval(q[1]);
|
|
|
|
if(ret != undefined) {
|
2012-05-19 20:14:07 +02:00
|
|
|
event.reply(ret);
|
2012-03-10 15:56:06 +01:00
|
|
|
}
|
2012-02-13 21:01:22 +01:00
|
|
|
}
|
2011-10-12 17:42:19 +02:00
|
|
|
}
|
|
|
|
};
|
2011-10-12 17:43:09 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
'onLoad': function() {
|
|
|
|
return commands;
|
2012-04-15 22:43:02 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
'name': 'js',
|
|
|
|
|
|
|
|
'ignorable': true
|
2011-10-12 17:43:09 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return js(dbot);
|
|
|
|
};
|