Update main.py

This commit is contained in:
ilyastar9999
2025-12-03 16:01:06 +03:00
parent eadfea67d1
commit abc891ae43

View File

@@ -174,16 +174,24 @@ async def send_telegram_alert(message: str):
"""Send alert to telegram bot""" """Send alert to telegram bot"""
import aiohttp import aiohttp
try: try:
print(f"📱 Sending alert to Telegram: {TELEGRAM_API_URL}")
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.post( async with session.post(
TELEGRAM_API_URL, TELEGRAM_API_URL,
json={"message": message}, json={"message": message},
headers={"Authorization": f"Bearer {SECRET_TOKEN}"} headers={"Authorization": f"Bearer {SECRET_TOKEN}"}
) as resp: ) as resp:
response_text = await resp.text()
if resp.status != 200: if resp.status != 200:
print(f"Failed to send telegram alert: {await resp.text()}") print(f"Failed to send telegram alert: Status {resp.status}")
print(f" Response: {response_text}")
else:
print(f"✅ Telegram alert sent successfully")
print(f" Response: {response_text}")
except Exception as e: except Exception as e:
print(f"Error sending telegram alert: {e}") print(f"Error sending telegram alert: {e}")
import traceback
traceback.print_exc()
async def fetch_task_names(): async def fetch_task_names():
"""Fetch task names from scoreboard API""" """Fetch task names from scoreboard API"""