@modelzen/feishu-codex-bridge 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +50 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10061,7 +10061,7 @@ function extractMessageText(msgType, content, mentions) {
|
|
|
10061
10061
|
case "sticker":
|
|
10062
10062
|
return "[\u8868\u60C5]";
|
|
10063
10063
|
case "interactive":
|
|
10064
|
-
return "[\u5361\u7247\u6D88\u606F]";
|
|
10064
|
+
return extractCardText(parsed) || "[\u5361\u7247\u6D88\u606F]";
|
|
10065
10065
|
case "share_chat":
|
|
10066
10066
|
return "[\u5206\u4EAB\u7FA4\u540D\u7247]";
|
|
10067
10067
|
case "share_user":
|
|
@@ -10123,6 +10123,55 @@ function nodeToText(node) {
|
|
|
10123
10123
|
return typeof n.text === "string" ? n.text : "";
|
|
10124
10124
|
}
|
|
10125
10125
|
}
|
|
10126
|
+
var CARD_UPGRADE_HINT = "\u8BF7\u5347\u7EA7\u81F3\u6700\u65B0\u7248\u672C\u5BA2\u6237\u7AEF";
|
|
10127
|
+
function extractCardText(parsed) {
|
|
10128
|
+
if (!parsed || typeof parsed !== "object") return "";
|
|
10129
|
+
const obj = parsed;
|
|
10130
|
+
const parts = [];
|
|
10131
|
+
const title = textValue(obj.title);
|
|
10132
|
+
if (title.trim()) parts.push(title.trim());
|
|
10133
|
+
if (Array.isArray(obj.elements)) {
|
|
10134
|
+
for (const line of obj.elements) {
|
|
10135
|
+
const nodes = Array.isArray(line) ? line : [line];
|
|
10136
|
+
const lineText = nodes.map(cardNodeToText).join("").trim();
|
|
10137
|
+
if (lineText && !lineText.includes(CARD_UPGRADE_HINT)) parts.push(lineText);
|
|
10138
|
+
}
|
|
10139
|
+
}
|
|
10140
|
+
return parts.join("\n").trim();
|
|
10141
|
+
}
|
|
10142
|
+
function textValue(t) {
|
|
10143
|
+
if (typeof t === "string") return t;
|
|
10144
|
+
if (t && typeof t === "object") {
|
|
10145
|
+
const c = t.content;
|
|
10146
|
+
if (typeof c === "string") return c;
|
|
10147
|
+
}
|
|
10148
|
+
return "";
|
|
10149
|
+
}
|
|
10150
|
+
function cardNodeToText(node) {
|
|
10151
|
+
if (typeof node === "string") return node;
|
|
10152
|
+
if (!node || typeof node !== "object") return "";
|
|
10153
|
+
const n = node;
|
|
10154
|
+
switch (n.tag) {
|
|
10155
|
+
case "text":
|
|
10156
|
+
return textValue(n.text);
|
|
10157
|
+
case "a":
|
|
10158
|
+
return textValue(n.text) || (typeof n.href === "string" ? n.href : "");
|
|
10159
|
+
case "at": {
|
|
10160
|
+
const name = typeof n.user_name === "string" ? n.user_name : "";
|
|
10161
|
+
return name ? `@${name}` : "@\u67D0\u4EBA";
|
|
10162
|
+
}
|
|
10163
|
+
case "note":
|
|
10164
|
+
return Array.isArray(n.elements) ? n.elements.map(cardNodeToText).join("") : "";
|
|
10165
|
+
case "button": {
|
|
10166
|
+
const label = textValue(n.text);
|
|
10167
|
+
return label ? `[\u6309\u94AE\uFF1A${label}]` : "";
|
|
10168
|
+
}
|
|
10169
|
+
case "img":
|
|
10170
|
+
return "";
|
|
10171
|
+
default:
|
|
10172
|
+
return textValue(n.text);
|
|
10173
|
+
}
|
|
10174
|
+
}
|
|
10126
10175
|
function replaceMentions(text, mentions) {
|
|
10127
10176
|
if (!text || !mentions?.length) return text;
|
|
10128
10177
|
let out = text;
|