Feat/fix start (#1)

format code
This commit is contained in:
Dmitry Afanasyev
2023-09-16 20:09:40 +03:00
committed by GitHub
parent 2d34a94eed
commit a95403f594
144 changed files with 8545 additions and 595 deletions

View File

@@ -9,7 +9,7 @@ TELEGRAM_API_TOKEN="123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
# webhook settings
WEBHOOK_HOST="https://mydomain.com"
WEBHOOK_PATH="/healthcheck"
URL_PREFIX="/gpt"
# set to true to start with webhook. Else bot will start on polling method
START_WITH_WEBHOOK="false"

View File

@@ -1,16 +1,16 @@
import os
from functools import cached_property
from os import environ
from pathlib import Path
from dotenv import load_dotenv
from pydantic import BaseSettings
from pydantic_settings import BaseSettings
BASE_DIR = Path(__file__).parent.parent
SHARED_DIR = BASE_DIR.resolve().joinpath('shared')
SHARED_DIR = BASE_DIR.resolve().joinpath("shared")
SHARED_DIR.mkdir(exist_ok=True)
SHARED_DIR.joinpath('logs').mkdir(exist_ok=True)
DIR_LOGS = SHARED_DIR.joinpath('logs')
SHARED_DIR.joinpath("logs").mkdir(exist_ok=True)
DIR_LOGS = SHARED_DIR.joinpath("logs")
env_path = f"{BASE_DIR}/settings/.env"
@@ -28,24 +28,24 @@ class Settings(BaseSettings):
PROJECT_NAME: str = "healthcheck bot"
APP_HOST: str = "0.0.0.0"
APP_PORT: int = 8082
APP_PORT: int = 8000
STAGE: str = "dev"
DEBUG: bool = False
TELEGRAM_API_TOKEN: str = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
START_WITH_WEBHOOK: bool = False
# webhook settings
START_WITH_WEBHOOK: bool = False
WEBHOOK_HOST: str = "https://mydomain.com"
WEBHOOK_PATH: str = "/healthcheck"
URL_PREFIX: str = ""
# quantity of workers for uvicorn
WORKERS_COUNT: int = 1
# Enable uvicorn reloading
RELOAD: bool = False
@property
@cached_property
def bot_webhook_url(self) -> str:
return os.path.join(self.WEBHOOK_PATH.strip('/'), self.TELEGRAM_API_TOKEN)
return "/" + self.TELEGRAM_API_TOKEN
class Config:
case_sensitive = True