mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
36 lines
761 B
Python
36 lines
761 B
Python
|
from abc import ABC
|
||
|
from dotenv import load_dotenv
|
||
|
import os
|
||
|
|
||
|
|
||
|
load_dotenv()
|
||
|
|
||
|
|
||
|
class _Settings(ABC):
|
||
|
@classmethod
|
||
|
def _get_env(cls, parameter: str) -> str:
|
||
|
parameter = os.getenv(parameter, None)
|
||
|
if not parameter:
|
||
|
raise ValueError(f"{parameter} not defined in ENV")
|
||
|
return parameter
|
||
|
|
||
|
|
||
|
class BotSettings(_Settings):
|
||
|
@classmethod
|
||
|
def token(cls) -> str:
|
||
|
return cls._get_env("BOT_TOKEN")
|
||
|
|
||
|
|
||
|
class DatabaseSettings(_Settings):
|
||
|
@classmethod
|
||
|
def user(cls) -> str:
|
||
|
return cls._get_env("POSTGRES_USER")
|
||
|
|
||
|
@classmethod
|
||
|
def password(cls) -> str:
|
||
|
return cls._get_env("POSTGRES_PASSWORD")
|
||
|
|
||
|
@classmethod
|
||
|
def database_name(cls) -> str:
|
||
|
return cls._get_env("POSTGRES_DB")
|