mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 04:49:25 +01:00
load root config changes [#145]
This commit is contained in:
parent
4f0cfaab93
commit
b24bd63cd0
40
run.js
40
run.js
@ -5,24 +5,8 @@ var fs = require('fs'),
|
|||||||
require('./snippets');
|
require('./snippets');
|
||||||
|
|
||||||
var DBot = function(timers) {
|
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;
|
var rawDB;
|
||||||
try {
|
try {
|
||||||
var rawDB = fs.readFileSync('db.json', 'utf-8');
|
var rawDB = fs.readFileSync('db.json', 'utf-8');
|
||||||
@ -42,6 +26,25 @@ var DBot = function(timers) {
|
|||||||
process.exit();
|
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
|
// Load Strings file
|
||||||
try {
|
try {
|
||||||
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
|
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
|
||||||
@ -123,6 +126,9 @@ DBot.prototype.reloadModules = function() {
|
|||||||
this.usage = {};
|
this.usage = {};
|
||||||
this.timers.clearTimers();
|
this.timers.clearTimers();
|
||||||
|
|
||||||
|
// Load config changes
|
||||||
|
_.extend(this.config, this.db.config);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
|
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user