mirror of
https://code.lenaisten.de/Lenaisten/lenaverse-bot.git
synced 2024-11-22 15:03:01 +00:00
23 lines
451 B
Python
23 lines
451 B
Python
|
import os
|
||
|
import tomllib
|
||
|
from typing import Self
|
||
|
|
||
|
from pydantic import BaseModel
|
||
|
|
||
|
|
||
|
class Config(BaseModel):
|
||
|
discord_token: str
|
||
|
|
||
|
@classmethod
|
||
|
def get(cls) -> Self:
|
||
|
cfg_path = os.getenv(
|
||
|
key="CONFIG_PATH",
|
||
|
default="/usr/local/etc/lenaverse-bot/lenaverse-bot.toml",
|
||
|
)
|
||
|
|
||
|
with open(cfg_path, "rb") as cfg_file:
|
||
|
return cls.model_validate(tomllib.load(cfg_file))
|
||
|
|
||
|
|
||
|
CONFIG = Config.get()
|