Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
import httpx
|
| 2 |
from fastapi import FastAPI, Request
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORS
|
| 4 |
|
| 5 |
TOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"
|
| 6 |
BASE_URL = f"https://api.telegram.org/bot{TOKEN}"
|
| 7 |
|
| 8 |
-
client = httpx.AsyncClient()
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
app.add_middleware(
|
|
@@ -19,12 +19,15 @@ app.add_middleware(
|
|
| 19 |
#https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/setWebhook?url=https://matteoscript-TelegramBotSimple.hf.space/
|
| 20 |
|
| 21 |
@app.post("/")
|
| 22 |
-
|
| 23 |
print(data)
|
| 24 |
chat_id = data['message']['chat']['id']
|
| 25 |
text = data['message']['text']
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
@app.get("/")
|
|
|
|
| 1 |
+
#import httpx
|
| 2 |
from fastapi import FastAPI, Request
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORS
|
| 4 |
|
| 5 |
TOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"
|
| 6 |
BASE_URL = f"https://api.telegram.org/bot{TOKEN}"
|
| 7 |
|
| 8 |
+
#client = httpx.AsyncClient()
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
app.add_middleware(
|
|
|
|
| 19 |
#https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/setWebhook?url=https://matteoscript-TelegramBotSimple.hf.space/
|
| 20 |
|
| 21 |
@app.post("/")
|
| 22 |
+
def webhook(data: dict):
|
| 23 |
print(data)
|
| 24 |
chat_id = data['message']['chat']['id']
|
| 25 |
text = data['message']['text']
|
| 26 |
+
resp = requests.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")
|
| 27 |
+
resp = requests.get("https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/sendMessage?chat_id=1738997897&text=Come_Stai_Vez")
|
| 28 |
+
print(resp)
|
| 29 |
+
#await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")
|
| 30 |
+
return {"response": "ok"}
|
| 31 |
|
| 32 |
|
| 33 |
@app.get("/")
|