diff --git a/.env.example b/.env.example index 5bde9bd..cf447e0 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/backend/config.py b/backend/config.py index f8cbbc0..fddf972 100644 --- a/backend/config.py +++ b/backend/config.py @@ -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") diff --git a/backend/main.py b/backend/main.py index fa58961..3a99fb5 100644 --- a/backend/main.py +++ b/backend/main.py @@ -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())