dj-embe/config.py

30 lines
838 B
Python
Raw Normal View History

2023-04-23 15:38:19 +00:00
import toml
2023-04-23 22:48:31 +00:00
class DiscordConfig:
2023-04-23 15:38:19 +00:00
def __init__(self, discord_config: any) -> None:
self.token: str = discord_config["token"]
2023-04-23 22:48:31 +00:00
class LoggingConfig:
2023-04-23 15:38:19 +00:00
def __init__(self, logging_config: any) -> None:
self.level: str = logging_config["level"]
2023-04-23 22:48:31 +00:00
class RedisConfig:
def __init__(self, redis_config: any) -> None:
self.host: str = redis_config["host"]
self.port: int = redis_config["port"]
self.password: str = redis_config["password"]
class Config:
2023-04-23 15:38:19 +00:00
def __init__(self, config_path: str) -> None:
self._config = toml.load(config_path)
self.discord = DiscordConfig(self._config["discord"])
self.logging = LoggingConfig(self._config["logging"])
2023-04-23 22:48:31 +00:00
self.redis = RedisConfig(self._config["redis"])
2023-04-23 15:38:19 +00:00
def __str__(self) -> str:
return str(self._config)