forked from GitHub/dbot
recursively call showconfig [#489]
This commit is contained in:
parent
4a7fcd57b3
commit
a25620bf9e
@ -9,52 +9,21 @@ var fs = require('fs'),
|
||||
var admin = function(dbot) {
|
||||
this.internalAPI = {
|
||||
'getCurrentConfig': function(configKey, callback) {
|
||||
if(configKey) {
|
||||
this.db.read('config', configKey, function(err, cRecord) {
|
||||
if(cRecord) {
|
||||
callback(cRecord.value)
|
||||
} else {
|
||||
var configPath = dbot.config;
|
||||
configKey = configKey.split('.');
|
||||
var configPath = dbot.config;
|
||||
configKey = configKey.split('.');
|
||||
|
||||
for(var i=0;i<configKey.length;i++) {
|
||||
if(_.has(configPath, configKey[i])) {
|
||||
configPath = configPath[configKey[i]];
|
||||
} else {
|
||||
callback(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
process.nextTick(function() {
|
||||
callback(configPath);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback(dbot.config);
|
||||
}
|
||||
}.bind(this)
|
||||
};
|
||||
|
||||
this.onLoad = function() {
|
||||
/*var configMap = dbot.config;
|
||||
this.db.scan('config', function(config) {
|
||||
if(config) {
|
||||
var currentPath = configMap,
|
||||
key = config.key.split('.'),
|
||||
value = config.value;
|
||||
|
||||
for(var i=0;i<key.length-1;i++) {
|
||||
if(_.has(currentPath, key[i])) {
|
||||
currentPath = currentPath[key[i]];
|
||||
}
|
||||
for(var i=0;i<configKey.length;i++) {
|
||||
if(_.has(configPath, configKey[i])) {
|
||||
configPath = configPath[configKey[i]];
|
||||
} else {
|
||||
configPath = null;
|
||||
break;
|
||||
}
|
||||
|
||||
currentPath[key[i]] = value;
|
||||
}
|
||||
}, function(err) { });*/
|
||||
}.bind(this);
|
||||
|
||||
callback(configPath);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
|
@ -191,7 +191,7 @@ var commands = function(dbot) {
|
||||
dbot.reloadModules();
|
||||
});
|
||||
} else {
|
||||
event.reply(dbot.t("no_config_key"));
|
||||
event.reply(dbot.t("no_config_key", {'path': configPath}));
|
||||
}
|
||||
}.bind(this));
|
||||
} else {
|
||||
@ -249,9 +249,13 @@ var commands = function(dbot) {
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
event.reply(dbot.t("no_config_key"));
|
||||
event.reply(dbot.t("no_config_key", {'path': configPath}));
|
||||
configPath = configPath.split('.');
|
||||
configPath.pop();
|
||||
event.params[1] = configPath.join('.');
|
||||
this.commands['showconfig'](event);
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
} else {
|
||||
event.reply(dbot.t("config_keys_location", {
|
||||
|
@ -141,9 +141,9 @@
|
||||
"de": "Konnte {module} nicht laden. Siehe 'status {module}'."
|
||||
},
|
||||
"no_config_key": {
|
||||
"en": "Config key doesn't exist bro",
|
||||
"cy": "Nid yw allwedd cyfluniad yn bodoli, fy mrawd",
|
||||
"de": "Einstellung existiert nicht, Bruder"
|
||||
"en": "{path} doesn't exist bro",
|
||||
"cy": "{path} cyfluniad yn bodoli, fy mrawd",
|
||||
"de": "{path} existiert nicht, Bruder"
|
||||
},
|
||||
"config_array": {
|
||||
"en": "Config option is an array. Try '{alternate}'.",
|
||||
|
Loading…
Reference in New Issue
Block a user