kin: BATON-ARCH-012-backend_dev

This commit is contained in:
Gros Frumos 2026-03-20 21:01:48 +02:00
parent 8ecaeeafc6
commit 9ee79f7a88
3 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,8 @@ BOT_TOKEN=your_telegram_bot_token_here
CHAT_ID=-1001234567890
WEBHOOK_SECRET=your_random_secret_here
WEBHOOK_URL=https://yourdomain.com/api/webhook/telegram
# Set to false for local development without ngrok
WEBHOOK_ENABLED=true
# Database
DB_PATH=baton.db

View file

@ -18,4 +18,5 @@ CHAT_ID: str = _require("CHAT_ID")
DB_PATH: str = os.getenv("DB_PATH", "baton.db")
WEBHOOK_SECRET: str = _require("WEBHOOK_SECRET")
WEBHOOK_URL: str = _require("WEBHOOK_URL")
WEBHOOK_ENABLED: bool = os.getenv("WEBHOOK_ENABLED", "true").lower() == "true"
FRONTEND_ORIGIN: str = os.getenv("FRONTEND_ORIGIN", "http://localhost:3000")

View file

@ -31,8 +31,9 @@ async def lifespan(app: FastAPI):
await db.init_db()
logger.info("Database initialized")
await telegram.set_webhook(url=config.WEBHOOK_URL, secret=config.WEBHOOK_SECRET)
logger.info("Webhook registered")
if config.WEBHOOK_ENABLED:
await telegram.set_webhook(url=config.WEBHOOK_URL, secret=config.WEBHOOK_SECRET)
logger.info("Webhook registered")
# v2.0 feature — агрегатор отключён в v1 (ADR-004)
# task = asyncio.create_task(aggregator.run())