@max1874/feishu 0.2.13 → 0.2.14
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/package.json +1 -1
- package/src/bot.ts +22 -9
- package/src/send.ts +5 -0
package/package.json
CHANGED
package/src/bot.ts
CHANGED
|
@@ -227,7 +227,7 @@ function parsePostContent(content: string): {
|
|
|
227
227
|
* Format merge_forward child messages into readable text.
|
|
228
228
|
*/
|
|
229
229
|
function formatMergeForwardContent(
|
|
230
|
-
messages: Array<{ content: string; contentType: string }>,
|
|
230
|
+
messages: Array<{ content: string; contentType: string; senderName?: string; senderId?: string }>,
|
|
231
231
|
): string {
|
|
232
232
|
if (messages.length === 0) {
|
|
233
233
|
return "[转发的聊天记录 - 无内容]";
|
|
@@ -236,20 +236,22 @@ function formatMergeForwardContent(
|
|
|
236
236
|
const lines: string[] = ["[转发的聊天记录]", "---"];
|
|
237
237
|
|
|
238
238
|
for (const msg of messages) {
|
|
239
|
+
const speaker = msg.senderName || msg.senderId || "未知";
|
|
240
|
+
|
|
239
241
|
if (msg.contentType === "text" || msg.contentType === "post") {
|
|
240
|
-
lines.push(msg.content);
|
|
242
|
+
lines.push(`${speaker}: ${msg.content}`);
|
|
241
243
|
} else if (msg.contentType === "image") {
|
|
242
|
-
lines.push(
|
|
244
|
+
lines.push(`${speaker}: [图片]`);
|
|
243
245
|
} else if (msg.contentType === "file") {
|
|
244
|
-
lines.push(
|
|
246
|
+
lines.push(`${speaker}: [文件]`);
|
|
245
247
|
} else if (msg.contentType === "audio") {
|
|
246
|
-
lines.push(
|
|
248
|
+
lines.push(`${speaker}: [语音]`);
|
|
247
249
|
} else if (msg.contentType === "video") {
|
|
248
|
-
lines.push(
|
|
250
|
+
lines.push(`${speaker}: [视频]`);
|
|
249
251
|
} else if (msg.contentType === "sticker") {
|
|
250
|
-
lines.push(
|
|
252
|
+
lines.push(`${speaker}: [表情]`);
|
|
251
253
|
} else {
|
|
252
|
-
lines.push(
|
|
254
|
+
lines.push(`${speaker}: [${msg.contentType}]`);
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
257
|
|
|
@@ -488,7 +490,18 @@ export async function handleFeishuMessage(params: {
|
|
|
488
490
|
cfg,
|
|
489
491
|
messageId: ctx.messageId,
|
|
490
492
|
});
|
|
491
|
-
|
|
493
|
+
|
|
494
|
+
// Resolve sender names for child messages (only when ID type is open_id)
|
|
495
|
+
const messagesWithNames = await Promise.all(
|
|
496
|
+
childMessages.map(async (msg) => ({
|
|
497
|
+
...msg,
|
|
498
|
+
senderName: (msg.senderId && msg.senderIdType === "open_id")
|
|
499
|
+
? await resolveFeishuSenderName({ feishuCfg, senderOpenId: msg.senderId, log })
|
|
500
|
+
: undefined,
|
|
501
|
+
}))
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
const formattedContent = formatMergeForwardContent(messagesWithNames);
|
|
492
505
|
ctx = { ...ctx, content: formattedContent };
|
|
493
506
|
log(`feishu: resolved merge_forward with ${childMessages.length} child message(s)`);
|
|
494
507
|
} catch (err) {
|
package/src/send.ts
CHANGED
|
@@ -22,6 +22,8 @@ export type FeishuMergeForwardMessage = {
|
|
|
22
22
|
content: string;
|
|
23
23
|
contentType: string;
|
|
24
24
|
upperMessageId?: string;
|
|
25
|
+
senderId?: string;
|
|
26
|
+
senderIdType?: string;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -124,6 +126,7 @@ export async function getMergeForwardMessagesFeishu(params: {
|
|
|
124
126
|
msg_type?: string;
|
|
125
127
|
body?: { content?: string };
|
|
126
128
|
upper_message_id?: string;
|
|
129
|
+
sender?: { id?: string; id_type?: string };
|
|
127
130
|
}>;
|
|
128
131
|
};
|
|
129
132
|
};
|
|
@@ -161,6 +164,8 @@ export async function getMergeForwardMessagesFeishu(params: {
|
|
|
161
164
|
content,
|
|
162
165
|
contentType: item.msg_type ?? "text",
|
|
163
166
|
upperMessageId: item.upper_message_id,
|
|
167
|
+
senderId: item.sender?.id,
|
|
168
|
+
senderIdType: item.sender?.id_type,
|
|
164
169
|
});
|
|
165
170
|
}
|
|
166
171
|
|