mirror of
https://github.com/reality/dbot.git
synced 2025-02-17 14:01:04 +01:00
set some config options not allowed to be changes [#145]
This commit is contained in:
parent
0a2b81c0d6
commit
2f05cba960
@ -4,6 +4,8 @@ var fs = require('fs'),
|
|||||||
exec = require('child_process').exec;
|
exec = require('child_process').exec;
|
||||||
|
|
||||||
var commands = function(dbot) {
|
var commands = function(dbot) {
|
||||||
|
var noChangeConfig = [ 'servers', 'name', 'moduleNames' ];
|
||||||
|
|
||||||
var getCurrentConfigPath = function(configKey) {
|
var getCurrentConfigPath = function(configKey) {
|
||||||
var defaultConfigPath = dbot.config;
|
var defaultConfigPath = dbot.config;
|
||||||
var userConfigPath = dbot.db.config;
|
var userConfigPath = dbot.db.config;
|
||||||
@ -183,6 +185,7 @@ var commands = function(dbot) {
|
|||||||
var configKey = _.last(configPathString.split('.'));
|
var configKey = _.last(configPathString.split('.'));
|
||||||
var newOption = event.params[2];
|
var newOption = event.params[2];
|
||||||
|
|
||||||
|
if(!_.include(noChangeConfig, configKey)) {
|
||||||
var configPath = getCurrentConfigPath(configPathString);
|
var configPath = getCurrentConfigPath(configPathString);
|
||||||
var currentOption;
|
var currentOption;
|
||||||
if(_.has(configPath['user'], configKey)) {
|
if(_.has(configPath['user'], configKey)) {
|
||||||
@ -208,6 +211,9 @@ var commands = function(dbot) {
|
|||||||
event.reply(configPathString + ": " + currentOption + " -> " + newOption);
|
event.reply(configPathString + ": " + currentOption + " -> " + newOption);
|
||||||
configPath['user'][configKey] = newOption;
|
configPath['user'][configKey] = newOption;
|
||||||
dbot.reloadModules();
|
dbot.reloadModules();
|
||||||
|
} else {
|
||||||
|
event.reply("This config option cannot be altered while the bot is running.");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'showconfig': function(event) {
|
'showconfig': function(event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user