fix: 【不发送】标签在sendProactive路径失效 + 群聊长消息截断防封控

- sendProactive端点新增【不发送】过滤(之前只有主回复路径有)
- sendProactive和主回复路径均增加群聊500字截断+最多2条限制
- 防止第三方平台适配器因过长消息触发封控

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-05 14:18:39 +08:00
parent f723194a17
commit 4ebdac42a1
2 changed files with 35 additions and 1 deletions
@@ -214,9 +214,36 @@ func (h *BridgeHandler) sendProactive(w http.ResponseWriter, r *http.Request) {
content := filterActions(req.Content)
content = convertMarkdownPlain(content)
// 过滤 【不发送】 自我审查标签
if strings.Contains(content, "【不发送】") {
trimmed := content
if len([]rune(trimmed)) > 80 {
trimmed = string([]rune(trimmed)[:80]) + "..."
}
log.Printf("[send-proactive] 昔涟自我审查,跳过发送: %s", trimmed)
writeJSON(w, http.StatusOK, map[string]string{"status": "self_censored"})
return
}
// 按 \n\n 和 ♪ 拆分为多条消息
messages := splitProactiveContent(content)
// 群聊长消息截断:超过 500 字的单条消息截断,防止封控
if msgType == "group" {
const maxLen = 500
for i, msg := range messages {
runes := []rune(msg)
if len(runes) > maxLen {
messages[i] = string(runes[:maxLen]) + "\n…(内容过长已截断)"
log.Printf("[send-proactive] 群聊消息过长截断: %d→%d 字", len(runes), maxLen)
}
}
// 群聊最多2条
if len(messages) > 2 {
messages = messages[:2]
}
}
// Prepend CQ @mention tag if at_user_id is specified
atPrefix := ""
if req.AtUserID != "" {