3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

dbot.modules is now an object

This commit is contained in:
reality 2012-12-30 00:45:25 +00:00
parent 8bd9f93632
commit 9f3596aa6a
3 changed files with 16 additions and 7 deletions

View File

@ -8,11 +8,12 @@ var ignore = function(dbot) {
var commands = {
'~ignore': function(event) {
var ignorableModules = [];
for(var i=0;i<dbot.modules.length;i++) {
if(dbot.modules[i].ignorable != null && dbot.modules[i].ignorable == true) {
ignorableModules.push(dbot.modules[i].name);
dbot.modules.each(function(module) {
if(module.ignorable != null && module.ignorable == true) {
ignorableModules.push(module.name);
}
}
});
var module = event.params[1];
if(module === undefined) {

4
run.js
View File

@ -117,7 +117,7 @@ DBot.prototype.reloadModules = function() {
}
this.rawModules = [];
this.modules = [];
this.modules = {};
this.commands = {};
this.commandMap = {}; // Map of which commands belong to which modules
this.usage = {};
@ -226,7 +226,7 @@ DBot.prototype.reloadModules = function() {
// Invalid or no string info
}
this.modules.push(module);
this.modules[module.name] = module;
} catch(err) {
console.log(this.t('module_load_error', {'moduleName': name}));
if(this.config.debugMode) {

View File

@ -204,7 +204,15 @@ Object.prototype.filter = function(fun) {
}
}
return filtered;
}
};
Object.prototype.each = function(fun) {
for(var key in this) {
if(this.hasOwnProperty(key)) {
fun(this[key]);
}
}
};
/*** Integer ***/