-
Notifications
You must be signed in to change notification settings - Fork 1
4.2 Getting a configuration
Ellen Fawkes edited this page Sep 3, 2017
·
2 revisions
RECOMMENDED
In your plugins get a configuration via PurrplingBot.getConfiguration()
/* plugins/MyP/lugin/myplugin.js */
var PurrplingBot = require("../../purrplingbot.js");
const CONFIG = PurrplingBot.getConfiguration();
var myPluginConf = CONFIG.myPlugin;
// Do your stuff here (Write init(), create logger and etc)
EXPERT MODE and live on edge
Configuration is loading by Configurator lib. PurrplingBot use it and propagate loaded config by method getConfiguration()
It's a RECOMMENDED for use!
If you want use low level configuration loading, then use a internal library Configurator.
// Load configuration (loads all in @imports)
const Configurator = require("./lib/configurator.js");
var config = {};
try {
config = Configurator.loadConfiguration("./config.json");
} catch (err) {
logger.error("*** Configuration failed to load! Check the config file.");
logger.error(err);
process.exit(6);
}
// Get a raw configuration file (NOT load @imports)
var rawConf = readConfigFile("./myConf.json");
if (!rawConf) throw new Error("Config can't be loaded!");
logger.dir(rawConf.foo); // export DEBUG=1