forked from GitHub/dbot
Fixed doom function binding bug and transformed js module [#131]
This commit is contained in:
parent
8b7953e906
commit
96792d5008
@ -8,12 +8,11 @@ var vm = require('vm');
|
||||
var sbox = require('sandbox');
|
||||
|
||||
var js = function(dbot) {
|
||||
var s = new sbox();
|
||||
|
||||
var commands = {
|
||||
// Run JS code sandboxed, return result to channel.
|
||||
'~js': function(event) {
|
||||
try {
|
||||
var s = new sbox();
|
||||
s.run(event.input[1], function(output) {
|
||||
event.reply(output.result);
|
||||
}.bind(this));
|
||||
@ -30,16 +29,13 @@ var js = function(dbot) {
|
||||
};
|
||||
commands['~js'].regex = [/^~js (.*)/, 2];
|
||||
commands['~ajs'].regex = [/^~ajs (.*)/, 2];
|
||||
|
||||
commands['~ajs'].access = 'admin';
|
||||
|
||||
return {
|
||||
'name': 'js',
|
||||
'ignorable': true,
|
||||
'commands': commands
|
||||
};
|
||||
this.name = 'js';
|
||||
this.ignorable = true;
|
||||
this.commands = commands;
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return js(dbot);
|
||||
return new js(dbot);
|
||||
};
|
||||
|
3
run.js
3
run.js
@ -194,7 +194,8 @@ DBot.prototype.reloadModules = function() {
|
||||
if(_.has(config, property) && _.has(config[property], itemName)) {
|
||||
_.extend(item, config[property][itemName]);
|
||||
}
|
||||
module[property][itemName] = item.bind(module);
|
||||
module[property][itemName] = _.bind(item, module);
|
||||
_.extend(module[property][itemName], item);
|
||||
}, this);
|
||||
_.extend(this[property], module[property]);
|
||||
}, this);
|
||||
|
Loading…
Reference in New Issue
Block a user