3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 19:52:36 +01:00

thats a little better on the module loader i suppose [#331]

This commit is contained in:
reality 2013-04-10 01:07:29 +00:00
parent 384fe3024a
commit 6cea1256ce

53
run.js
View File

@ -207,29 +207,7 @@ DBot.prototype.reloadModules = function() {
}
this.config[name] = config;
// Groovy funky database shit
if(!_.has(config, 'dbType') || config.dbType == 'olde') {
// Generate missing DB keys
_.each(config.dbKeys, function(dbKey) {
if(!_.has(this.db, dbKey)) {
this.db[dbKey] = {};
}
}, this);
this.loadModule(name, this.db);
} else {
// Just use the name of the module for now, add dbKey iteration later
this.ddb.createDB(name, config.dbType, {}, function(db) {
this.loadModule(name, db);
}.bind(this));
}
}.bind(this));
this.save();
};
// Load the module itself
DBot.prototype.loadModule = function(name, db) {
var moduleDir = './modules/' + name + '/';
var loadModule = function(db) {
var rawModule = require(moduleDir + name);
var module = rawModule.fetch(this);
this.rawModules.push(rawModule);
@ -297,9 +275,6 @@ DBot.prototype.loadModule = function(name, db) {
return this.name;
}
console.log(module);
console.log(this);
this.modules[module.name] = module;
if(_.has(this.modules, 'web')) this.modules.web.reloadPages();
@ -314,7 +289,31 @@ DBot.prototype.loadModule = function(name, db) {
}
}
}, this);
}
}.bind(this);
// Groovy funky database shit
if(!_.has(config, 'dbType') || config.dbType == 'olde') {
// Generate missing DB keys
_.each(config.dbKeys, function(dbKey) {
if(!_.has(this.db, dbKey)) {
this.db[dbKey] = {};
}
}, this);
loadModule(this.db);
} else {
// Just use the name of the module for now, add dbKey iteration later
this.ddb.createDB(name, config.dbType, {}, function(db) {
loadModule(db);
});
}
}.bind(this));
this.save();
};
// Load the module itself
DBot.prototype.loadModule = function(name, db) {
}
DBot.prototype.cleanNick = function(key) {
key = key.toLowerCase();