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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user