From 74c56881fdc351fa81fb856609252e7431dc2d70 Mon Sep 17 00:00:00 2001 From: deploy Date: Fri, 29 May 2026 18:18:11 +0000 Subject: [PATCH] fix: strip tag decorators from winner/loser before guild_squadron comparison guild_squadron is the clean short name from SQUADRONS.json (e.g. DSPLA) but winning_team_squadron in the replay is the raw tagged value (-DSPLA-). They never matched for dash/underscore-tagged squads so bar_color was always not_involved instead of win/loss on the guild's own scoreboard. Co-Authored-By: Claude Sonnet 4.6 --- BOT/autologging.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/BOT/autologging.py b/BOT/autologging.py index a540f24..150739e 100644 --- a/BOT/autologging.py +++ b/BOT/autologging.py @@ -971,11 +971,17 @@ async def process_session( logging.error(f"Replay file for session ID {session_id} is invalid: {e}") return - # Extract winner/loser/draw + # Extract winner/loser/draw — strip tag decorators so bare short names + # (e.g. "DSPLA" stored in SQUADRONS.json) match raw replay values like "-DSPLA-". + def _strip_tag(s: Optional[str]) -> Optional[str]: + if s is None: + return None + return re.sub(r'^[^A-Za-z0-9]+|[^A-Za-z0-9]+$', '', s) or s + squadrons = replay_data.get("squadrons", []) - winner = replay_data.get("winning_team_squadron") + winner = _strip_tag(replay_data.get("winning_team_squadron")) is_draw = replay_data.get("draw", False) - loser_candidates = [sq for sq in squadrons if sq != winner] + loser_candidates = [_strip_tag(sq) for sq in squadrons if _strip_tag(sq) != winner] loser = loser_candidates[0] if loser_candidates else None # Guild-specific squadron (short name) guild_data = squadrons_data.get(str(guild_id), {})