fix: persist last_offense_time and reset offenses after 24h

last_offense_time was in-memory only — lost on restart, so the
offense_reset_minutes check never fired after a reboot. Now persisted
as LastOffenseAt FLOAT in UserState. On startup hydration, stale
offenses (and warned flag) are auto-cleared if the reset window has
passed. Bumped offense_reset_minutes from 2h to 24h.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 11:24:38 -05:00
parent 71c7b45e9a
commit 8734f1883b
4 changed files with 27 additions and 9 deletions
+7
View File
@@ -286,6 +286,13 @@ class DramaTracker:
user.notes = state["user_notes"]
if state.get("warned"):
user.warned_since_reset = True
if state.get("last_offense_at"):
user.last_offense_time = state["last_offense_at"]
# Apply time-based offense reset at load time
if time.time() - user.last_offense_time > self.offense_reset_seconds:
user.offense_count = 0
user.warned_since_reset = False
user.last_offense_time = 0.0
count += 1
return count