mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
admin.internalAPI.setConfig operational [#489]
This commit is contained in:
parent
97907603f5
commit
546ce64707
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Module Name: Admin
|
* Module Name: Admin
|
||||||
* Description: Set of commands which only one who is a DepressionBot
|
* 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'),
|
var fs = require('fs'),
|
||||||
_ = require('underscore')._;
|
_ = require('underscore')._;
|
||||||
@ -25,21 +25,26 @@ var admin = function(dbot) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'setConfig': function(configKey, newOption, callback) {
|
'setConfig': function(configKey, newOption, callback) {
|
||||||
var configPath = dbot.customConfig;
|
var configPath = dbot.customConfig,
|
||||||
|
oldOption = null;
|
||||||
configKey = configKey.split('.');
|
configKey = configKey.split('.');
|
||||||
|
|
||||||
for(var i=0;i<configKey.length-1;i++) {
|
for(var i=0;i<configKey.length-1;i++) {
|
||||||
if(_.has(configPath, configKey[i])) {
|
if(!_.has(configPath, configKey[i])) {
|
||||||
|
configPath[configKey[i]] = {};
|
||||||
|
}
|
||||||
configPath = configPath[configKey[i]];
|
configPath = configPath[configKey[i]];
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_.has(configPath, configKey[i])) {
|
||||||
|
oldOption = configPath[configKey[i]];
|
||||||
}
|
}
|
||||||
|
configPath[configKey[i]] = newOption;
|
||||||
|
|
||||||
this.internalAPI.saveConfig();
|
this.internalAPI.saveConfig();
|
||||||
dbot.reloadConfig();
|
dbot.reloadConfig();
|
||||||
callback(true);
|
callback(null, oldOption);
|
||||||
},
|
}.bind(this),
|
||||||
|
|
||||||
'saveConfig': function() {
|
'saveConfig': function() {
|
||||||
var config = dbot.customConfig;
|
var config = dbot.customConfig;
|
||||||
|
Loading…
Reference in New Issue
Block a user