import os import threading import uvicorn from fastapi import FastAPI from fastapi.responses import HTMLResponse from bot import main as start_bot # Define lifespan to manage startup/shutdown from contextlib import asynccontextmanager @asynccontextmanager async def lifespan(app: FastAPI): # Startup: Run bot in background thread print("Starting Telegram Bot in background thread...") bot_thread = threading.Thread(target=start_bot, daemon=True) bot_thread.start() yield # Shutdown logic (if any) app = FastAPI(lifespan=lifespan) @app.get("/", response_class=HTMLResponse) def home(): return """
The bot is active and polling for updates.