fix silent addgamer drop on restart and periodic-check backlog buildup
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 13s

Persist user_data (PicklePersistence) so an in-flight /addgamer username
prompt survives a bot restart instead of being silently swallowed by
handle_username when the in-memory awaiting flag is gone.

Collapse periodic-check backlog into a single request spanning the whole
missed gap instead of replaying it one period_minutes window at a time —
with enough tracked gamers sharing one RequestQueue, per-window replay
could never catch up and the checkpoint fell further behind indefinitely.
Notification period label now reflects the actual queried span (minutes/
hours/days) instead of the configured interval, so a weeks-old catch-up
no longer gets mislabeled as "for 15 minutes".
This commit is contained in:
vrubelroman 2026-07-04 18:33:45 +00:00
parent 62cdd750f8
commit b0173950b8
3 changed files with 62 additions and 21 deletions

View file

@ -282,14 +282,24 @@ class StatsFormatter:
def format_period_notification(username: str, games_data: Optional[Dict], puzzles_data: Optional[Dict], period_minutes: int, lang: str = 'en') -> str:
"""Format notification for periodic checks"""
from datetime import datetime
# Format period text
if period_minutes == 1:
period_text = t('period_1_minute', lang)
elif period_minutes in [2, 3, 4]:
period_text = t('period_2_3_4_minutes', lang, period=period_minutes)
# Format period text. period_minutes here is the actual queried span, which
# can be much larger than the configured check interval after a backlog
# collapse (see periodic_check in bot.py) — fall back to hours/days so a
# weeks-old catch-up doesn't get mislabeled as "for 15 minutes".
if period_minutes < 60:
if period_minutes == 1:
period_text = t('period_1_minute', lang)
elif period_minutes in [2, 3, 4]:
period_text = t('period_2_3_4_minutes', lang, period=period_minutes)
else:
period_text = t('period_minutes_text', lang, period=period_minutes)
elif period_minutes < 1440:
hours = round(period_minutes / 60)
period_text = t('period_hours_text', lang, hours=hours)
else:
period_text = t('period_minutes_text', lang, period=period_minutes)
days = round(period_minutes / 1440)
period_text = t('period_days_text', lang, days=days)
result = t('period_notification_title', lang, username=username, period_text=period_text)