diff --git a/bots/client_bot.py b/bots/client_bot.py index ab77bde..351284a 100644 --- a/bots/client_bot.py +++ b/bots/client_bot.py @@ -105,13 +105,13 @@ def _pad_col(s: str, width: int) -> str: def format_pairings(pairings_data: dict, tournament_name: str, lang: str = '', - player_name: str = '') -> str: + player_name: str = '', player_sno: int = 0) -> str: locale = _get_locale(lang) pairings = pairings_data['pairings'] rnd = pairings_data['round'] # If highlighting a player, reduce name width to compensate for ✅ emoji (visually 2 chars wide) - w_name = 15 if player_name else 17 + w_name = 15 if player_sno else 17 w_board, w_rating, w_pts, w_tb1 = 2, 4, 4, 5 border = '+'.join('-' * w for w in [w_board, w_name, w_rating, w_pts, w_tb1]) @@ -130,7 +130,7 @@ def format_pairings(pairings_data: dict, tournament_name: str, lang: str = '', return { 'title': title, 'rows': _build_table_rows(pairings, w_board, w_name, w_rating, w_pts, w_tb1, border, - locale['bye'], player_name), + locale['bye'], player_name, player_sno), 'table_header': table_header, 'footer': footer, } @@ -138,14 +138,16 @@ def format_pairings(pairings_data: dict, tournament_name: str, lang: str = '', def _build_table_rows(pairings: list, w_board: int, w_name: int, w_rating: int, w_pts: int, w_tb1: int, border: str, bye_label: str = '— BYE —', - player_name: str = '') -> list: + player_name: str = '', player_sno: int = 0) -> list: def _rating_str(p): return str(p.rating) if p.rating else '' def _tb1_str(p): return f"{p.tb[0]:.1f}" if p.tb else '' - # Find the board where the player plays (normalize names: strip commas, collapse spaces) + # Find the board where the player plays. + # Primary: match by SNo (reliable across Latin/Cyrillic name variations). + # Fallback: match by normalized name. def _n(s: str) -> str: return s.replace(',', '').replace(' ', ' ').lower() @@ -156,13 +158,13 @@ def _build_table_rows(pairings: list, w_board: int, w_name: int, w_rating: int, if len(pairing) != 3: continue p1, p2, _color = pairing + if player_sno and (p1.sno == player_sno or p2.sno == player_sno): + player_board = board_idx + player_name = p1.name if p1.sno == player_sno else p2.name + break if player_norm and (player_norm == _n(p1.name) or player_norm == _n(p2.name)): player_board = board_idx - # Store the actual name from pairings for the ✅ marker - if player_norm == _n(p1.name): - player_name = p1.name - else: - player_name = p2.name + player_name = p1.name if player_norm == _n(p1.name) else p2.name break board_idx += 1 diff --git a/bots/tracker.py b/bots/tracker.py index 230ab4e..45a7109 100644 --- a/bots/tracker.py +++ b/bots/tracker.py @@ -729,7 +729,7 @@ async def check_all_subscriptions(context): try: result = calculate_next_round(tournament) fmt = format_pairings(result, tournament.get('name', ''), sub['lang'], - sub['player_name']) + sub['player_name'], sub['player_sno']) chunks = _render_chunks(fmt) for chunk in chunks: try: