asd
This commit is contained in:
@@ -185,6 +185,22 @@ async def send_telegram_alert(message: str):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error sending telegram alert: {e}")
|
print(f"Error sending telegram alert: {e}")
|
||||||
|
|
||||||
|
async def fetch_task_names():
|
||||||
|
"""Fetch task names from scoreboard API"""
|
||||||
|
import aiohttp
|
||||||
|
try:
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(f"{SCOREBOARD_URL}/api/client/tasks/") as resp:
|
||||||
|
if resp.status == 200:
|
||||||
|
tasks = await resp.json()
|
||||||
|
return {task['id']: task['name'] for task in tasks}
|
||||||
|
else:
|
||||||
|
print(f"Failed to fetch tasks: {resp.status}")
|
||||||
|
return {}
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error fetching task names: {e}")
|
||||||
|
return {}
|
||||||
|
|
||||||
async def socketio_listener():
|
async def socketio_listener():
|
||||||
"""Listen to ForcAD scoreboard using Socket.IO"""
|
"""Listen to ForcAD scoreboard using Socket.IO"""
|
||||||
sio = socketio.AsyncClient(logger=False, engineio_logger=False)
|
sio = socketio.AsyncClient(logger=False, engineio_logger=False)
|
||||||
@@ -193,6 +209,11 @@ async def socketio_listener():
|
|||||||
task_names = {}
|
task_names = {}
|
||||||
team_names = {}
|
team_names = {}
|
||||||
|
|
||||||
|
# Fetch task names on startup
|
||||||
|
task_names.update(await fetch_task_names())
|
||||||
|
if task_names:
|
||||||
|
print(f"📋 Loaded task names: {', '.join([f'{name} (ID:{tid})' for tid, name in task_names.items()])}")
|
||||||
|
|
||||||
@sio.on('*', namespace='/live_events')
|
@sio.on('*', namespace='/live_events')
|
||||||
async def catch_all(event, data):
|
async def catch_all(event, data):
|
||||||
"""Catch all events from live_events namespace"""
|
"""Catch all events from live_events namespace"""
|
||||||
|
|||||||
Reference in New Issue
Block a user