@max1874/feishu 0.2.15 → 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 +40 -3
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;
|
|
@@ -626,22 +642,43 @@ export async function handleFeishuMessage(params: {
|
|
|
626
642
|
maxBytes: mediaMaxBytes,
|
|
627
643
|
log,
|
|
628
644
|
});
|
|
629
|
-
const mediaPayload = buildFeishuMediaPayload(mediaList);
|
|
630
645
|
|
|
631
646
|
// Fetch quoted/replied message content if parentId exists
|
|
632
647
|
let quotedContent: string | undefined;
|
|
648
|
+
let quotedMediaList: FeishuMediaInfo[] = [];
|
|
649
|
+
|
|
633
650
|
if (ctx.parentId) {
|
|
634
651
|
try {
|
|
635
652
|
const quotedMsg = await getMessageFeishu({ cfg, messageId: ctx.parentId });
|
|
636
653
|
if (quotedMsg) {
|
|
637
|
-
|
|
638
|
-
|
|
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
|
+
}
|
|
639
672
|
}
|
|
640
673
|
} catch (err) {
|
|
641
674
|
log(`feishu: failed to fetch quoted message: ${String(err)}`);
|
|
642
675
|
}
|
|
643
676
|
}
|
|
644
677
|
|
|
678
|
+
// Merge quoted media with current message media
|
|
679
|
+
const allMediaList = [...mediaList, ...quotedMediaList];
|
|
680
|
+
const mediaPayload = buildFeishuMediaPayload(allMediaList);
|
|
681
|
+
|
|
645
682
|
const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
646
683
|
|
|
647
684
|
// Build message body with quoted content if available
|