убрана чувствительность к регистру в никнейме

This commit is contained in:
vrubelroman 2025-11-23 12:51:14 +03:00
parent e6967db17d
commit 4b6790be14
4 changed files with 57 additions and 19 deletions

View file

@ -126,25 +126,41 @@ class StatsFormatter:
result = t('period_notification_title', lang, username=username, period_text=period_text)
# Format puzzles first (if available and there's actual activity)
if puzzles_data and puzzles_data.get('data'):
puzzles_info = puzzles_data['data']
total_puzzles = puzzles_info.get('total_attempts', 0)
solved = puzzles_info.get('solved', 0)
failed = puzzles_info.get('failed', 0)
# Only show tasks section if there's actual activity (not all zeros)
if total_puzzles > 0 or solved > 0 or failed > 0:
result += t('period_puzzles_section', lang, total=total_puzzles, solved=solved, failed=failed)
has_puzzles_data = False
if puzzles_data:
# Check puzzles_in_period on top level first (priority)
top_level_puzzles = puzzles_data.get('puzzles_in_period', 0)
# Also check data.total_attempts
if puzzles_data.get('data'):
puzzles_info = puzzles_data['data']
total_puzzles = puzzles_info.get('total_attempts', 0)
solved = puzzles_info.get('solved', 0)
failed = puzzles_info.get('failed', 0)
effective_puzzles = top_level_puzzles if top_level_puzzles > 0 else total_puzzles
# Only show tasks section if there's actual activity (not all zeros)
if effective_puzzles > 0 or solved > 0 or failed > 0:
has_puzzles_data = True
result += t('period_puzzles_section', lang, total=effective_puzzles, solved=solved, failed=failed)
# Format games
has_games_data = False
if games_data and games_data.get('data'):
games_info = games_data['data']
# Check games_count on top level first (priority)
top_level_games_count = games_data.get('games_count', 0)
# Also check data.total.games_played
total_games = games_info.get('total', {}).get('games_played', 0)
# Use top-level games_count if available, otherwise use total.games_played
effective_games_count = top_level_games_count if top_level_games_count > 0 else total_games
# Show details for each game type if there were games
if total_games > 0:
if effective_games_count > 0:
for game_type, game_data in games_info.items():
if game_type != 'total' and game_data and game_data.get('games_played', 0) > 0:
has_games_data = True # Only set to True if we actually add game data
emoji = StatsFormatter._get_game_type_emoji(game_type)
games_count = game_data.get('games_played', 0)
rating_change = game_data.get('rating_change', 0)
@ -167,8 +183,8 @@ class StatsFormatter:
draws=draws
)
# If no activity
if not (games_data and games_data.get('data')) and not (puzzles_data and puzzles_data.get('data')):
# If no activity at all
if not has_games_data and not has_puzzles_data:
result += t('no_activity', lang)
return result.rstrip()