LichessStatTgWeb/LichessWebServices
vrubelroman d24cc1a2bd structured events.log, count games in the window they finished in, immediate reopened notice
- events.py (bot): one grep-able line per event into data/events.log (10 MB x 5 rotation,
  survives container recreation): user_start, cmd, text/callback/non_text, addgamer_input/
  addgamer_result, addtoken_result, gamer_added, gamer_deleted, period_set, lang_set,
  check (decision=request|skip_unchanged|skip_closed, games, notified, lag), check_error,
  closed_notice, reopened_notice, blocked, token_rejected, status_refresh, admin_notify,
  tg_error; a SUMMARY line at midnight, also shown by admin /status as "Вчера".
  Service side: EVT lichess_429 (kind=concurrency|burst|unknown) and lichess_error in its log.
- /games/{username}/period?by_finish=true: query Lichess from since-3h and keep games with
  since < lastMoveAt <= until. Periodic checks use it, so a game created 14:58 and finished
  15:06 is reported in the 15:00-16:00 window instead of being lost on the boundary.
- reopened-account notice is sent as soon as the status flips, not after the next game.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-20 22:51:11 +00:00
..
API_DOCUMENTATION.md structured events.log, count games in the window they finished in, immediate reopened notice 2026-10-20 22:51:11 +00:00
Dockerfile Создание единого проекта Lichess Statistics Ecosystem 2025-10-26 20:23:26 +03:00
events.py structured events.log, count games in the window they finished in, immediate reopened notice 2026-10-20 22:51:11 +00:00
lichess_client.py structured events.log, count games in the window they finished in, immediate reopened notice 2026-10-20 22:51:11 +00:00
main.py structured events.log, count games in the window they finished in, immediate reopened notice 2026-10-20 22:51:11 +00:00
models.py bulk player status: skip periodic checks for players who did not play, pause closed accounts 2026-10-20 22:31:33 +00:00
rate_limiter.py fix never-sent notifications for periods >= 3h, lower shared-token gap to 3s, handle both Lichess 429s 2026-10-20 21:55:30 +00:00
README.md Создание единого проекта Lichess Statistics Ecosystem 2025-10-26 20:23:26 +03:00
requirements.txt Создание единого проекта Lichess Statistics Ecosystem 2025-10-26 20:23:26 +03:00
stats_service.py structured events.log, count games in the window they finished in, immediate reopened notice 2026-10-20 22:51:11 +00:00

Lichess Statistics API

REST API сервис для получения статистики игроков Lichess.org по играм и решению задач.

Возможности

  • Получение статистики за сегодняшний день
  • Получение статистики за вчерашний день
  • Получение статистики за последние 7 дней
  • Поддержка режимов игры: Bullet, Blitz, Rapid
  • Статистика по решению задач (пазлов)
  • Расчет изменения рейтинга
  • Подсчет побед, поражений и ничьих

Запуск с Docker

1. Сборка и запуск контейнера

# Сборка образа
docker-compose build

# Запуск сервиса
docker-compose up -d

2. Проверка работы

Сервис будет доступен по адресу: http://localhost:8000

API Endpoints

Получить статистику за сегодня

GET /stats/{username}/today

Получить статистику за вчера

GET /stats/{username}/yesterday

Получить статистику за неделю

GET /stats/{username}/week

Примеры использования

Статистика за сегодня

curl http://localhost:8000/stats/vrubelroman/today

Статистика за вчера

curl http://localhost:8000/stats/vrubelroman/yesterday

Статистика за неделю

curl http://localhost:8000/stats/vrubelroman/week

Формат ответа

{
  "message": "Статистика за сегодняшний день",
  "data": {
    "username": "vrubelroman",
    "tasks": {
      "total": 28,
      "solved": 25,
      "unsolved": 3
    },
    "games": {
      "bullet": {
        "games_played": 7,
        "rating_change": 30,
        "final_rating": 2320,
        "wins": 5,
        "losses": 0,
        "draws": 0
      },
      "blitz": {
        "games_played": 5,
        "rating_change": 32,
        "final_rating": 2224,
        "wins": 5,
        "losses": 0,
        "draws": 0
      },
      "rapid": {
        "games_played": 2,
        "rating_change": -10,
        "final_rating": 2210,
        "wins": 1,
        "losses": 1,
        "draws": 0
      }
    }
  }
}

Остановка сервиса

docker-compose down

Логи

Для просмотра логов:

docker-compose logs -f