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>
This commit is contained in:
vrubelroman 2026-10-20 22:51:11 +00:00
parent 27e76b2399
commit d24cc1a2bd
14 changed files with 484 additions and 80 deletions

View file

@ -151,6 +151,7 @@ curl http://localhost:8001/stats/magnus/week
- `since` (integer, обязательный) - начало периода (Unix timestamp в миллисекундах)
- `until` (integer, обязательный) - конец периода (Unix timestamp в миллисекундах)
- `rated_only` (boolean, опциональный) - только рейтинговые игры (по умолчанию true - рекомендуется)
- `by_finish` (boolean, опциональный, по умолчанию false) - относить партию к периоду по моменту её **окончания** (`lastMoveAt` в `(since, until]`), а не создания, как фильтрует сам Lichess; запрос к Lichess при этом расширяется на 3 часа назад. Так работают периодические проверки бота: партия попадает в то окно, в котором закончилась
**Пример запроса:**
```bash