(event)
| 2552 | } |
| 2553 | |
| 2554 | function shouldUseGroupRecentContext(event) { |
| 2555 | if (event.type === "private_message" || !event.groupId) return false; |
| 2556 | if (event.proactiveDecision?.includeRecentContext) return true; |
| 2557 | if (event.replyContext) return true; |
| 2558 | const text = stripMentionText(event.text); |
| 2559 | if (!text) return false; |
| 2560 | const hasExplicitTarget = extractMentionedUserIds(event).length > 0 || extractPossibleTargetNames(text).length > 0; |
| 2561 | const asksForRecentContext = /(刚刚|刚才|刚|刚那|刚那会|前面|上面|之前|前文|上文|前几句|前几条|上一条|这几句|这几条|这波|刚干|干的事|做的事|发生什么|发生啥|什么情况|啥情况|咋回事|怎么回事|咋了|怎么了|聊到哪|说到哪|上下文)/.test(text); |
| 2562 | const asksForJudgement = /(评价|锐评|评一下|点评|怎么看|说说|讲讲|总结|概括|复盘|分析一下|解释一下|翻译一下|帮我看|看一下|看看|捋一下|理一下|聊什么|聊啥|说什么|说啥|在说什么|在说啥|在聊啥|在聊什么|干什么|干啥|在干嘛|在干什么|在干啥|做什么|做啥|在做什么|在做啥)/.test(text); |
| 2563 | const asksForWholeGroup = /(群里|群友|大家|他们|她们|这群|这帮|这几个人|刚才那几个人|前面那几个人).*(聊什么|聊啥|说什么|说啥|在聊|在说|在干嘛|在干什么|在干啥|干什么|干啥|做什么|做啥|在做什么|在做啥|什么情况|啥情况|咋回事|怎么回事|总结|概括|复盘)|^((刚刚|刚才|前面|上面|之前|刚才那会儿|刚才那会)?(聊什么|聊啥|在聊什么|在聊啥|说什么|说啥|在说什么|在说啥|什么情况|啥情况|咋回事|怎么回事|发生什么|发生啥)|总结一下|概括一下|复盘一下)$/i.test(text.trim()); |
| 2564 | const shortGeneric = /^(在吗|测试|状态|你好|哈喽|hello|hi|来|出来|探头|叫你一下)$/i.test(text.trim()); |
| 2565 | if (shortGeneric) return false; |
| 2566 | return asksForWholeGroup || (hasExplicitTarget && (asksForRecentContext || asksForJudgement)) || (asksForRecentContext && asksForJudgement); |
| 2567 | } |
| 2568 | |
| 2569 | function extractMentionedUserIds(event) { |
| 2570 | const ids = new Set((event.atTargets || []).map(String).filter((id) => id !== String(event.selfId))); |
no test coverage detected