MCPcopy Create free account
hub / github.com/WecomTeam/wecom-openclaw-plugin / shouldProcessBotInboundMessage

Function shouldProcessBotInboundMessage

src/webhook/handler.ts:64–87  ·  view source on GitHub ↗

* 判断入站消息是否应该被处理(对齐原版 shouldProcessBotInboundMessage) * * 仅允许"真实用户消息"进入 Bot 会话: * - 发送者缺失 → 丢弃(避免 unknown 会话串会话) * - 发送者是 sys → 丢弃(避免系统回调触发 AI 自动回复) * - 群消息缺失 chatid → 丢弃(避免 group:unknown 串群)

(
  msg: WebhookInboundMessage,
)

Source from the content-addressed store, hash-verified

62 * - 群消息缺失 chatid → 丢弃(避免 group:unknown 串群)
63 */
64function shouldProcessBotInboundMessage(
65 msg: WebhookInboundMessage,
66): { shouldProcess: boolean; reason: string; senderUserId?: string; chatId?: string } {
67 const senderUserId = resolveWecomSenderUserId(msg)?.trim();
68
69 if (!senderUserId) {
70 return { shouldProcess: false, reason: "missing_sender" };
71 }
72 if (senderUserId.toLowerCase() === "sys") {
73 return { shouldProcess: false, reason: "system_sender" };
74 }
75
76 // 企微 Bot 回调中 chattype 是扁平字段(非嵌套在 chat_info 内)
77 const chatType = String(msg.chattype ?? "").trim().toLowerCase();
78 if (chatType === "group") {
79 const chatId = msg.chatid?.trim();
80 if (!chatId) {
81 return { shouldProcess: false, reason: "missing_chatid", senderUserId };
82 }
83 return { shouldProcess: true, reason: "user_message", senderUserId, chatId };
84 }
85
86 return { shouldProcess: true, reason: "user_message", senderUserId, chatId: senderUserId };
87}
88
89/**
90 * 从 Target 配置中提取预期的 Bot Identity 集合

Callers 1

dispatchMessageFunction · 0.85

Calls 1

resolveWecomSenderUserIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…