diff options
author | 2023-04-30 13:06:18 +0100 | |
---|---|---|
committer | 2023-05-06 13:20:46 +0100 | |
commit | 31188d41ff25699ab595a0ef7565c93ff3797695 (patch) | |
tree | a74b71ee432e4157422b7ff25d14741371100ec2 /bot/constants.py | |
parent | add pydantic to the list of dependencies (diff) |
add base EnvConfig
Diffstat (limited to 'bot/constants.py')
-rw-r--r-- | bot/constants.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/bot/constants.py b/bot/constants.py index 7e5fa1d9..827c5356 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -1,7 +1,9 @@ import enum import logging from os import environ -from typing import NamedTuple + +from pydantic import BaseSettings + __all__ = ( "Branding", @@ -36,8 +38,23 @@ log = logging.getLogger(__name__) PYTHON_PREFIX = "!" -class Branding: - cycle_frequency = int(environ.get("CYCLE_FREQUENCY", 3)) # 0: never, 1: every day, 2: every other day, ... +class EnvConfig(BaseSettings): + """Our default configuration for models that should load from .env files.""" + + class Config: + """Specify what .env files to load, and how to load them.""" + + env_file = ".env.server", ".env", + env_file_encoding = "utf-8" + + +class _Branding(EnvConfig): + EnvConfig.Config.env_prefix = "branding_" + + cycle_frequency = 3 # 0: never, 1: every day, 2: every other day, ... + + +Branding = _Branding() class Cats: |