3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +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 = { var commands = {
'~ignore': function(event) { '~ignore': function(event) {
var ignorableModules = []; var ignorableModules = [];
for(var i=0;i<dbot.modules.length;i++) {
if(dbot.modules[i].ignorable != null && dbot.modules[i].ignorable == true) { dbot.modules.each(function(module) {
ignorableModules.push(dbot.modules[i].name); if(module.ignorable != null && module.ignorable == true) {
ignorableModules.push(module.name);
} }
} });
var module = event.params[1]; var module = event.params[1];
if(module === undefined) { if(module === undefined) {

4
run.js
View File

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

View File

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