12345678910111213141516171819202122232425262728293031323334 |
- import os
- import os.path
- import toml
- _dir = os.environ.get("ROLLBOT_CFG_DIR", ".")
- with open(os.path.join(_dir, "config.toml")) as cfile:
- _cfg = toml.load(cfile)
- with open(os.path.join(_dir, "secrets.toml")) as sfile:
- _secrets = toml.load(sfile)
- def get_config(key):
- c = _cfg
- for k in key.split("."):
- c = c[k]
- return c
- def get_secret(key):
- c = _secrets
- for k in key.split("."):
- c = c[k]
- return c
- BOTS_LOOKUP = get_secret("bots")
- GLOBAL_ADMINS = get_secret("auths.global")
- GROUP_ADMINS = get_secret("auths.group")
- PLUGINS = get_config("plugins")
- API_KEY = get_secret("api_key")
- DB_FILE = os.path.abspath(get_config("database"))
|