config.py 684 B

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. import os.path
  3. import toml
  4. _dir = os.environ.get("ROLLBOT_CFG_DIR", ".")
  5. with open(os.path.join(_dir, "config.toml")) as cfile:
  6. _cfg = toml.load(cfile)
  7. with open(os.path.join(_dir, "secrets.toml")) as sfile:
  8. _secrets = toml.load(sfile)
  9. def get_config(key):
  10. c = _cfg
  11. for k in key.split("."):
  12. c = c[k]
  13. return c
  14. def get_secret(key):
  15. c = _secrets
  16. for k in key.split("."):
  17. c = c[k]
  18. return c
  19. BOTS_LOOKUP = get_secret("bots")
  20. GLOBAL_ADMINS = get_secret("auths.global")
  21. GROUP_ADMINS = get_secret("auths.group")
  22. PLUGINS = get_config("plugins")
  23. API_KEY = get_secret("api_key")
  24. DB_FILE = os.path.abspath(get_config("database"))