tune xiaoniu mention reply behavior
This commit is contained in:
@@ -57,6 +57,10 @@ max_bot_reply_streak = 2
|
||||
[cooldown]
|
||||
group_reply_cooldown_sec = 90
|
||||
same_user_followup_cooldown_sec = 18
|
||||
at_mention_min_interval_sec = 5
|
||||
at_mention_burst_window_sec = 90
|
||||
at_mention_burst_limit = 5
|
||||
at_mention_silent_sec = 180
|
||||
night_silent_hours = ["01:00-07:30"]
|
||||
|
||||
[memory]
|
||||
|
||||
@@ -71,6 +71,7 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
self.group_messages: Dict[str, List[Dict]] = {}
|
||||
self.enable = True
|
||||
self.last_reply_at: Dict[str, float] = {}
|
||||
self.at_mention_history: Dict[str, List[float]] = {}
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
self.LOG = logger
|
||||
@@ -232,7 +233,7 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
"skip",
|
||||
room_id=room_id,
|
||||
sender=sender,
|
||||
reason="cooldown",
|
||||
reason=trigger.__dict__.get("_cooldown_reason", "cooldown"),
|
||||
trigger_type=trigger.trigger_type,
|
||||
reply_mode=reply_mode,
|
||||
)
|
||||
@@ -370,9 +371,28 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
current_ts = time.time()
|
||||
room_cd = int(self.cooldown_config.get("group_reply_cooldown_sec", 45))
|
||||
user_cd = int(self.cooldown_config.get("same_user_followup_cooldown_sec", 10))
|
||||
at_min_interval = int(self.cooldown_config.get("at_mention_min_interval_sec", 8))
|
||||
at_burst_window = int(self.cooldown_config.get("at_mention_burst_window_sec", 90))
|
||||
at_burst_limit = int(self.cooldown_config.get("at_mention_burst_limit", 4))
|
||||
at_silent_sec = int(self.cooldown_config.get("at_mention_silent_sec", 180))
|
||||
last_room_reply = self.last_reply_at.get(room_id, 0.0)
|
||||
if trigger.get("is_question") or trigger.get("is_followup") or trigger.get("trigger_type") == "at_trigger":
|
||||
if trigger.get("trigger_type") == "at_trigger":
|
||||
history = [ts for ts in self.at_mention_history.get(room_id, []) if current_ts - ts <= at_burst_window]
|
||||
self.at_mention_history[room_id] = history
|
||||
if history and (current_ts - history[-1]) < at_min_interval:
|
||||
trigger["_cooldown_reason"] = "at_min_interval"
|
||||
return False
|
||||
if len(history) >= at_burst_limit:
|
||||
if (current_ts - history[-1]) < at_silent_sec:
|
||||
trigger["_cooldown_reason"] = "at_burst_silent"
|
||||
return False
|
||||
self.at_mention_history[room_id] = []
|
||||
self.at_mention_history.setdefault(room_id, []).append(current_ts)
|
||||
return True
|
||||
if trigger.get("is_question") or trigger.get("is_followup"):
|
||||
trigger["_cooldown_reason"] = "followup_cooldown"
|
||||
return (current_ts - last_room_reply) >= user_cd
|
||||
trigger["_cooldown_reason"] = "group_cooldown"
|
||||
return (current_ts - last_room_reply) >= room_cd
|
||||
|
||||
def _build_user_prompt(self, context: Dict, memory_hints: Dict) -> str:
|
||||
|
||||
Reference in New Issue
Block a user