refactoring (#26)

This commit is contained in:
Dmitry Afanasyev
2023-10-03 23:30:19 +03:00
committed by GitHub
parent 482e1fdda1
commit c401e1006c
22 changed files with 423 additions and 395 deletions

View File

@@ -1,4 +1,4 @@
from functools import cached_property
from functools import cached_property, lru_cache
from os import environ
from pathlib import Path
from typing import Any
@@ -83,14 +83,19 @@ class AppSettings(SentrySettings, BaseSettings):
return "/" + "/".join([self.URL_PREFIX.strip("/"), API_PREFIX.strip("/")])
return API_PREFIX
@cached_property
def token_part(self) -> str:
return self.TELEGRAM_API_TOKEN[15:30]
@cached_property
def bot_webhook_url(self) -> str:
return "/".join([self.api_prefix, self.TELEGRAM_API_TOKEN])
return "/".join([self.api_prefix, self.token_part])
class Config:
case_sensitive = True
@lru_cache(maxsize=None)
def get_settings() -> AppSettings:
return AppSettings()