node-karin 1.9.9 → 1.9.11
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +115 -52
- package/dist/index.mjs +500 -394
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -893,30 +893,30 @@ var init_watch = __esm({
|
|
|
893
893
|
"src/utils/fs/watch.ts"() {
|
|
894
894
|
init_require();
|
|
895
895
|
cache2 = /* @__PURE__ */ new Map();
|
|
896
|
-
watch = (
|
|
897
|
-
const isWatch = cache2.get(
|
|
896
|
+
watch = (file2, fnc2, options) => {
|
|
897
|
+
const isWatch = cache2.get(file2);
|
|
898
898
|
if (isWatch) {
|
|
899
899
|
isWatch.close();
|
|
900
|
-
cache2.delete(
|
|
900
|
+
cache2.delete(file2);
|
|
901
901
|
}
|
|
902
|
-
const watcher2 = chokidar.watch(
|
|
903
|
-
cache2.set(
|
|
902
|
+
const watcher2 = chokidar.watch(file2);
|
|
903
|
+
cache2.set(file2, watcher2);
|
|
904
904
|
watcher2.on("change", async () => {
|
|
905
|
-
logger.info(`[watch][change] ${path4.relative(process.cwd(),
|
|
906
|
-
const oldData = requireFileSync(
|
|
907
|
-
clearRequireFile(
|
|
908
|
-
const newData = requireFileSync(
|
|
905
|
+
logger.info(`[watch][change] ${path4.relative(process.cwd(), file2).replace(/\\/g, "/")}`);
|
|
906
|
+
const oldData = requireFileSync(file2, { ...options, readCache: true });
|
|
907
|
+
clearRequireFile(file2);
|
|
908
|
+
const newData = requireFileSync(file2, { ...options, force: true });
|
|
909
909
|
typeof fnc2 === "function" && fnc2(oldData, newData);
|
|
910
910
|
});
|
|
911
911
|
watcher2.on("unlink", () => {
|
|
912
|
-
logger.info(`[watch][unlink] ${path4.relative(process.cwd(),
|
|
913
|
-
clearRequireFile(
|
|
912
|
+
logger.info(`[watch][unlink] ${path4.relative(process.cwd(), file2).replace(/\\/g, "/")}`);
|
|
913
|
+
clearRequireFile(file2);
|
|
914
914
|
});
|
|
915
915
|
watcher2.once("close", () => {
|
|
916
|
-
cache2.delete(
|
|
917
|
-
clearRequireFile(
|
|
916
|
+
cache2.delete(file2);
|
|
917
|
+
clearRequireFile(file2);
|
|
918
918
|
});
|
|
919
|
-
return new Watch(
|
|
919
|
+
return new Watch(file2, watcher2, options);
|
|
920
920
|
};
|
|
921
921
|
watchAndMerge = (dynamicFile, defaultCFile, fnc2) => {
|
|
922
922
|
const watcher2 = watch(dynamicFile, fnc2);
|
|
@@ -926,9 +926,9 @@ var init_watch = __esm({
|
|
|
926
926
|
watcher;
|
|
927
927
|
file;
|
|
928
928
|
options;
|
|
929
|
-
constructor(
|
|
929
|
+
constructor(file2, watcher2, options) {
|
|
930
930
|
this.watcher = watcher2;
|
|
931
|
-
this.file =
|
|
931
|
+
this.file = file2;
|
|
932
932
|
this.options = options;
|
|
933
933
|
}
|
|
934
934
|
/**
|
|
@@ -983,25 +983,25 @@ var init_watch = __esm({
|
|
|
983
983
|
var exists, isDir, isFile, mkdir, existToMkdir;
|
|
984
984
|
var init_fsPromises = __esm({
|
|
985
985
|
"src/utils/fs/fsPromises.ts"() {
|
|
986
|
-
exists = async (
|
|
986
|
+
exists = async (file2) => {
|
|
987
987
|
try {
|
|
988
|
-
await fs5.promises.access(
|
|
988
|
+
await fs5.promises.access(file2, fs5.constants.F_OK);
|
|
989
989
|
return true;
|
|
990
990
|
} catch {
|
|
991
991
|
return false;
|
|
992
992
|
}
|
|
993
993
|
};
|
|
994
|
-
isDir = async (
|
|
994
|
+
isDir = async (file2) => {
|
|
995
995
|
try {
|
|
996
|
-
const stat = await fs5.promises.stat(
|
|
996
|
+
const stat = await fs5.promises.stat(file2);
|
|
997
997
|
return stat.isDirectory();
|
|
998
998
|
} catch {
|
|
999
999
|
return false;
|
|
1000
1000
|
}
|
|
1001
1001
|
};
|
|
1002
|
-
isFile = async (
|
|
1002
|
+
isFile = async (file2) => {
|
|
1003
1003
|
try {
|
|
1004
|
-
const stat = await fs5.promises.stat(
|
|
1004
|
+
const stat = await fs5.promises.stat(file2);
|
|
1005
1005
|
return stat.isFile();
|
|
1006
1006
|
} catch {
|
|
1007
1007
|
return false;
|
|
@@ -1015,9 +1015,9 @@ var init_fsPromises = __esm({
|
|
|
1015
1015
|
return false;
|
|
1016
1016
|
}
|
|
1017
1017
|
};
|
|
1018
|
-
existToMkdir = async (
|
|
1018
|
+
existToMkdir = async (file2) => {
|
|
1019
1019
|
try {
|
|
1020
|
-
if (!await exists(
|
|
1020
|
+
if (!await exists(file2)) await mkdir(file2);
|
|
1021
1021
|
return true;
|
|
1022
1022
|
} catch {
|
|
1023
1023
|
return false;
|
|
@@ -1028,19 +1028,19 @@ var init_fsPromises = __esm({
|
|
|
1028
1028
|
var existsSync, isDirSync, isFileSync, mkdirSync, existToMkdirSync, rmSync;
|
|
1029
1029
|
var init_fsSync = __esm({
|
|
1030
1030
|
"src/utils/fs/fsSync.ts"() {
|
|
1031
|
-
existsSync = (
|
|
1032
|
-
return fs5.existsSync(
|
|
1031
|
+
existsSync = (file2) => {
|
|
1032
|
+
return fs5.existsSync(file2);
|
|
1033
1033
|
};
|
|
1034
|
-
isDirSync = (
|
|
1034
|
+
isDirSync = (file2) => {
|
|
1035
1035
|
try {
|
|
1036
|
-
return fs5.statSync(
|
|
1036
|
+
return fs5.statSync(file2).isDirectory();
|
|
1037
1037
|
} catch {
|
|
1038
1038
|
return false;
|
|
1039
1039
|
}
|
|
1040
1040
|
};
|
|
1041
|
-
isFileSync = (
|
|
1041
|
+
isFileSync = (file2) => {
|
|
1042
1042
|
try {
|
|
1043
|
-
return fs5.statSync(
|
|
1043
|
+
return fs5.statSync(file2).isFile();
|
|
1044
1044
|
} catch {
|
|
1045
1045
|
return false;
|
|
1046
1046
|
}
|
|
@@ -1053,9 +1053,9 @@ var init_fsSync = __esm({
|
|
|
1053
1053
|
return false;
|
|
1054
1054
|
}
|
|
1055
1055
|
};
|
|
1056
|
-
existToMkdirSync = (
|
|
1056
|
+
existToMkdirSync = (file2) => {
|
|
1057
1057
|
try {
|
|
1058
|
-
if (!fs5.existsSync(
|
|
1058
|
+
if (!fs5.existsSync(file2)) mkdirSync(file2);
|
|
1059
1059
|
return true;
|
|
1060
1060
|
} catch {
|
|
1061
1061
|
return false;
|
|
@@ -1089,13 +1089,13 @@ var init_file = __esm({
|
|
|
1089
1089
|
downFile = async (fileUrl, savePath, param = {}) => {
|
|
1090
1090
|
return downloadFile(fileUrl, savePath, { ...param, returnBoolean: true });
|
|
1091
1091
|
};
|
|
1092
|
-
absPath = (
|
|
1093
|
-
|
|
1094
|
-
if (
|
|
1095
|
-
|
|
1096
|
-
if (absPath2)
|
|
1097
|
-
if (prefix)
|
|
1098
|
-
return
|
|
1092
|
+
absPath = (file2, absPath2 = true, prefix = false) => {
|
|
1093
|
+
file2 = file2.replace(/\\/g, "/");
|
|
1094
|
+
if (file2.startsWith("file://")) file2 = file2.replace(sep, "");
|
|
1095
|
+
file2 = path4.normalize(file2);
|
|
1096
|
+
if (absPath2) file2 = path4.resolve(file2);
|
|
1097
|
+
if (prefix) file2 = "file://" + file2;
|
|
1098
|
+
return file2.replace(/\\/g, "/");
|
|
1099
1099
|
};
|
|
1100
1100
|
createPluginDir = async (name, files) => {
|
|
1101
1101
|
if (!Array.isArray(files)) files = ["config", "data", "resources"];
|
|
@@ -1106,8 +1106,8 @@ var init_file = __esm({
|
|
|
1106
1106
|
const [orgName, pkgName] = name.split("/");
|
|
1107
1107
|
pluginPath = path4.join(karinPathBase, orgName, pkgName);
|
|
1108
1108
|
}
|
|
1109
|
-
await Promise.all(files.map((
|
|
1110
|
-
const filePath = path4.join(pluginPath,
|
|
1109
|
+
await Promise.all(files.map((file2) => {
|
|
1110
|
+
const filePath = path4.join(pluginPath, file2);
|
|
1111
1111
|
if (!fs5.existsSync(filePath)) return fs5.promises.mkdir(filePath, { recursive: true });
|
|
1112
1112
|
return Promise.resolve();
|
|
1113
1113
|
}));
|
|
@@ -1116,29 +1116,29 @@ var init_file = __esm({
|
|
|
1116
1116
|
if (!fs5.existsSync(filePath)) {
|
|
1117
1117
|
throw new Error(`\u8DEF\u5F84\u4E0D\u5B58\u5728: ${filePath}`);
|
|
1118
1118
|
}
|
|
1119
|
-
let files = fs5.readdirSync(filePath, { withFileTypes: true }).filter((
|
|
1119
|
+
let files = fs5.readdirSync(filePath, { withFileTypes: true }).filter((file2) => file2.isFile()).map((file2) => file2.name);
|
|
1120
1120
|
if (suffixs.length) {
|
|
1121
1121
|
const normalizedSuffixs = suffixs.map((suffix) => suffix.startsWith(".") ? suffix : `.${suffix}`);
|
|
1122
|
-
files = files.filter((
|
|
1123
|
-
const suffix = path4.extname(
|
|
1122
|
+
files = files.filter((file2) => {
|
|
1123
|
+
const suffix = path4.extname(file2);
|
|
1124
1124
|
return suffix && normalizedSuffixs.includes(suffix);
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
1127
1127
|
return files;
|
|
1128
1128
|
};
|
|
1129
1129
|
copyFilesSync = (files, defaulPath, userPath) => {
|
|
1130
|
-
files.forEach((
|
|
1131
|
-
const defaulFile = path4.join(defaulPath,
|
|
1132
|
-
const userFile = path4.join(userPath,
|
|
1130
|
+
files.forEach((file2) => {
|
|
1131
|
+
const defaulFile = path4.join(defaulPath, file2);
|
|
1132
|
+
const userFile = path4.join(userPath, file2);
|
|
1133
1133
|
if (!fs5.existsSync(userFile)) {
|
|
1134
1134
|
fs5.copyFileSync(defaulFile, userFile);
|
|
1135
1135
|
}
|
|
1136
1136
|
});
|
|
1137
1137
|
};
|
|
1138
1138
|
copyFiles = async (files, defaulPath, userPath) => {
|
|
1139
|
-
await Promise.all(files.map(async (
|
|
1140
|
-
const defaulFile = path4.join(defaulPath,
|
|
1141
|
-
const userFile = path4.join(userPath,
|
|
1139
|
+
await Promise.all(files.map(async (file2) => {
|
|
1140
|
+
const defaulFile = path4.join(defaulPath, file2);
|
|
1141
|
+
const userFile = path4.join(userPath, file2);
|
|
1142
1142
|
if (!fs5.existsSync(userFile)) {
|
|
1143
1143
|
await fs5.promises.copyFile(defaulFile, userFile);
|
|
1144
1144
|
}
|
|
@@ -1175,13 +1175,13 @@ var init_file = __esm({
|
|
|
1175
1175
|
const result = [];
|
|
1176
1176
|
const readDirRecursive = (currentDir, prefix = "") => {
|
|
1177
1177
|
const files = fs5.readdirSync(currentDir, { withFileTypes: true });
|
|
1178
|
-
for (const
|
|
1179
|
-
const relativePath = path4.join(prefix,
|
|
1180
|
-
const fullPath = path4.join(currentDir,
|
|
1181
|
-
if (
|
|
1178
|
+
for (const file2 of files) {
|
|
1179
|
+
const relativePath = path4.join(prefix, file2.name);
|
|
1180
|
+
const fullPath = path4.join(currentDir, file2.name);
|
|
1181
|
+
if (file2.isDirectory()) {
|
|
1182
1182
|
readDirRecursive(fullPath, relativePath);
|
|
1183
|
-
} else if (
|
|
1184
|
-
const suffix = path4.extname(
|
|
1183
|
+
} else if (file2.isFile()) {
|
|
1184
|
+
const suffix = path4.extname(file2.name);
|
|
1185
1185
|
if (suffixs.length > 0) {
|
|
1186
1186
|
const normalizedSuffixs = suffixs.map((s) => s.startsWith(".") ? s : `.${s}`);
|
|
1187
1187
|
if (normalizedSuffixs.includes(suffix)) {
|
|
@@ -1209,13 +1209,13 @@ var init_file = __esm({
|
|
|
1209
1209
|
const result = [];
|
|
1210
1210
|
const readDirRecursive = async (currentDir, prefix = "") => {
|
|
1211
1211
|
const files = await fs5.promises.readdir(currentDir, { withFileTypes: true });
|
|
1212
|
-
await Promise.all(files.map(async (
|
|
1213
|
-
const relativePath = path4.join(prefix,
|
|
1214
|
-
const fullPath = path4.join(currentDir,
|
|
1215
|
-
if (
|
|
1212
|
+
await Promise.all(files.map(async (file2) => {
|
|
1213
|
+
const relativePath = path4.join(prefix, file2.name);
|
|
1214
|
+
const fullPath = path4.join(currentDir, file2.name);
|
|
1215
|
+
if (file2.isDirectory()) {
|
|
1216
1216
|
await readDirRecursive(fullPath, relativePath);
|
|
1217
|
-
} else if (
|
|
1218
|
-
const suffix = path4.extname(
|
|
1217
|
+
} else if (file2.isFile()) {
|
|
1218
|
+
const suffix = path4.extname(file2.name);
|
|
1219
1219
|
if (suffixs.length > 0) {
|
|
1220
1220
|
const normalizedSuffixs = suffixs.map((s) => s.startsWith(".") ? s : `.${s}`);
|
|
1221
1221
|
if (normalizedSuffixs.includes(suffix)) {
|
|
@@ -1370,8 +1370,8 @@ var init_path = __esm({
|
|
|
1370
1370
|
if (returnType === "name") {
|
|
1371
1371
|
list2.push(entry.name);
|
|
1372
1372
|
} else if (returnType === "rel") {
|
|
1373
|
-
const
|
|
1374
|
-
list2.push(path4.relative(process.cwd(),
|
|
1373
|
+
const file2 = path4.resolve(dir2, entry.name);
|
|
1374
|
+
list2.push(path4.relative(process.cwd(), file2));
|
|
1375
1375
|
} else if (returnType === "abs") {
|
|
1376
1376
|
list2.push(formatPath(path4.resolve(dir2, entry.name)));
|
|
1377
1377
|
}
|
|
@@ -1520,9 +1520,9 @@ var init_yaml = __esm({
|
|
|
1520
1520
|
filePath;
|
|
1521
1521
|
doc;
|
|
1522
1522
|
document;
|
|
1523
|
-
constructor(
|
|
1524
|
-
this.filePath =
|
|
1525
|
-
const data = YAML.parseDocument(fs5.existsSync(
|
|
1523
|
+
constructor(file2) {
|
|
1524
|
+
this.filePath = file2;
|
|
1525
|
+
const data = YAML.parseDocument(fs5.existsSync(file2) ? fs5.readFileSync(file2, "utf8") : file2);
|
|
1526
1526
|
this.doc = data;
|
|
1527
1527
|
this.document = data;
|
|
1528
1528
|
}
|
|
@@ -2426,6 +2426,7 @@ __export(segment_exports, {
|
|
|
2426
2426
|
customMusic: () => customMusic,
|
|
2427
2427
|
dice: () => dice,
|
|
2428
2428
|
face: () => face,
|
|
2429
|
+
file: () => file,
|
|
2429
2430
|
gift: () => gift,
|
|
2430
2431
|
image: () => image,
|
|
2431
2432
|
json: () => json2,
|
|
@@ -2449,7 +2450,7 @@ __export(segment_exports, {
|
|
|
2449
2450
|
weather: () => weather,
|
|
2450
2451
|
xml: () => xml
|
|
2451
2452
|
});
|
|
2452
|
-
var text, at, face, reply, image, video, record, json2, xml, markdown, markdownTpl, pasmsg, keyboard, button, longMsg, raw, basketball, dice, rps, bubbleFace, weather, location, share, gift, marketFace, contact, music, customMusic, node, nodeDirect;
|
|
2453
|
+
var text, at, face, reply, image, video, record, json2, xml, markdown, markdownTpl, pasmsg, keyboard, button, longMsg, raw, basketball, dice, rps, bubbleFace, weather, location, share, gift, marketFace, contact, music, customMusic, node, nodeDirect, file;
|
|
2453
2454
|
var init_segment = __esm({
|
|
2454
2455
|
"src/utils/message/segment.ts"() {
|
|
2455
2456
|
text = (text2) => {
|
|
@@ -2464,10 +2465,10 @@ var init_segment = __esm({
|
|
|
2464
2465
|
reply = (messageId) => {
|
|
2465
2466
|
return { type: "reply", messageId: String(messageId) };
|
|
2466
2467
|
};
|
|
2467
|
-
image = (
|
|
2468
|
+
image = (file2, options = {}) => {
|
|
2468
2469
|
return {
|
|
2469
2470
|
type: "image",
|
|
2470
|
-
file,
|
|
2471
|
+
file: file2,
|
|
2471
2472
|
fileType: options.fileType,
|
|
2472
2473
|
height: options?.height,
|
|
2473
2474
|
width: options?.width,
|
|
@@ -2476,20 +2477,20 @@ var init_segment = __esm({
|
|
|
2476
2477
|
subType: options?.subType
|
|
2477
2478
|
};
|
|
2478
2479
|
};
|
|
2479
|
-
video = (
|
|
2480
|
+
video = (file2, options) => {
|
|
2480
2481
|
return {
|
|
2481
2482
|
type: "video",
|
|
2482
|
-
file,
|
|
2483
|
+
file: file2,
|
|
2483
2484
|
height: options?.height,
|
|
2484
2485
|
width: options?.width,
|
|
2485
2486
|
md5: options?.md5,
|
|
2486
2487
|
name: options?.name
|
|
2487
2488
|
};
|
|
2488
2489
|
};
|
|
2489
|
-
record = (
|
|
2490
|
+
record = (file2, magic = false, options) => {
|
|
2490
2491
|
return {
|
|
2491
2492
|
type: "record",
|
|
2492
|
-
file,
|
|
2493
|
+
file: file2,
|
|
2493
2494
|
magic,
|
|
2494
2495
|
md5: options?.md5,
|
|
2495
2496
|
name: options?.name
|
|
@@ -2575,6 +2576,16 @@ var init_segment = __esm({
|
|
|
2575
2576
|
nodeDirect = (id) => {
|
|
2576
2577
|
return { type: "node", subType: "messageID", messageId: id, message_id: id };
|
|
2577
2578
|
};
|
|
2579
|
+
file = (file2, options) => {
|
|
2580
|
+
return {
|
|
2581
|
+
type: "file",
|
|
2582
|
+
file: file2,
|
|
2583
|
+
name: options?.name,
|
|
2584
|
+
hash: options?.hash,
|
|
2585
|
+
size: options?.size,
|
|
2586
|
+
fid: options?.fid
|
|
2587
|
+
};
|
|
2588
|
+
};
|
|
2578
2589
|
}
|
|
2579
2590
|
});
|
|
2580
2591
|
var createRawMessage, makeMessage, makeForward;
|
|
@@ -2598,9 +2609,9 @@ var init_message = __esm({
|
|
|
2598
2609
|
return `[${v.type}:base64://...]`;
|
|
2599
2610
|
}
|
|
2600
2611
|
case "file": {
|
|
2601
|
-
if (Buffer.isBuffer(v.file)) return `[file:Buffer://..., fid:${v.fid},
|
|
2602
|
-
if (/^http|^file/.test(v.file)) return `[file:${v.file}, fid:${v.fid},
|
|
2603
|
-
return `[file:base64://..., fid:${v.fid},
|
|
2612
|
+
if (Buffer.isBuffer(v.file)) return `[file:Buffer://..., fid:${v.fid}, hash:${v.hash}]`;
|
|
2613
|
+
if (/^http|^file/.test(v.file)) return `[file:${v.file}, fid:${v.fid}, hash:${v.hash}]`;
|
|
2614
|
+
return `[file:base64://..., fid:${v.fid}, hash:${v.hash}]`;
|
|
2604
2615
|
}
|
|
2605
2616
|
case "json":
|
|
2606
2617
|
case "xml": {
|
|
@@ -3026,6 +3037,9 @@ var init_base = __esm({
|
|
|
3026
3037
|
connectTime: Date.now()
|
|
3027
3038
|
};
|
|
3028
3039
|
}
|
|
3040
|
+
get #errMsg() {
|
|
3041
|
+
return `[adapter][${this.adapter.protocol}] \u6B64\u63A5\u53E3\u672A\u5B9E\u73B0`;
|
|
3042
|
+
}
|
|
3029
3043
|
get selfId() {
|
|
3030
3044
|
return this.account.selfId;
|
|
3031
3045
|
}
|
|
@@ -3050,7 +3064,7 @@ var init_base = __esm({
|
|
|
3050
3064
|
* @param _retryCount 重试次数 默认为0
|
|
3051
3065
|
*/
|
|
3052
3066
|
sendMsg(_contact, _elements, _retryCount) {
|
|
3053
|
-
throw new Error(
|
|
3067
|
+
throw new Error(this.#errMsg);
|
|
3054
3068
|
}
|
|
3055
3069
|
/**
|
|
3056
3070
|
* 发送长消息
|
|
@@ -3058,7 +3072,7 @@ var init_base = __esm({
|
|
|
3058
3072
|
* @param _resId 资源ID
|
|
3059
3073
|
*/
|
|
3060
3074
|
sendLongMsg(_contact, _resId) {
|
|
3061
|
-
throw new Error(
|
|
3075
|
+
throw new Error(this.#errMsg);
|
|
3062
3076
|
}
|
|
3063
3077
|
/**
|
|
3064
3078
|
* 发送合并转发消息
|
|
@@ -3067,7 +3081,7 @@ var init_base = __esm({
|
|
|
3067
3081
|
* @param _options 首层小卡片外显参数
|
|
3068
3082
|
*/
|
|
3069
3083
|
sendForwardMsg(_contact, _elements, _options) {
|
|
3070
|
-
throw new Error(
|
|
3084
|
+
throw new Error(this.#errMsg);
|
|
3071
3085
|
}
|
|
3072
3086
|
/**
|
|
3073
3087
|
* 撤回消息
|
|
@@ -3076,7 +3090,7 @@ var init_base = __esm({
|
|
|
3076
3090
|
* @returns 此接口的返回值不值得信任
|
|
3077
3091
|
*/
|
|
3078
3092
|
recallMsg(_contact, _messageId) {
|
|
3079
|
-
throw new Error(
|
|
3093
|
+
throw new Error(this.#errMsg);
|
|
3080
3094
|
}
|
|
3081
3095
|
/**
|
|
3082
3096
|
* 获取头像url
|
|
@@ -3085,7 +3099,7 @@ var init_base = __esm({
|
|
|
3085
3099
|
* @returns 头像的url地址
|
|
3086
3100
|
*/
|
|
3087
3101
|
getAvatarUrl(_userId, _size) {
|
|
3088
|
-
throw new Error(
|
|
3102
|
+
throw new Error(this.#errMsg);
|
|
3089
3103
|
}
|
|
3090
3104
|
/**
|
|
3091
3105
|
* 获取群头像url
|
|
@@ -3095,7 +3109,7 @@ var init_base = __esm({
|
|
|
3095
3109
|
* @returns 头像的url地址
|
|
3096
3110
|
*/
|
|
3097
3111
|
getGroupAvatarUrl(_groupId, _size, _history) {
|
|
3098
|
-
throw new Error(
|
|
3112
|
+
throw new Error(this.#errMsg);
|
|
3099
3113
|
}
|
|
3100
3114
|
/**
|
|
3101
3115
|
* 获取消息
|
|
@@ -3104,7 +3118,7 @@ var init_base = __esm({
|
|
|
3104
3118
|
* @returns MessageResponse对象
|
|
3105
3119
|
*/
|
|
3106
3120
|
getMsg(_contact, _messageId) {
|
|
3107
|
-
throw new Error(
|
|
3121
|
+
throw new Error(this.#errMsg);
|
|
3108
3122
|
}
|
|
3109
3123
|
/**
|
|
3110
3124
|
* 获取msgId获取历史消息
|
|
@@ -3114,7 +3128,7 @@ var init_base = __esm({
|
|
|
3114
3128
|
* @returns 包含历史消息的数组
|
|
3115
3129
|
*/
|
|
3116
3130
|
getHistoryMsg(_contact, _startMsgId, _count) {
|
|
3117
|
-
throw new Error(
|
|
3131
|
+
throw new Error(this.#errMsg);
|
|
3118
3132
|
}
|
|
3119
3133
|
/**
|
|
3120
3134
|
* 获取合并转发消息
|
|
@@ -3122,7 +3136,7 @@ var init_base = __esm({
|
|
|
3122
3136
|
* @returns 包含MessageResponse对象的数组
|
|
3123
3137
|
*/
|
|
3124
3138
|
getForwardMsg(_resId) {
|
|
3125
|
-
throw new Error(
|
|
3139
|
+
throw new Error(this.#errMsg);
|
|
3126
3140
|
}
|
|
3127
3141
|
/**
|
|
3128
3142
|
* 获取精华消息
|
|
@@ -3132,7 +3146,7 @@ var init_base = __esm({
|
|
|
3132
3146
|
* @returns EssenceMessageBody对象
|
|
3133
3147
|
*/
|
|
3134
3148
|
getGroupHighlights(_groupId, _page, _pageSize) {
|
|
3135
|
-
throw new Error(
|
|
3149
|
+
throw new Error(this.#errMsg);
|
|
3136
3150
|
}
|
|
3137
3151
|
/**
|
|
3138
3152
|
* 构造一个资源ID 即上传合并转发消息后不进行发送
|
|
@@ -3141,7 +3155,7 @@ var init_base = __esm({
|
|
|
3141
3155
|
* @description 此接口并不是所有协议端都支持的,因此在使用时请注意
|
|
3142
3156
|
*/
|
|
3143
3157
|
createResId(_contact, _elements) {
|
|
3144
|
-
throw new Error(
|
|
3158
|
+
throw new Error(this.#errMsg);
|
|
3145
3159
|
}
|
|
3146
3160
|
/**
|
|
3147
3161
|
* 设置、取消群精华消息
|
|
@@ -3150,7 +3164,7 @@ var init_base = __esm({
|
|
|
3150
3164
|
* @param _create true为添加精华消息,false为删除精华消息 默认为true
|
|
3151
3165
|
*/
|
|
3152
3166
|
setGgroupHighlights(_groupId, _messageId, _create) {
|
|
3153
|
-
throw new Error(
|
|
3167
|
+
throw new Error(this.#errMsg);
|
|
3154
3168
|
}
|
|
3155
3169
|
/**
|
|
3156
3170
|
* 发送好友赞
|
|
@@ -3159,7 +3173,7 @@ var init_base = __esm({
|
|
|
3159
3173
|
* @returns 此接口的返回值不值得信任
|
|
3160
3174
|
*/
|
|
3161
3175
|
sendLike(_targetId, _count) {
|
|
3162
|
-
throw new Error(
|
|
3176
|
+
throw new Error(this.#errMsg);
|
|
3163
3177
|
}
|
|
3164
3178
|
/**
|
|
3165
3179
|
* 群踢人
|
|
@@ -3170,7 +3184,7 @@ var init_base = __esm({
|
|
|
3170
3184
|
* @returns 此接口的返回值不值得信任
|
|
3171
3185
|
*/
|
|
3172
3186
|
groupKickMember(_groupId, _targetId, _rejectAddRequest, _kickReason) {
|
|
3173
|
-
throw new Error(
|
|
3187
|
+
throw new Error(this.#errMsg);
|
|
3174
3188
|
}
|
|
3175
3189
|
/**
|
|
3176
3190
|
* 禁言群成员
|
|
@@ -3180,7 +3194,7 @@ var init_base = __esm({
|
|
|
3180
3194
|
* @returns 此接口的返回值不值得信任
|
|
3181
3195
|
*/
|
|
3182
3196
|
setGroupMute(_groupId, _targetId, _duration) {
|
|
3183
|
-
throw new Error(
|
|
3197
|
+
throw new Error(this.#errMsg);
|
|
3184
3198
|
}
|
|
3185
3199
|
/**
|
|
3186
3200
|
* 群全员禁言
|
|
@@ -3189,7 +3203,7 @@ var init_base = __esm({
|
|
|
3189
3203
|
* @returns 此接口的返回值不值得信任
|
|
3190
3204
|
*/
|
|
3191
3205
|
setGroupAllMute(_groupId, _isBan) {
|
|
3192
|
-
throw new Error(
|
|
3206
|
+
throw new Error(this.#errMsg);
|
|
3193
3207
|
}
|
|
3194
3208
|
/**
|
|
3195
3209
|
* 设置群管理员
|
|
@@ -3199,7 +3213,7 @@ var init_base = __esm({
|
|
|
3199
3213
|
* @returns 此接口的返回值不值得信任
|
|
3200
3214
|
*/
|
|
3201
3215
|
setGroupAdmin(_groupId, _targetId, _isAdmin) {
|
|
3202
|
-
throw new Error(
|
|
3216
|
+
throw new Error(this.#errMsg);
|
|
3203
3217
|
}
|
|
3204
3218
|
/**
|
|
3205
3219
|
* 设置群名片
|
|
@@ -3209,7 +3223,7 @@ var init_base = __esm({
|
|
|
3209
3223
|
* @returns 此接口的返回值不值得信任
|
|
3210
3224
|
*/
|
|
3211
3225
|
setGroupMemberCard(_groupId, _targetId, _card) {
|
|
3212
|
-
throw new Error(
|
|
3226
|
+
throw new Error(this.#errMsg);
|
|
3213
3227
|
}
|
|
3214
3228
|
/**
|
|
3215
3229
|
* 设置群名
|
|
@@ -3218,7 +3232,7 @@ var init_base = __esm({
|
|
|
3218
3232
|
* @returns 此接口的返回值不值得信任
|
|
3219
3233
|
*/
|
|
3220
3234
|
setGroupName(_groupId, _groupName) {
|
|
3221
|
-
throw new Error(
|
|
3235
|
+
throw new Error(this.#errMsg);
|
|
3222
3236
|
}
|
|
3223
3237
|
/**
|
|
3224
3238
|
* 退出群组
|
|
@@ -3227,7 +3241,7 @@ var init_base = __esm({
|
|
|
3227
3241
|
* @returns 此接口的返回值不值得信任
|
|
3228
3242
|
*/
|
|
3229
3243
|
setGroupQuit(_groupId, _isDismiss) {
|
|
3230
|
-
throw new Error(
|
|
3244
|
+
throw new Error(this.#errMsg);
|
|
3231
3245
|
}
|
|
3232
3246
|
/**
|
|
3233
3247
|
* 设置群专属头衔 仅群主可用
|
|
@@ -3237,7 +3251,7 @@ var init_base = __esm({
|
|
|
3237
3251
|
* @returns 此接口的返回值不值得信任
|
|
3238
3252
|
*/
|
|
3239
3253
|
setGroupMemberTitle(_groupId, _targetId, _title) {
|
|
3240
|
-
throw new Error(
|
|
3254
|
+
throw new Error(this.#errMsg);
|
|
3241
3255
|
}
|
|
3242
3256
|
/**
|
|
3243
3257
|
* 获取陌生人信息 此接口数据无法保证完全正确并且无法保证数据的完整性
|
|
@@ -3245,7 +3259,7 @@ var init_base = __esm({
|
|
|
3245
3259
|
* @returns 陌生人信息数组
|
|
3246
3260
|
*/
|
|
3247
3261
|
getStrangerInfo(_targetId) {
|
|
3248
|
-
throw new Error(
|
|
3262
|
+
throw new Error(this.#errMsg);
|
|
3249
3263
|
}
|
|
3250
3264
|
/**
|
|
3251
3265
|
* 获取好友列表
|
|
@@ -3253,7 +3267,7 @@ var init_base = __esm({
|
|
|
3253
3267
|
* @returns 好友列表数组
|
|
3254
3268
|
*/
|
|
3255
3269
|
getFriendList(_refresh) {
|
|
3256
|
-
throw new Error(
|
|
3270
|
+
throw new Error(this.#errMsg);
|
|
3257
3271
|
}
|
|
3258
3272
|
/**
|
|
3259
3273
|
* 获取群信息
|
|
@@ -3262,7 +3276,7 @@ var init_base = __esm({
|
|
|
3262
3276
|
* @returns 群信息
|
|
3263
3277
|
*/
|
|
3264
3278
|
getGroupInfo(_groupId, _noCache) {
|
|
3265
|
-
throw new Error(
|
|
3279
|
+
throw new Error(this.#errMsg);
|
|
3266
3280
|
}
|
|
3267
3281
|
/**
|
|
3268
3282
|
* 获取群列表
|
|
@@ -3270,7 +3284,7 @@ var init_base = __esm({
|
|
|
3270
3284
|
* @returns 群列表数组
|
|
3271
3285
|
*/
|
|
3272
3286
|
getGroupList(_refresh) {
|
|
3273
|
-
throw new Error(
|
|
3287
|
+
throw new Error(this.#errMsg);
|
|
3274
3288
|
}
|
|
3275
3289
|
/**
|
|
3276
3290
|
* 获取群成员信息
|
|
@@ -3281,7 +3295,7 @@ var init_base = __esm({
|
|
|
3281
3295
|
* @returns 群成员信息
|
|
3282
3296
|
*/
|
|
3283
3297
|
getGroupMemberInfo(_groupId, _targetId, _refresh) {
|
|
3284
|
-
throw new Error(
|
|
3298
|
+
throw new Error(this.#errMsg);
|
|
3285
3299
|
}
|
|
3286
3300
|
/**
|
|
3287
3301
|
* 获取群成员列表
|
|
@@ -3290,7 +3304,7 @@ var init_base = __esm({
|
|
|
3290
3304
|
* @returns 群成员列表数组
|
|
3291
3305
|
*/
|
|
3292
3306
|
getGroupMemberList(_groupId, _refresh) {
|
|
3293
|
-
throw new Error(
|
|
3307
|
+
throw new Error(this.#errMsg);
|
|
3294
3308
|
}
|
|
3295
3309
|
/**
|
|
3296
3310
|
* 获取群荣誉信息
|
|
@@ -3299,7 +3313,7 @@ var init_base = __esm({
|
|
|
3299
3313
|
* @returns 群荣誉信息数组
|
|
3300
3314
|
*/
|
|
3301
3315
|
getGroupHonor(_groupId) {
|
|
3302
|
-
throw new Error(
|
|
3316
|
+
throw new Error(this.#errMsg);
|
|
3303
3317
|
}
|
|
3304
3318
|
/**
|
|
3305
3319
|
* 设置好友请求结果
|
|
@@ -3309,7 +3323,7 @@ var init_base = __esm({
|
|
|
3309
3323
|
* @returns 设置结果
|
|
3310
3324
|
*/
|
|
3311
3325
|
setFriendApplyResult(_requestId, _isApprove, _remark) {
|
|
3312
|
-
throw new Error(
|
|
3326
|
+
throw new Error(this.#errMsg);
|
|
3313
3327
|
}
|
|
3314
3328
|
/**
|
|
3315
3329
|
* 设置申请加入群请求结果
|
|
@@ -3319,7 +3333,7 @@ var init_base = __esm({
|
|
|
3319
3333
|
* @returns 此接口的返回值不值得信任
|
|
3320
3334
|
*/
|
|
3321
3335
|
setGroupApplyResult(_requestId, _isApprove, _denyReason) {
|
|
3322
|
-
throw new Error(
|
|
3336
|
+
throw new Error(this.#errMsg);
|
|
3323
3337
|
}
|
|
3324
3338
|
/**
|
|
3325
3339
|
* 设置邀请加入群请求结果
|
|
@@ -3328,7 +3342,7 @@ var init_base = __esm({
|
|
|
3328
3342
|
* @returns 此接口的返回值不值得信任
|
|
3329
3343
|
*/
|
|
3330
3344
|
setInvitedJoinGroupResult(_requestId, _isApprove) {
|
|
3331
|
-
throw new Error(
|
|
3345
|
+
throw new Error(this.#errMsg);
|
|
3332
3346
|
}
|
|
3333
3347
|
/**
|
|
3334
3348
|
* 设置消息表情回应
|
|
@@ -3338,7 +3352,7 @@ var init_base = __esm({
|
|
|
3338
3352
|
* @returns 此接口的返回值不值得信任
|
|
3339
3353
|
*/
|
|
3340
3354
|
setMsgReaction(_contact, _messageId, _faceId, _isSet) {
|
|
3341
|
-
throw new Error(
|
|
3355
|
+
throw new Error(this.#errMsg);
|
|
3342
3356
|
}
|
|
3343
3357
|
/**
|
|
3344
3358
|
* 上传群文件、私聊文件
|
|
@@ -3349,7 +3363,7 @@ var init_base = __esm({
|
|
|
3349
3363
|
* @returns 此接口的返回值不值得信任
|
|
3350
3364
|
*/
|
|
3351
3365
|
uploadFile(_contact, _file, _name, _folder) {
|
|
3352
|
-
throw new Error(
|
|
3366
|
+
throw new Error(this.#errMsg);
|
|
3353
3367
|
}
|
|
3354
3368
|
/**
|
|
3355
3369
|
* 让协议端下载文件到协议端本地
|
|
@@ -3357,7 +3371,7 @@ var init_base = __esm({
|
|
|
3357
3371
|
* @returns 下载文件的绝对路径和文件MD5
|
|
3358
3372
|
*/
|
|
3359
3373
|
downloadFile(_options) {
|
|
3360
|
-
throw new Error(
|
|
3374
|
+
throw new Error(this.#errMsg);
|
|
3361
3375
|
}
|
|
3362
3376
|
/**
|
|
3363
3377
|
* 创建群文件夹
|
|
@@ -3366,7 +3380,7 @@ var init_base = __esm({
|
|
|
3366
3380
|
* @returns 返回文件夹id和已使用空间
|
|
3367
3381
|
*/
|
|
3368
3382
|
createGroupFolder(_groupId, _name) {
|
|
3369
|
-
throw new Error(
|
|
3383
|
+
throw new Error(this.#errMsg);
|
|
3370
3384
|
}
|
|
3371
3385
|
/**
|
|
3372
3386
|
* 重命名群文件的文件夹
|
|
@@ -3376,7 +3390,7 @@ var init_base = __esm({
|
|
|
3376
3390
|
* @returns 无返回值
|
|
3377
3391
|
*/
|
|
3378
3392
|
renameGroupFolder(_groupId, _folderId, _name) {
|
|
3379
|
-
throw new Error(
|
|
3393
|
+
throw new Error(this.#errMsg);
|
|
3380
3394
|
}
|
|
3381
3395
|
/**
|
|
3382
3396
|
* 删除群文件的文件夹
|
|
@@ -3385,7 +3399,7 @@ var init_base = __esm({
|
|
|
3385
3399
|
* @returns 无返回值
|
|
3386
3400
|
*/
|
|
3387
3401
|
delGroupFolder(_groupId, _folderId) {
|
|
3388
|
-
throw new Error(
|
|
3402
|
+
throw new Error(this.#errMsg);
|
|
3389
3403
|
}
|
|
3390
3404
|
/**
|
|
3391
3405
|
* 上传群文件
|
|
@@ -3396,7 +3410,16 @@ var init_base = __esm({
|
|
|
3396
3410
|
* @returns 无返回值
|
|
3397
3411
|
*/
|
|
3398
3412
|
uploadGroupFile(_groupId, _file, _name) {
|
|
3399
|
-
throw new Error(
|
|
3413
|
+
throw new Error(this.#errMsg);
|
|
3414
|
+
}
|
|
3415
|
+
/**
|
|
3416
|
+
* 获取文件url
|
|
3417
|
+
* @param _contact 目标信息
|
|
3418
|
+
* @param _fileId 文件id
|
|
3419
|
+
* @returns 文件url
|
|
3420
|
+
*/
|
|
3421
|
+
getFileUrl(_contact, _fileId) {
|
|
3422
|
+
throw new Error(this.#errMsg);
|
|
3400
3423
|
}
|
|
3401
3424
|
/**
|
|
3402
3425
|
* 删除群文件
|
|
@@ -3406,7 +3429,7 @@ var init_base = __esm({
|
|
|
3406
3429
|
* @returns 无返回值
|
|
3407
3430
|
*/
|
|
3408
3431
|
delGroupFile(_groupId, _fileId, _busId) {
|
|
3409
|
-
throw new Error(
|
|
3432
|
+
throw new Error(this.#errMsg);
|
|
3410
3433
|
}
|
|
3411
3434
|
/**
|
|
3412
3435
|
* 获取群文件系统信息
|
|
@@ -3414,7 +3437,7 @@ var init_base = __esm({
|
|
|
3414
3437
|
* @returns 返回文件数量、文件数量上限、已使用空间和空间上限
|
|
3415
3438
|
*/
|
|
3416
3439
|
getGroupFileSystemInfo(_groupId) {
|
|
3417
|
-
throw new Error(
|
|
3440
|
+
throw new Error(this.#errMsg);
|
|
3418
3441
|
}
|
|
3419
3442
|
/**
|
|
3420
3443
|
* 获取群文件夹下文件列表
|
|
@@ -3423,7 +3446,7 @@ var init_base = __esm({
|
|
|
3423
3446
|
* @returns 返回文件和文件夹的列表
|
|
3424
3447
|
*/
|
|
3425
3448
|
getGroupFileList(_groupId, _folderId) {
|
|
3426
|
-
throw new Error(
|
|
3449
|
+
throw new Error(this.#errMsg);
|
|
3427
3450
|
}
|
|
3428
3451
|
/**
|
|
3429
3452
|
* 设置群备注
|
|
@@ -3432,14 +3455,14 @@ var init_base = __esm({
|
|
|
3432
3455
|
* @returns 此接口的返回值不值得信任
|
|
3433
3456
|
*/
|
|
3434
3457
|
setGroupRemark(_groupId, _remark) {
|
|
3435
|
-
throw new Error(
|
|
3458
|
+
throw new Error(this.#errMsg);
|
|
3436
3459
|
}
|
|
3437
3460
|
/**
|
|
3438
3461
|
* 获取陌生群信息
|
|
3439
3462
|
* @param _groupId 群号
|
|
3440
3463
|
*/
|
|
3441
3464
|
getNotJoinedGroupInfo(_groupId) {
|
|
3442
|
-
throw new Error(
|
|
3465
|
+
throw new Error(this.#errMsg);
|
|
3443
3466
|
}
|
|
3444
3467
|
/**
|
|
3445
3468
|
* 获取艾特全体成员剩余次数
|
|
@@ -3447,7 +3470,7 @@ var init_base = __esm({
|
|
|
3447
3470
|
* @returns 返回是否允许at全体成员和全群剩余次数、个人剩余次数
|
|
3448
3471
|
*/
|
|
3449
3472
|
getAtAllCount(_groupId) {
|
|
3450
|
-
throw new Error(
|
|
3473
|
+
throw new Error(this.#errMsg);
|
|
3451
3474
|
}
|
|
3452
3475
|
/**
|
|
3453
3476
|
* 获取群被禁言用户列表
|
|
@@ -3455,7 +3478,7 @@ var init_base = __esm({
|
|
|
3455
3478
|
* @returns 返回禁言用户列表
|
|
3456
3479
|
*/
|
|
3457
3480
|
getGroupMuteList(_groupId) {
|
|
3458
|
-
throw new Error(
|
|
3481
|
+
throw new Error(this.#errMsg);
|
|
3459
3482
|
}
|
|
3460
3483
|
/**
|
|
3461
3484
|
* 戳一戳用户 支持群聊和私聊
|
|
@@ -3464,28 +3487,28 @@ var init_base = __esm({
|
|
|
3464
3487
|
* @returns 此接口的返回值不值得信任
|
|
3465
3488
|
*/
|
|
3466
3489
|
pokeUser(_contact, _count) {
|
|
3467
|
-
throw new Error(
|
|
3490
|
+
throw new Error(this.#errMsg);
|
|
3468
3491
|
}
|
|
3469
3492
|
/**
|
|
3470
3493
|
* 获取 Cookies
|
|
3471
3494
|
* @param _domain The domain to get cookies from
|
|
3472
3495
|
*/
|
|
3473
3496
|
getCookies(_domain) {
|
|
3474
|
-
throw new Error(
|
|
3497
|
+
throw new Error(this.#errMsg);
|
|
3475
3498
|
}
|
|
3476
3499
|
/**
|
|
3477
3500
|
* 获取 QQ 相关接口凭证
|
|
3478
3501
|
* @param _domain The domain to get credentials from
|
|
3479
3502
|
*/
|
|
3480
3503
|
getCredentials(_domain) {
|
|
3481
|
-
throw new Error(
|
|
3504
|
+
throw new Error(this.#errMsg);
|
|
3482
3505
|
}
|
|
3483
3506
|
/**
|
|
3484
3507
|
* 获取 CSRF Token
|
|
3485
3508
|
* @param _domain The domain to get the CSRF token from
|
|
3486
3509
|
*/
|
|
3487
3510
|
getCSRFToken(_domain) {
|
|
3488
|
-
throw new Error(
|
|
3511
|
+
throw new Error(this.#errMsg);
|
|
3489
3512
|
}
|
|
3490
3513
|
/**
|
|
3491
3514
|
* 获取 HTTP Cookies
|
|
@@ -3494,7 +3517,7 @@ var init_base = __esm({
|
|
|
3494
3517
|
* @param _jumpUrl The jump url
|
|
3495
3518
|
*/
|
|
3496
3519
|
getHttpCookies(_appid, _daid, _jumpUrl) {
|
|
3497
|
-
throw new Error(
|
|
3520
|
+
throw new Error(this.#errMsg);
|
|
3498
3521
|
}
|
|
3499
3522
|
};
|
|
3500
3523
|
}
|
|
@@ -3555,6 +3578,8 @@ var init_api = __esm({
|
|
|
3555
3578
|
OB11ApiAction2["getEssenceMsgList"] = "get_essence_msg_list";
|
|
3556
3579
|
OB11ApiAction2["setEssenceMsg"] = "set_essence_msg";
|
|
3557
3580
|
OB11ApiAction2["deleteEssenceMsg"] = "delete_essence_msg";
|
|
3581
|
+
OB11ApiAction2["getGroupFileUrl"] = "get_group_file_url";
|
|
3582
|
+
OB11ApiAction2["getPrivateFileUrl"] = "get_private_file_url";
|
|
3558
3583
|
return OB11ApiAction2;
|
|
3559
3584
|
})(OB11ApiAction || {});
|
|
3560
3585
|
}
|
|
@@ -3606,6 +3631,7 @@ var init_event2 = __esm({
|
|
|
3606
3631
|
OB11NoticeType2["GroupMsgEmojiLikeLagrange"] = "reaction";
|
|
3607
3632
|
OB11NoticeType2["GroupEssence"] = "essence";
|
|
3608
3633
|
OB11NoticeType2["GroupCard"] = "group_card";
|
|
3634
|
+
OB11NoticeType2["OfflineFile"] = "offline_file";
|
|
3609
3635
|
return OB11NoticeType2;
|
|
3610
3636
|
})(OB11NoticeType || {});
|
|
3611
3637
|
OB11RequestType = /* @__PURE__ */ ((OB11RequestType2) => {
|
|
@@ -3615,62 +3641,7 @@ var init_event2 = __esm({
|
|
|
3615
3641
|
})(OB11RequestType || {});
|
|
3616
3642
|
}
|
|
3617
3643
|
});
|
|
3618
|
-
|
|
3619
|
-
const elements = [];
|
|
3620
|
-
try {
|
|
3621
|
-
for (const i of data) {
|
|
3622
|
-
switch (i.type) {
|
|
3623
|
-
case "text":
|
|
3624
|
-
elements.push(segment_exports.text(i.data.text));
|
|
3625
|
-
break;
|
|
3626
|
-
case "face":
|
|
3627
|
-
elements.push(segment_exports.face(Number(i.data.id)));
|
|
3628
|
-
break;
|
|
3629
|
-
case "image":
|
|
3630
|
-
elements.push(segment_exports.image(i.data.url || i.data.file, { fileType: i.data.type }));
|
|
3631
|
-
break;
|
|
3632
|
-
case "record":
|
|
3633
|
-
elements.push(segment_exports.record(i.data.url || i.data.file, i.data.magic === 1));
|
|
3634
|
-
break;
|
|
3635
|
-
case "video":
|
|
3636
|
-
elements.push(segment_exports.video(i.data.url || i.data.file));
|
|
3637
|
-
break;
|
|
3638
|
-
case "at":
|
|
3639
|
-
elements.push(segment_exports.at(i.data.qq, i.data.name));
|
|
3640
|
-
break;
|
|
3641
|
-
case "contact":
|
|
3642
|
-
elements.push(segment_exports.contact(i.data.type === "qq" ? "friend" : "group", i.data.id));
|
|
3643
|
-
break;
|
|
3644
|
-
case "location":
|
|
3645
|
-
elements.push(segment_exports.location(
|
|
3646
|
-
Number(i.data.lat),
|
|
3647
|
-
Number(i.data.lon),
|
|
3648
|
-
i.data.title || "",
|
|
3649
|
-
i.data.content || ""
|
|
3650
|
-
));
|
|
3651
|
-
break;
|
|
3652
|
-
case "reply":
|
|
3653
|
-
elements.push(segment_exports.reply(i.data.id));
|
|
3654
|
-
break;
|
|
3655
|
-
case "json":
|
|
3656
|
-
elements.push(segment_exports.json(i.data.data));
|
|
3657
|
-
break;
|
|
3658
|
-
case "xml":
|
|
3659
|
-
elements.push(segment_exports.xml(i.data.data));
|
|
3660
|
-
break;
|
|
3661
|
-
default: {
|
|
3662
|
-
elements.push(segment_exports.text(JSON.stringify(i)));
|
|
3663
|
-
}
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
} catch (error) {
|
|
3667
|
-
logger.error("[AdapterConvertKarin] \u8F6C\u6362\u9519\u8BEF");
|
|
3668
|
-
logger.error(error);
|
|
3669
|
-
return elements;
|
|
3670
|
-
}
|
|
3671
|
-
return elements;
|
|
3672
|
-
}
|
|
3673
|
-
var formatLogString, buildError, fileToBase64, KarinConvertAdapter;
|
|
3644
|
+
var formatLogString, buildError, AdapterConvertKarin, getFileSegment, fileToBase64, KarinConvertAdapter;
|
|
3674
3645
|
var init_convert = __esm({
|
|
3675
3646
|
"src/adapter/onebot/core/convert.ts"() {
|
|
3676
3647
|
init_message2();
|
|
@@ -3689,11 +3660,88 @@ var init_convert = __esm({
|
|
|
3689
3660
|
action: ${action}
|
|
3690
3661
|
params: ${formatLogString(request2)}`);
|
|
3691
3662
|
};
|
|
3692
|
-
|
|
3693
|
-
if (!
|
|
3663
|
+
AdapterConvertKarin = async (data, onebot, contact3) => {
|
|
3664
|
+
if (!Array.isArray(data)) return [];
|
|
3665
|
+
const elements = [];
|
|
3666
|
+
try {
|
|
3667
|
+
for (const i of data) {
|
|
3668
|
+
switch (i.type) {
|
|
3669
|
+
case "text":
|
|
3670
|
+
elements.push(segment_exports.text(i.data.text));
|
|
3671
|
+
break;
|
|
3672
|
+
case "face":
|
|
3673
|
+
elements.push(segment_exports.face(Number(i.data.id)));
|
|
3674
|
+
break;
|
|
3675
|
+
case "image":
|
|
3676
|
+
elements.push(segment_exports.image(i.data.url || i.data.file, { fileType: i.data.type }));
|
|
3677
|
+
break;
|
|
3678
|
+
case "record":
|
|
3679
|
+
elements.push(segment_exports.record(i.data.url || i.data.file, i.data.magic === 1));
|
|
3680
|
+
break;
|
|
3681
|
+
case "video":
|
|
3682
|
+
elements.push(segment_exports.video(i.data.url || i.data.file));
|
|
3683
|
+
break;
|
|
3684
|
+
case "at":
|
|
3685
|
+
elements.push(segment_exports.at(i.data.qq, i.data.name));
|
|
3686
|
+
break;
|
|
3687
|
+
case "contact":
|
|
3688
|
+
elements.push(segment_exports.contact(i.data.type === "qq" ? "friend" : "group", i.data.id));
|
|
3689
|
+
break;
|
|
3690
|
+
case "location":
|
|
3691
|
+
elements.push(segment_exports.location(
|
|
3692
|
+
Number(i.data.lat),
|
|
3693
|
+
Number(i.data.lon),
|
|
3694
|
+
i.data.title || "",
|
|
3695
|
+
i.data.content || ""
|
|
3696
|
+
));
|
|
3697
|
+
break;
|
|
3698
|
+
case "reply":
|
|
3699
|
+
elements.push(segment_exports.reply(i.data.id));
|
|
3700
|
+
break;
|
|
3701
|
+
case "json":
|
|
3702
|
+
elements.push(segment_exports.json(i.data.data));
|
|
3703
|
+
break;
|
|
3704
|
+
case "xml":
|
|
3705
|
+
elements.push(segment_exports.xml(i.data.data));
|
|
3706
|
+
break;
|
|
3707
|
+
case "file":
|
|
3708
|
+
elements.push(await getFileSegment(i.data, onebot, contact3));
|
|
3709
|
+
break;
|
|
3710
|
+
default: {
|
|
3711
|
+
elements.push(segment_exports.text(JSON.stringify(i)));
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
} catch (error) {
|
|
3716
|
+
logger.error("[AdapterConvertKarin] \u8F6C\u6362\u9519\u8BEF");
|
|
3717
|
+
logger.error(error);
|
|
3718
|
+
return elements;
|
|
3719
|
+
}
|
|
3720
|
+
return elements;
|
|
3721
|
+
};
|
|
3722
|
+
getFileSegment = async (file2, onebot, contact3) => {
|
|
3723
|
+
if ("file_name" in file2 && "file_hash" in file2) {
|
|
3724
|
+
return segment_exports.file(file2.url, {
|
|
3725
|
+
name: file2.file_name,
|
|
3726
|
+
hash: file2.file_hash,
|
|
3727
|
+
fid: file2.file_id
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3730
|
+
if (Object.keys(file2).length === 3 && "file_size" in file2 && "file_id" in file2) {
|
|
3731
|
+
const url = await onebot.getFileUrl(contact3, file2.file_id);
|
|
3732
|
+
return segment_exports.file(url, {
|
|
3733
|
+
name: file2.file,
|
|
3734
|
+
size: file2.file_size,
|
|
3735
|
+
fid: file2.file_id
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3738
|
+
return segment_exports.file(file2.file, { ...file2 });
|
|
3739
|
+
};
|
|
3740
|
+
fileToBase64 = (file2, url) => {
|
|
3741
|
+
if (!url || !file2.startsWith("file://")) return file2;
|
|
3694
3742
|
const list2 = ["127.0.0.1", "localhost"];
|
|
3695
3743
|
const link = new URL(url);
|
|
3696
|
-
return list2.includes(link.hostname) ?
|
|
3744
|
+
return list2.includes(link.hostname) ? file2 : `base64://${fs5.readFileSync(file2.replace("file://", "")).toString("base64")}`;
|
|
3697
3745
|
};
|
|
3698
3746
|
KarinConvertAdapter = (data, onebot) => {
|
|
3699
3747
|
const elements = [];
|
|
@@ -3886,14 +3934,14 @@ var init_error2 = __esm({
|
|
|
3886
3934
|
"src/core/internal/error.ts"() {
|
|
3887
3935
|
init_listeners();
|
|
3888
3936
|
missing = /* @__PURE__ */ new Map();
|
|
3889
|
-
loaderPlugin = (name,
|
|
3937
|
+
loaderPlugin = (name, file2, error) => {
|
|
3890
3938
|
const pkg2 = /Cannot find package '(.+?)'/.exec(error)?.[1];
|
|
3891
3939
|
if (pkg2) {
|
|
3892
3940
|
const key = `${name}.${pkg2}`;
|
|
3893
3941
|
if (missing.has(key)) return;
|
|
3894
|
-
missing.set(key, { name, file, depend: pkg2 });
|
|
3942
|
+
missing.set(key, { name, file: file2, depend: pkg2 });
|
|
3895
3943
|
} else {
|
|
3896
|
-
logger.error(`\u8F7D\u5165\u63D2\u4EF6\u9519\u8BEF\uFF1A${logger.red(`${name}/${path4.basename(
|
|
3944
|
+
logger.error(`\u8F7D\u5165\u63D2\u4EF6\u9519\u8BEF\uFF1A${logger.red(`${name}/${path4.basename(file2)}`)}`);
|
|
3897
3945
|
listeners.emit("error", error);
|
|
3898
3946
|
}
|
|
3899
3947
|
};
|
|
@@ -3905,8 +3953,8 @@ var init_error2 = __esm({
|
|
|
3905
3953
|
try {
|
|
3906
3954
|
if (!missing.size) return;
|
|
3907
3955
|
const msg = ["\n-----\u4F9D\u8D56\u7F3A\u5931----"];
|
|
3908
|
-
for (const [, { name, file, depend }] of missing) {
|
|
3909
|
-
msg.push(`[${name}][${path4.basename(
|
|
3956
|
+
for (const [, { name, file: file2, depend }] of missing) {
|
|
3957
|
+
msg.push(`[${name}][${path4.basename(file2)}] \u7F3A\u5C11\u4F9D\u8D56\uFF1A${logger.red(depend)}`);
|
|
3910
3958
|
}
|
|
3911
3959
|
msg.push("-------------------");
|
|
3912
3960
|
const one = missing.values().next().value;
|
|
@@ -4706,8 +4754,8 @@ var init_other = __esm({
|
|
|
4706
4754
|
case "friendRecall":
|
|
4707
4755
|
ctx3.tips = `\u64A4\u56DE\u6D88\u606F: ${ctx3.content.messageId}`;
|
|
4708
4756
|
break;
|
|
4709
|
-
case "
|
|
4710
|
-
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [
|
|
4757
|
+
case "privateFileUploaded":
|
|
4758
|
+
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [fid:${ctx3.content.fid}] [name:${ctx3.content.name}]`;
|
|
4711
4759
|
break;
|
|
4712
4760
|
case "friendIncrease":
|
|
4713
4761
|
ctx3.tips = `\u65B0\u589E\u597D\u53CB: ${ctx3.content.targetId}`;
|
|
@@ -4725,7 +4773,7 @@ var init_other = __esm({
|
|
|
4725
4773
|
ctx3.tips = `\u64A4\u56DE\u6D88\u606F: ${ctx3.content.messageId}`;
|
|
4726
4774
|
break;
|
|
4727
4775
|
case "groupFileUploaded":
|
|
4728
|
-
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [
|
|
4776
|
+
ctx3.tips = `\u6587\u4EF6\u4E0A\u4F20: [fid:${ctx3.content.fid}] [fid:${ctx3.content.fid}] [name:${ctx3.content.name}]`;
|
|
4729
4777
|
break;
|
|
4730
4778
|
case "groupMemberAdd":
|
|
4731
4779
|
ctx3.tips = `\u65B0\u589E\u6210\u5458: [\u64CD\u4F5C\u8005:${ctx3.content.operatorId}] [\u76EE\u6807\u6210\u5458:${ctx3.content.targetId}]`;
|
|
@@ -4778,8 +4826,15 @@ var init_other = __esm({
|
|
|
4778
4826
|
}
|
|
4779
4827
|
};
|
|
4780
4828
|
initPrint = (ctx3, type, prefix, level = "info") => {
|
|
4781
|
-
|
|
4782
|
-
|
|
4829
|
+
let idPath = "\u672A\u77E5";
|
|
4830
|
+
if (ctx3.isFriend) {
|
|
4831
|
+
idPath = ctx3.userId;
|
|
4832
|
+
} else if (ctx3.isGroup) {
|
|
4833
|
+
idPath = `${ctx3.groupId}-${ctx3.userId}`;
|
|
4834
|
+
}
|
|
4835
|
+
const nick = ctx3.sender.nick || "";
|
|
4836
|
+
ctx3.logText = `[${type}:${idPath}(${nick})]`;
|
|
4837
|
+
logger.bot(level, ctx3.selfId, `${prefix}: ${ctx3.logText} ${ctx3.tips}`);
|
|
4783
4838
|
};
|
|
4784
4839
|
deal = async (ctx3, config3) => {
|
|
4785
4840
|
for (const plugin of cache3.accept) {
|
|
@@ -6397,8 +6452,8 @@ var init_notice2 = __esm({
|
|
|
6397
6452
|
#sender;
|
|
6398
6453
|
content;
|
|
6399
6454
|
constructor(options) {
|
|
6400
|
-
super(Object.assign(options, { subEvent: "
|
|
6401
|
-
this.#subEvent = "
|
|
6455
|
+
super(Object.assign(options, { subEvent: "privateFileUploaded" }));
|
|
6456
|
+
this.#subEvent = "privateFileUploaded";
|
|
6402
6457
|
this.#contact = options.contact;
|
|
6403
6458
|
this.#sender = options.sender;
|
|
6404
6459
|
this.content = options.content;
|
|
@@ -7547,7 +7602,7 @@ var init_message5 = __esm({
|
|
|
7547
7602
|
init_convert();
|
|
7548
7603
|
init_create();
|
|
7549
7604
|
init_event3();
|
|
7550
|
-
createMessage = (event, bot) => {
|
|
7605
|
+
createMessage = async (event, bot) => {
|
|
7551
7606
|
debug("onebot:createMessage", event);
|
|
7552
7607
|
const time2 = event.time;
|
|
7553
7608
|
if (event.message_type === "private") {
|
|
@@ -7569,7 +7624,7 @@ var init_message5 = __esm({
|
|
|
7569
7624
|
messageId: event.message_id + "",
|
|
7570
7625
|
messageSeq: event.message_id,
|
|
7571
7626
|
eventId: `message:${event.message_id}`,
|
|
7572
|
-
elements: AdapterConvertKarin(event.message),
|
|
7627
|
+
elements: await AdapterConvertKarin(event.message, bot, contact3),
|
|
7573
7628
|
srcReply: (elements) => bot.sendMsg(contact3, elements)
|
|
7574
7629
|
});
|
|
7575
7630
|
return;
|
|
@@ -7582,7 +7637,7 @@ var init_message5 = __esm({
|
|
|
7582
7637
|
createGroupTempMessage({
|
|
7583
7638
|
bot,
|
|
7584
7639
|
contact: contact3,
|
|
7585
|
-
elements: AdapterConvertKarin(event.message),
|
|
7640
|
+
elements: await AdapterConvertKarin(event.message, bot, contact3),
|
|
7586
7641
|
eventId: `message:${event.message_id}`,
|
|
7587
7642
|
messageId: event.message_id + "",
|
|
7588
7643
|
messageSeq: event.message_id,
|
|
@@ -7605,7 +7660,7 @@ var init_message5 = __esm({
|
|
|
7605
7660
|
createGroupMessage({
|
|
7606
7661
|
bot,
|
|
7607
7662
|
contact: contact3,
|
|
7608
|
-
elements: AdapterConvertKarin(event.message),
|
|
7663
|
+
elements: await AdapterConvertKarin(event.message, bot, contact3),
|
|
7609
7664
|
eventId: `message:${event.message_id}`,
|
|
7610
7665
|
messageId: event.message_id + "",
|
|
7611
7666
|
messageSeq: event.message_id,
|
|
@@ -7628,6 +7683,7 @@ var init_notice3 = __esm({
|
|
|
7628
7683
|
init_event3();
|
|
7629
7684
|
init_event2();
|
|
7630
7685
|
init_create();
|
|
7686
|
+
init_convert();
|
|
7631
7687
|
createNotice = (event, bot) => {
|
|
7632
7688
|
const time2 = event.time;
|
|
7633
7689
|
if (event.notice_type === "friend_recall" /* FriendRecall */) {
|
|
@@ -7826,7 +7882,11 @@ var init_notice3 = __esm({
|
|
|
7826
7882
|
fid: event.file.id,
|
|
7827
7883
|
name: event.file.name,
|
|
7828
7884
|
size: event.file.size,
|
|
7829
|
-
subId: event.file.busid
|
|
7885
|
+
subId: event.file.busid,
|
|
7886
|
+
url: async () => {
|
|
7887
|
+
const { file: file2 } = await getFileSegment(event.file, bot, contact3);
|
|
7888
|
+
return file2;
|
|
7889
|
+
}
|
|
7830
7890
|
}
|
|
7831
7891
|
});
|
|
7832
7892
|
return;
|
|
@@ -7954,6 +8014,32 @@ var init_notice3 = __esm({
|
|
|
7954
8014
|
});
|
|
7955
8015
|
return;
|
|
7956
8016
|
}
|
|
8017
|
+
if (event.notice_type === "offline_file" /* OfflineFile */) {
|
|
8018
|
+
const userId = event.user_id + "";
|
|
8019
|
+
const contact3 = contactFriend(userId);
|
|
8020
|
+
createPrivateFileUploadedNotice({
|
|
8021
|
+
bot,
|
|
8022
|
+
eventId: `notice:${userId}.${event.time}`,
|
|
8023
|
+
rawEvent: event,
|
|
8024
|
+
time: time2,
|
|
8025
|
+
contact: contact3,
|
|
8026
|
+
sender: senderFriend(userId),
|
|
8027
|
+
srcReply: (elements) => bot.sendMsg(contact3, elements),
|
|
8028
|
+
content: {
|
|
8029
|
+
operatorId: userId,
|
|
8030
|
+
subId: 0,
|
|
8031
|
+
fid: event.file.id,
|
|
8032
|
+
name: event.file.name,
|
|
8033
|
+
size: event.file.size,
|
|
8034
|
+
expireTime: 0,
|
|
8035
|
+
url: async () => {
|
|
8036
|
+
const { file: file2 } = await getFileSegment(event.file, bot, contact3);
|
|
8037
|
+
return file2;
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
});
|
|
8041
|
+
return;
|
|
8042
|
+
}
|
|
7957
8043
|
logger.warn(`[AdapterOneBot] \u6536\u5230\u672A\u77E5\u4E8B\u4EF6: ${JSON.stringify(event)}`);
|
|
7958
8044
|
};
|
|
7959
8045
|
}
|
|
@@ -8058,24 +8144,19 @@ var init_base3 = __esm({
|
|
|
8058
8144
|
* @param str 事件字符串
|
|
8059
8145
|
*/
|
|
8060
8146
|
eventHandlers(data, str) {
|
|
8061
|
-
debug("onebot", str);
|
|
8062
8147
|
if (data.post_type === "message" /* Message */ || data.post_type === "message_sent" /* MessageSent */) {
|
|
8063
|
-
debug("onebot:message", str);
|
|
8064
8148
|
createMessage(data, this);
|
|
8065
8149
|
return;
|
|
8066
8150
|
}
|
|
8067
8151
|
if (data.post_type === "notice" /* Notice */) {
|
|
8068
|
-
debug("onebot:notice", str);
|
|
8069
8152
|
createNotice(data, this);
|
|
8070
8153
|
return;
|
|
8071
8154
|
}
|
|
8072
8155
|
if (data.post_type === "request" /* Request */) {
|
|
8073
|
-
debug("onebot:request", str);
|
|
8074
8156
|
createRequest(data, this);
|
|
8075
8157
|
return;
|
|
8076
8158
|
}
|
|
8077
8159
|
if (data.post_type === "meta_event" /* MetaEvent */) {
|
|
8078
|
-
debug("onebot:meta", str);
|
|
8079
8160
|
if (data.meta_event_type === "lifecycle") {
|
|
8080
8161
|
if (data.sub_type === "enable") {
|
|
8081
8162
|
logger.bot("debug", this.selfId, "OneBot\u542F\u7528");
|
|
@@ -8092,7 +8173,6 @@ var init_base3 = __esm({
|
|
|
8092
8173
|
return;
|
|
8093
8174
|
}
|
|
8094
8175
|
if (data.retcode) {
|
|
8095
|
-
debug("onebot:retcode", str);
|
|
8096
8176
|
const { retcode } = data;
|
|
8097
8177
|
if (retcode === 1401 || retcode === 1403) {
|
|
8098
8178
|
logger.error(`[oneBot11][\u9274\u6743\u5931\u8D25] address: ${this.adapter.address} event: ${str}`);
|
|
@@ -8100,15 +8180,16 @@ var init_base3 = __esm({
|
|
|
8100
8180
|
}
|
|
8101
8181
|
logger.bot("error", this.selfId, `\u53D1\u751F\u672A\u77E5\u9519\u8BEF: ${str}`);
|
|
8102
8182
|
}
|
|
8103
|
-
debug("onebot:unknown", str);
|
|
8104
8183
|
logger.bot("warn", this.selfId, `\u6536\u5230\u672A\u77E5\u4E8B\u4EF6: ${str}`);
|
|
8105
8184
|
}
|
|
8106
8185
|
/**
|
|
8107
8186
|
* onebot11转karin
|
|
8187
|
+
* @param data onebot11格式消息
|
|
8188
|
+
* @param contact 联系人信息 如果需要转换napcat的文件消息则需要传入
|
|
8108
8189
|
* @return karin格式消息
|
|
8109
8190
|
*/
|
|
8110
|
-
AdapterConvertKarin(data) {
|
|
8111
|
-
return AdapterConvertKarin(data);
|
|
8191
|
+
AdapterConvertKarin(data, contact3) {
|
|
8192
|
+
return AdapterConvertKarin(data, this, contact3);
|
|
8112
8193
|
}
|
|
8113
8194
|
/**
|
|
8114
8195
|
* karin转onebot11
|
|
@@ -8299,7 +8380,7 @@ var init_base3 = __esm({
|
|
|
8299
8380
|
role: "unknown",
|
|
8300
8381
|
name: result.sender.nickname
|
|
8301
8382
|
},
|
|
8302
|
-
elements: this.AdapterConvertKarin(result.message)
|
|
8383
|
+
elements: await this.AdapterConvertKarin(result.message, contact3)
|
|
8303
8384
|
};
|
|
8304
8385
|
}
|
|
8305
8386
|
/**
|
|
@@ -8373,7 +8454,7 @@ var init_base3 = __esm({
|
|
|
8373
8454
|
role: v?.sender?.role || "unknown",
|
|
8374
8455
|
card: contact3.scene === "group" ? v?.sender?.card || "" : ""
|
|
8375
8456
|
},
|
|
8376
|
-
elements: this.AdapterConvertKarin(v.message)
|
|
8457
|
+
elements: await this.AdapterConvertKarin(v.message, contact3)
|
|
8377
8458
|
};
|
|
8378
8459
|
all.push(data);
|
|
8379
8460
|
}
|
|
@@ -9055,12 +9136,12 @@ var init_base3 = __esm({
|
|
|
9055
9136
|
* @param folder 父目录ID 不提供则上传到根目录 仅在群聊时有效
|
|
9056
9137
|
* @returns 此接口的返回值不值得信任
|
|
9057
9138
|
*/
|
|
9058
|
-
async uploadFile(contact3,
|
|
9139
|
+
async uploadFile(contact3, file2, name, folder) {
|
|
9059
9140
|
try {
|
|
9060
9141
|
if (contact3.scene === "group") {
|
|
9061
|
-
await this.sendApi("upload_group_file" /* uploadGroupFile */, { group_id: Number(contact3.peer), file, name, folder });
|
|
9142
|
+
await this.sendApi("upload_group_file" /* uploadGroupFile */, { group_id: Number(contact3.peer), file: file2, name, folder });
|
|
9062
9143
|
} else {
|
|
9063
|
-
await this.sendApi("upload_private_file" /* uploadPrivateFile */, { user_id: Number(contact3.peer), file, name });
|
|
9144
|
+
await this.sendApi("upload_private_file" /* uploadPrivateFile */, { user_id: Number(contact3.peer), file: file2, name });
|
|
9064
9145
|
}
|
|
9065
9146
|
return true;
|
|
9066
9147
|
} catch {
|
|
@@ -9070,14 +9151,14 @@ var init_base3 = __esm({
|
|
|
9070
9151
|
/**
|
|
9071
9152
|
* @deprecated 已废弃,请使用`uploadFile`
|
|
9072
9153
|
*/
|
|
9073
|
-
async UploadGroupFile(groupId,
|
|
9074
|
-
return this.uploadFile({ scene: "group", peer: groupId, name: "" },
|
|
9154
|
+
async UploadGroupFile(groupId, file2, name, folder) {
|
|
9155
|
+
return this.uploadFile({ scene: "group", peer: groupId, name: "" }, file2, name, folder);
|
|
9075
9156
|
}
|
|
9076
9157
|
/**
|
|
9077
9158
|
* @deprecated 已废弃,请使用`uploadFile`
|
|
9078
9159
|
*/
|
|
9079
|
-
async UploadPrivateFile(userId,
|
|
9080
|
-
return this.uploadFile({ scene: "friend", peer: userId, name: "" },
|
|
9160
|
+
async UploadPrivateFile(userId, file2, name) {
|
|
9161
|
+
return this.uploadFile({ scene: "friend", peer: userId, name: "" }, file2, name);
|
|
9081
9162
|
}
|
|
9082
9163
|
/**
|
|
9083
9164
|
* 设置、取消群精华消息
|
|
@@ -9237,6 +9318,29 @@ var init_base3 = __esm({
|
|
|
9237
9318
|
async sendForwardMessage(contact3, elements) {
|
|
9238
9319
|
return this.sendForwardMsg(contact3, elements);
|
|
9239
9320
|
}
|
|
9321
|
+
/**
|
|
9322
|
+
* 获取文件url
|
|
9323
|
+
* @param contact 目标信息
|
|
9324
|
+
* @param fid 文件id
|
|
9325
|
+
* @returns 文件url
|
|
9326
|
+
*/
|
|
9327
|
+
async getFileUrl(contact3, fid) {
|
|
9328
|
+
if (contact3.scene === "group") {
|
|
9329
|
+
const { url } = await this.sendApi(
|
|
9330
|
+
"get_group_file_url" /* getGroupFileUrl */,
|
|
9331
|
+
{ group_id: Number(contact3.peer), file_id: fid }
|
|
9332
|
+
);
|
|
9333
|
+
return url;
|
|
9334
|
+
}
|
|
9335
|
+
if (contact3.scene === "friend") {
|
|
9336
|
+
const { url } = await this.sendApi(
|
|
9337
|
+
"get_private_file_url" /* getPrivateFileUrl */,
|
|
9338
|
+
{ user_id: Number(contact3.peer), file_id: fid }
|
|
9339
|
+
);
|
|
9340
|
+
return url;
|
|
9341
|
+
}
|
|
9342
|
+
throw TypeError(`\u4E0D\u652F\u6301\u7684\u573A\u666F\u7C7B\u578B: ${contact3.scene}`);
|
|
9343
|
+
}
|
|
9240
9344
|
/**
|
|
9241
9345
|
* 发送API请求
|
|
9242
9346
|
* @param action API端点
|
|
@@ -10049,8 +10153,8 @@ var init_list = __esm({
|
|
|
10049
10153
|
dir: dir2,
|
|
10050
10154
|
id: -1,
|
|
10051
10155
|
get pkgPath() {
|
|
10052
|
-
const
|
|
10053
|
-
return fs5.existsSync(
|
|
10156
|
+
const file2 = path4.join(this.dir, "package.json");
|
|
10157
|
+
return fs5.existsSync(file2) ? file2 : "";
|
|
10054
10158
|
},
|
|
10055
10159
|
get pkgData() {
|
|
10056
10160
|
if (!this.pkgPath) return {};
|
|
@@ -10133,18 +10237,18 @@ var init_list = __esm({
|
|
|
10133
10237
|
list2.map(async (v) => {
|
|
10134
10238
|
const [type, name] = v.split(":");
|
|
10135
10239
|
if (type === "app") {
|
|
10136
|
-
const
|
|
10137
|
-
await getAppInfo(info,
|
|
10240
|
+
const file2 = path4.join(karinPathPlugins, name);
|
|
10241
|
+
await getAppInfo(info, file2, name, ext, isForce);
|
|
10138
10242
|
return;
|
|
10139
10243
|
}
|
|
10140
10244
|
if (type === "git" || type === "root") {
|
|
10141
|
-
const
|
|
10142
|
-
await getGitInfo(info,
|
|
10245
|
+
const file2 = type === "root" ? process.cwd() : path4.join(karinPathPlugins, name);
|
|
10246
|
+
await getGitInfo(info, file2, name, ext, isForce, env3);
|
|
10143
10247
|
return;
|
|
10144
10248
|
}
|
|
10145
10249
|
if (type === "npm") {
|
|
10146
|
-
const
|
|
10147
|
-
await getNpmInfo(info,
|
|
10250
|
+
const file2 = path4.join(process.cwd(), "node_modules", name);
|
|
10251
|
+
await getNpmInfo(info, file2, name, isForce, env3);
|
|
10148
10252
|
}
|
|
10149
10253
|
})
|
|
10150
10254
|
);
|
|
@@ -10173,8 +10277,9 @@ var init_list = __esm({
|
|
|
10173
10277
|
if (!v.name.startsWith("karin-plugin-")) return;
|
|
10174
10278
|
if (!fs5.existsSync(path4.join(karinPathPlugins, v.name, "package.json"))) return;
|
|
10175
10279
|
const pkg2 = await requireFile(path4.join(karinPathPlugins, v.name, "package.json"));
|
|
10176
|
-
|
|
10177
|
-
|
|
10280
|
+
const engines = pkg2?.karin?.engines?.karin || pkg2?.engines?.karin;
|
|
10281
|
+
if (engines && !satisfies(engines, process.env.KARIN_VERSION)) {
|
|
10282
|
+
const msg = `[getPlugins][git] ${v.name} \u8981\u6C42 node-karin \u7248\u672C\u4E3A ${engines}\uFF0C\u5F53\u524D\u4E0D\u7B26\u5408\u8981\u6C42\uFF0C\u8DF3\u8FC7\u52A0\u8F7D\u63D2\u4EF6`;
|
|
10178
10283
|
isInit && setTimeout(() => logger.error(msg), 1e3);
|
|
10179
10284
|
return;
|
|
10180
10285
|
}
|
|
@@ -10218,13 +10323,14 @@ var init_list = __esm({
|
|
|
10218
10323
|
].filter((name) => !NPM_EXCLUDE_LIST.includes(name) && !name.startsWith("@types"));
|
|
10219
10324
|
await Promise.allSettled(
|
|
10220
10325
|
dependencies.map(async (name) => {
|
|
10221
|
-
const
|
|
10222
|
-
const pkg3 = await requireFile(
|
|
10326
|
+
const file2 = path4.join(process.cwd(), "node_modules", name, "package.json");
|
|
10327
|
+
const pkg3 = await requireFile(file2);
|
|
10223
10328
|
if (!pkg3.karin) return;
|
|
10224
|
-
|
|
10225
|
-
|
|
10329
|
+
const engines = pkg3.karin?.engines?.karin || pkg3.engines?.karin;
|
|
10330
|
+
if (engines) {
|
|
10331
|
+
if (!satisfies(engines, process.env.KARIN_VERSION)) {
|
|
10226
10332
|
isInit && logger.error(
|
|
10227
|
-
`[getPlugins][npm] ${name} \u8981\u6C42 node-karin \u7248\u672C\u4E3A ${
|
|
10333
|
+
`[getPlugins][npm] ${name} \u8981\u6C42 node-karin \u7248\u672C\u4E3A ${engines}\uFF0C\u5F53\u524D\u4E0D\u7B26\u5408\u8981\u6C42\uFF0C\u8DF3\u8FC7\u52A0\u8F7D\u63D2\u4EF6`
|
|
10228
10334
|
);
|
|
10229
10335
|
return;
|
|
10230
10336
|
}
|
|
@@ -11188,9 +11294,9 @@ var init_fileToUrl = __esm({
|
|
|
11188
11294
|
"src/utils/system/fileToUrl.ts"() {
|
|
11189
11295
|
init_handler2();
|
|
11190
11296
|
fileToUrlHandlerKey = "fileToUrl";
|
|
11191
|
-
fileToUrl = async (type,
|
|
11297
|
+
fileToUrl = async (type, file2, filename2, args) => {
|
|
11192
11298
|
if (!handler.has(fileToUrlHandlerKey)) throw new Error("[Handler][Error]: \u6CA1\u6709\u914D\u7F6E\u6587\u4EF6\u8F6C\u6362\u4E3Aurl\u7684\u5904\u7406\u5668");
|
|
11193
|
-
return handler(fileToUrlHandlerKey, { file, type, filename: filename2, args });
|
|
11299
|
+
return handler(fileToUrlHandlerKey, { file: file2, type, filename: filename2, args });
|
|
11194
11300
|
};
|
|
11195
11301
|
}
|
|
11196
11302
|
});
|
|
@@ -15886,10 +15992,10 @@ var init_env4 = __esm({
|
|
|
15886
15992
|
};
|
|
15887
15993
|
initEnv = () => {
|
|
15888
15994
|
const name = process.env.EBV_FILE;
|
|
15889
|
-
const
|
|
15995
|
+
const file2 = `${process.cwd()}/${name}`;
|
|
15890
15996
|
getEnv();
|
|
15891
|
-
watch(
|
|
15892
|
-
dotenv_default.config({ path:
|
|
15997
|
+
watch(file2, (old, data) => {
|
|
15998
|
+
dotenv_default.config({ path: file2, override: true });
|
|
15893
15999
|
process.env.RUNTIME = data.RUNTIME.value || "node";
|
|
15894
16000
|
logger.level = process.env.LOG_LEVEL || "info";
|
|
15895
16001
|
if (old?.WS_SERVER_AUTH_KEY?.value !== data?.WS_SERVER_AUTH_KEY?.value) {
|
|
@@ -15900,7 +16006,7 @@ var init_env4 = __esm({
|
|
|
15900
16006
|
logger.warn("[hmr] HTTP\u9274\u6743\u79D8\u94A5\u5DF2\u66F4\u65B0");
|
|
15901
16007
|
updateJwt();
|
|
15902
16008
|
}
|
|
15903
|
-
const options = { file, old, data };
|
|
16009
|
+
const options = { file: file2, old, data };
|
|
15904
16010
|
listeners.emit(FILE_CHANGE, options);
|
|
15905
16011
|
listeners.emit(`${FILE_CHANGE}:${name}`, options);
|
|
15906
16012
|
}, { parser });
|
|
@@ -16006,17 +16112,17 @@ var init_admin = __esm({
|
|
|
16006
16112
|
init_env4();
|
|
16007
16113
|
init_require();
|
|
16008
16114
|
getYaml = (name, type, isRefresh) => {
|
|
16009
|
-
const
|
|
16010
|
-
if (!fs5.existsSync(
|
|
16011
|
-
throw new TypeError(`${
|
|
16115
|
+
const file2 = `${type === "user" ? configPath : defaultConfigPath}/${name}.json`;
|
|
16116
|
+
if (!fs5.existsSync(file2)) {
|
|
16117
|
+
throw new TypeError(`${file2} \u6587\u4EF6\u4E0D\u5B58\u5728`);
|
|
16012
16118
|
}
|
|
16013
|
-
return requireFileSync(
|
|
16119
|
+
return requireFileSync(file2, { force: isRefresh });
|
|
16014
16120
|
};
|
|
16015
16121
|
setYaml = (name, data) => {
|
|
16016
16122
|
if (name === "env") return setEnv(data);
|
|
16017
|
-
const
|
|
16018
|
-
if (!fs5.existsSync(
|
|
16019
|
-
fs5.writeFileSync(
|
|
16123
|
+
const file2 = `${configPath}/${name}.json`;
|
|
16124
|
+
if (!fs5.existsSync(file2)) return false;
|
|
16125
|
+
fs5.writeFileSync(file2, JSON.stringify(data, null, 2));
|
|
16020
16126
|
return true;
|
|
16021
16127
|
};
|
|
16022
16128
|
setConfig = (name, data) => {
|
|
@@ -16024,8 +16130,8 @@ var init_admin = __esm({
|
|
|
16024
16130
|
};
|
|
16025
16131
|
clearFiles = (dir2) => {
|
|
16026
16132
|
const list2 = fs5.readdirSync(dir2);
|
|
16027
|
-
list2.forEach((
|
|
16028
|
-
fs5.promises.rm(
|
|
16133
|
+
list2.forEach((file2) => {
|
|
16134
|
+
fs5.promises.rm(file2, { recursive: true, force: true });
|
|
16029
16135
|
});
|
|
16030
16136
|
};
|
|
16031
16137
|
updateLevel = (level) => {
|
|
@@ -16373,7 +16479,7 @@ var init_common = __esm({
|
|
|
16373
16479
|
fs5.mkdirSync(rootTemp, { recursive: true });
|
|
16374
16480
|
const files = getAbsPath(images, rootTemp);
|
|
16375
16481
|
const filterComplex = await buildFilterComplex(files, perRow);
|
|
16376
|
-
const inputImages = files.map((
|
|
16482
|
+
const inputImages = files.map((file2) => `-i "${file2}"`).join(" ");
|
|
16377
16483
|
const output = path4.join(rootTemp, "output.png");
|
|
16378
16484
|
const ffmpegCmd = `${inputImages} -filter_complex "${filterComplex}" -map "[out]" ${output}`;
|
|
16379
16485
|
const result = await ffmpeg(ffmpegCmd);
|
|
@@ -16393,20 +16499,20 @@ var init_common = __esm({
|
|
|
16393
16499
|
if (image2.startsWith("base64://")) {
|
|
16394
16500
|
const base642 = image2.replace(/^base64:\/\//, "");
|
|
16395
16501
|
const buffer2 = Buffer.from(base642, "base64");
|
|
16396
|
-
const
|
|
16397
|
-
fs5.writeFileSync(
|
|
16398
|
-
files.push(
|
|
16502
|
+
const file3 = path4.join(root2, `${index6}.png`);
|
|
16503
|
+
fs5.writeFileSync(file3, buffer2);
|
|
16504
|
+
files.push(file3);
|
|
16399
16505
|
return;
|
|
16400
16506
|
}
|
|
16401
16507
|
if (!fs5.existsSync(image2)) throw Error(`\u56FE\u7247\u8DEF\u5F84\u4E0D\u5B58\u5728: ${image2}`);
|
|
16402
|
-
const
|
|
16403
|
-
fs5.copyFileSync(image2,
|
|
16404
|
-
files.push(
|
|
16508
|
+
const file2 = path4.join(root2, path4.basename(image2));
|
|
16509
|
+
fs5.copyFileSync(image2, file2);
|
|
16510
|
+
files.push(file2);
|
|
16405
16511
|
});
|
|
16406
16512
|
return files;
|
|
16407
16513
|
};
|
|
16408
|
-
getImageSize = async (
|
|
16409
|
-
const { stdout } = await ffprobe(`-v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 "${
|
|
16514
|
+
getImageSize = async (file2) => {
|
|
16515
|
+
const { stdout } = await ffprobe(`-v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 "${file2}"`);
|
|
16410
16516
|
const [width, height] = stdout.trim().split(",").map(Number);
|
|
16411
16517
|
return { width, height };
|
|
16412
16518
|
};
|
|
@@ -16420,9 +16526,9 @@ var init_common = __esm({
|
|
|
16420
16526
|
};
|
|
16421
16527
|
buildFilterComplex = async (files, perRow) => {
|
|
16422
16528
|
const list2 = await Promise.all(
|
|
16423
|
-
files.map(async (
|
|
16424
|
-
const { width, height } = await getImageSize(
|
|
16425
|
-
return { file, width, height };
|
|
16529
|
+
files.map(async (file2) => {
|
|
16530
|
+
const { width, height } = await getImageSize(file2);
|
|
16531
|
+
return { file: file2, width, height };
|
|
16426
16532
|
})
|
|
16427
16533
|
);
|
|
16428
16534
|
const maxWidth = Math.max(...list2.map((d) => d.width));
|
|
@@ -16657,10 +16763,10 @@ var init_adapter = __esm({
|
|
|
16657
16763
|
};
|
|
16658
16764
|
initAdapter = (dir2) => {
|
|
16659
16765
|
const name = "adapter.json";
|
|
16660
|
-
const
|
|
16661
|
-
const data = requireFileSync(
|
|
16766
|
+
const file2 = `${dir2}/${name}`;
|
|
16767
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16662
16768
|
cache6 = format(data);
|
|
16663
|
-
watch(
|
|
16769
|
+
watch(file2, (old, data2) => {
|
|
16664
16770
|
cache6 = format(data2);
|
|
16665
16771
|
const options = { file: name, old, data: cache6 };
|
|
16666
16772
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16700,10 +16806,10 @@ var init_config2 = __esm({
|
|
|
16700
16806
|
init_listeners();
|
|
16701
16807
|
initConfig = (dir2) => {
|
|
16702
16808
|
const name = "config.json";
|
|
16703
|
-
const
|
|
16704
|
-
const data = requireFileSync(
|
|
16809
|
+
const file2 = `${dir2}/${name}`;
|
|
16810
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16705
16811
|
cache7 = formatObject(data);
|
|
16706
|
-
watch(
|
|
16812
|
+
watch(file2, (old, data2) => {
|
|
16707
16813
|
cache7 = formatObject(data2);
|
|
16708
16814
|
const options = { file: name, old, data: cache7 };
|
|
16709
16815
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16732,12 +16838,12 @@ var init_groups4 = __esm({
|
|
|
16732
16838
|
if (Array.isArray(obj)) return false;
|
|
16733
16839
|
return Object.keys(obj).every((key) => typeof obj[key] === "object");
|
|
16734
16840
|
};
|
|
16735
|
-
migrate = (
|
|
16841
|
+
migrate = (file2, data) => {
|
|
16736
16842
|
const list2 = [];
|
|
16737
16843
|
Object.entries(data).forEach(([key, value]) => {
|
|
16738
16844
|
list2.push({ key, ...value });
|
|
16739
16845
|
});
|
|
16740
|
-
fs5.writeFileSync(
|
|
16846
|
+
fs5.writeFileSync(file2, JSON.stringify(list2, null, 2));
|
|
16741
16847
|
logger.mark("[migrate] \u8FC1\u79FB groups.json \u914D\u7F6E\u6587\u4EF6\u6210\u529F");
|
|
16742
16848
|
return format2(list2);
|
|
16743
16849
|
};
|
|
@@ -16788,12 +16894,12 @@ var init_groups4 = __esm({
|
|
|
16788
16894
|
};
|
|
16789
16895
|
initGroups = async (dir2) => {
|
|
16790
16896
|
const name = "groups.json";
|
|
16791
|
-
const
|
|
16792
|
-
const data = requireFileSync(
|
|
16793
|
-
staticCache = isOld(data) ? migrate(
|
|
16897
|
+
const file2 = `${dir2}/${name}`;
|
|
16898
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16899
|
+
staticCache = isOld(data) ? migrate(file2, data) : format2(data);
|
|
16794
16900
|
dynamicCache = format2(data);
|
|
16795
|
-
watch(
|
|
16796
|
-
staticCache = isOld(data2) ? migrate(
|
|
16901
|
+
watch(file2, async (old, data2) => {
|
|
16902
|
+
staticCache = isOld(data2) ? migrate(file2, data2) : format2(data2);
|
|
16797
16903
|
dynamicCache = staticCache;
|
|
16798
16904
|
const options = { file: name, old, data: dynamicCache };
|
|
16799
16905
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16830,9 +16936,9 @@ var init_groups4 = __esm({
|
|
|
16830
16936
|
};
|
|
16831
16937
|
getGroupsFileData = (dir2) => {
|
|
16832
16938
|
const name = "groups.json";
|
|
16833
|
-
const
|
|
16834
|
-
const data = requireFileSync(
|
|
16835
|
-
return isOld(data) ? migrate(
|
|
16939
|
+
const file2 = `${dir2}/${name}`;
|
|
16940
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
16941
|
+
return isOld(data) ? migrate(file2, data) : format2(data);
|
|
16836
16942
|
};
|
|
16837
16943
|
groups_default = initGroups;
|
|
16838
16944
|
}
|
|
@@ -16853,12 +16959,12 @@ var init_privates = __esm({
|
|
|
16853
16959
|
if (Array.isArray(obj)) return false;
|
|
16854
16960
|
return Object.keys(obj).every((key) => typeof obj[key] === "object");
|
|
16855
16961
|
};
|
|
16856
|
-
migrate2 = (
|
|
16962
|
+
migrate2 = (file2, data) => {
|
|
16857
16963
|
const list2 = [];
|
|
16858
16964
|
Object.entries(data).forEach(([key, value]) => {
|
|
16859
16965
|
list2.push({ key, ...value });
|
|
16860
16966
|
});
|
|
16861
|
-
fs5.writeFileSync(
|
|
16967
|
+
fs5.writeFileSync(file2, JSON.stringify(list2, null, 2));
|
|
16862
16968
|
logger.mark("[migrate] \u8FC1\u79FB privates.json \u914D\u7F6E\u6587\u4EF6\u6210\u529F");
|
|
16863
16969
|
return format3(list2);
|
|
16864
16970
|
};
|
|
@@ -16902,12 +17008,12 @@ var init_privates = __esm({
|
|
|
16902
17008
|
};
|
|
16903
17009
|
initPrivates = async (dir2) => {
|
|
16904
17010
|
const name = "privates.json";
|
|
16905
|
-
const
|
|
16906
|
-
const data = requireFileSync(
|
|
16907
|
-
staticCache2 = isOld2(data) ? migrate2(
|
|
17011
|
+
const file2 = `${dir2}/${name}`;
|
|
17012
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
17013
|
+
staticCache2 = isOld2(data) ? migrate2(file2, data) : format3(data);
|
|
16908
17014
|
dynamicCache2 = format3(data);
|
|
16909
|
-
watch(
|
|
16910
|
-
staticCache2 = isOld2(data2) ? migrate2(
|
|
17015
|
+
watch(file2, async (old, data2) => {
|
|
17016
|
+
staticCache2 = isOld2(data2) ? migrate2(file2, data2) : format3(data2);
|
|
16911
17017
|
dynamicCache2 = staticCache2;
|
|
16912
17018
|
const options = { file: name, old, data: dynamicCache2 };
|
|
16913
17019
|
listeners.emit(FILE_CHANGE, options);
|
|
@@ -16926,9 +17032,9 @@ var init_privates = __esm({
|
|
|
16926
17032
|
};
|
|
16927
17033
|
getPrivatesFileData = (dir2) => {
|
|
16928
17034
|
const name = "privates.json";
|
|
16929
|
-
const
|
|
16930
|
-
const data = requireFileSync(
|
|
16931
|
-
return isOld2(data) ? migrate2(
|
|
17035
|
+
const file2 = `${dir2}/${name}`;
|
|
17036
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
17037
|
+
return isOld2(data) ? migrate2(file2, data) : format3(data);
|
|
16932
17038
|
};
|
|
16933
17039
|
privates_default = initPrivates;
|
|
16934
17040
|
}
|
|
@@ -17045,8 +17151,8 @@ var init_template = __esm({
|
|
|
17045
17151
|
if (options.file.startsWith("http")) {
|
|
17046
17152
|
throw TypeError("\u4ED6\u55B5\u7684 \u4E0D\u4F1A\u771F\u7684\u6709\u7B28\u6BD4\u4F20\u4E2Ahttp\u6765\u5F53\u505A\u6A21\u677F\u5427...");
|
|
17047
17153
|
}
|
|
17048
|
-
const
|
|
17049
|
-
const tplData = fs5.readFileSync(
|
|
17154
|
+
const file2 = path4.resolve(options.file);
|
|
17155
|
+
const tplData = fs5.readFileSync(file2, "utf-8");
|
|
17050
17156
|
const renderData = template.render(tplData, options.data);
|
|
17051
17157
|
const outputPath = getOutputPath(options.file, renderData, options.name);
|
|
17052
17158
|
fs5.writeFileSync(outputPath, renderData);
|
|
@@ -17075,8 +17181,8 @@ var init_template = __esm({
|
|
|
17075
17181
|
if (options.file.startsWith("http")) {
|
|
17076
17182
|
throw TypeError("\u4ED6\u55B5\u7684 \u4E0D\u4F1A\u771F\u7684\u6709\u7B28\u6BD4\u4F20\u4E2Ahttp\u6765\u5F53\u505A\u6A21\u677F\u5427...");
|
|
17077
17183
|
}
|
|
17078
|
-
const
|
|
17079
|
-
const tplData = fs5.readFileSync(
|
|
17184
|
+
const file2 = path4.resolve(options.file);
|
|
17185
|
+
const tplData = fs5.readFileSync(file2, "utf-8");
|
|
17080
17186
|
const renderData = template.render(tplData, options.data);
|
|
17081
17187
|
const outputPath = getOutputPath(options.file, renderData, options.file_name);
|
|
17082
17188
|
fs5.writeFileSync(outputPath, renderData);
|
|
@@ -17090,9 +17196,9 @@ var init_template = __esm({
|
|
|
17090
17196
|
delete options.data;
|
|
17091
17197
|
return options;
|
|
17092
17198
|
};
|
|
17093
|
-
getOutputPath = (
|
|
17094
|
-
const extname = path4.extname(
|
|
17095
|
-
const basename = path4.basename(
|
|
17199
|
+
getOutputPath = (file2, data, name) => {
|
|
17200
|
+
const extname = path4.extname(file2);
|
|
17201
|
+
const basename = path4.basename(file2, extname);
|
|
17096
17202
|
const fileDir = path4.join(htmlPath, name || "render");
|
|
17097
17203
|
mkdirSync(fileDir);
|
|
17098
17204
|
const contentHash = crypto.createHash("md5").update(data).digest("hex").substring(0, 8);
|
|
@@ -17115,16 +17221,16 @@ var init_template = __esm({
|
|
|
17115
17221
|
const files = await getAllFiles(htmlPath, { suffixs: [".html"], returnType: "abs" });
|
|
17116
17222
|
if (files.length === 0) return;
|
|
17117
17223
|
const EXPIRE_TIME = 10 * 60 * 1e3;
|
|
17118
|
-
for (const
|
|
17224
|
+
for (const file2 of files) {
|
|
17119
17225
|
try {
|
|
17120
|
-
const stats = await fs5.promises.stat(
|
|
17226
|
+
const stats = await fs5.promises.stat(file2);
|
|
17121
17227
|
const lastModified = stats.mtimeMs;
|
|
17122
17228
|
if (now - lastModified > EXPIRE_TIME) {
|
|
17123
|
-
await fs5.promises.unlink(
|
|
17229
|
+
await fs5.promises.unlink(file2);
|
|
17124
17230
|
count3++;
|
|
17125
17231
|
}
|
|
17126
17232
|
} catch (err) {
|
|
17127
|
-
logger.error(`[\u6587\u4EF6\u6E05\u7406] \u5904\u7406\u6587\u4EF6\u65F6\u51FA\u9519: ${
|
|
17233
|
+
logger.error(`[\u6587\u4EF6\u6E05\u7406] \u5904\u7406\u6587\u4EF6\u65F6\u51FA\u9519: ${file2}, ${err}`);
|
|
17128
17234
|
}
|
|
17129
17235
|
}
|
|
17130
17236
|
logger.mark(`[\u6587\u4EF6\u6E05\u7406] \u6E05\u7406HTML\u5B8C\u6210: ${count3}/${files.length}`);
|
|
@@ -17192,10 +17298,10 @@ var init_cache3 = __esm({
|
|
|
17192
17298
|
}
|
|
17193
17299
|
});
|
|
17194
17300
|
};
|
|
17195
|
-
renderMultiHtml = (
|
|
17301
|
+
renderMultiHtml = (file2, multiPage) => {
|
|
17196
17302
|
if (!multiPage && multiPage !== 0) multiPage = true;
|
|
17197
17303
|
return callRender({
|
|
17198
|
-
file,
|
|
17304
|
+
file: file2,
|
|
17199
17305
|
name: "render",
|
|
17200
17306
|
encoding: "base64",
|
|
17201
17307
|
multiPage,
|
|
@@ -17342,10 +17448,10 @@ var init_client2 = __esm({
|
|
|
17342
17448
|
return logger.error(`${PREFIX}\u6536\u5230\u672A\u77E5\u6D88\u606F: ${raw2}`);
|
|
17343
17449
|
}
|
|
17344
17450
|
if (options.action === "uploadFile") {
|
|
17345
|
-
const
|
|
17451
|
+
const file2 = fileURLToPath$1(options.params.path);
|
|
17346
17452
|
logger.debug(`${PREFIX}\u6536\u5230\u4E0A\u4F20\u6587\u4EF6\u8BF7\u6C42: ${options.params.path}`);
|
|
17347
|
-
if (!isPublic(
|
|
17348
|
-
logger.error(`${PREFIX}\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25: \u975E\u6CD5\u7684\u8DEF\u5F84\uFF0C${
|
|
17453
|
+
if (!isPublic(file2)) {
|
|
17454
|
+
logger.error(`${PREFIX}\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25: \u975E\u6CD5\u7684\u8DEF\u5F84\uFF0C${file2} \u6CA1\u6709\u5904\u4E8E\u5141\u8BB8\u9759\u6001\u8D44\u6E90\u76EE\u5F55\u4E0B`);
|
|
17349
17455
|
client.send(JSON.stringify({
|
|
17350
17456
|
type: "response",
|
|
17351
17457
|
action: "uploadFile",
|
|
@@ -17363,7 +17469,7 @@ var init_client2 = __esm({
|
|
|
17363
17469
|
target.toString(),
|
|
17364
17470
|
{
|
|
17365
17471
|
echo: options.echo,
|
|
17366
|
-
file: `base64://${fs5.readFileSync(
|
|
17472
|
+
file: `base64://${fs5.readFileSync(file2, "base64")}`
|
|
17367
17473
|
},
|
|
17368
17474
|
{
|
|
17369
17475
|
headers: {
|
|
@@ -17599,10 +17705,10 @@ var init_render = __esm({
|
|
|
17599
17705
|
};
|
|
17600
17706
|
initRender = (dir2) => {
|
|
17601
17707
|
const name = "render.json";
|
|
17602
|
-
const
|
|
17603
|
-
const data = requireFileSync(
|
|
17708
|
+
const file2 = `${dir2}/${name}`;
|
|
17709
|
+
const data = requireFileSync(file2, { type: "json" });
|
|
17604
17710
|
cache9 = format4(data);
|
|
17605
|
-
watch(
|
|
17711
|
+
watch(file2, async (old, data2) => {
|
|
17606
17712
|
cache9 = format4(data2);
|
|
17607
17713
|
const wsClient = diffArray(
|
|
17608
17714
|
Array.isArray(old?.ws_client) ? old?.ws_client : [],
|
|
@@ -19314,7 +19420,7 @@ var init_load = __esm({
|
|
|
19314
19420
|
init_internal();
|
|
19315
19421
|
init_list();
|
|
19316
19422
|
seq = 0;
|
|
19317
|
-
pkgLoads = async (pkg2, allPromises
|
|
19423
|
+
pkgLoads = async (pkg2, allPromises) => {
|
|
19318
19424
|
pkg2.id = ++seq;
|
|
19319
19425
|
cache3.index[pkg2.id] = pkg2;
|
|
19320
19426
|
const files = [];
|
|
@@ -19324,7 +19430,17 @@ var init_load = __esm({
|
|
|
19324
19430
|
files.push(...pkg2.pkgData.karin.files);
|
|
19325
19431
|
}
|
|
19326
19432
|
await createPluginDir(pkg2.name, files);
|
|
19327
|
-
|
|
19433
|
+
if (pkg2.type !== "app") {
|
|
19434
|
+
const main3 = pkg2.type === "npm" || !isTs() ? await loadMainFile(pkg2, pkg2.pkgData?.main) : await loadMainFile(pkg2, pkg2.pkgData?.karin?.main);
|
|
19435
|
+
if (main3 && main3.KARIN_PLUGIN_INIT) {
|
|
19436
|
+
try {
|
|
19437
|
+
await main3.KARIN_PLUGIN_INIT();
|
|
19438
|
+
logger.debug(`[load][${pkg2.name}] \u63D2\u4EF6\u6267\u884CKARIN_PLUGIN_INIT\u51FD\u6570\u6210\u529F`);
|
|
19439
|
+
} catch (error) {
|
|
19440
|
+
logger.error(new Error(`[load][${pkg2.name}] \u63D2\u4EF6\u6267\u884CKARIN_PLUGIN_INIT\u51FD\u6570\u5931\u8D25`, { cause: error }));
|
|
19441
|
+
}
|
|
19442
|
+
}
|
|
19443
|
+
}
|
|
19328
19444
|
pkg2.apps.forEach((app4) => {
|
|
19329
19445
|
const promise = async () => {
|
|
19330
19446
|
const result = await pkgLoadModule(pkg2.name, app4);
|
|
@@ -19332,33 +19448,27 @@ var init_load = __esm({
|
|
|
19332
19448
|
};
|
|
19333
19449
|
allPromises.push(promise());
|
|
19334
19450
|
});
|
|
19335
|
-
if (pkg2.type !== "app") {
|
|
19336
|
-
if (pkg2.type === "npm" || !isTs()) {
|
|
19337
|
-
loadMainFile(entryPromises, pkg2, pkg2.pkgData?.main);
|
|
19338
|
-
} else {
|
|
19339
|
-
loadMainFile(entryPromises, pkg2, pkg2.pkgData?.karin?.main);
|
|
19340
|
-
}
|
|
19341
|
-
}
|
|
19342
19451
|
if (pkg2.type !== "app" && pkg2?.pkgData?.karin?.static) {
|
|
19343
19452
|
const list2 = Array.isArray(pkg2.pkgData.karin.static) ? pkg2.pkgData.karin.static : [pkg2.pkgData.karin.static];
|
|
19344
|
-
cache3.static.push(...list2.map((
|
|
19453
|
+
cache3.static.push(...list2.map((file2) => path4.resolve(pkg2.dir, file2)));
|
|
19345
19454
|
} else {
|
|
19346
19455
|
cache3.static.push(path4.resolve(pkg2.dir, "resource"));
|
|
19347
19456
|
cache3.static.push(path4.resolve(pkg2.dir, "resources"));
|
|
19348
19457
|
}
|
|
19349
19458
|
};
|
|
19350
|
-
loadMainFile = async (
|
|
19459
|
+
loadMainFile = async (pkg2, dir2) => {
|
|
19351
19460
|
if (!dir2) return;
|
|
19352
|
-
const
|
|
19353
|
-
if (fs5.existsSync(
|
|
19354
|
-
|
|
19461
|
+
const file2 = path4.join(pkg2.dir, dir2);
|
|
19462
|
+
if (fs5.existsSync(file2)) {
|
|
19463
|
+
return pkgLoadModule(pkg2.name, file2);
|
|
19355
19464
|
}
|
|
19465
|
+
return null;
|
|
19356
19466
|
};
|
|
19357
|
-
pkgLoadModule = async (name,
|
|
19358
|
-
const { status, data } = await importModule(
|
|
19467
|
+
pkgLoadModule = async (name, file2, isRefresh = false) => {
|
|
19468
|
+
const { status, data } = await importModule(file2, isRefresh);
|
|
19359
19469
|
if (status) return data;
|
|
19360
|
-
logger.debug(new Error(`\u52A0\u8F7D\u6A21\u5757\u5931\u8D25: ${name} ${
|
|
19361
|
-
errorHandler.loaderPlugin(name,
|
|
19470
|
+
logger.debug(new Error(`\u52A0\u8F7D\u6A21\u5757\u5931\u8D25: ${name} ${file2}`, { cause: data }));
|
|
19471
|
+
errorHandler.loaderPlugin(name, file2, data);
|
|
19362
19472
|
return {};
|
|
19363
19473
|
};
|
|
19364
19474
|
isType = (val, type) => {
|
|
@@ -19465,15 +19575,15 @@ var init_load = __esm({
|
|
|
19465
19575
|
});
|
|
19466
19576
|
});
|
|
19467
19577
|
};
|
|
19468
|
-
findPkgByFile = (
|
|
19469
|
-
|
|
19578
|
+
findPkgByFile = (file2) => {
|
|
19579
|
+
file2 = formatPath(file2);
|
|
19470
19580
|
return Object.values(cache3.index).find(
|
|
19471
|
-
(pkg2) => pkg2.apps.includes(
|
|
19581
|
+
(pkg2) => pkg2.apps.includes(file2) || pkg2.allApps.some((dir2) => file2.startsWith(dir2)) || /**
|
|
19472
19582
|
* 第三种情况
|
|
19473
19583
|
* - 例如karin-plugin-example文件夹为空 则需要判断pkg是否为app类型
|
|
19474
19584
|
* - 并且文件是否处于karin-plugin-example文件夹下
|
|
19475
19585
|
*/
|
|
19476
|
-
pkg2.type === "app" && path4.normalize(
|
|
19586
|
+
pkg2.type === "app" && path4.normalize(file2).startsWith(path4.normalize(pkg2.dir))
|
|
19477
19587
|
) || null;
|
|
19478
19588
|
};
|
|
19479
19589
|
pkgSort = () => {
|
|
@@ -19487,15 +19597,13 @@ var init_load = __esm({
|
|
|
19487
19597
|
};
|
|
19488
19598
|
pkgHotReload = async (type, name) => {
|
|
19489
19599
|
const allPromises = [];
|
|
19490
|
-
const entryPromises = [];
|
|
19491
19600
|
const pkg2 = await getPluginsInfo([`${type}:${name}`], true, true);
|
|
19492
19601
|
if (pkg2.length === 0) {
|
|
19493
19602
|
throw new Error(`[load][${type}:${name}] \u63D2\u4EF6\u4E0D\u5B58\u5728`);
|
|
19494
19603
|
}
|
|
19495
|
-
await pkgLoads(pkg2[0], allPromises
|
|
19496
|
-
await Promise.allSettled(
|
|
19604
|
+
await pkgLoads(pkg2[0], allPromises);
|
|
19605
|
+
await Promise.allSettled(allPromises);
|
|
19497
19606
|
allPromises.length = 0;
|
|
19498
|
-
entryPromises.length = 0;
|
|
19499
19607
|
pkgSort();
|
|
19500
19608
|
};
|
|
19501
19609
|
}
|
|
@@ -20547,19 +20655,19 @@ var init_console = __esm({
|
|
|
20547
20655
|
return createForbiddenResponse(res, "\u65E0\u6548\u7684 token");
|
|
20548
20656
|
}
|
|
20549
20657
|
}
|
|
20550
|
-
const
|
|
20658
|
+
const file2 = path4.join(consolePath, url);
|
|
20551
20659
|
try {
|
|
20552
|
-
if (!
|
|
20660
|
+
if (!file2.startsWith(consolePath)) {
|
|
20553
20661
|
return createForbiddenResponse(res, "\u975E\u6CD5\u8BF7\u6C42");
|
|
20554
20662
|
}
|
|
20555
|
-
const stats = await promises.stat(
|
|
20663
|
+
const stats = await promises.stat(file2);
|
|
20556
20664
|
if (stats.size > MAX_FILE_SIZE) {
|
|
20557
20665
|
return createPayloadTooLargeResponse(res, "\u6587\u4EF6\u8FC7\u5927");
|
|
20558
20666
|
}
|
|
20559
20667
|
} catch {
|
|
20560
20668
|
return createNotFoundResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
20561
20669
|
}
|
|
20562
|
-
const data = await promises.readFile(
|
|
20670
|
+
const data = await promises.readFile(file2);
|
|
20563
20671
|
res.setHeader("Content-Type", ALLOWED_TYPES[ext]);
|
|
20564
20672
|
res.setHeader("Content-Length", data.length);
|
|
20565
20673
|
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
@@ -20760,7 +20868,7 @@ var init_getLog = __esm({
|
|
|
20760
20868
|
activeConnections--;
|
|
20761
20869
|
return createBadRequestResponse(res, "\u65E5\u671F\u683C\u5F0F\u9519\u8BEF");
|
|
20762
20870
|
}
|
|
20763
|
-
const
|
|
20871
|
+
const file2 = path4.join(logsPath, `logger.${date.format("YYYY-MM-DD")}.log`);
|
|
20764
20872
|
res.setHeader("Content-Type", "text/event-stream; charset=utf-8");
|
|
20765
20873
|
res.setHeader("Cache-Control", "no-cache");
|
|
20766
20874
|
res.setHeader("Connection", "keep-alive");
|
|
@@ -20775,7 +20883,7 @@ var init_getLog = __esm({
|
|
|
20775
20883
|
}, 3e4);
|
|
20776
20884
|
const tailFile = () => {
|
|
20777
20885
|
if (isStreaming) return;
|
|
20778
|
-
fs5.stat(
|
|
20886
|
+
fs5.stat(file2, (err, stats) => {
|
|
20779
20887
|
if (err) {
|
|
20780
20888
|
logger.error("\u8BFB\u53D6\u65E5\u5FD7\u6587\u4EF6\u72B6\u6001\u9519\u8BEF:", err);
|
|
20781
20889
|
return;
|
|
@@ -20786,7 +20894,7 @@ var init_getLog = __esm({
|
|
|
20786
20894
|
if (position < stats.size) {
|
|
20787
20895
|
isStreaming = true;
|
|
20788
20896
|
const endPosition = Math.min(position + MAX_CHUNK_SIZE, stats.size);
|
|
20789
|
-
const stream3 = fs5.createReadStream(
|
|
20897
|
+
const stream3 = fs5.createReadStream(file2, {
|
|
20790
20898
|
start: position,
|
|
20791
20899
|
end: endPosition - 1,
|
|
20792
20900
|
encoding: "utf-8",
|
|
@@ -20834,15 +20942,15 @@ var init_getLog = __esm({
|
|
|
20834
20942
|
};
|
|
20835
20943
|
getLogFileListRouter = async (_, res) => {
|
|
20836
20944
|
const files = fs5.readdirSync(logsPath);
|
|
20837
|
-
const logFiles = files.filter((
|
|
20945
|
+
const logFiles = files.filter((file2) => file2.startsWith("logger.") && file2.endsWith(".log")).map((file2) => file2.replace("logger.", "").replace(".log", ""));
|
|
20838
20946
|
createSuccessResponse(res, logFiles, "\u6210\u529F");
|
|
20839
20947
|
};
|
|
20840
20948
|
getLogFileRouter = async (req, res) => {
|
|
20841
|
-
const
|
|
20842
|
-
if (!isStandardDate(
|
|
20949
|
+
const file2 = req.query.file;
|
|
20950
|
+
if (!isStandardDate(file2)) {
|
|
20843
20951
|
return createBadRequestResponse(res, "\u65E5\u671F\u683C\u5F0F\u9519\u8BEF");
|
|
20844
20952
|
}
|
|
20845
|
-
const filePath = path4.join(logsPath, `logger.${
|
|
20953
|
+
const filePath = path4.join(logsPath, `logger.${file2}.log`);
|
|
20846
20954
|
if (!fs5.existsSync(filePath)) {
|
|
20847
20955
|
return createBadRequestResponse(res, "\u65E5\u5FD7\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
20848
20956
|
}
|
|
@@ -22666,8 +22774,8 @@ var init_uninstall = __esm({
|
|
|
22666
22774
|
continue;
|
|
22667
22775
|
}
|
|
22668
22776
|
const arr = v.split("/");
|
|
22669
|
-
const [pkg2,
|
|
22670
|
-
if (arr.length !== 2 || !pkg2 || !
|
|
22777
|
+
const [pkg2, file2] = arr;
|
|
22778
|
+
if (arr.length !== 2 || !pkg2 || !file2) {
|
|
22671
22779
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u683C\u5F0F\u9519\u8BEF`);
|
|
22672
22780
|
continue;
|
|
22673
22781
|
}
|
|
@@ -22676,17 +22784,17 @@ var init_uninstall = __esm({
|
|
|
22676
22784
|
continue;
|
|
22677
22785
|
}
|
|
22678
22786
|
const dir2 = path4.join(karinPathPlugins, pkg2);
|
|
22679
|
-
if (!fs5.existsSync(path4.join(dir2,
|
|
22787
|
+
if (!fs5.existsSync(path4.join(dir2, file2))) {
|
|
22680
22788
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u6587\u4EF6\u4E0D\u5B58\u5728`);
|
|
22681
22789
|
continue;
|
|
22682
22790
|
}
|
|
22683
|
-
const ext = path4.extname(
|
|
22791
|
+
const ext = path4.extname(file2);
|
|
22684
22792
|
if (![".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"].includes(ext)) {
|
|
22685
22793
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u9519\u8BEF\u7684\u6587\u4EF6\u7C7B\u578B`);
|
|
22686
22794
|
continue;
|
|
22687
22795
|
}
|
|
22688
22796
|
try {
|
|
22689
|
-
await fs5.promises.unlink(path4.join(dir2,
|
|
22797
|
+
await fs5.promises.unlink(path4.join(dir2, file2));
|
|
22690
22798
|
emitLog(`\u5378\u8F7D ${v} \u6210\u529F`);
|
|
22691
22799
|
} catch (error) {
|
|
22692
22800
|
emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: ${error.message}`);
|
|
@@ -23421,10 +23529,10 @@ var init_list4 = __esm({
|
|
|
23421
23529
|
});
|
|
23422
23530
|
Object.keys(map).forEach((key) => {
|
|
23423
23531
|
const files = [];
|
|
23424
|
-
Object.keys(map[key]).forEach((
|
|
23532
|
+
Object.keys(map[key]).forEach((file2) => {
|
|
23425
23533
|
files.push({
|
|
23426
|
-
fileName:
|
|
23427
|
-
command: map[key][
|
|
23534
|
+
fileName: file2,
|
|
23535
|
+
command: map[key][file2]
|
|
23428
23536
|
});
|
|
23429
23537
|
});
|
|
23430
23538
|
list2.push({
|
|
@@ -23976,8 +24084,8 @@ var init_input = __esm({
|
|
|
23976
24084
|
async getUrl(data, ext) {
|
|
23977
24085
|
const cfg = adapter();
|
|
23978
24086
|
const name = (++index5).toString();
|
|
23979
|
-
const
|
|
23980
|
-
await fs5.promises.writeFile(
|
|
24087
|
+
const file2 = path4.join(consolePath, `${name}${ext}`);
|
|
24088
|
+
await fs5.promises.writeFile(file2, await buffer(data));
|
|
23981
24089
|
if (cfg.console.isLocal) {
|
|
23982
24090
|
return `http://127.0.0.1:${process.env.HTTP_PORT}/api/v1/console/${name}${ext}`;
|
|
23983
24091
|
}
|
|
@@ -24067,8 +24175,8 @@ var init_input = __esm({
|
|
|
24067
24175
|
logger.info(`[setMsgReaction] ${contact3} ${messageId} ${faceId} ${isSet}`);
|
|
24068
24176
|
return true;
|
|
24069
24177
|
}
|
|
24070
|
-
async uploadFile(contact3,
|
|
24071
|
-
logger.info(`[uploadFile] ${contact3} ${
|
|
24178
|
+
async uploadFile(contact3, file2, name, folder) {
|
|
24179
|
+
logger.info(`[uploadFile] ${contact3} ${file2} ${name} ${folder}`);
|
|
24072
24180
|
return true;
|
|
24073
24181
|
}
|
|
24074
24182
|
};
|
|
@@ -24150,9 +24258,9 @@ var init_db = __esm({
|
|
|
24150
24258
|
stream: void 0
|
|
24151
24259
|
}
|
|
24152
24260
|
};
|
|
24153
|
-
addWrite = (name,
|
|
24261
|
+
addWrite = (name, file2, key, value) => {
|
|
24154
24262
|
if (!stream2[name].stream) {
|
|
24155
|
-
stream2[name].stream = createWriteStream(
|
|
24263
|
+
stream2[name].stream = createWriteStream(file2, {
|
|
24156
24264
|
flags: "a+",
|
|
24157
24265
|
encoding: "utf-8"
|
|
24158
24266
|
});
|
|
@@ -24161,14 +24269,14 @@ var init_db = __esm({
|
|
|
24161
24269
|
stream2[name].stream.write(`${key}="${JSON.stringify(value)}
|
|
24162
24270
|
`);
|
|
24163
24271
|
};
|
|
24164
|
-
deleteData = async (
|
|
24272
|
+
deleteData = async (file2, key) => {
|
|
24165
24273
|
try {
|
|
24166
|
-
await promises.access(
|
|
24167
|
-
const content = await promises.readFile(
|
|
24274
|
+
await promises.access(file2);
|
|
24275
|
+
const content = await promises.readFile(file2, "utf-8");
|
|
24168
24276
|
if (!content) return;
|
|
24169
24277
|
const lines = content.split("\n").filter(Boolean);
|
|
24170
24278
|
const newLines = lines.filter((line) => !line.startsWith(`${key}=`));
|
|
24171
|
-
await promises.writeFile(
|
|
24279
|
+
await promises.writeFile(file2, newLines.join("\n") + "\n");
|
|
24172
24280
|
} catch {
|
|
24173
24281
|
}
|
|
24174
24282
|
};
|
|
@@ -24197,8 +24305,8 @@ var init_db = __esm({
|
|
|
24197
24305
|
}
|
|
24198
24306
|
};
|
|
24199
24307
|
main2 = async () => {
|
|
24200
|
-
Object.values(dir).forEach(async (
|
|
24201
|
-
if (
|
|
24308
|
+
Object.values(dir).forEach(async (file2) => {
|
|
24309
|
+
if (file2 === dir.account) {
|
|
24202
24310
|
try {
|
|
24203
24311
|
await promises.access(dir.account);
|
|
24204
24312
|
} catch {
|
|
@@ -24208,11 +24316,11 @@ var init_db = __esm({
|
|
|
24208
24316
|
return;
|
|
24209
24317
|
}
|
|
24210
24318
|
try {
|
|
24211
|
-
await promises.access(
|
|
24212
|
-
if (
|
|
24319
|
+
await promises.access(file2);
|
|
24320
|
+
if (file2 === dir.frinendList) writeAccountToFriendList();
|
|
24213
24321
|
} catch {
|
|
24214
|
-
await promises.mkdir(path4.dirname(
|
|
24215
|
-
await promises.writeFile(
|
|
24322
|
+
await promises.mkdir(path4.dirname(file2), { recursive: true });
|
|
24323
|
+
await promises.writeFile(file2, "");
|
|
24216
24324
|
}
|
|
24217
24325
|
});
|
|
24218
24326
|
setInterval(() => {
|
|
@@ -24308,8 +24416,8 @@ var env2 = () => {
|
|
|
24308
24416
|
comment: "\u65E5\u5FD7\u5B9E\u65F6Api\u6700\u591A\u652F\u6301\u540C\u65F6\u8FDE\u63A5\u6570"
|
|
24309
24417
|
}
|
|
24310
24418
|
];
|
|
24311
|
-
const
|
|
24312
|
-
if (!fs5.existsSync(
|
|
24419
|
+
const file2 = `${process.cwd()}/${process.env.EBV_FILE}`;
|
|
24420
|
+
if (!fs5.existsSync(file2)) {
|
|
24313
24421
|
logger.error(logger.yellow("\u68C0\u67E5\u5230\u9879\u76EE\u914D\u7F6E\u6587\u4EF6\u7F3A\u5931\uFF0C\u6B63\u5728\u521D\u59CB\u5316..."));
|
|
24314
24422
|
const cwd = fileURLToPath$1(new URL$1("./cli/index.mjs", import.meta.url));
|
|
24315
24423
|
execSync(`node ${cwd} init`, {
|
|
@@ -24318,10 +24426,10 @@ var env2 = () => {
|
|
|
24318
24426
|
});
|
|
24319
24427
|
logger.info(logger.green("\u521D\u59CB\u5316\u6210\u529F~"));
|
|
24320
24428
|
}
|
|
24321
|
-
const content = fs5.readFileSync(
|
|
24429
|
+
const content = fs5.readFileSync(file2, "utf-8");
|
|
24322
24430
|
list2.forEach((v) => {
|
|
24323
24431
|
if (!content.includes(v.key)) {
|
|
24324
|
-
fs5.appendFileSync(
|
|
24432
|
+
fs5.appendFileSync(file2, `
|
|
24325
24433
|
${v.comment}
|
|
24326
24434
|
${v.key}=${v.value}`);
|
|
24327
24435
|
process.env[v.key] = v.value;
|
|
@@ -24358,10 +24466,10 @@ var initConfig2 = async (dir2) => {
|
|
|
24358
24466
|
return Promise.resolve();
|
|
24359
24467
|
}));
|
|
24360
24468
|
await Promise.all(Object.keys(defaultConfig).map(async (key) => {
|
|
24361
|
-
const
|
|
24362
|
-
if (fs5.existsSync(
|
|
24469
|
+
const file2 = `${dir2.configPath}/${key}.json`;
|
|
24470
|
+
if (fs5.existsSync(file2)) return;
|
|
24363
24471
|
const data = JSON.stringify(defaultConfig[key], null, 2);
|
|
24364
|
-
await fs5.promises.writeFile(
|
|
24472
|
+
await fs5.promises.writeFile(file2, data, "utf-8");
|
|
24365
24473
|
return true;
|
|
24366
24474
|
}));
|
|
24367
24475
|
initConfigCache(dir2.configPath);
|
|
@@ -24408,19 +24516,19 @@ init_load();
|
|
|
24408
24516
|
// src/plugin/admin/uninstall.ts
|
|
24409
24517
|
init_cache();
|
|
24410
24518
|
init_path();
|
|
24411
|
-
var pkgRemoveModule = async (
|
|
24412
|
-
cache3.accept = cache3.accept.filter((p) => !isPathEqual(p.file.absPath,
|
|
24413
|
-
cache3.command = cache3.command.filter((p) => !isPathEqual(p.file.absPath,
|
|
24519
|
+
var pkgRemoveModule = async (file2) => {
|
|
24520
|
+
cache3.accept = cache3.accept.filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24521
|
+
cache3.command = cache3.command.filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24414
24522
|
cache3.task = cache3.task.filter((p) => {
|
|
24415
|
-
const isEqual = isPathEqual(p.file.absPath,
|
|
24523
|
+
const isEqual = isPathEqual(p.file.absPath, file2);
|
|
24416
24524
|
if (isEqual && p.schedule) {
|
|
24417
24525
|
p.schedule.cancel();
|
|
24418
24526
|
}
|
|
24419
24527
|
return !isEqual;
|
|
24420
24528
|
});
|
|
24421
|
-
cache3.button = cache3.button.filter((p) => !isPathEqual(p.file.absPath,
|
|
24529
|
+
cache3.button = cache3.button.filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24422
24530
|
Object.keys(cache3.handler).forEach((key) => {
|
|
24423
|
-
cache3.handler[key] = cache3.handler[key].filter((p) => !isPathEqual(p.file.absPath,
|
|
24531
|
+
cache3.handler[key] = cache3.handler[key].filter((p) => !isPathEqual(p.file.absPath, file2));
|
|
24424
24532
|
});
|
|
24425
24533
|
};
|
|
24426
24534
|
|
|
@@ -24445,7 +24553,7 @@ var initPluginHmr = async () => {
|
|
|
24445
24553
|
ignoreInitial: true,
|
|
24446
24554
|
ignored: /(^|[/\\])\../
|
|
24447
24555
|
});
|
|
24448
|
-
watcher.on("add", (
|
|
24556
|
+
watcher.on("add", (file2) => handleFileChange(file2, "add")).on("change", (file2) => handleFileChange(file2, "change")).on("unlink", (file2) => handleFileChange(file2, "unlink"));
|
|
24449
24557
|
const relativePaths = Array.from(watchDirs).map((dir2) => {
|
|
24450
24558
|
return path4.relative(process.cwd(), dir2).replace(/\\/g, "/");
|
|
24451
24559
|
});
|
|
@@ -24454,18 +24562,18 @@ var initPluginHmr = async () => {
|
|
|
24454
24562
|
[hmr] ${logger.magenta("\u6B63\u5728\u76D1\u542C\u6587\u4EF6\u5939")}:
|
|
24455
24563
|
${relativePaths.join("\n")}`);
|
|
24456
24564
|
};
|
|
24457
|
-
var handleFileChange = async (
|
|
24458
|
-
const ext = path4.extname(
|
|
24565
|
+
var handleFileChange = async (file2, action) => {
|
|
24566
|
+
const ext = path4.extname(file2);
|
|
24459
24567
|
const exts = getModuleType();
|
|
24460
24568
|
if (!exts.includes(ext)) return;
|
|
24461
|
-
const absPath2 = formatPath(
|
|
24569
|
+
const absPath2 = formatPath(file2);
|
|
24462
24570
|
const pkg2 = findPkgByFile(absPath2);
|
|
24463
24571
|
if (!pkg2) return;
|
|
24464
|
-
const relativePath = path4.relative(process.cwd(),
|
|
24572
|
+
const relativePath = path4.relative(process.cwd(), file2).replace(/\\/g, "/");
|
|
24465
24573
|
logger.debug(`[hmr][${pkg2.name}] \u6587\u4EF6${action}: ${relativePath}`);
|
|
24466
24574
|
if (action === "unlink") {
|
|
24467
24575
|
pkgRemoveModule(absPath2);
|
|
24468
|
-
logger.info(`[hmr][${pkg2.name}] \u5DF2\u5378\u8F7D: ${path4.basename(
|
|
24576
|
+
logger.info(`[hmr][${pkg2.name}] \u5DF2\u5378\u8F7D: ${path4.basename(file2)}`);
|
|
24469
24577
|
return;
|
|
24470
24578
|
}
|
|
24471
24579
|
if (action === "change") {
|
|
@@ -24476,7 +24584,7 @@ var handleFileChange = async (file, action) => {
|
|
|
24476
24584
|
pkgCache(result, pkg2, absPath2);
|
|
24477
24585
|
pkgSort();
|
|
24478
24586
|
const actionText = action === "add" ? "\u65B0\u589E\u63D2\u4EF6" : "\u91CD\u8F7D\u5B8C\u6210";
|
|
24479
|
-
logger.info(`[hmr][${pkg2.name}] ${actionText}: ${path4.basename(
|
|
24587
|
+
logger.info(`[hmr][${pkg2.name}] ${actionText}: ${path4.basename(file2)}`);
|
|
24480
24588
|
} catch (error) {
|
|
24481
24589
|
logger.error(`[hmr][${pkg2.name}] \u52A0\u8F7D\u5931\u8D25:`);
|
|
24482
24590
|
logger.error(error);
|
|
@@ -24490,12 +24598,10 @@ var initPlugins = async () => {
|
|
|
24490
24598
|
logger.info(logger.green("-----------"));
|
|
24491
24599
|
logger.info("\u52A0\u8F7D\u63D2\u4EF6\u4E2D...");
|
|
24492
24600
|
const allPromises = [];
|
|
24493
|
-
const entryPromises = [];
|
|
24494
24601
|
const list2 = await getPlugins("all", true, false, true);
|
|
24495
|
-
await Promise.all(list2.map(async (pkg2) => pkgLoads(pkg2, allPromises
|
|
24496
|
-
await Promise.allSettled(
|
|
24602
|
+
await Promise.all(list2.map(async (pkg2) => pkgLoads(pkg2, allPromises)));
|
|
24603
|
+
await Promise.allSettled(allPromises);
|
|
24497
24604
|
allPromises.length = 0;
|
|
24498
|
-
entryPromises.length = 0;
|
|
24499
24605
|
pkgSort();
|
|
24500
24606
|
errorHandler.printMissing();
|
|
24501
24607
|
logger.info("\u63D2\u4EF6\u52A0\u8F7D\u5B8C\u6210");
|