koishi-plugin-nitter 0.0.18 → 0.0.19
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/lib/download.d.ts +1 -1
- package/lib/index.js +3 -22
- package/package.json +2 -2
package/lib/download.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function downloadImagesToBase64(imageUrls:
|
|
1
|
+
export declare function downloadImagesToBase64(imageUrls: any): Promise<any[]>;
|
|
2
2
|
export declare function downloadVideosToTempFiles(videoUrls: string[], tempDir: string, maxSize?: number): Promise<string[]>;
|
|
3
3
|
export declare function cleanupTempFiles(files: Array<string | null>): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -176,19 +176,6 @@ var import_fluent_ffmpeg = __toESM(require("fluent-ffmpeg"));
|
|
|
176
176
|
var import_path = __toESM(require("path"));
|
|
177
177
|
var import_promises = __toESM(require("fs/promises"));
|
|
178
178
|
var import_axios2 = __toESM(require("axios"));
|
|
179
|
-
async function downloadImagesToBase64(imageUrls) {
|
|
180
|
-
return Promise.all(imageUrls.map(async (url) => {
|
|
181
|
-
try {
|
|
182
|
-
const response = await import_axios2.default.get(url, { responseType: "arraybuffer" });
|
|
183
|
-
const base64 = Buffer.from(response.data).toString("base64");
|
|
184
|
-
const contentType = response.headers?.["content-type"] || "image/jpeg";
|
|
185
|
-
return `data:${contentType};base64,${base64}`;
|
|
186
|
-
} catch {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
__name(downloadImagesToBase64, "downloadImagesToBase64");
|
|
192
179
|
async function downloadVideosToTempFiles(videoUrls, tempDir, maxSize = 20) {
|
|
193
180
|
await import_promises.default.mkdir(tempDir, { recursive: true });
|
|
194
181
|
const results = [];
|
|
@@ -413,13 +400,10 @@ function apply(ctx, config) {
|
|
|
413
400
|
await sendFunc(screenshotMsg);
|
|
414
401
|
const forwardMsg = [];
|
|
415
402
|
const videoUrls = pieces.filter((p) => p.type === "video").map((p) => p.url);
|
|
416
|
-
const imageUrls = pieces.filter((p) => p.type === "image").map((p) => p.url);
|
|
417
403
|
const tmpDir = config.tmpDir ?? "/shared/tmp";
|
|
418
|
-
const imageSources = imageUrls.length ? await downloadImagesToBase64(imageUrls) : [];
|
|
419
404
|
if (videoUrls.length) {
|
|
420
405
|
videoFiles = await downloadVideosToTempFiles(videoUrls, tmpDir, config.maxSize ?? 20);
|
|
421
406
|
}
|
|
422
|
-
let iIdx = 0;
|
|
423
407
|
let vIdx = 0;
|
|
424
408
|
for (const p of pieces) {
|
|
425
409
|
if (p.type === "account") {
|
|
@@ -427,12 +411,9 @@ function apply(ctx, config) {
|
|
|
427
411
|
} else if (p.type === "text") {
|
|
428
412
|
forwardMsg.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("message", { children: p.text }));
|
|
429
413
|
} else if (p.type === "image") {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("message", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src }) })
|
|
434
|
-
);
|
|
435
|
-
}
|
|
414
|
+
forwardMsg.push(
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("message", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: p.url }) })
|
|
416
|
+
);
|
|
436
417
|
} else if (p.type === "video") {
|
|
437
418
|
const file = videoFiles[vIdx++];
|
|
438
419
|
if (file) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-nitter",
|
|
3
3
|
"description": "使用Rettiwt-API订阅推文,并使用nitter渲染",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.19",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"fluent-ffmpeg": "^2.1.3",
|
|
26
26
|
"node-cron": "^4.2.1",
|
|
27
|
-
"rettiwt-api": "^7.
|
|
27
|
+
"rettiwt-api": "^7.1.2"
|
|
28
28
|
}
|
|
29
29
|
}
|