import telebot from fastapi import FastAPI, Request import uvicorn TOKEN = "6655373829:AAGduLdLyNx7zUtxH73Sp3Z1vHKS35tV9WU" WEBHOOK_URL = "https://astraos-testing.hf.space/webhook" # Replace with your actual webhook URL bot = telebot.TeleBot(TOKEN, parse_mode="HTML") app = FastAPI() @app.post("/webhook") async def webhook(request: Request): json_data = await request.json() update = telebot.types.Update.de_json(json_data) bot.process_new_updates([update]) return {"status": "ok"} @app.get("/") def home(): return {"message": "Bot is running"} @app.on_event("startup") async def on_startup(): bot.remove_webhook() bot.set_webhook(WEBHOOK_URL) print(f"Webhook set to {WEBHOOK_URL}") @app.on_event("shutdown") async def on_shutdown(): bot.remove_webhook() print("Webhook removed") @bot.message_handler(commands=["start"]) def start_command(message): bot.reply_to(message, "Hello! I am a FastAPI Telegram bot!") # if __name__ == "__main__": # uvicorn.run(app, host="0.0.0.0", port=7860)