1
0
mirror of https://github.com/civsocit/olgram.git synced 2025-12-16 23:46:17 +00:00

minor changes, auto-certificate

This commit is contained in:
mihalin
2021-09-15 22:53:18 +03:00
parent cf80e903da
commit 289b0d239a
13 changed files with 95 additions and 270 deletions

View File

@@ -8,9 +8,9 @@ load_dotenv()
class AbstractSettings(ABC):
@classmethod
def _get_env(cls, parameter: str) -> str:
def _get_env(cls, parameter: str, allow_none: bool = False) -> str:
parameter = os.getenv(parameter, None)
if not parameter:
if not parameter and not allow_none:
raise ValueError(f"{parameter} not defined in ENV")
return parameter
@@ -54,6 +54,19 @@ class ServerSettings(AbstractSettings):
"""
return cls._get_env("REDIS_PATH")
@classmethod
def use_custom_cert(cls) -> bool:
use = cls._get_env("CUSTOM_CERT", allow_none=True)
return use and "true" in use.lower()
@classmethod
def priv_path(cls) -> str:
return "/cert/private.key"
@classmethod
def public_path(cls) -> str:
return "/cert/public.pem"
class BotSettings(AbstractSettings):
@classmethod