Update app.py
Browse files
app.py
CHANGED
|
@@ -76,4 +76,15 @@ async def set_webhook():
|
|
| 76 |
# Send a POST request to Telegram's setWebhook API with the payload
|
| 77 |
async with session.post(set_webhook_url, json=payload) as response:
|
| 78 |
# Await and return the JSON response from Telegram confirming the webhook setup
|
| 79 |
-
return await response.json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
# Send a POST request to Telegram's setWebhook API with the payload
|
| 77 |
async with session.post(set_webhook_url, json=payload) as response:
|
| 78 |
# Await and return the JSON response from Telegram confirming the webhook setup
|
| 79 |
+
return await response.json()
|
| 80 |
+
|
| 81 |
+
@app.get("/test_conn")
|
| 82 |
+
async def test_conn():
|
| 83 |
+
try:
|
| 84 |
+
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10)) as session:
|
| 85 |
+
async with session.get("https://api.telegram.org") as response:
|
| 86 |
+
return {"status": "success", "telegram_api_status": response.status}
|
| 87 |
+
except Exception as e:
|
| 88 |
+
logger.error(f"Connection test failed: {str(e)}", exc_info=True)
|
| 89 |
+
return {"status": "failed", "error": str(e)}
|
| 90 |
+
|