@max1874/feishu 0.2.14 → 0.2.16
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 +41 -3
- package/src/types.ts +1 -0
package/package.json
CHANGED
package/src/bot.ts
CHANGED
|
@@ -123,6 +123,22 @@ function parseMessageContent(content: string, messageType: string): string {
|
|
|
123
123
|
const { textContent } = parsePostContent(content);
|
|
124
124
|
return textContent;
|
|
125
125
|
}
|
|
126
|
+
// For media types, return a user-friendly description
|
|
127
|
+
if (messageType === "file") {
|
|
128
|
+
return `[File: ${parsed.file_name || "unknown"}]`;
|
|
129
|
+
}
|
|
130
|
+
if (messageType === "image") {
|
|
131
|
+
return "[Image]";
|
|
132
|
+
}
|
|
133
|
+
if (messageType === "audio") {
|
|
134
|
+
return "[Audio]";
|
|
135
|
+
}
|
|
136
|
+
if (messageType === "video") {
|
|
137
|
+
return "[Video]";
|
|
138
|
+
}
|
|
139
|
+
if (messageType === "sticker") {
|
|
140
|
+
return "[Sticker]";
|
|
141
|
+
}
|
|
126
142
|
return content;
|
|
127
143
|
} catch {
|
|
128
144
|
return content;
|
|
@@ -395,6 +411,7 @@ async function resolveFeishuMediaList(params: {
|
|
|
395
411
|
path: saved.path,
|
|
396
412
|
contentType: saved.contentType,
|
|
397
413
|
placeholder: inferPlaceholder(messageType),
|
|
414
|
+
fileName,
|
|
398
415
|
});
|
|
399
416
|
|
|
400
417
|
log?.(`feishu: downloaded ${messageType} media, saved to ${saved.path}`);
|
|
@@ -625,22 +642,43 @@ export async function handleFeishuMessage(params: {
|
|
|
625
642
|
maxBytes: mediaMaxBytes,
|
|
626
643
|
log,
|
|
627
644
|
});
|
|
628
|
-
const mediaPayload = buildFeishuMediaPayload(mediaList);
|
|
629
645
|
|
|
630
646
|
// Fetch quoted/replied message content if parentId exists
|
|
631
647
|
let quotedContent: string | undefined;
|
|
648
|
+
let quotedMediaList: FeishuMediaInfo[] = [];
|
|
649
|
+
|
|
632
650
|
if (ctx.parentId) {
|
|
633
651
|
try {
|
|
634
652
|
const quotedMsg = await getMessageFeishu({ cfg, messageId: ctx.parentId });
|
|
635
653
|
if (quotedMsg) {
|
|
636
|
-
|
|
637
|
-
|
|
654
|
+
// Parse quoted content for display (text-friendly)
|
|
655
|
+
quotedContent = parseMessageContent(quotedMsg.content, quotedMsg.contentType);
|
|
656
|
+
log(`feishu: fetched quoted message (${quotedMsg.contentType}): ${quotedContent?.slice(0, 100)}`);
|
|
657
|
+
|
|
658
|
+
// If quoted message is a media type, download the file
|
|
659
|
+
// Use raw content for media resolution (contains file_key/image_key)
|
|
660
|
+
const mediaTypes = ["image", "file", "audio", "video", "sticker", "post"];
|
|
661
|
+
if (mediaTypes.includes(quotedMsg.contentType)) {
|
|
662
|
+
log(`feishu: quoted message is media type, downloading...`);
|
|
663
|
+
quotedMediaList = await resolveFeishuMediaList({
|
|
664
|
+
cfg,
|
|
665
|
+
messageId: ctx.parentId,
|
|
666
|
+
messageType: quotedMsg.contentType,
|
|
667
|
+
content: quotedMsg.content, // Use raw content for media keys
|
|
668
|
+
maxBytes: mediaMaxBytes,
|
|
669
|
+
log,
|
|
670
|
+
});
|
|
671
|
+
}
|
|
638
672
|
}
|
|
639
673
|
} catch (err) {
|
|
640
674
|
log(`feishu: failed to fetch quoted message: ${String(err)}`);
|
|
641
675
|
}
|
|
642
676
|
}
|
|
643
677
|
|
|
678
|
+
// Merge quoted media with current message media
|
|
679
|
+
const allMediaList = [...mediaList, ...quotedMediaList];
|
|
680
|
+
const mediaPayload = buildFeishuMediaPayload(allMediaList);
|
|
681
|
+
|
|
644
682
|
const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
645
683
|
|
|
646
684
|
// Build message body with quoted content if available
|