Commit graph

14 commits

Author SHA1 Message Date
vrubelroman
619c00aa06 stop infinite retry loop on rejected Lichess tokens
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 12s
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.
2026-07-05 07:37:14 +00:00
vrubelroman
26cb066515 simplify per-game table: tracked player only, no rating diff column
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 31s
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.
2026-07-03 10:08:35 +00:00
vrubelroman
d479e14bf9 add per-game accuracy and outcome table to stats/notifications
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 31s
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'
2026-07-03 09:38:51 +00:00
vrubelroman
4a783225af fix periodic activity-check algorithm silently losing player activity
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 38s
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>
2026-07-02 19:29:06 +00:00
vrubel
20f96d0e0a fix critical bugs 2026-02-05 01:38:33 +03:00
vrubelroman
4b6790be14 убрана чувствительность к регистру в никнейме 2025-11-23 12:51:14 +03:00
vrubelroman
0c9a66a73c fix bug today yesterday 2025-11-20 13:16:15 +03:00
vrubelroman
4dc5539da2 bug today 2025-11-20 03:14:06 +03:00
vrubelroman
24d53e731a rate limiter 0.2 sec 2025-11-18 15:10:19 +03:00
vrubel
3e61fa33c4 bug fixed 1000 games 2025-11-16 13:24:39 +03:00
vrubelroman
b031539f5e Добавлена поддержка классических игр в статистике
- Добавлен classical в модель GamesStats
- Добавлена обработка classical в методе _process_games_by_mode
- Теперь команды /today, /yesterday и /week выводят информацию по классическим играм
- Форматтер уже поддерживает classical (emoji ♟️)
2025-10-31 19:24:27 +03:00
vrubelroman
22a0371fc9 Удалены старые docker-compose.yml из подпапок (завершение) 2025-10-28 22:02:38 +03:00
vrubelroman
e8ced9bca7 Добавлена документация и скрипты для работы с БД
- Удалены лишние .gitignore из подпапок (теперь один общий в корне)
- Добавлен import_db.sh для импорта базы данных
- Создана документация: docs/ARCHITECTURE.md для разработчиков
- Создана документация: docs/USER_GUIDE.md для пользователей
- Обновлен .gitignore для исключения временных файлов
2025-10-28 21:38:10 +03:00
vrubelroman
a08fc8c962 Создание единого проекта Lichess Statistics Ecosystem
- Объединены три проекта в один репозиторий
- LichessWebServices - REST API для статистики
- LichessClientTG_bot - Telegram бот с поддержкой множества пользователей
- LichessWebView - Веб-интерфейс для просмотра пользователей и игроков
- Добавлен общий docker-compose.yml для запуска всех сервисов
- Добавлен скрипт start.sh для удобного запуска
- Добавлен README с полным описанием проекта
2025-10-26 20:23:26 +03:00