artemis/artemis/utils/config.py
2025-02-01 16:35:18 +01:00

44 lines
738 B
Python

import os
from dataclasses import dataclass
from .common import read_toml
@dataclass
class Secrets:
api: str
catbox: str
github: str
cloudflare: str
openai: str
deepl: str
huggingface: str
@dataclass
class Config:
token: str
prefix: str
user_agent: str
real_user_agent: str
internal_api_url: str
cdn_url: str
main_guild_id: int
dev_guild_id: int
secrets: Secrets
def __post_init__(self):
self.secrets = Secrets(**self.secrets)
def load_config() -> Config:
if os.getenv("ENV") == "production":
values = read_toml("config.prod.toml")
else:
values = read_toml("config.dev.toml")
return Config(**values)
config = load_config()