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

admin.internalAPI.setConfig operational [#489]

This commit is contained in:
reality 2013-06-05 21:41:20 +00:00
parent 97907603f5
commit 546ce64707

View File

@ -1,7 +1,7 @@
/**
* Module Name: Admin
* Description: Set of commands which only one who is a DepressionBot
* administrator can run - as such, it has its own command execution listener.
* administrator can run.
*/
var fs = require('fs'),
_ = require('underscore')._;
@ -25,21 +25,26 @@ var admin = function(dbot) {
},
'setConfig': function(configKey, newOption, callback) {
var configPath = dbot.customConfig;
var configPath = dbot.customConfig,
oldOption = null;
configKey = configKey.split('.');
for(var i=0;i<configKey.length-1;i++) {
if(_.has(configPath, configKey[i])) {
configPath = configPath[configKey[i]];
} else {
return;
if(!_.has(configPath, configKey[i])) {
configPath[configKey[i]] = {};
}
configPath = configPath[configKey[i]];
}
if(_.has(configPath, configKey[i])) {
oldOption = configPath[configKey[i]];
}
configPath[configKey[i]] = newOption;
this.internalAPI.saveConfig();
dbot.reloadConfig();
callback(true);
},
callback(null, oldOption);
}.bind(this),
'saveConfig': function() {
var config = dbot.customConfig;