From 190152733e2beef3fb327e7a1389ca8b3cbdece6 Mon Sep 17 00:00:00 2001 From: Debian Date: Wed, 16 Sep 2026 21:31:31 +0200 Subject: [PATCH] Add timestamps to game events and connection messages Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- lib/parser.py | 6 +++++- main.py | 15 ++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/parser.py b/lib/parser.py index b3797a2..3931ee5 100644 --- a/lib/parser.py +++ b/lib/parser.py @@ -72,7 +72,11 @@ class EventParser: handler = handler_map.get(event_type) if handler: - return handler(data) + formatted = handler(data) + if formatted: + timestamp = time.strftime('%H:%M:%S') + return f"^3[^7{timestamp}^3]^7 {formatted}" + return None else: # Unknown event logger.debug(f'Unknown event type: {event_type}') diff --git a/main.py b/main.py index c40df03..4b807a8 100644 --- a/main.py +++ b/main.py @@ -361,7 +361,8 @@ def main_loop(screen, args): # Initialize network connections password_display = '***' if args.password else '(none)' - ui.print_message(f"Connecting with host={args.host} password={password_display}\n") + timestamp = time.strftime('%H:%M:%S') + ui.print_message(f"^3[^7{timestamp}^3]^7 Connecting with host={args.host} password={password_display}\n") rcon = RconConnection(args.host, args.password, args.identity) rcon.connect() @@ -403,11 +404,13 @@ def main_loop(screen, args): # Check monitor for connection events monitor_event = rcon.check_monitor() if monitor_event and monitor_event[0] == zmq.EVENT_CONNECTED: - ui.print_message("Connected to server\n") + timestamp = time.strftime('%H:%M:%S') + ui.print_message(f"^3[^7{timestamp}^3]^7 Connected to server\n") rcon.send_command(b'register') logger.info('Registration message sent') - ui.print_message("Requesting connection info...\n") + timestamp = time.strftime('%H:%M:%S') + ui.print_message(f"^3[^7{timestamp}^3]^7 Requesting connection info...\n") rcon.send_command(b'zmq_stats_password') rcon.send_command(b'net_port') name_capture.request(rcon) @@ -491,14 +494,16 @@ def main_loop(screen, args): # Connect to stats if we have both credentials if stats_port and stats_password and stats_conn is None: try: - ui.print_message("Connecting to stats stream...\n") + timestamp = time.strftime('%H:%M:%S') + ui.print_message(f"^3[^7{timestamp}^3]^7 Connecting to stats stream...\n") host_ip = args.host.split('//')[1].split(':')[0] stats_conn = StatsConnection(host_ip, stats_port, stats_password) stats_conn.connect() poller.register(stats_conn.socket, zmq.POLLIN) - ui.print_message("Stats stream connected - ready for game events\n") + timestamp = time.strftime('%H:%M:%S') + ui.print_message(f"^3[^7{timestamp}^3]^7 Stats stream connected - ready for game events\n") # Request initial server info logger.info('Sending initial server info queries')