feat: add unblock-nag detection and redirect
Keyword-based detection for users repeatedly asking to be unblocked in chat. Fires an LLM-generated snarky redirect (with static fallback), tracks per-user nag count with escalating sass, and respects a 30-min cooldown. Configurable via config.yaml unblock_nag section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,9 @@ class UserDrama:
|
||||
coherence_scores: list[float] = field(default_factory=list)
|
||||
baseline_coherence: float = 0.85
|
||||
last_coherence_alert_time: float = 0.0
|
||||
# Unblock nagging tracking
|
||||
unblock_nag_count: int = 0
|
||||
last_unblock_nag_time: float = 0.0
|
||||
# Per-user LLM notes
|
||||
notes: str = ""
|
||||
# Known aliases/nicknames
|
||||
@@ -256,6 +259,21 @@ class DramaTracker:
|
||||
"""Return {user_id: [aliases]} for all users that have aliases set."""
|
||||
return {uid: user.aliases for uid, user in self._users.items() if user.aliases}
|
||||
|
||||
def record_unblock_nag(self, user_id: int) -> int:
|
||||
user = self.get_user(user_id)
|
||||
user.unblock_nag_count += 1
|
||||
user.last_unblock_nag_time = time.time()
|
||||
return user.unblock_nag_count
|
||||
|
||||
def can_unblock_remind(self, user_id: int, cooldown_minutes: int) -> bool:
|
||||
user = self.get_user(user_id)
|
||||
if user.last_unblock_nag_time == 0.0:
|
||||
return True
|
||||
return time.time() - user.last_unblock_nag_time > cooldown_minutes * 60
|
||||
|
||||
def get_unblock_nag_count(self, user_id: int) -> int:
|
||||
return self.get_user(user_id).unblock_nag_count
|
||||
|
||||
def reset_off_topic(self, user_id: int) -> None:
|
||||
user = self.get_user(user_id)
|
||||
user.off_topic_count = 0
|
||||
|
||||
Reference in New Issue
Block a user