/** * 空运群出站报文:禁止 stream(企微会加「内容由AI生成」和赞踩)。 * 只发 markdown,且不带 feedback。 * 有这次 @ 的 req_id 才走 aibot_respond_msg,群里才会引用原消息。 */ function pickReplyReqId({ fromCaller, fromChat, lastAny }) { const caller = String(fromCaller || "").trim(); if (caller) { return caller; } const chat = String(fromChat || "").trim(); if (chat) { return chat; } return String(lastAny || "").trim(); } function buildGroupMessageFrame({ chatId, content, callbackReqId, reqId }) { const text = String(content || ""); const markdown = { content: text }; if (callbackReqId) { return { cmd: "aibot_respond_msg", headers: { req_id: callbackReqId }, body: { chatid: chatId, chat_type: 2, msgtype: "markdown", markdown, }, }; } return { cmd: "aibot_send_msg", headers: { req_id: reqId || "aibot_send_msg" }, body: { chatid: chatId, chat_type: 2, msgtype: "markdown", markdown, }, }; } module.exports = { buildGroupMessageFrame, pickReplyReqId };