@luckylillia-dev/plugin-onebot11 1.0.3 → 1.0.4
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/index.js +23 -19
- package/lib/index.js.map +3 -3
- package/package.json +14 -2
package/lib/index.js
CHANGED
|
@@ -5489,7 +5489,7 @@ var require_sift = __commonJS({
|
|
|
5489
5489
|
// src/adapter.ts
|
|
5490
5490
|
import { Service as Service2 } from "cordis";
|
|
5491
5491
|
|
|
5492
|
-
// _integration/ntqq/lib/chunk-
|
|
5492
|
+
// _integration/ntqq/lib/chunk-ZRREWJ3L.js
|
|
5493
5493
|
import path from "node:path";
|
|
5494
5494
|
import { defaultFormatters } from "cordis";
|
|
5495
5495
|
|
|
@@ -6460,10 +6460,10 @@ function hasBuffer() {
|
|
|
6460
6460
|
}
|
|
6461
6461
|
if (!hasBuffer()) throw new Error("Buffer is not available in this environment. TypeProto requires Buffer API support.");
|
|
6462
6462
|
|
|
6463
|
-
// _integration/ntqq/lib/chunk-
|
|
6463
|
+
// _integration/ntqq/lib/chunk-ZRREWJ3L.js
|
|
6464
6464
|
import pathLib from "node:path";
|
|
6465
6465
|
import { stat, copyFile, unlink, mkdir } from "node:fs/promises";
|
|
6466
|
-
import
|
|
6466
|
+
import fs3 from "node:fs";
|
|
6467
6467
|
import fsPromise from "node:fs/promises";
|
|
6468
6468
|
import path3 from "node:path";
|
|
6469
6469
|
|
|
@@ -10836,8 +10836,8 @@ async function fileTypeFromFile(path6, options) {
|
|
|
10836
10836
|
return new FileTypeParser(options).fromFile(path6);
|
|
10837
10837
|
}
|
|
10838
10838
|
|
|
10839
|
-
// _integration/ntqq/lib/chunk-
|
|
10840
|
-
import * as
|
|
10839
|
+
// _integration/ntqq/lib/chunk-ZRREWJ3L.js
|
|
10840
|
+
import * as fs2 from "node:fs";
|
|
10841
10841
|
import * as path2 from "node:path";
|
|
10842
10842
|
import { randomUUID, createHash } from "node:crypto";
|
|
10843
10843
|
import { fileURLToPath } from "node:url";
|
|
@@ -10850,11 +10850,15 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
10850
10850
|
import { isNullable, noop } from "cosmokit";
|
|
10851
10851
|
import { isNonNullable } from "cosmokit";
|
|
10852
10852
|
import { defineProperty } from "cosmokit";
|
|
10853
|
+
var PLUGIN_DATA_KEY = "@luckylillia-dev+plugin-nt-protocol";
|
|
10853
10854
|
var DATA_DIR = path.resolve("data");
|
|
10854
|
-
var TEMP_DIR = path.join(DATA_DIR, "temp");
|
|
10855
10855
|
var LOG_DIR = path.join(DATA_DIR, "logs");
|
|
10856
|
-
var dbDir = path.join(DATA_DIR, "database");
|
|
10857
10856
|
var STATE_DIR = path.join(DATA_DIR, "state");
|
|
10857
|
+
var hostDataDir = path.join(DATA_DIR, "plugin-data", PLUGIN_DATA_KEY);
|
|
10858
|
+
var tempDir = path.join(hostDataDir, "temp");
|
|
10859
|
+
function getTempDir() {
|
|
10860
|
+
return tempDir;
|
|
10861
|
+
}
|
|
10858
10862
|
defaultFormatters.h = (value) => Buffer.isBuffer(value) ? value.toString("hex") : value == null ? "" : String(value);
|
|
10859
10863
|
var DEBUG_ARGV = process.argv.includes("--debug");
|
|
10860
10864
|
var LEVELS = { error: 0, warn: 1, info: 2, debug: 3 };
|
|
@@ -18678,7 +18682,7 @@ var processQueue = async () => {
|
|
|
18678
18682
|
const promises2 = jobs.map(async ({ filePath, resolve: resolve3, reject }) => {
|
|
18679
18683
|
let handle;
|
|
18680
18684
|
try {
|
|
18681
|
-
handle = await
|
|
18685
|
+
handle = await fs2.promises.open(path2.resolve(filePath), "r");
|
|
18682
18686
|
} catch (err) {
|
|
18683
18687
|
return reject(err);
|
|
18684
18688
|
}
|
|
@@ -18729,7 +18733,7 @@ function checkUriType(uri) {
|
|
|
18729
18733
|
/* FileURL */
|
|
18730
18734
|
};
|
|
18731
18735
|
}
|
|
18732
|
-
if (
|
|
18736
|
+
if (fs3.existsSync(uri)) {
|
|
18733
18737
|
return {
|
|
18734
18738
|
type: 5
|
|
18735
18739
|
/* Path */
|
|
@@ -18771,7 +18775,7 @@ async function uri2local(ctx, uri, needExt, fileName) {
|
|
|
18771
18775
|
const { type } = checkUriType(uri);
|
|
18772
18776
|
if (type === 1) {
|
|
18773
18777
|
const filePath = fileURLToPath(uri);
|
|
18774
|
-
if (!
|
|
18778
|
+
if (!fs3.existsSync(filePath)) {
|
|
18775
18779
|
return { success: false, errMsg: "\u8DEF\u5F84\u4E0D\u5B58\u5728", fileName: "", path: "", isLocal: false };
|
|
18776
18780
|
}
|
|
18777
18781
|
const fileName2 = path3.basename(filePath);
|
|
@@ -18785,12 +18789,12 @@ async function uri2local(ctx, uri, needExt, fileName) {
|
|
|
18785
18789
|
try {
|
|
18786
18790
|
const res = await fetchFile(uri);
|
|
18787
18791
|
if (fileName) {
|
|
18788
|
-
const filePath = path3.join(
|
|
18792
|
+
const filePath = path3.join(getTempDir(), randomUUID());
|
|
18789
18793
|
await fsPromise.writeFile(filePath, res.data);
|
|
18790
18794
|
return { success: true, errMsg: "", fileName, path: filePath, isLocal: false };
|
|
18791
18795
|
} else {
|
|
18792
18796
|
let fileName2 = randomUUID();
|
|
18793
|
-
let filePath = path3.join(
|
|
18797
|
+
let filePath = path3.join(getTempDir(), fileName2);
|
|
18794
18798
|
await fsPromise.writeFile(filePath, res.data);
|
|
18795
18799
|
if (needExt) {
|
|
18796
18800
|
const ext = (await getFileType(filePath)).ext;
|
|
@@ -18808,7 +18812,7 @@ async function uri2local(ctx, uri, needExt, fileName) {
|
|
|
18808
18812
|
}
|
|
18809
18813
|
if (type === 3) {
|
|
18810
18814
|
let filename = randomUUID();
|
|
18811
|
-
let filePath = path3.join(
|
|
18815
|
+
let filePath = path3.join(getTempDir(), filename);
|
|
18812
18816
|
const base64 = uri.replace(/^base64:\/\//, "");
|
|
18813
18817
|
await fsPromise.writeFile(filePath, base64, "base64");
|
|
18814
18818
|
if (needExt) {
|
|
@@ -18824,7 +18828,7 @@ async function uri2local(ctx, uri, needExt, fileName) {
|
|
|
18824
18828
|
if (capture) {
|
|
18825
18829
|
let filename = randomUUID();
|
|
18826
18830
|
const [, _type, base64] = capture;
|
|
18827
|
-
let filePath = path3.join(
|
|
18831
|
+
let filePath = path3.join(getTempDir(), filename);
|
|
18828
18832
|
await fsPromise.writeFile(filePath, base64, "base64");
|
|
18829
18833
|
if (needExt) {
|
|
18830
18834
|
const ext = (await getFileType(filePath)).ext;
|
|
@@ -18895,7 +18899,7 @@ async function getImageSize3(path6) {
|
|
|
18895
18899
|
}
|
|
18896
18900
|
async function getMd5HexFromFile(filePath) {
|
|
18897
18901
|
const hash = createHash("md5");
|
|
18898
|
-
const stream2 =
|
|
18902
|
+
const stream2 = fs3.createReadStream(filePath);
|
|
18899
18903
|
for await (const chunk of stream2) {
|
|
18900
18904
|
hash.update(chunk);
|
|
18901
18905
|
}
|
|
@@ -19164,7 +19168,7 @@ async function createThumb(ctx, videoFilePath) {
|
|
|
19164
19168
|
clearTimeout(timeout);
|
|
19165
19169
|
}
|
|
19166
19170
|
if (!thumbnail) ctx.logger.info("\u83B7\u53D6\u89C6\u9891\u5C01\u9762\u5931\u8D25\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u5C01\u9762");
|
|
19167
|
-
const thumbPath = path4.join(
|
|
19171
|
+
const thumbPath = path4.join(getTempDir(), randomUUID2() + (thumbnail ? ".png" : ".jpg"));
|
|
19168
19172
|
await writeFile(thumbPath, thumbnail ?? defaultVideoThumb);
|
|
19169
19173
|
return thumbPath;
|
|
19170
19174
|
}
|
|
@@ -19197,7 +19201,7 @@ async function encodeSilk(ctx, filePath) {
|
|
|
19197
19201
|
return { converted: false, path: filePath, duration };
|
|
19198
19202
|
}
|
|
19199
19203
|
const native = getSilkAddon(ctx);
|
|
19200
|
-
const output = path5.join(
|
|
19204
|
+
const output = path5.join(getTempDir(), randomUUID3() + ".silk");
|
|
19201
19205
|
ctx.logger.info(`\u8BED\u97F3\u6587\u4EF6 ${filePath} \u9700\u8981\u8F6C\u6362\u6210 SILK`);
|
|
19202
19206
|
try {
|
|
19203
19207
|
await native.transcodeAudio(filePath, output, { format: "silk" });
|
|
@@ -19289,7 +19293,7 @@ var SendElement;
|
|
|
19289
19293
|
ctx.logger.info("\u83B7\u53D6\u89C6\u9891\u4FE1\u606F\u5931\u8D25", e);
|
|
19290
19294
|
}
|
|
19291
19295
|
const md5 = await getMd5HexFromFile(filePath);
|
|
19292
|
-
const thumbDir =
|
|
19296
|
+
const thumbDir = getTempDir();
|
|
19293
19297
|
const thumbFilePath = pathLib.join(thumbDir, `${md5}_0.png`);
|
|
19294
19298
|
await mkdir(thumbDir, { recursive: true });
|
|
19295
19299
|
if (diyThumbPath) {
|
|
@@ -19454,7 +19458,7 @@ var SendElement;
|
|
|
19454
19458
|
SendElement2.file = file;
|
|
19455
19459
|
})(SendElement || (SendElement = {}));
|
|
19456
19460
|
|
|
19457
|
-
// _integration/ntqq/lib/chunk-
|
|
19461
|
+
// _integration/ntqq/lib/chunk-UQQCLM4G.js
|
|
19458
19462
|
import { isNullable as isNullable2 } from "cosmokit";
|
|
19459
19463
|
import z from "schemastery";
|
|
19460
19464
|
import { pathToFileURL } from "node:url";
|