@max1874/feishu 0.2.13 → 0.2.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@max1874/feishu",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Feishu/Lark channel plugin",
6
6
  "license": "MIT",
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(`[${msg.contentType}]`);
254
+ lines.push(`${speaker}: [${msg.contentType}]`);
253
255
  }
254
256
  }
255
257
 
@@ -393,6 +395,7 @@ async function resolveFeishuMediaList(params: {
393
395
  path: saved.path,
394
396
  contentType: saved.contentType,
395
397
  placeholder: inferPlaceholder(messageType),
398
+ fileName,
396
399
  });
397
400
 
398
401
  log?.(`feishu: downloaded ${messageType} media, saved to ${saved.path}`);
@@ -488,7 +491,18 @@ export async function handleFeishuMessage(params: {
488
491
  cfg,
489
492
  messageId: ctx.messageId,
490
493
  });
491
- const formattedContent = formatMergeForwardContent(childMessages);
494
+
495
+ // Resolve sender names for child messages (only when ID type is open_id)
496
+ const messagesWithNames = await Promise.all(
497
+ childMessages.map(async (msg) => ({
498
+ ...msg,
499
+ senderName: (msg.senderId && msg.senderIdType === "open_id")
500
+ ? await resolveFeishuSenderName({ feishuCfg, senderOpenId: msg.senderId, log })
501
+ : undefined,
502
+ }))
503
+ );
504
+
505
+ const formattedContent = formatMergeForwardContent(messagesWithNames);
492
506
  ctx = { ...ctx, content: formattedContent };
493
507
  log(`feishu: resolved merge_forward with ${childMessages.length} child message(s)`);
494
508
  } 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
 
package/src/types.ts CHANGED
@@ -52,4 +52,5 @@ export type FeishuMediaInfo = {
52
52
  path: string;
53
53
  contentType?: string;
54
54
  placeholder: string;
55
+ fileName?: string;
55
56
  };