Spaces:
Sleeping
Sleeping
Update main.py
Browse files1123456788910117 unmodified lines192021222223242526272627282930313233import httpx#import httpxfrom fastapi import FastAPI, Requestfrom fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORS
TOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"BASE_URL = f"https://api.telegram.org/bot{TOKEN}"
client = httpx.AsyncClient()#client = httpx.AsyncClient()
app = FastAPI()app.add_middleware(7 unmodified lines#https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/setWebhook?url=https://matteoscript-TelegramBotSimple.hf.space/
@app.post("/")async def webhook(data: dict):def webhook(data: dict): print(data) chat_id = data['message']['chat']['id'] text = data['message']['text'] await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}") return data resp = requests.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}") resp = requests.get("https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/sendMessage?chat_id=1738997897&text=Come_Stai_Vez") print(resp) #await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}") return {"response": "ok"}
@app.get("/")main.py+8-5