From b69cc38ccee0b88314cac9a96f4e7ca869f51f92 Mon Sep 17 00:00:00 2001 From: Debian Date: Fri, 18 Sep 2026 12:26:42 +0200 Subject: [PATCH] Consume every LIVESTATS heartbeat variant and show them all only with -v Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- main.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 0cf59dc..f02f423 100644 --- a/main.py +++ b/main.py @@ -37,7 +37,7 @@ RENAME_PATTERN = re.compile(r'^(.+?)\s+renamed to\s+(.+?)$') STATUS_HEAD_PATTERN = re.compile(r'^\s*\d+\s+-?\d+\s+(bot|\d+)\s+\S', re.MULTILINE) STATUS_MAP_PATTERN = re.compile(r'^map:\s+\S+\s*$', re.MULTILINE) STEAMID_PATTERN = re.compile(r'\b\d{16,}\b') -LIVESTATS_PATTERN = re.compile(r'^LIVESTATS\s+(\S+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*$') +LIVESTATS_PATTERN = re.compile(r'^LIVESTATS\s+(.+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*$') ROSTER_CHAT_GUARD_PATTERN = re.compile(r'^.{1,40}:\s') VOTE_CAST_PATTERN = re.compile(r'^(.+?) voted for (.+)\.$') CHAT_SHAPE_PATTERN = re.compile(r'^[\w(][^:]*:\s') @@ -156,17 +156,20 @@ def is_engine_output(message): def handle_livestats(message, game_state, ui, verbose=0): """ - Parse a LIVESTATS print (engine damage counters, emitted every 10s by the - livedamage plugin) and update the player's live score/damage/ping. - Returns True when the line is consumed. The raw line displays only at -v - or higher verbosity; it is never treated as chat. + Consume every LIVESTATS heartbeat line (engine damage counters emitted + every 10s by the livedamage plugin, plus its summary variants). Lines + matching the full player shape update live score/damage/ping; names may + contain spaces, so the counters anchor from the end. The raw lines + display only at -v or higher verbosity; they are never treated as chat. """ - match = LIVESTATS_PATTERN.match(strip_color_codes(message).strip()) - if not match: + clean = strip_color_codes(message).strip() + if not clean.lower().startswith('livestats'): return False - name, score, dealt, taken, ping = match.groups() - game_state.player_tracker.update_livestats(name, int(score), int(dealt), int(taken), int(ping)) - ui.update_server_info(game_state) + match = LIVESTATS_PATTERN.match(clean) + if match: + name, score, dealt, taken, ping = match.groups() + game_state.player_tracker.update_livestats(name, int(score), int(dealt), int(taken), int(ping)) + ui.update_server_info(game_state) if verbose > 0: timestamp = time.strftime('%H:%M:%S') ui.print_message(f"^3[^7{timestamp}^3]^7 {message.rstrip()}\n")