improve xiaoniu group awareness and solver suppression

This commit is contained in:
liuwei
2026-04-07 12:27:53 +08:00
parent faa5d68eb0
commit d507cdf88d
4 changed files with 112 additions and 5 deletions

View File

@@ -59,6 +59,7 @@ class FlowManager:
if since_reply <= 180 and event.get("message_after_bot"):
state.score += float(self.config.get("response_accepted_boost", 15))
state.accepted_reply_count += 1
state.bot_reply_streak = 0
state.last_human_message_at = now
state.last_topic = event.get("topic") or state.last_topic
state.state = self._score_to_state(state.score)
@@ -66,6 +67,12 @@ class FlowManager:
def note_bot_reply(self, room_id: str) -> FlowState:
state = self.decay(room_id)
now = datetime.now()
if state.last_bot_reply_at and (not state.last_human_message_at or state.last_human_message_at < state.last_bot_reply_at):
since_last_bot_reply = (now - state.last_bot_reply_at).total_seconds()
if since_last_bot_reply <= 180:
state.ignored_reply_count += 1
state.score = max(0.0, state.score - float(self.config.get("ignored_reply_penalty", 20)))
state.last_bot_reply_at = datetime.now()
state.bot_reply_streak += 1
max_streak = int(self.config.get("max_bot_reply_streak", 3))
@@ -74,6 +81,20 @@ class FlowManager:
state.state = self._score_to_state(state.score)
return state
def get_acceptance_state(self, room_id: str) -> str:
state = self.get_state(room_id)
accepted = int(state.accepted_reply_count)
ignored = int(state.ignored_reply_count)
total = accepted + ignored
if total < 3:
return "neutral"
ratio = accepted / max(total, 1)
if ratio >= 0.7 and accepted >= 3:
return "warm"
if ratio <= 0.35 and ignored >= 2:
return "cold"
return "neutral"
def _score_to_state(self, score: float) -> str:
idle_threshold = float(self.config.get("idle_threshold", 20))
warming_threshold = float(self.config.get("warming_threshold", 40))