Commit graph

3 commits

Author SHA1 Message Date
vrubelroman
99b1275834 v1.5.0: startup status-refresh retries, /today skips dormant players, unknown-command hint, /cancel fix
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 16s
- player status: initial bulk refresh retries 4x5s (bot and stats service start in the
  same second on prod, the first attempt failed with connection reset); admin is
  notified after 3 consecutive failed refreshes
- /today, /yesterday, /week: players whose bulk status shows they were not online since
  the period start (or whose account is closed) are skipped without any Lichess call;
  stats service paces user/activity at 8.5s (Lichess allows 15 per 2 min per IP), so a
  user with 16+ tracked players no longer hits 429 mid-command
- unknown /commands in private chats get the usual hint and a cmd name=unknown event
- /addtoken -> /cancel used to crash (sync lambda awaited by PTB 20); now an async handler
- version 1.5.0, CHANGELOG entry for everything since 1.1.0 that shipped today
- docs: CURRENT_STATE.md rewritten for 30aaa34, README brought in line with the code
  (port 8002, module list, commands, .env vars, DB tables, events.log section)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-20 23:21:53 +00:00
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
vrubelroman
7178b80854 split bot.py into periodic/notifications/onboarding modules, drop redundant request queue
Behaviour-preserving refactor:
- periodic.py: PeriodicMonitor (periodic_check & friends, moved verbatim with comments)
- notifications.py: one AdminNotifier for both processes (was 4 copies of the same
  direct-API code), with a 10 s HTTP timeout and the TTS announcer
- onboarding.py: link_player(), the add-player flow shared by /addgamer and /addtoken
- bot.py 2040 -> 1372 lines; no inline sqlite3 left (Database.gamer_exists/get_counts)
- request_queue.py removed: periodic checks call the local stats service under a
  10-slot semaphore; the only real Lichess limiter is SharedTokenGate in the service.
  Bot-side RateLimiter kept only for direct lichess.org calls.
- /addtoken "already tracked" check is now case-insensitive like /addgamer
- docs/CURRENT_STATE.md: system map as of 6355cd9 (analyst)
- .claude/agents: analyst / developer / tester definitions

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-20 21:46:48 +00:00