@ynhcj/xiaoyi-channel 0.0.52-next → 0.0.53-next
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/src/bot.js +1 -0
- package/dist/src/file-download.js +4 -5
- package/package.json +1 -1
package/dist/src/bot.js
CHANGED
|
@@ -178,6 +178,7 @@ export async function handleXYMessage(params) {
|
|
|
178
178
|
const fileParts = extractFileParts(parsed.parts);
|
|
179
179
|
// Download files to local disk
|
|
180
180
|
const downloadedFiles = await downloadFilesFromParts(fileParts);
|
|
181
|
+
console.log("Downloaded files:", JSON.stringify(downloadedFiles, null, 2));
|
|
181
182
|
const mediaPayload = buildXYMediaPayload(downloadedFiles);
|
|
182
183
|
// Resolve envelope format options (following feishu pattern)
|
|
183
184
|
const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
3
|
import fs from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { logger } from "./utils/logger.js";
|
|
6
5
|
/**
|
|
7
6
|
* Download a file from URL to local path.
|
|
8
7
|
*/
|
|
@@ -18,14 +17,14 @@ export async function downloadFile(url, destPath) {
|
|
|
18
17
|
const arrayBuffer = await response.arrayBuffer();
|
|
19
18
|
const buffer = Buffer.from(arrayBuffer);
|
|
20
19
|
await fs.writeFile(destPath, buffer);
|
|
21
|
-
|
|
20
|
+
console.log(`File downloaded successfully: ${destPath}`);
|
|
22
21
|
}
|
|
23
22
|
catch (error) {
|
|
24
23
|
if (error.name === 'AbortError') {
|
|
25
|
-
|
|
24
|
+
console.log(`Download timeout (30s) for ${url}`);
|
|
26
25
|
throw new Error(`Download timeout after 30 seconds`);
|
|
27
26
|
}
|
|
28
|
-
|
|
27
|
+
console.log(`Failed to download file from ${url}:`, error);
|
|
29
28
|
throw error;
|
|
30
29
|
}
|
|
31
30
|
finally {
|
|
@@ -54,7 +53,7 @@ export async function downloadFilesFromParts(fileParts, tempDir = "/tmp/xy_chann
|
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
55
|
catch (error) {
|
|
57
|
-
|
|
56
|
+
console.log(`Failed to download file ${name}:`, error);
|
|
58
57
|
// Continue with other files
|
|
59
58
|
}
|
|
60
59
|
}
|