mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 11:42:36 +01:00
Module specific config. Allows specify dbKeys to ensure default objects there for use.
This commit is contained in:
parent
65414f6975
commit
c64e66da17
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
# Ignore the user config files
|
||||
config.json
|
||||
./config.json
|
||||
|
||||
# Ignore the user database
|
||||
db.json
|
||||
|
3
modules/admin/config.json
Normal file
3
modules/admin/config.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"dbKeys": [ "bans", "locks" ]
|
||||
}
|
3
modules/kick/config.json
Normal file
3
modules/kick/config.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"dbKeys": [ "kicks", "kickers" ]
|
||||
}
|
3
modules/quotes/config.json
Normal file
3
modules/quotes/config.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"dbKeys": [ "quoteArrs" ]
|
||||
}
|
4
modules/web/config.json
Normal file
4
modules/web/config.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"webHost": "localhost",
|
||||
"webPort": 8080
|
||||
}
|
42
run.js
42
run.js
@ -23,35 +23,6 @@ var DBot = function(timers) {
|
||||
this.db = {};
|
||||
}
|
||||
|
||||
// Repair any deficiencies in the DB; if this is a new DB, that's everything
|
||||
if(!this.db.hasOwnProperty("bans")) {
|
||||
this.db.bans = {};
|
||||
}
|
||||
if(!this.db.bans.hasOwnProperty("*")) {
|
||||
this.db.bans["*"] = [];
|
||||
}
|
||||
if(!this.db.hasOwnProperty("quoteArrs")) {
|
||||
this.db.quoteArrs = {};
|
||||
}
|
||||
if(!this.db.hasOwnProperty("kicks")) {
|
||||
this.db.kicks = {};
|
||||
}
|
||||
if(!this.db.hasOwnProperty("kickers")) {
|
||||
this.db.kickers = {};
|
||||
}
|
||||
if(!this.db.hasOwnProperty("modehate")) {
|
||||
this.db.modehate = [];
|
||||
}
|
||||
if(!this.db.hasOwnProperty("locks")) {
|
||||
this.db.locks = [];
|
||||
}
|
||||
if(!this.db.hasOwnProperty("ignores")) {
|
||||
this.db.ignores = {};
|
||||
}
|
||||
if(!this.db.hasOwnProperty('polls')) {
|
||||
this.db.polls = {};
|
||||
}
|
||||
|
||||
// Load Strings file
|
||||
try {
|
||||
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));
|
||||
@ -236,6 +207,19 @@ DBot.prototype.reloadModules = function() {
|
||||
// Invalid or no string info
|
||||
}
|
||||
|
||||
// Load the module config data
|
||||
try {
|
||||
var config = JSON.parse(fs.readFileSync(moduleDir + 'config.json', 'utf-8'))
|
||||
this.config[name] = config;
|
||||
for(var i=0;i<config.dbKeys;i++) {
|
||||
if(!this.db.hasOwnProperty(config.dbKeys[i])) {
|
||||
this.db[config.dbKeys[i]] = {};
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
// Invalid or no config data
|
||||
}
|
||||
|
||||
this.modules.push(module);
|
||||
} catch(err) {
|
||||
console.log(this.t('module_load_error', {'moduleName': name}));
|
||||
|
Loading…
Reference in New Issue
Block a user