- periodic report rebuilt in HTML: title with games count, mode lines, one <pre>
table (± · colour · accuracy · opponent rating · opponent accuracy), 10-row cap,
span note after catch-up; stats service returns tracked_rating_diff per game
- /getgamers shows player state from the DB (played today / N days quiet /
closed / not found, report period) without Lichess calls; ratings on a button
- "player silent 30 days — keep?" prompt with keep/delete buttons, repeat 90 days
- /today, /yesterday, /week: one message edited into the result, nav buttons
- /year localised; active-gamer leftovers and N/A removed; one period wording
- docker-compose.prod.yml: stats port 8002 bound to 127.0.0.1
- product review docs: user journeys, concepts, Mini App feasibility, proposal
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- players absent from two consecutive bulk answers (deleted/renamed on Lichess) are paused
like closed accounts with their own notice; ❓ mark; stats service answers 404 instead
of "0 games" for unknown users
- /getgamers table stays unmarked, a legend line under it lists closed / not-found players
- daily SUMMARY is computed from events.log (survives restarts); lichess_429 comes from the
stats service /health, which now exposes lichess_429_24h / lichess_429_total
- admin /status reads its numbers through Database.get_admin_stats
- tests/: 36 bot + 15 service unittest cases, run_tests.sh runs them inside the real images,
CI runs them after the build and before pushing/deploying
- docs: USER_GUIDE/about/API_DOCUMENTATION rewritten for the current code, ARCHITECTURE.md and
two sub-READMEs removed, 7 obsolete helper scripts removed, CURRENT_STATE updated
- .claude/agents/designer.md: Telegram-aware designer role
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- stats service: POST /users/status proxies Lichess POST /api/users (up to 300 names,
through the shared-token gate) -> disabled / seen_at / games_total (sum of perfs.*.games)
- bot: PlayerStatusRefresher refreshes all tracked players every 15 min (2 bulk calls for
~500 players) into the new gamer_status table
- periodic_check: before the games request, _decide_skip() compares the player's
games_total with the pair's stored baseline (user_gamers.last_games_total); unchanged
and no token -> no HTTP call, checkpoint advances only to what the status proves
(status.checked_at - 60s), so games finished between a refresh and the window end
are still reported next time. Closed account -> skip + one notice to the owner,
auto-resume when reopened.
- /getgamers and /delgamer mark closed accounts with ⛔
Background load drops from ~445 games/user calls per hour to ~8 bulk calls plus one
games call per player who actually played.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A gamer's periodic check would get permanently stuck if their stored token
was revoked/expired: our stats API collapsed both "Lichess rejected the
token" (401/403, permanent) and genuine transient errors into the same 502
response, so the bot treated an invalid token exactly like a network blip —
retrying the same window forever at a capped 300s backoff, never advancing
the checkpoint (observed in prod: Dor1zz stuck for 100+ consecutive errors
over 8+ hours, admin alerts firing every 25 failures).
Preserve the distinction that already existed one layer down (lichess_client.py
already tells 401/403 apart from other failures) instead of collapsing it in
stats_service.py: add PuzzleOfPeriodResponse.auth_failed, have main.py return
401 specifically for that case, and have the bot raise a distinct
InvalidTokenError instead of returning None. On InvalidTokenError, the bot now
clears the token for that pair, notifies the user to reconnect via /addtoken,
and continues tracking games normally instead of stalling forever.
Reworked the per-game row layout to be relative to the tracked player
instead of white/black: the tracked player's name+accuracy+rating are
always shown first, the opponent's rating+accuracy (no name) always
second, regardless of which color each side played in a given game -
this keeps columns aligned across rows even as the tracked player
switches sides. Dropped the rating-change-per-game column added
earlier; it pushed the line past mobile width limits.
Games-of-period responses can now include a per-game breakdown
(include_games) with Lichess post-analysis accuracy, plus which side
the tracked player was on and their rating change for that game.
- lichess_client.py requests accuracy=true from Lichess; stats_service
computes per-mode average accuracy and builds GameRow entries
(tracked_is_white, tracked_rating_diff) for blitz/rapid/classical
- /games/{username}/period gained an include_games query param
- formatters.py renders a column-aligned monospace table per game:
outcome circle (win/loss/draw relative to the tracked player),
rating change, accuracy, names/ratings, result — for today/yesterday
and periodic notifications; week keeps an aggregate accuracy line
- usernames are Markdown-escaped before formatting since messages are
now sent with parse_mode='Markdown'
Errors from Lichess (timeouts/5xx/invalid tokens) were being disguised
as "no activity" (HTTP 200, games_count/puzzles_in_period=0), causing
the bot to silently advance its checkpoint past real, undetected
activity. Puzzle-fetch failures weren't counted as errors at all, and
the periodic task died permanently after 5 consecutive errors with no
way to recover short of a manual restart. /setperiod also unconditionally
reset the checkpoint, dropping the window between the last check and
the command.
- API now returns success=false/502 on real errors instead of masking
them as zero activity (models.py, stats_service.py, main.py)
- Puzzle-fetch errors are now treated the same as game-fetch errors:
retry the same window instead of reporting "no puzzles"
- Notification delivery failures no longer silently advance the
checkpoint
- Replaced the hard 5-error kill switch with capped backoff that keeps
retrying indefinitely, plus an admin-bot notification if a player's
monitoring has been failing for a prolonged period (~2h+)
- /setperiod only clears the checkpoint when disabling notifications,
preserving continuity when a period is just changed
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Добавлен classical в модель GamesStats
- Добавлена обработка classical в методе _process_games_by_mode
- Теперь команды /today, /yesterday и /week выводят информацию по классическим играм
- Форматтер уже поддерживает classical (emoji ♟️)
- Объединены три проекта в один репозиторий
- LichessWebServices - REST API для статистики
- LichessClientTG_bot - Telegram бот с поддержкой множества пользователей
- LichessWebView - Веб-интерфейс для просмотра пользователей и игроков
- Добавлен общий docker-compose.yml для запуска всех сервисов
- Добавлен скрипт start.sh для удобного запуска
- Добавлен README с полным описанием проекта