mirror of
https://github.com/reality/dbot.git
synced 2025-01-23 18:44:14 +01:00
well lets give this a try
This commit is contained in:
parent
fc415aa6c6
commit
2ce0e67d4b
26
database.js
26
database.js
@ -15,19 +15,23 @@ var DatabaseDriver = function(config) {
|
|||||||
* Connect to or create a new DataBank
|
* Connect to or create a new DataBank
|
||||||
*/
|
*/
|
||||||
DatabaseDriver.prototype.createDB = function(name, driver, schema, callback) {
|
DatabaseDriver.prototype.createDB = function(name, driver, schema, callback) {
|
||||||
var params = { 'schema': schema };
|
if(!_.has(this.databanks, name)) {
|
||||||
|
var params = { 'schema': schema };
|
||||||
|
|
||||||
if(driver == 'redis' && _.has(this.config, 'redisPort')) params.port = this.config.redisPort;
|
if(driver == 'redis' && _.has(this.config, 'redisPort')) params.port = this.config.redisPort;
|
||||||
if(driver == 'disk') params.dir = 'db';
|
if(driver == 'disk') params.dir = 'db';
|
||||||
|
|
||||||
this.databanks[name] = Databank.get(driver, params);
|
this.databanks[name] = Databank.get(driver, params);
|
||||||
this.databanks[name].connect({}, function(err) {
|
this.databanks[name].connect({}, function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log('Didn\'t manage to connect to the data source - ' + err);
|
console.log('Didn\'t manage to connect to the data source - ' + err);
|
||||||
} else {
|
} else {
|
||||||
callback(this.databanks[name]);
|
callback(this.databanks[name]);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
callback(this.databanks[name]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.DatabaseDriver = DatabaseDriver;
|
exports.DatabaseDriver = DatabaseDriver;
|
||||||
|
3
run.js
3
run.js
@ -165,6 +165,7 @@ DBot.prototype.reloadModules = function() {
|
|||||||
delete require.cache[path];
|
delete require.cache[path];
|
||||||
require('./snippets');
|
require('./snippets');
|
||||||
|
|
||||||
|
// Clear JSBot listeners and hooks
|
||||||
this.instance.removeListeners();
|
this.instance.removeListeners();
|
||||||
this.instance.clearHooks();
|
this.instance.clearHooks();
|
||||||
|
|
||||||
@ -217,7 +218,6 @@ DBot.prototype.reloadModules = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process.nextTick(function() {
|
|
||||||
_.each(moduleNames, function(name) {
|
_.each(moduleNames, function(name) {
|
||||||
if(this.status[name] === true) {
|
if(this.status[name] === true) {
|
||||||
try {
|
try {
|
||||||
@ -304,7 +304,6 @@ DBot.prototype.reloadModules = function() {
|
|||||||
this.modules[module.name] = module;
|
this.modules[module.name] = module;
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
if(_.has(this.modules, 'web')) this.modules.web.reloadPages();
|
if(_.has(this.modules, 'web')) this.modules.web.reloadPages();
|
||||||
|
Loading…
Reference in New Issue
Block a user