mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
save a seperate customconfig so not everything is saved to config.json. create saveconfig internal api function for admin [#489]
This commit is contained in:
parent
eafc2dbee1
commit
b7a3b6a139
@ -35,6 +35,11 @@ var admin = function(dbot) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'saveConfig': function() {
|
||||||
|
var config = dbot.customConfig;
|
||||||
|
fs.writeFileSync('config.json', JSON.stringify(config, null, ' '));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
11
run.js
11
run.js
@ -7,7 +7,6 @@ require('./snippets');
|
|||||||
var DBot = function() {
|
var DBot = function() {
|
||||||
|
|
||||||
/*** Load the DB ***/
|
/*** Load the DB ***/
|
||||||
|
|
||||||
if(fs.existsSync('db.json')) {
|
if(fs.existsSync('db.json')) {
|
||||||
try {
|
try {
|
||||||
this.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
this.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
||||||
@ -25,7 +24,6 @@ var DBot = function() {
|
|||||||
this.reloadConfig();
|
this.reloadConfig();
|
||||||
|
|
||||||
/*** Load main strings ***/
|
/*** Load main strings ***/
|
||||||
|
|
||||||
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) {
|
||||||
@ -65,7 +63,9 @@ DBot.prototype.reloadConfig = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
|
var configFile = fs.readFileSync('config.json', 'utf-8');
|
||||||
|
this.config = JSON.parse(configFile);
|
||||||
|
this.customConfig = JSON.parse(configFile);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log('Config file is invalid. Stopping: ' + err);
|
console.log('Config file is invalid. Stopping: ' + err);
|
||||||
process.exit();
|
process.exit();
|
||||||
@ -79,7 +79,10 @@ DBot.prototype.reloadConfig = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load missing config directives from sample file
|
// Load missing config directives from sample file
|
||||||
if(!_.has(this.config, 'modules')) this.config.modules = {};
|
if(!_.has(this.customConfig, 'modules')) {
|
||||||
|
this.customConfig.modules = {};
|
||||||
|
this.config.modules = {};
|
||||||
|
}
|
||||||
_.defaults(this.config, defaultConfig);
|
_.defaults(this.config, defaultConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user