3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00

load root config changes [#145]

This commit is contained in:
reality 2013-01-21 00:05:42 +00:00
parent 4f0cfaab93
commit b24bd63cd0

40
run.js
View File

@ -5,24 +5,8 @@ var fs = require('fs'),
require('./snippets');
var DBot = function(timers) {
// Load config
try {
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
} catch(err) {
console.log('Config file is invalid. Stopping');
process.exit();
}
try {
var defaultConfig = JSON.parse(fs.readFileSync('config.json.sample', 'utf-8'));
} catch(err) {
console.log('Error loading sample config. Bugger off this should not even be edited. Stopping.');
process.exit();
}
// Load missing config directives from sample file
_.defaults(this.config, defaultConfig);
// Load DB
var rawDB;
try {
var rawDB = fs.readFileSync('db.json', 'utf-8');
@ -42,6 +26,25 @@ var DBot = function(timers) {
process.exit();
}
// Load config
this.config = this.db.config;
try {
_.defaults(this.config, JSON.parse(fs.readFileSync('config.json', 'utf-8')));
} catch(err) {
console.log('Config file is invalid. Stopping');
process.exit();
}
try {
var defaultConfig = JSON.parse(fs.readFileSync('config.json.sample', 'utf-8'));
} catch(err) {
console.log('Error loading sample config. Bugger off this should not even be edited. Stopping.');
process.exit();
}
// Load missing config directives from sample file
_.defaults(this.config, defaultConfig);
// Load Strings file
try {
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
@ -123,6 +126,9 @@ DBot.prototype.reloadModules = function() {
this.usage = {};
this.timers.clearTimers();
// Load config changes
_.extend(this.config, this.db.config);
try {
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
} catch(err) {