Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import asyncio
|
|
7 |
from transformers import pipeline
|
8 |
from langdetect import detect
|
9 |
from huggingface_hub import login
|
|
|
10 |
|
11 |
|
12 |
# Global variables
|
@@ -97,12 +98,22 @@ telegram_app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_
|
|
97 |
|
98 |
# Initialize Telegram Bot properly on startup
|
99 |
@app.on_event("startup")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
async def startup_event():
|
101 |
await init_telegram()
|
102 |
await telegram_app.start()
|
103 |
print("Telegram bot initialized successfully!")
|
104 |
|
105 |
|
|
|
|
|
106 |
# API Route to receive updates from Telegram
|
107 |
@app.post("/")
|
108 |
async def receive_update(request: Request):
|
|
|
7 |
from transformers import pipeline
|
8 |
from langdetect import detect
|
9 |
from huggingface_hub import login
|
10 |
+
import httpx
|
11 |
|
12 |
|
13 |
# Global variables
|
|
|
98 |
|
99 |
# Initialize Telegram Bot properly on startup
|
100 |
@app.on_event("startup")
|
101 |
+
async def test_network():
|
102 |
+
try:
|
103 |
+
async with httpx.AsyncClient() as client:
|
104 |
+
response = await client.get("https://api.telegram.org")
|
105 |
+
print(f"Network test successful! Status Code: {response.status_code}")
|
106 |
+
except Exception as e:
|
107 |
+
print(f"Network test failed: {e}")
|
108 |
+
|
109 |
async def startup_event():
|
110 |
await init_telegram()
|
111 |
await telegram_app.start()
|
112 |
print("Telegram bot initialized successfully!")
|
113 |
|
114 |
|
115 |
+
|
116 |
+
|
117 |
# API Route to receive updates from Telegram
|
118 |
@app.post("/")
|
119 |
async def receive_update(request: Request):
|