|
import telebot |
|
from fastapi import FastAPI, Request |
|
import uvicorn |
|
|
|
|
|
TOKEN = "6655373829:AAGduLdLyNx7zUtxH73Sp3Z1vHKS35tV9WU" |
|
|
|
WEBHOOK_URL = "https://astraos-testing.hf.space/webhook" |
|
|
|
bot = telebot.TeleBot(TOKEN, parse_mode="HTML") |
|
app = FastAPI() |
|
|
|
@app.post("/webhook") |
|
async def telegram_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 via webhook"} |
|
|
|
@bot.message_handler(commands=["start"]) |
|
def start_command(message): |
|
bot.reply_to(message, "Hello! I'm running via FastAPI webhook!") |
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=7860) |
|
|