@lmcl/ailo-mcp-feishu 0.0.6 → 0.0.7
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/feishu-handler.js +10 -6
- package/package.json +1 -1
- package/src/feishu-handler.ts +11 -6
package/dist/feishu-handler.js
CHANGED
|
@@ -542,22 +542,26 @@ export class FeishuHandler {
|
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
/**
|
|
545
|
-
* 获取消息资源并转为 attachment。有 file_name
|
|
545
|
+
* 获取消息资源并转为 attachment。有 file_name 时用原名;无则用默认名(如图片用 image_xxx.png)。
|
|
546
|
+
* 下载到本地后传绝对路径给 LLM,否则 LLM 无法访问。
|
|
546
547
|
*/
|
|
547
548
|
async fetchMessageResourceAttachment(messageId, fileKey, resourceType, aidoType, fileName) {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
const pathOrNull = await this.downloadToCache(messageId, fileKey, resourceType, aidoType, fileName);
|
|
549
|
+
const effectiveName = fileName?.trim() || this.defaultFileNameForResource(aidoType, fileKey);
|
|
550
|
+
const pathOrNull = await this.downloadToCache(messageId, fileKey, resourceType, aidoType, effectiveName);
|
|
552
551
|
if (pathOrNull) {
|
|
553
552
|
return {
|
|
554
553
|
type: aidoType,
|
|
555
|
-
path: pathOrNull,
|
|
554
|
+
path: path.resolve(pathOrNull),
|
|
556
555
|
name: path.basename(pathOrNull),
|
|
557
556
|
};
|
|
558
557
|
}
|
|
559
558
|
return { type: aidoType, ref: `im:${messageId}:${fileKey}:${aidoType}`, channel: "feishu" };
|
|
560
559
|
}
|
|
560
|
+
/** 无 file_name 时的默认文件名(如图片、无名的文件等) */
|
|
561
|
+
defaultFileNameForResource(aidoType, fileKey) {
|
|
562
|
+
const ext = { image: "png", audio: "mp3", video: "mp4", file: "bin" }[aidoType] ?? "bin";
|
|
563
|
+
return `${aidoType}_${fileKey.slice(-12)}.${ext}`;
|
|
564
|
+
}
|
|
561
565
|
/**
|
|
562
566
|
* 使用飞书 WebSocket 长连接接收事件,无需配置回调地址。
|
|
563
567
|
* 需在飞书开放平台「事件与回调」中选择「使用长连接接收事件」并保存(本客户端需在线)。
|
package/package.json
CHANGED
package/src/feishu-handler.ts
CHANGED
|
@@ -634,7 +634,8 @@ export class FeishuHandler implements BridgeHandler {
|
|
|
634
634
|
}
|
|
635
635
|
|
|
636
636
|
/**
|
|
637
|
-
* 获取消息资源并转为 attachment。有 file_name
|
|
637
|
+
* 获取消息资源并转为 attachment。有 file_name 时用原名;无则用默认名(如图片用 image_xxx.png)。
|
|
638
|
+
* 下载到本地后传绝对路径给 LLM,否则 LLM 无法访问。
|
|
638
639
|
*/
|
|
639
640
|
private async fetchMessageResourceAttachment(
|
|
640
641
|
messageId: string,
|
|
@@ -643,26 +644,30 @@ export class FeishuHandler implements BridgeHandler {
|
|
|
643
644
|
aidoType: "image" | "audio" | "video" | "file",
|
|
644
645
|
fileName?: string
|
|
645
646
|
): Promise<FeishuAttachment | null> {
|
|
646
|
-
|
|
647
|
-
return { type: aidoType, ref: `im:${messageId}:${fileKey}:${aidoType}`, channel: "feishu" };
|
|
648
|
-
}
|
|
647
|
+
const effectiveName = fileName?.trim() || this.defaultFileNameForResource(aidoType, fileKey);
|
|
649
648
|
const pathOrNull = await this.downloadToCache(
|
|
650
649
|
messageId,
|
|
651
650
|
fileKey,
|
|
652
651
|
resourceType,
|
|
653
652
|
aidoType,
|
|
654
|
-
|
|
653
|
+
effectiveName
|
|
655
654
|
);
|
|
656
655
|
if (pathOrNull) {
|
|
657
656
|
return {
|
|
658
657
|
type: aidoType,
|
|
659
|
-
path: pathOrNull,
|
|
658
|
+
path: path.resolve(pathOrNull),
|
|
660
659
|
name: path.basename(pathOrNull),
|
|
661
660
|
};
|
|
662
661
|
}
|
|
663
662
|
return { type: aidoType, ref: `im:${messageId}:${fileKey}:${aidoType}`, channel: "feishu" };
|
|
664
663
|
}
|
|
665
664
|
|
|
665
|
+
/** 无 file_name 时的默认文件名(如图片、无名的文件等) */
|
|
666
|
+
private defaultFileNameForResource(aidoType: string, fileKey: string): string {
|
|
667
|
+
const ext = { image: "png", audio: "mp3", video: "mp4", file: "bin" }[aidoType] ?? "bin";
|
|
668
|
+
return `${aidoType}_${fileKey.slice(-12)}.${ext}`;
|
|
669
|
+
}
|
|
670
|
+
|
|
666
671
|
/**
|
|
667
672
|
* 使用飞书 WebSocket 长连接接收事件,无需配置回调地址。
|
|
668
673
|
* 需在飞书开放平台「事件与回调」中选择「使用长连接接收事件」并保存(本客户端需在线)。
|