node-karin 1.1.4 → 1.2.0
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 +1238 -1213
- package/default/comment/config.json +33 -33
- package/default/comment/friendDirect.json +9 -9
- package/default/comment/groupGuild.json +10 -10
- package/default/comment/server.json +16 -16
- package/default/config/adapter.json +27 -27
- package/default/config/config.json +44 -44
- package/default/config/groups.json +46 -46
- package/default/config/privates.json +22 -22
- package/default/config/redis.json +5 -9
- package/default/config/render.json +18 -18
- package/default/view/App.yaml +67 -67
- package/default/view/config.yaml +170 -170
- package/default/view/group.yaml +73 -73
- package/default/view/pm2.yaml +41 -41
- package/default/view/redis.yaml +20 -20
- package/default/view/server.yaml +73 -73
- package/dist/cli/index.cjs +4 -2
- package/dist/cli/index.js +4 -2
- package/dist/index.d.ts +67 -21
- package/dist/index.js +1752 -524
- package/dist/web/assets/favicon-onvkvGKB.ico +0 -0
- package/dist/web/assets/index-CcauG-3d.js +1 -0
- package/dist/web/assets/index-D7_l6OR8.js +330 -0
- package/dist/web/assets/index-DTAhadOx.css +1 -0
- package/dist/web/index.html +24 -0
- package/dist/web/karin.png +0 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -14,9 +14,9 @@ var __export = (target, all) => {
|
|
|
14
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
// ../../node_modules/.pnpm/tsup@8.3.
|
|
17
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.7_@swc+helpers@0.5.15__jiti@1.21.7_postcss@8.5.1_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js
|
|
18
18
|
var init_esm_shims = __esm({
|
|
19
|
-
"../../node_modules/.pnpm/tsup@8.3.
|
|
19
|
+
"../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.7_@swc+helpers@0.5.15__jiti@1.21.7_postcss@8.5.1_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
20
20
|
"use strict";
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -104,42 +104,42 @@ var init_tools = __esm({
|
|
|
104
104
|
init_esm_shims();
|
|
105
105
|
NODE_TYPES = ["number", "string", "boolean", "undefined", "null"];
|
|
106
106
|
lint = async (defData, data) => {
|
|
107
|
-
const
|
|
107
|
+
const list3 = {};
|
|
108
108
|
await Promise.all(Object.keys(defData).map(async (key) => {
|
|
109
109
|
if (Array.isArray(data == null ? void 0 : data[key])) {
|
|
110
110
|
if (data == null ? void 0 : data[key].every((v) => typeof v !== "object")) {
|
|
111
|
-
|
|
111
|
+
list3[key] = setStr((data == null ? void 0 : data[key]) || defData[key]);
|
|
112
112
|
return;
|
|
113
113
|
} else {
|
|
114
|
-
|
|
114
|
+
list3[key] = (data == null ? void 0 : data[key]) || defData[key];
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
if (NODE_TYPES.includes(typeof (data == null ? void 0 : data[key]))) {
|
|
119
|
-
|
|
119
|
+
list3[key] = (data == null ? void 0 : data[key]) ?? defData[key];
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
if (typeof (data == null ? void 0 : data[key]) === "object") {
|
|
123
|
-
|
|
123
|
+
list3[key] = await lint(defData[key], data == null ? void 0 : data[key]);
|
|
124
124
|
}
|
|
125
125
|
}));
|
|
126
|
-
return
|
|
126
|
+
return list3;
|
|
127
127
|
};
|
|
128
128
|
mergeData = (defData, data) => {
|
|
129
|
-
const
|
|
129
|
+
const list3 = {};
|
|
130
130
|
Object.keys(defData).forEach((key) => {
|
|
131
131
|
if (typeof defData[key] === "number") {
|
|
132
|
-
|
|
132
|
+
list3[key] = Number(data[key]) ?? defData[key];
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
if (Array.isArray(defData[key])) {
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
list3[key] = Array.isArray(data[key]) ? data[key] : [];
|
|
137
|
+
list3[key] = list3[key].map((val) => String(val));
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
throw TypeError(`${key} is not a number or array`);
|
|
141
141
|
});
|
|
142
|
-
return
|
|
142
|
+
return list3;
|
|
143
143
|
};
|
|
144
144
|
setStr = (data) => {
|
|
145
145
|
try {
|
|
@@ -492,9 +492,9 @@ var init_data = __esm({
|
|
|
492
492
|
stream2.on("end", () => resolve(Buffer.concat(chunks)));
|
|
493
493
|
stream2.on("error", (error) => reject(error));
|
|
494
494
|
});
|
|
495
|
-
readFile = async (
|
|
495
|
+
readFile = async (path18) => {
|
|
496
496
|
try {
|
|
497
|
-
const data = await fs5.promises.readFile(
|
|
497
|
+
const data = await fs5.promises.readFile(path18);
|
|
498
498
|
return data;
|
|
499
499
|
} catch (error) {
|
|
500
500
|
logger.error(error);
|
|
@@ -683,10 +683,6 @@ var init_default = __esm({
|
|
|
683
683
|
},
|
|
684
684
|
redis: {
|
|
685
685
|
url: "redis://127.0.0.1:6379",
|
|
686
|
-
socket: {
|
|
687
|
-
host: "127.0.0.1",
|
|
688
|
-
port: 6379
|
|
689
|
-
},
|
|
690
686
|
username: "",
|
|
691
687
|
password: "",
|
|
692
688
|
database: 0
|
|
@@ -726,8 +722,8 @@ var config_exports = {};
|
|
|
726
722
|
__export(config_exports, {
|
|
727
723
|
admin: () => admin,
|
|
728
724
|
authKey: () => authKey,
|
|
729
|
-
clearTemp: () => clearTemp,
|
|
730
725
|
config: () => config,
|
|
726
|
+
env: () => env,
|
|
731
727
|
ffmpegPath: () => ffmpegPath,
|
|
732
728
|
ffplayPath: () => ffplayPath,
|
|
733
729
|
ffprobePath: () => ffprobePath,
|
|
@@ -742,7 +738,7 @@ __export(config_exports, {
|
|
|
742
738
|
updateLevel: () => updateLevel
|
|
743
739
|
});
|
|
744
740
|
import fs6 from "node:fs";
|
|
745
|
-
var FILE, cache3, config, port, host, master, admin, redis, pm2, ffmpegPath, ffprobePath, ffplayPath, authKey, pkg, getYaml, setYaml,
|
|
741
|
+
var FILE, cache3, config, port, host, master, admin, redis, pm2, env, ffmpegPath, ffprobePath, ffplayPath, authKey, pkg, getYaml, setYaml, updateLevel;
|
|
746
742
|
var init_config = __esm({
|
|
747
743
|
async "src/utils/config/config.ts"() {
|
|
748
744
|
"use strict";
|
|
@@ -763,6 +759,7 @@ var init_config = __esm({
|
|
|
763
759
|
admin = () => config().admin;
|
|
764
760
|
redis = () => requireFileSync(`${configPath}/redis.json`, { ex: 30 });
|
|
765
761
|
pm2 = () => requireFileSync(`${configPath}/pm2.json`, { ex: 30 });
|
|
762
|
+
env = () => requireFileSync(`${process.cwd()}/.env`, { ex: 30 });
|
|
766
763
|
ffmpegPath = () => process.env.FFMPEG_PATH;
|
|
767
764
|
ffprobePath = () => process.env.FFPROBE_PATH;
|
|
768
765
|
ffplayPath = () => process.env.FFPLAY_PATH;
|
|
@@ -790,14 +787,6 @@ var init_config = __esm({
|
|
|
790
787
|
fs6.writeFileSync(file, JSON.stringify(data, null, 2));
|
|
791
788
|
return true;
|
|
792
789
|
};
|
|
793
|
-
clearTemp = () => {
|
|
794
|
-
const list4 = [htmlPath, consolePath];
|
|
795
|
-
list4.forEach((file) => {
|
|
796
|
-
if (fs6.existsSync(file)) {
|
|
797
|
-
fs6.rmSync(file, { recursive: true, force: true });
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
};
|
|
801
790
|
updateLevel = (level2) => {
|
|
802
791
|
if (level2) {
|
|
803
792
|
logger.level = level2;
|
|
@@ -858,34 +847,56 @@ var init_env = __esm({
|
|
|
858
847
|
});
|
|
859
848
|
|
|
860
849
|
// src/utils/config/init.ts
|
|
861
|
-
|
|
850
|
+
import fs7 from "node:fs";
|
|
851
|
+
var env2;
|
|
862
852
|
var init_init = __esm({
|
|
863
853
|
async "src/utils/config/init.ts"() {
|
|
864
854
|
"use strict";
|
|
865
855
|
init_esm_shims();
|
|
866
856
|
init_root();
|
|
867
857
|
init_fsSync();
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
858
|
+
env2 = () => {
|
|
859
|
+
const list3 = [
|
|
860
|
+
{
|
|
861
|
+
key: "LOG_MAX_CONNECTIONS",
|
|
862
|
+
value: "5",
|
|
863
|
+
comment: "\u65E5\u5FD7\u5B9E\u65F6Api\u6700\u591A\u652F\u6301\u540C\u65F6\u8FDE\u63A5\u6570"
|
|
864
|
+
}
|
|
865
|
+
];
|
|
866
|
+
const file = `${process.cwd()}/.env`;
|
|
867
|
+
const content = fs7.readFileSync(file, "utf-8");
|
|
868
|
+
list3.forEach((v) => {
|
|
869
|
+
if (!content.includes(v.key)) {
|
|
870
|
+
fs7.appendFileSync(file, `
|
|
871
|
+
${v.comment}
|
|
872
|
+
${v.key}=${v.value}`);
|
|
873
|
+
process.env[v.key] = v.value;
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
};
|
|
877
|
+
await (async () => {
|
|
878
|
+
const list3 = [
|
|
879
|
+
basePath,
|
|
880
|
+
configPath,
|
|
881
|
+
dataPath,
|
|
882
|
+
tempPath,
|
|
883
|
+
htmlPath,
|
|
884
|
+
consolePath,
|
|
885
|
+
resourcePath
|
|
886
|
+
];
|
|
887
|
+
list3.map((v) => existToMkdirSync(v));
|
|
888
|
+
const [
|
|
889
|
+
{ pkg: pkg2 },
|
|
890
|
+
{ setVersion: setVersion2, setRuntime: setRuntime2 }
|
|
891
|
+
] = await Promise.all([
|
|
892
|
+
init_config().then(() => config_exports),
|
|
893
|
+
Promise.resolve().then(() => (init_env(), env_exports)),
|
|
894
|
+
init_default().then(() => default_exports)
|
|
895
|
+
]);
|
|
896
|
+
setVersion2(pkg2().version);
|
|
897
|
+
env2();
|
|
898
|
+
if (process.env.pm_id) setRuntime2("pm2");
|
|
899
|
+
})();
|
|
889
900
|
}
|
|
890
901
|
});
|
|
891
902
|
|
|
@@ -1090,42 +1101,6 @@ var init_exec = __esm({
|
|
|
1090
1101
|
}
|
|
1091
1102
|
});
|
|
1092
1103
|
|
|
1093
|
-
// src/utils/system/system.ts
|
|
1094
|
-
import os from "node:os";
|
|
1095
|
-
import fs7 from "node:fs";
|
|
1096
|
-
var isWin2, isLinux2, isMac2, isDocker, isRoot;
|
|
1097
|
-
var init_system = __esm({
|
|
1098
|
-
"src/utils/system/system.ts"() {
|
|
1099
|
-
"use strict";
|
|
1100
|
-
init_esm_shims();
|
|
1101
|
-
isWin2 = os.platform() === "win32";
|
|
1102
|
-
isLinux2 = os.platform() === "linux";
|
|
1103
|
-
isMac2 = os.platform() === "darwin";
|
|
1104
|
-
isDocker = fs7.existsSync("/.dockerenv");
|
|
1105
|
-
isRoot = os.userInfo().uid === 0;
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
|
|
1109
|
-
// src/utils/system/pid.ts
|
|
1110
|
-
var getPid;
|
|
1111
|
-
var init_pid = __esm({
|
|
1112
|
-
"src/utils/system/pid.ts"() {
|
|
1113
|
-
"use strict";
|
|
1114
|
-
init_esm_shims();
|
|
1115
|
-
init_exec();
|
|
1116
|
-
init_system();
|
|
1117
|
-
getPid = async (port2) => {
|
|
1118
|
-
const command2 = isWin2 ? `netstat -ano | findstr :${port2}` : `lsof -i:${port2} | grep LISTEN | awk '{print $2}'`;
|
|
1119
|
-
const { stdout } = await exec(command2);
|
|
1120
|
-
if (isWin2) {
|
|
1121
|
-
const pid = stdout.toString().split(/\s+/).filter(Boolean).pop();
|
|
1122
|
-
return Number(pid);
|
|
1123
|
-
}
|
|
1124
|
-
return Number(stdout);
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
|
|
1129
1104
|
// src/utils/fs/yaml.ts
|
|
1130
1105
|
import fs8 from "node:fs";
|
|
1131
1106
|
import lodash from "lodash";
|
|
@@ -1149,10 +1124,10 @@ var init_yaml = __esm({
|
|
|
1149
1124
|
* 获取指定路径的值
|
|
1150
1125
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1151
1126
|
*/
|
|
1152
|
-
get(
|
|
1127
|
+
get(path18) {
|
|
1153
1128
|
try {
|
|
1154
|
-
if (!
|
|
1155
|
-
return lodash.get(this.document.toJSON(),
|
|
1129
|
+
if (!path18) return this.document.toJSON();
|
|
1130
|
+
return lodash.get(this.document.toJSON(), path18);
|
|
1156
1131
|
} catch (error) {
|
|
1157
1132
|
logger.error(`[YamlEditor] \u83B7\u53D6\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
1158
1133
|
return null;
|
|
@@ -1164,9 +1139,9 @@ var init_yaml = __esm({
|
|
|
1164
1139
|
* @param value - 要设置的值 允许的类型:`string`, `boolean`, `number`, `object`, `array`
|
|
1165
1140
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1166
1141
|
*/
|
|
1167
|
-
set(
|
|
1142
|
+
set(path18, value, isSplit = true) {
|
|
1168
1143
|
try {
|
|
1169
|
-
const _path = typeof
|
|
1144
|
+
const _path = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1170
1145
|
this.document.setIn(_path, value);
|
|
1171
1146
|
return true;
|
|
1172
1147
|
} catch (error) {
|
|
@@ -1180,11 +1155,11 @@ var init_yaml = __esm({
|
|
|
1180
1155
|
* @param value - 要添加的值
|
|
1181
1156
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1182
1157
|
*/
|
|
1183
|
-
add(
|
|
1158
|
+
add(path18, value, isSplit = true) {
|
|
1184
1159
|
try {
|
|
1185
|
-
const _path = typeof
|
|
1160
|
+
const _path = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1186
1161
|
this.document.addIn(_path, value);
|
|
1187
|
-
logger.debug(`[YamlEditor] \u5DF2\u5728 ${
|
|
1162
|
+
logger.debug(`[YamlEditor] \u5DF2\u5728 ${path18} \u6DFB\u52A0\u65B0\u7684\u503C`);
|
|
1188
1163
|
return true;
|
|
1189
1164
|
} catch (error) {
|
|
1190
1165
|
logger.error(`[YamlEditor] \u6DFB\u52A0\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1197,9 +1172,9 @@ var init_yaml = __esm({
|
|
|
1197
1172
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1198
1173
|
* @returns 是否删除成功
|
|
1199
1174
|
*/
|
|
1200
|
-
del(
|
|
1175
|
+
del(path18, isSplit = true) {
|
|
1201
1176
|
try {
|
|
1202
|
-
const _path = typeof
|
|
1177
|
+
const _path = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1203
1178
|
this.document.deleteIn(_path);
|
|
1204
1179
|
return true;
|
|
1205
1180
|
} catch (error) {
|
|
@@ -1214,9 +1189,9 @@ var init_yaml = __esm({
|
|
|
1214
1189
|
* @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
|
|
1215
1190
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1216
1191
|
*/
|
|
1217
|
-
append(
|
|
1192
|
+
append(path18, value, prepend = false, isSplit = true) {
|
|
1218
1193
|
try {
|
|
1219
|
-
const _path = typeof
|
|
1194
|
+
const _path = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1220
1195
|
let current = this.document.getIn(_path);
|
|
1221
1196
|
if (!current) {
|
|
1222
1197
|
current = new YAML.YAMLSeq();
|
|
@@ -1227,7 +1202,7 @@ var init_yaml = __esm({
|
|
|
1227
1202
|
} else {
|
|
1228
1203
|
prepend ? current.items.unshift(value) : current.add(value);
|
|
1229
1204
|
}
|
|
1230
|
-
logger.debug(`[YamlEditor] \u5DF2\u5411 ${
|
|
1205
|
+
logger.debug(`[YamlEditor] \u5DF2\u5411 ${path18} \u6570\u7EC4${prepend ? "\u5F00\u5934" : "\u672B\u5C3E"}\u6DFB\u52A0\u65B0\u5143\u7D20\uFF1A${value}`);
|
|
1231
1206
|
return true;
|
|
1232
1207
|
} catch (error) {
|
|
1233
1208
|
logger.error(`[YamlEditor] \u5411\u6570\u7EC4\u6DFB\u52A0\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1240,9 +1215,9 @@ var init_yaml = __esm({
|
|
|
1240
1215
|
* @param value - 要删除的值
|
|
1241
1216
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1242
1217
|
*/
|
|
1243
|
-
remove(
|
|
1218
|
+
remove(path18, value, isSplit = true) {
|
|
1244
1219
|
try {
|
|
1245
|
-
const _path = typeof
|
|
1220
|
+
const _path = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1246
1221
|
const current = this.document.getIn(_path);
|
|
1247
1222
|
if (!current) {
|
|
1248
1223
|
logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u5B58\u5728");
|
|
@@ -1258,7 +1233,7 @@ var init_yaml = __esm({
|
|
|
1258
1233
|
return false;
|
|
1259
1234
|
}
|
|
1260
1235
|
current.items.splice(index4, 1);
|
|
1261
|
-
logger.debug(`[YamlEditor] \u5DF2\u4ECE ${
|
|
1236
|
+
logger.debug(`[YamlEditor] \u5DF2\u4ECE ${path18} \u6570\u7EC4\u5220\u9664\u5143\u7D20\uFF1A${value}`);
|
|
1262
1237
|
return true;
|
|
1263
1238
|
} catch (error) {
|
|
1264
1239
|
logger.error(`[YamlEditor] \u4ECE\u6570\u7EC4\u5220\u9664\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1270,9 +1245,9 @@ var init_yaml = __esm({
|
|
|
1270
1245
|
* @param path - 路径,用点号分隔
|
|
1271
1246
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1272
1247
|
*/
|
|
1273
|
-
has(
|
|
1248
|
+
has(path18, isSplit = true) {
|
|
1274
1249
|
try {
|
|
1275
|
-
const _path = typeof
|
|
1250
|
+
const _path = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1276
1251
|
return this.document.hasIn(_path);
|
|
1277
1252
|
} catch (error) {
|
|
1278
1253
|
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84\u662F\u5426\u5B58\u5728\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1285,9 +1260,9 @@ var init_yaml = __esm({
|
|
|
1285
1260
|
* @param value - 要查询的值
|
|
1286
1261
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1287
1262
|
*/
|
|
1288
|
-
hasval(
|
|
1263
|
+
hasval(path18, value, isSplit = true) {
|
|
1289
1264
|
try {
|
|
1290
|
-
const _path = typeof
|
|
1265
|
+
const _path = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1291
1266
|
const current = this.document.getIn(_path);
|
|
1292
1267
|
if (!current) return false;
|
|
1293
1268
|
if (current instanceof YAML.YAMLSeq) {
|
|
@@ -1298,7 +1273,7 @@ var init_yaml = __esm({
|
|
|
1298
1273
|
return lodash.isEqual(current, value);
|
|
1299
1274
|
}
|
|
1300
1275
|
} catch (error) {
|
|
1301
|
-
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${
|
|
1276
|
+
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${path18} \u662F\u5426\u5305\u542B\u503C\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
1302
1277
|
return false;
|
|
1303
1278
|
}
|
|
1304
1279
|
}
|
|
@@ -1308,8 +1283,8 @@ var init_yaml = __esm({
|
|
|
1308
1283
|
* @param value - 要查询的值
|
|
1309
1284
|
* @deprecated 请使用 `hasval` 代替
|
|
1310
1285
|
*/
|
|
1311
|
-
hasVal(
|
|
1312
|
-
return this.hasval(
|
|
1286
|
+
hasVal(path18, value) {
|
|
1287
|
+
return this.hasval(path18, value);
|
|
1313
1288
|
}
|
|
1314
1289
|
/**
|
|
1315
1290
|
* 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
|
|
@@ -1354,9 +1329,9 @@ var init_yaml = __esm({
|
|
|
1354
1329
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1355
1330
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1356
1331
|
*/
|
|
1357
|
-
getpair(
|
|
1358
|
-
if (!
|
|
1359
|
-
const keys = typeof
|
|
1332
|
+
getpair(path18, isSplit = true) {
|
|
1333
|
+
if (!path18) throw new Error("path is required");
|
|
1334
|
+
const keys = typeof path18 === "string" ? isSplit ? path18.split(".") : [path18] : path18;
|
|
1360
1335
|
let pair = this.document.contents;
|
|
1361
1336
|
keys.forEach((key) => {
|
|
1362
1337
|
if (isMap(pair)) {
|
|
@@ -1376,10 +1351,10 @@ var init_yaml = __esm({
|
|
|
1376
1351
|
* @param prepend - 如果为 true,则添加注释到开头,否则添加到同一行的末尾
|
|
1377
1352
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1378
1353
|
*/
|
|
1379
|
-
comment(
|
|
1380
|
-
if (!
|
|
1381
|
-
const pair = this.getpair(
|
|
1382
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1354
|
+
comment(path18, comment2, prepend = true, isSplit = true) {
|
|
1355
|
+
if (!path18) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1356
|
+
const pair = this.getpair(path18, isSplit);
|
|
1357
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path18}`);
|
|
1383
1358
|
comment2 = ` ${comment2}`;
|
|
1384
1359
|
if (prepend) {
|
|
1385
1360
|
pair.key.commentBefore = comment2;
|
|
@@ -1393,10 +1368,10 @@ var init_yaml = __esm({
|
|
|
1393
1368
|
* @param type - 要删除的注释类型,`before` 为注释前,`after` 为注释后,`all` 为全部
|
|
1394
1369
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1395
1370
|
*/
|
|
1396
|
-
uncomment(
|
|
1397
|
-
if (!
|
|
1398
|
-
const pair = this.getpair(
|
|
1399
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1371
|
+
uncomment(path18, type = "all", isSplit = true) {
|
|
1372
|
+
if (!path18) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1373
|
+
const pair = this.getpair(path18, isSplit);
|
|
1374
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path18}`);
|
|
1400
1375
|
if (type === "all") {
|
|
1401
1376
|
delete pair.key.comment;
|
|
1402
1377
|
delete pair.key.commentBefore;
|
|
@@ -1412,10 +1387,10 @@ var init_yaml = __esm({
|
|
|
1412
1387
|
* @param type - 要检查的注释类型,`before` 为注释前,`after` 为注释后
|
|
1413
1388
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1414
1389
|
*/
|
|
1415
|
-
hascomment(
|
|
1416
|
-
if (!
|
|
1417
|
-
const pair = this.getpair(
|
|
1418
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1390
|
+
hascomment(path18, type, isSplit = true) {
|
|
1391
|
+
if (!path18) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1392
|
+
const pair = this.getpair(path18, isSplit);
|
|
1393
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path18}`);
|
|
1419
1394
|
if (type === "before") {
|
|
1420
1395
|
return !!pair.key.commentBefore;
|
|
1421
1396
|
} else if (type === "after") {
|
|
@@ -1428,10 +1403,10 @@ var init_yaml = __esm({
|
|
|
1428
1403
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1429
1404
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1430
1405
|
*/
|
|
1431
|
-
getcomment(
|
|
1432
|
-
if (!
|
|
1433
|
-
const pair = this.getpair(
|
|
1434
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1406
|
+
getcomment(path18, isSplit = true) {
|
|
1407
|
+
if (!path18) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1408
|
+
const pair = this.getpair(path18, isSplit);
|
|
1409
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path18}`);
|
|
1435
1410
|
return pair.key.commentBefore || pair.key.comment;
|
|
1436
1411
|
}
|
|
1437
1412
|
/**
|
|
@@ -1443,11 +1418,11 @@ var init_yaml = __esm({
|
|
|
1443
1418
|
logger.debug("[YamlEditor] \u6587\u4EF6\u5DF2\u4FDD\u5B58");
|
|
1444
1419
|
}
|
|
1445
1420
|
};
|
|
1446
|
-
read = (
|
|
1447
|
-
const data = YAML.parse(fs8.readFileSync(
|
|
1421
|
+
read = (path18) => {
|
|
1422
|
+
const data = YAML.parse(fs8.readFileSync(path18, "utf-8"));
|
|
1448
1423
|
read.save = (options) => {
|
|
1449
1424
|
try {
|
|
1450
|
-
save(
|
|
1425
|
+
save(path18, data, typeof options === "string" ? JSON.parse(options) : options);
|
|
1451
1426
|
return true;
|
|
1452
1427
|
} catch (error) {
|
|
1453
1428
|
logger.error("[YamlEditor] \u4FDD\u5B58\u6587\u4EF6\u65F6\u51FA\u9519");
|
|
@@ -1457,23 +1432,23 @@ var init_yaml = __esm({
|
|
|
1457
1432
|
};
|
|
1458
1433
|
return data;
|
|
1459
1434
|
};
|
|
1460
|
-
write = (
|
|
1435
|
+
write = (path18, value) => {
|
|
1461
1436
|
try {
|
|
1462
|
-
fs8.writeFileSync(
|
|
1437
|
+
fs8.writeFileSync(path18, YAML.stringify(value));
|
|
1463
1438
|
return true;
|
|
1464
1439
|
} catch {
|
|
1465
1440
|
return false;
|
|
1466
1441
|
}
|
|
1467
1442
|
};
|
|
1468
|
-
save = (
|
|
1443
|
+
save = (path18, value, options) => {
|
|
1469
1444
|
if (!options) {
|
|
1470
|
-
fs8.writeFileSync(
|
|
1445
|
+
fs8.writeFileSync(path18, YAML.stringify(value));
|
|
1471
1446
|
return;
|
|
1472
1447
|
}
|
|
1473
1448
|
const editor = new YamlEditor(YAML.stringify(value));
|
|
1474
1449
|
const comment2 = typeof options === "string" ? JSON.parse(fs8.readFileSync(options, "utf8")) : options;
|
|
1475
1450
|
applyComments(editor, comment2);
|
|
1476
|
-
fs8.writeFileSync(
|
|
1451
|
+
fs8.writeFileSync(path18, editor.document.toString());
|
|
1477
1452
|
};
|
|
1478
1453
|
comment = (filePath, commentConfig) => {
|
|
1479
1454
|
const editor = new YamlEditor(filePath);
|
|
@@ -1520,9 +1495,9 @@ var init_groups = __esm({
|
|
|
1520
1495
|
FILE2 = `${configPath}/groups.json`;
|
|
1521
1496
|
count = {};
|
|
1522
1497
|
lint2 = async (defData, data) => {
|
|
1523
|
-
const
|
|
1498
|
+
const list3 = defData;
|
|
1524
1499
|
await Promise.all(Object.keys(data).map(async (key) => {
|
|
1525
|
-
|
|
1500
|
+
list3[key] = {
|
|
1526
1501
|
key,
|
|
1527
1502
|
cd: Number(data[key].cd) ?? defData.default.cd,
|
|
1528
1503
|
userCD: Number(data[key].userCD) ?? defData.default.userCD,
|
|
@@ -1534,7 +1509,7 @@ var init_groups = __esm({
|
|
|
1534
1509
|
memberEnable: setStr(Array.isArray(data[key].memberEnable) ? data[key].memberEnable : [])
|
|
1535
1510
|
};
|
|
1536
1511
|
}));
|
|
1537
|
-
return
|
|
1512
|
+
return list3;
|
|
1538
1513
|
};
|
|
1539
1514
|
cache4 = await lint2(defaultConfig.groups, requireFileSync(FILE2));
|
|
1540
1515
|
groups = () => cache4;
|
|
@@ -1619,11 +1594,11 @@ var init_error2 = __esm({
|
|
|
1619
1594
|
missing = /* @__PURE__ */ new Map();
|
|
1620
1595
|
loaderPlugin = (name, file, error) => {
|
|
1621
1596
|
var _a;
|
|
1622
|
-
const
|
|
1623
|
-
if (
|
|
1624
|
-
const key = `${name}.${
|
|
1597
|
+
const pkg2 = (_a = /Cannot find package '(.+?)'/.exec(error)) == null ? void 0 : _a[1];
|
|
1598
|
+
if (pkg2) {
|
|
1599
|
+
const key = `${name}.${pkg2}`;
|
|
1625
1600
|
if (!missing.has(key)) return;
|
|
1626
|
-
missing.set(key, { name, file, depend:
|
|
1601
|
+
missing.set(key, { name, file, depend: pkg2 });
|
|
1627
1602
|
} else {
|
|
1628
1603
|
logger.error(`\u8F7D\u5165\u63D2\u4EF6\u9519\u8BEF\uFF1A${logger.red(`${name}/${path5.basename(file)}`)}`);
|
|
1629
1604
|
listeners.emit("error", error);
|
|
@@ -1666,6 +1641,125 @@ var init_error2 = __esm({
|
|
|
1666
1641
|
}
|
|
1667
1642
|
});
|
|
1668
1643
|
|
|
1644
|
+
// src/core/internal/status_listener.ts
|
|
1645
|
+
import os from "node:os";
|
|
1646
|
+
import EventEmitter2 from "node:events";
|
|
1647
|
+
var StatusHelper, StatusHelperSubscription, statusListener;
|
|
1648
|
+
var init_status_listener = __esm({
|
|
1649
|
+
"src/core/internal/status_listener.ts"() {
|
|
1650
|
+
"use strict";
|
|
1651
|
+
init_esm_shims();
|
|
1652
|
+
StatusHelper = class {
|
|
1653
|
+
psCpuUsage = process.cpuUsage();
|
|
1654
|
+
psCurrentTime = process.hrtime();
|
|
1655
|
+
cpuTimes = os.cpus().map((cpu) => cpu.times);
|
|
1656
|
+
replaceNaN(value) {
|
|
1657
|
+
return isNaN(value) ? 0 : value;
|
|
1658
|
+
}
|
|
1659
|
+
sysCpuInfo() {
|
|
1660
|
+
const currentTimes = os.cpus().map((cpu) => cpu.times);
|
|
1661
|
+
const { total, active } = currentTimes.map((times, index4) => {
|
|
1662
|
+
const prevTimes = this.cpuTimes[index4];
|
|
1663
|
+
const totalCurrent = times.user + times.nice + times.sys + times.idle + times.irq;
|
|
1664
|
+
const totalPrev = prevTimes.user + prevTimes.nice + prevTimes.sys + prevTimes.idle + prevTimes.irq;
|
|
1665
|
+
const activeCurrent = totalCurrent - times.idle;
|
|
1666
|
+
const activePrev = totalPrev - prevTimes.idle;
|
|
1667
|
+
return {
|
|
1668
|
+
total: totalCurrent - totalPrev,
|
|
1669
|
+
active: activeCurrent - activePrev
|
|
1670
|
+
};
|
|
1671
|
+
}).reduce(
|
|
1672
|
+
(acc, cur) => ({
|
|
1673
|
+
total: acc.total + cur.total,
|
|
1674
|
+
active: acc.active + cur.active
|
|
1675
|
+
}),
|
|
1676
|
+
{ total: 0, active: 0 }
|
|
1677
|
+
);
|
|
1678
|
+
this.cpuTimes = currentTimes;
|
|
1679
|
+
return {
|
|
1680
|
+
usage: this.replaceNaN(active / total * 100).toFixed(2),
|
|
1681
|
+
model: os.cpus()[0].model,
|
|
1682
|
+
speed: os.cpus()[0].speed,
|
|
1683
|
+
core: os.cpus().length
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
sysMemoryUsage() {
|
|
1687
|
+
const { total, free } = { total: os.totalmem(), free: os.freemem() };
|
|
1688
|
+
return ((total - free) / 1024 / 1024).toFixed(2);
|
|
1689
|
+
}
|
|
1690
|
+
karinUsage() {
|
|
1691
|
+
const mem = process.memoryUsage();
|
|
1692
|
+
const numCpus = os.cpus().length;
|
|
1693
|
+
const usageDiff = process.cpuUsage(this.psCpuUsage);
|
|
1694
|
+
const endTime = process.hrtime(this.psCurrentTime);
|
|
1695
|
+
this.psCpuUsage = process.cpuUsage();
|
|
1696
|
+
this.psCurrentTime = process.hrtime();
|
|
1697
|
+
const usageMS = (usageDiff.user + usageDiff.system) / 1e3;
|
|
1698
|
+
const totalMS = endTime[0] * 1e3 + endTime[1] / 1e6;
|
|
1699
|
+
const normPercent = usageMS / totalMS / numCpus * 100;
|
|
1700
|
+
return {
|
|
1701
|
+
cpu: this.replaceNaN(normPercent).toFixed(2),
|
|
1702
|
+
memory: ((mem.heapTotal + mem.external + mem.arrayBuffers) / 1024 / 1024).toFixed(2)
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
systemStatus() {
|
|
1706
|
+
const karinUsage = this.karinUsage();
|
|
1707
|
+
const sysCpuInfo = this.sysCpuInfo();
|
|
1708
|
+
return {
|
|
1709
|
+
cpu: {
|
|
1710
|
+
core: sysCpuInfo.core,
|
|
1711
|
+
model: sysCpuInfo.model,
|
|
1712
|
+
speed: (sysCpuInfo.speed / 1e3).toFixed(2),
|
|
1713
|
+
usage: {
|
|
1714
|
+
system: sysCpuInfo.usage,
|
|
1715
|
+
karin: karinUsage.cpu
|
|
1716
|
+
}
|
|
1717
|
+
},
|
|
1718
|
+
memory: {
|
|
1719
|
+
total: (os.totalmem() / 1024 / 1024).toFixed(2),
|
|
1720
|
+
usage: {
|
|
1721
|
+
system: this.sysMemoryUsage(),
|
|
1722
|
+
karin: karinUsage.memory
|
|
1723
|
+
}
|
|
1724
|
+
},
|
|
1725
|
+
arch: `${os.platform()} ${os.arch()} ${os.release()}`
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
StatusHelperSubscription = class extends EventEmitter2 {
|
|
1730
|
+
statusHelper;
|
|
1731
|
+
interval = null;
|
|
1732
|
+
constructor(time2 = 3e3) {
|
|
1733
|
+
super();
|
|
1734
|
+
this.statusHelper = new StatusHelper();
|
|
1735
|
+
this.on("newListener", (event) => {
|
|
1736
|
+
if (event === "statusUpdate" && this.listenerCount("statusUpdate") === 0) {
|
|
1737
|
+
this.startInterval(time2);
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
this.on("removeListener", (event) => {
|
|
1741
|
+
if (event === "statusUpdate" && this.listenerCount("statusUpdate") === 0) {
|
|
1742
|
+
this.stopInterval();
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
startInterval(time2) {
|
|
1747
|
+
this.interval ??= setInterval(() => {
|
|
1748
|
+
const status = this.statusHelper.systemStatus();
|
|
1749
|
+
this.emit("statusUpdate", status);
|
|
1750
|
+
}, time2);
|
|
1751
|
+
}
|
|
1752
|
+
stopInterval() {
|
|
1753
|
+
if (this.interval) {
|
|
1754
|
+
clearInterval(this.interval);
|
|
1755
|
+
this.interval = null;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
statusListener = new StatusHelperSubscription();
|
|
1760
|
+
}
|
|
1761
|
+
});
|
|
1762
|
+
|
|
1669
1763
|
// src/core/internal/index.ts
|
|
1670
1764
|
var init_internal = __esm({
|
|
1671
1765
|
"src/core/internal/index.ts"() {
|
|
@@ -1674,6 +1768,7 @@ var init_internal = __esm({
|
|
|
1674
1768
|
init_error2();
|
|
1675
1769
|
init_process();
|
|
1676
1770
|
init_listeners();
|
|
1771
|
+
init_status_listener();
|
|
1677
1772
|
}
|
|
1678
1773
|
});
|
|
1679
1774
|
|
|
@@ -1715,9 +1810,9 @@ var init_privates = __esm({
|
|
|
1715
1810
|
FILE5 = `${configPath}/privates.json`;
|
|
1716
1811
|
count2 = {};
|
|
1717
1812
|
lint3 = async (defData, data) => {
|
|
1718
|
-
const
|
|
1813
|
+
const list3 = defData;
|
|
1719
1814
|
await Promise.all(Object.keys(data).map(async (key) => {
|
|
1720
|
-
|
|
1815
|
+
list3[key] = {
|
|
1721
1816
|
key,
|
|
1722
1817
|
cd: Number(data[key].cd) ?? defData.default.cd,
|
|
1723
1818
|
mode: Number(data[key].mode) ?? defData.default.mode,
|
|
@@ -1726,7 +1821,7 @@ var init_privates = __esm({
|
|
|
1726
1821
|
disable: setStr(Array.isArray(data[key].disable) ? data[key].disable : [])
|
|
1727
1822
|
};
|
|
1728
1823
|
}));
|
|
1729
|
-
return
|
|
1824
|
+
return list3;
|
|
1730
1825
|
};
|
|
1731
1826
|
cache7 = await lint3(defaultConfig.privates, requireFileSync(FILE5));
|
|
1732
1827
|
privates = () => cache7;
|
|
@@ -1803,9 +1898,9 @@ __export(config_exports2, {
|
|
|
1803
1898
|
adapter: () => adapter,
|
|
1804
1899
|
admin: () => admin,
|
|
1805
1900
|
authKey: () => authKey,
|
|
1806
|
-
clearTemp: () => clearTemp,
|
|
1807
1901
|
config: () => config,
|
|
1808
1902
|
defaultConfig: () => defaultConfig,
|
|
1903
|
+
env: () => env,
|
|
1809
1904
|
ffmpegPath: () => ffmpegPath,
|
|
1810
1905
|
ffplayPath: () => ffplayPath,
|
|
1811
1906
|
ffprobePath: () => ffprobePath,
|
|
@@ -1859,8 +1954,8 @@ var init_ffmpeg = __esm({
|
|
|
1859
1954
|
ffprobePath2 = "ffprobe";
|
|
1860
1955
|
ffplayPath2 = "ffplay";
|
|
1861
1956
|
setTimeout(async () => {
|
|
1862
|
-
const
|
|
1863
|
-
if (!
|
|
1957
|
+
const env3 = await exec("ffmpeg -version", { booleanResult: true });
|
|
1958
|
+
if (!env3) {
|
|
1864
1959
|
const cfg = await init_config2().then(() => config_exports2);
|
|
1865
1960
|
const ffmpeg2 = cfg.ffmpegPath();
|
|
1866
1961
|
const ffprobe2 = cfg.ffprobePath();
|
|
@@ -1937,22 +2032,22 @@ var init_path = __esm({
|
|
|
1937
2032
|
filesByExt = (filePath, ext, returnType = "name") => {
|
|
1938
2033
|
if (!fs9.existsSync(filePath) || !fs9.statSync(filePath).isDirectory()) return [];
|
|
1939
2034
|
const files = fs9.readdirSync(filePath, { withFileTypes: true });
|
|
1940
|
-
const
|
|
2035
|
+
const list3 = [];
|
|
1941
2036
|
if (!Array.isArray(ext)) ext = [ext];
|
|
1942
2037
|
files.forEach((v) => {
|
|
1943
2038
|
if (v.isDirectory()) return;
|
|
1944
2039
|
if (ext.includes(path7.extname(v.name))) {
|
|
1945
2040
|
if (returnType === "name") {
|
|
1946
|
-
|
|
2041
|
+
list3.push(v.name);
|
|
1947
2042
|
} else if (returnType === "rel") {
|
|
1948
2043
|
const file = path7.resolve(filePath, v.name);
|
|
1949
|
-
|
|
2044
|
+
list3.push(path7.relative(process.cwd(), file));
|
|
1950
2045
|
} else if (returnType === "abs") {
|
|
1951
|
-
|
|
2046
|
+
list3.push(path7.resolve(filePath, v.name));
|
|
1952
2047
|
}
|
|
1953
2048
|
}
|
|
1954
2049
|
});
|
|
1955
|
-
return
|
|
2050
|
+
return list3;
|
|
1956
2051
|
};
|
|
1957
2052
|
splitPath = (filePath) => {
|
|
1958
2053
|
const dirname = path7.dirname(filePath).replace(sep, "");
|
|
@@ -1999,28 +2094,28 @@ var init_list = __esm({
|
|
|
1999
2094
|
if (!cache8.list) cache8.list = {};
|
|
2000
2095
|
if (!cache8.info) cache8.info = {};
|
|
2001
2096
|
if (!["npm", "all", "git", "app"].includes(type)) return [];
|
|
2002
|
-
const
|
|
2097
|
+
const list3 = [];
|
|
2003
2098
|
const files = type === "npm" ? [] : fs10.existsSync(pluginDir) ? await fs10.promises.readdir(pluginDir, { withFileTypes: true }) : [];
|
|
2004
2099
|
const pluginHandlers = {
|
|
2005
|
-
app: () => filterApp(files,
|
|
2006
|
-
git: () => filterGit(files,
|
|
2007
|
-
npm: () => filterPkg(
|
|
2100
|
+
app: () => filterApp(files, list3),
|
|
2101
|
+
git: () => filterGit(files, list3),
|
|
2102
|
+
npm: () => filterPkg(list3),
|
|
2008
2103
|
all: async () => {
|
|
2009
2104
|
await Promise.all([
|
|
2010
|
-
filterApp(files,
|
|
2011
|
-
filterGit(files,
|
|
2012
|
-
filterPkg(
|
|
2105
|
+
filterApp(files, list3),
|
|
2106
|
+
filterGit(files, list3),
|
|
2107
|
+
filterPkg(list3)
|
|
2013
2108
|
]);
|
|
2014
2109
|
}
|
|
2015
2110
|
};
|
|
2016
2111
|
await pluginHandlers[type]();
|
|
2017
|
-
cache8.list[type] =
|
|
2112
|
+
cache8.list[type] = list3;
|
|
2018
2113
|
setTimeout(() => {
|
|
2019
2114
|
var _a2;
|
|
2020
2115
|
return (_a2 = cache8 == null ? void 0 : cache8.list) == null ? true : delete _a2[type];
|
|
2021
2116
|
}, 60 * 1e3);
|
|
2022
|
-
if (!isInfo) return
|
|
2023
|
-
const info = await getPluginsInfo(
|
|
2117
|
+
if (!isInfo) return list3;
|
|
2118
|
+
const info = await getPluginsInfo(list3);
|
|
2024
2119
|
cache8.info[type] = info;
|
|
2025
2120
|
setTimeout(() => {
|
|
2026
2121
|
var _a2;
|
|
@@ -2028,10 +2123,10 @@ var init_list = __esm({
|
|
|
2028
2123
|
}, 60 * 1e3);
|
|
2029
2124
|
return info;
|
|
2030
2125
|
};
|
|
2031
|
-
getPluginsInfo = async (
|
|
2126
|
+
getPluginsInfo = async (list3) => {
|
|
2032
2127
|
const info = [];
|
|
2033
2128
|
const ext = isTsx() ? [".ts", ".js"] : [".js"];
|
|
2034
|
-
await Promise.allSettled(
|
|
2129
|
+
await Promise.allSettled(list3.map(async (v) => {
|
|
2035
2130
|
const [type, name] = v.split(":");
|
|
2036
2131
|
if (type === "app") {
|
|
2037
2132
|
const file = path8.join(pluginDir, name);
|
|
@@ -2074,8 +2169,8 @@ var init_list = __esm({
|
|
|
2074
2169
|
info.push(createPkg("app", name, dir, apps, [dir]));
|
|
2075
2170
|
};
|
|
2076
2171
|
getGitInfo = async (info, dir, name, ext) => {
|
|
2077
|
-
const
|
|
2078
|
-
if (!
|
|
2172
|
+
const pkg2 = await requireFile(path8.join(dir, "package.json"));
|
|
2173
|
+
if (!pkg2 || !pkg2.karin) {
|
|
2079
2174
|
info.push(createPkg("git", name, dir, [], []));
|
|
2080
2175
|
return;
|
|
2081
2176
|
}
|
|
@@ -2089,10 +2184,10 @@ var init_list = __esm({
|
|
|
2089
2184
|
files.push(...app2);
|
|
2090
2185
|
}
|
|
2091
2186
|
};
|
|
2092
|
-
if (isTsx() &&
|
|
2093
|
-
pushApps(
|
|
2094
|
-
} else if (
|
|
2095
|
-
pushApps(
|
|
2187
|
+
if (isTsx() && pkg2.karin["ts-apps"]) {
|
|
2188
|
+
pushApps(pkg2.karin["ts-apps"]);
|
|
2189
|
+
} else if (pkg2.karin.apps) {
|
|
2190
|
+
pushApps(pkg2.karin.apps);
|
|
2096
2191
|
}
|
|
2097
2192
|
await Promise.allSettled(files.map(async (app2) => {
|
|
2098
2193
|
const appPath = path8.join(dir, app2);
|
|
@@ -2107,16 +2202,16 @@ var init_list = __esm({
|
|
|
2107
2202
|
const ext = ".js";
|
|
2108
2203
|
const apps = [];
|
|
2109
2204
|
const allApps = [];
|
|
2110
|
-
const
|
|
2111
|
-
if (!((_b = (_a =
|
|
2205
|
+
const pkg2 = await requireFile(path8.join(dir, "package.json"));
|
|
2206
|
+
if (!((_b = (_a = pkg2.karin) == null ? void 0 : _a.apps) == null ? void 0 : _b.length)) {
|
|
2112
2207
|
info.push(createPkg("npm", name, dir, [], []));
|
|
2113
2208
|
return;
|
|
2114
2209
|
}
|
|
2115
2210
|
const files = [];
|
|
2116
|
-
if (typeof
|
|
2117
|
-
files.push(
|
|
2118
|
-
} else if (Array.isArray(
|
|
2119
|
-
files.push(...
|
|
2211
|
+
if (typeof pkg2.karin.apps === "string") {
|
|
2212
|
+
files.push(pkg2.karin.apps);
|
|
2213
|
+
} else if (Array.isArray(pkg2.karin.apps)) {
|
|
2214
|
+
files.push(...pkg2.karin.apps);
|
|
2120
2215
|
}
|
|
2121
2216
|
await Promise.allSettled(files.map(async (app2) => {
|
|
2122
2217
|
const appPath = path8.join(dir, app2);
|
|
@@ -2129,38 +2224,38 @@ var init_list = __esm({
|
|
|
2129
2224
|
isNpmPlugin = async (name) => {
|
|
2130
2225
|
try {
|
|
2131
2226
|
const file = path8.join(process.cwd(), "node_modules", name, "package.json");
|
|
2132
|
-
const
|
|
2133
|
-
return !!
|
|
2227
|
+
const pkg2 = await requireFile(file);
|
|
2228
|
+
return !!pkg2.karin;
|
|
2134
2229
|
} catch {
|
|
2135
2230
|
return false;
|
|
2136
2231
|
}
|
|
2137
2232
|
};
|
|
2138
|
-
filterApp = async (files,
|
|
2233
|
+
filterApp = async (files, list3) => {
|
|
2139
2234
|
await Promise.all(files.map(async (v) => {
|
|
2140
2235
|
if (!v.isDirectory()) return;
|
|
2141
2236
|
if (!v.name.startsWith("karin-plugin-")) return;
|
|
2142
2237
|
if (fs10.existsSync(`${pluginDir}/${v.name}/package.json`)) return;
|
|
2143
|
-
|
|
2238
|
+
list3.push(`app:${v.name}`);
|
|
2144
2239
|
}));
|
|
2145
2240
|
const root = await requireFile("./package.json");
|
|
2146
|
-
if (root.name && root.karin)
|
|
2241
|
+
if (root.name && root.karin) list3.push(`root:${root.name}`);
|
|
2147
2242
|
};
|
|
2148
|
-
filterGit = async (files,
|
|
2243
|
+
filterGit = async (files, list3) => {
|
|
2149
2244
|
await Promise.all(files.map(async (v) => {
|
|
2150
2245
|
if (!v.isDirectory()) return;
|
|
2151
2246
|
if (!v.name.startsWith("karin-plugin-")) return;
|
|
2152
2247
|
if (!fs10.existsSync(path8.join(pluginDir, v.name, "package.json"))) return;
|
|
2153
|
-
|
|
2248
|
+
list3.push(`git:${v.name}`);
|
|
2154
2249
|
}));
|
|
2155
2250
|
};
|
|
2156
|
-
filterPkg = async (
|
|
2251
|
+
filterPkg = async (list3) => {
|
|
2157
2252
|
const karinPkg = await requireFile(path8.join(karinDir, "package.json"));
|
|
2158
2253
|
const exclude = [...Object.keys(karinPkg.dependencies || {}), ...Object.keys(karinPkg.devDependencies || {})];
|
|
2159
|
-
const
|
|
2160
|
-
const dependencies = Object.keys(
|
|
2254
|
+
const pkg2 = await requireFile("./package.json");
|
|
2255
|
+
const dependencies = Object.keys(pkg2.dependencies || {}).filter((name) => !exclude.includes(name) && !name.startsWith("@types"));
|
|
2161
2256
|
await Promise.all(dependencies.map(async (name) => {
|
|
2162
2257
|
const isPlugin2 = await isNpmPlugin(name);
|
|
2163
|
-
if (isPlugin2)
|
|
2258
|
+
if (isPlugin2) list3.push(`npm:${name}`);
|
|
2164
2259
|
}));
|
|
2165
2260
|
};
|
|
2166
2261
|
}
|
|
@@ -2223,36 +2318,36 @@ var init_json = __esm({
|
|
|
2223
2318
|
"src/utils/fs/json.ts"() {
|
|
2224
2319
|
"use strict";
|
|
2225
2320
|
init_esm_shims();
|
|
2226
|
-
readJsonSync = (
|
|
2321
|
+
readJsonSync = (path18, isThrow = false) => {
|
|
2227
2322
|
try {
|
|
2228
|
-
const data = fs12.readFileSync(
|
|
2323
|
+
const data = fs12.readFileSync(path18, "utf8");
|
|
2229
2324
|
return JSON.parse(data);
|
|
2230
2325
|
} catch (error) {
|
|
2231
2326
|
if (isThrow) throw error;
|
|
2232
2327
|
return null;
|
|
2233
2328
|
}
|
|
2234
2329
|
};
|
|
2235
|
-
writeJsonSync = (
|
|
2330
|
+
writeJsonSync = (path18, data, isThrow = false) => {
|
|
2236
2331
|
try {
|
|
2237
|
-
fs12.writeFileSync(
|
|
2332
|
+
fs12.writeFileSync(path18, JSON.stringify(data, null, 2));
|
|
2238
2333
|
return true;
|
|
2239
2334
|
} catch (error) {
|
|
2240
2335
|
if (isThrow) throw error;
|
|
2241
2336
|
return false;
|
|
2242
2337
|
}
|
|
2243
2338
|
};
|
|
2244
|
-
readJson = async (
|
|
2339
|
+
readJson = async (path18, isThrow = false) => {
|
|
2245
2340
|
try {
|
|
2246
|
-
const data = await fs12.promises.readFile(
|
|
2341
|
+
const data = await fs12.promises.readFile(path18, "utf8");
|
|
2247
2342
|
return JSON.parse(data);
|
|
2248
2343
|
} catch (error) {
|
|
2249
2344
|
if (isThrow) throw error;
|
|
2250
2345
|
return null;
|
|
2251
2346
|
}
|
|
2252
2347
|
};
|
|
2253
|
-
writeJson = async (
|
|
2348
|
+
writeJson = async (path18, data, isThrow = false) => {
|
|
2254
2349
|
try {
|
|
2255
|
-
await fs12.promises.writeFile(
|
|
2350
|
+
await fs12.promises.writeFile(path18, JSON.stringify(data, null, 2));
|
|
2256
2351
|
return true;
|
|
2257
2352
|
} catch (error) {
|
|
2258
2353
|
if (isThrow) throw error;
|
|
@@ -2340,8 +2435,8 @@ var init_pkg = __esm({
|
|
|
2340
2435
|
}
|
|
2341
2436
|
};
|
|
2342
2437
|
getPluginInfo = (name) => {
|
|
2343
|
-
const
|
|
2344
|
-
const plugin =
|
|
2438
|
+
const list3 = Object.values(cache9.index);
|
|
2439
|
+
const plugin = list3.find((item) => item.name === name);
|
|
2345
2440
|
if (!plugin) return null;
|
|
2346
2441
|
const info = {
|
|
2347
2442
|
get pkg() {
|
|
@@ -2366,9 +2461,9 @@ var init_convert = __esm({
|
|
|
2366
2461
|
karinToQQBot = (button3) => {
|
|
2367
2462
|
let id = 0;
|
|
2368
2463
|
const rows = [];
|
|
2369
|
-
const
|
|
2370
|
-
button3.type === "button" ?
|
|
2371
|
-
for (const row of
|
|
2464
|
+
const list3 = [];
|
|
2465
|
+
button3.type === "button" ? list3.push(button3.data) : list3.push(...button3.rows);
|
|
2466
|
+
for (const row of list3) {
|
|
2372
2467
|
const buttons = [];
|
|
2373
2468
|
for (const i of row) {
|
|
2374
2469
|
const type = i.link ? 0 : i.callback ? 1 : i.type ?? 2;
|
|
@@ -2870,20 +2965,20 @@ var init_common = __esm({
|
|
|
2870
2965
|
return layouts;
|
|
2871
2966
|
};
|
|
2872
2967
|
buildFilterComplex = async (files, perRow) => {
|
|
2873
|
-
const
|
|
2968
|
+
const list3 = await Promise.all(
|
|
2874
2969
|
files.map(async (file) => {
|
|
2875
2970
|
const { width, height } = await getImageSize(file);
|
|
2876
2971
|
return { file, width, height };
|
|
2877
2972
|
})
|
|
2878
2973
|
);
|
|
2879
|
-
const maxWidth = Math.max(...
|
|
2880
|
-
const maxHeight = Math.max(...
|
|
2974
|
+
const maxWidth = Math.max(...list3.map((d) => d.width));
|
|
2975
|
+
const maxHeight = Math.max(...list3.map((d) => d.height));
|
|
2881
2976
|
let cmd = "";
|
|
2882
|
-
|
|
2977
|
+
list3.forEach((dim, index4) => {
|
|
2883
2978
|
cmd += `[${index4}:v]pad=${maxWidth}:${maxHeight}:(ow-iw)/2:(oh-ih)/2[p${index4}]; `;
|
|
2884
2979
|
});
|
|
2885
|
-
const layouts = generateLayout(
|
|
2886
|
-
cmd += `${
|
|
2980
|
+
const layouts = generateLayout(list3, perRow, maxWidth, maxHeight);
|
|
2981
|
+
cmd += `${list3.map((_, index4) => `[p${index4}]`).join("")}xstack=inputs=${list3.length}:layout=${layouts}[out]`;
|
|
2887
2982
|
return cmd;
|
|
2888
2983
|
};
|
|
2889
2984
|
}
|
|
@@ -2900,8 +2995,8 @@ var init_level = __esm({
|
|
|
2900
2995
|
LevelDB = class extends Level {
|
|
2901
2996
|
id;
|
|
2902
2997
|
get;
|
|
2903
|
-
constructor(
|
|
2904
|
-
super(
|
|
2998
|
+
constructor(path18) {
|
|
2999
|
+
super(path18, { valueEncoding: "json" });
|
|
2905
3000
|
this.id = "Level";
|
|
2906
3001
|
this.get = super.get.bind(this);
|
|
2907
3002
|
}
|
|
@@ -2935,7 +3030,7 @@ var init_level = __esm({
|
|
|
2935
3030
|
import { Level as Level2 } from "level";
|
|
2936
3031
|
import lodash4 from "lodash";
|
|
2937
3032
|
import moment from "moment";
|
|
2938
|
-
import { EventEmitter as
|
|
3033
|
+
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
2939
3034
|
var RedisClient;
|
|
2940
3035
|
var init_mock = __esm({
|
|
2941
3036
|
"src/core/db/redis/mock.ts"() {
|
|
@@ -2943,7 +3038,7 @@ var init_mock = __esm({
|
|
|
2943
3038
|
init_esm_shims();
|
|
2944
3039
|
init_root();
|
|
2945
3040
|
init_fsSync();
|
|
2946
|
-
RedisClient = class extends
|
|
3041
|
+
RedisClient = class extends EventEmitter3 {
|
|
2947
3042
|
/** 键、类型、过期时间映射 */
|
|
2948
3043
|
#info = {};
|
|
2949
3044
|
/** 键值对 */
|
|
@@ -2984,8 +3079,8 @@ var init_mock = __esm({
|
|
|
2984
3079
|
keys.forEach((key) => this.checkExpire(key));
|
|
2985
3080
|
}, 3e4);
|
|
2986
3081
|
setInterval(() => this.save(), 12e4);
|
|
2987
|
-
const
|
|
2988
|
-
await Promise.all(
|
|
3082
|
+
const list3 = await this.#level.keys().all();
|
|
3083
|
+
await Promise.all(list3.map(async (key) => {
|
|
2989
3084
|
const data = await this.#level.get(key).catch(() => null);
|
|
2990
3085
|
if (!data) return;
|
|
2991
3086
|
const { type, expire, value } = JSON.parse(data);
|
|
@@ -3008,43 +3103,43 @@ var init_mock = __esm({
|
|
|
3008
3103
|
return;
|
|
3009
3104
|
}
|
|
3010
3105
|
case "list" /* LIST */: {
|
|
3011
|
-
const
|
|
3012
|
-
for (let i = 0; i <
|
|
3013
|
-
if (typeof
|
|
3014
|
-
|
|
3106
|
+
const list4 = JSON.parse(value);
|
|
3107
|
+
for (let i = 0; i < list4.length; i++) {
|
|
3108
|
+
if (typeof list4[i] !== "string") {
|
|
3109
|
+
list4[i] = Buffer.from(list4[i]);
|
|
3015
3110
|
}
|
|
3016
3111
|
}
|
|
3017
|
-
this.#list[key] =
|
|
3112
|
+
this.#list[key] = list4;
|
|
3018
3113
|
return;
|
|
3019
3114
|
}
|
|
3020
3115
|
case "set" /* SET */: {
|
|
3021
|
-
const
|
|
3022
|
-
for (let i = 0; i <
|
|
3023
|
-
if (typeof
|
|
3024
|
-
|
|
3116
|
+
const list4 = JSON.parse(value);
|
|
3117
|
+
for (let i = 0; i < list4.length; i++) {
|
|
3118
|
+
if (typeof list4[i] !== "string") {
|
|
3119
|
+
list4[i] = Buffer.from(list4[i]);
|
|
3025
3120
|
}
|
|
3026
3121
|
}
|
|
3027
|
-
this.#set[key] = new Set(
|
|
3122
|
+
this.#set[key] = new Set(list4);
|
|
3028
3123
|
return;
|
|
3029
3124
|
}
|
|
3030
3125
|
case "zset" /* ZSET */: {
|
|
3031
|
-
const
|
|
3032
|
-
for (let i = 0; i <
|
|
3033
|
-
if (typeof
|
|
3034
|
-
|
|
3126
|
+
const list4 = JSON.parse(value);
|
|
3127
|
+
for (let i = 0; i < list4.length; i++) {
|
|
3128
|
+
if (typeof list4[i].member !== "string") {
|
|
3129
|
+
list4[i].member = Buffer.from(list4[i].member);
|
|
3035
3130
|
}
|
|
3036
3131
|
}
|
|
3037
|
-
this.#zset[key] =
|
|
3132
|
+
this.#zset[key] = list4;
|
|
3038
3133
|
return;
|
|
3039
3134
|
}
|
|
3040
3135
|
case "pf" /* PF */: {
|
|
3041
|
-
const
|
|
3042
|
-
for (let i = 0; i <
|
|
3043
|
-
if (typeof
|
|
3044
|
-
|
|
3136
|
+
const list4 = JSON.parse(value);
|
|
3137
|
+
for (let i = 0; i < list4.length; i++) {
|
|
3138
|
+
if (typeof list4[i] !== "string") {
|
|
3139
|
+
list4[i] = Buffer.from(list4[i]);
|
|
3045
3140
|
}
|
|
3046
3141
|
}
|
|
3047
|
-
this.#pf[key] = new Set(
|
|
3142
|
+
this.#pf[key] = new Set(list4);
|
|
3048
3143
|
return;
|
|
3049
3144
|
}
|
|
3050
3145
|
case "bit" /* BIT */:
|
|
@@ -3734,14 +3829,14 @@ var init_mock = __esm({
|
|
|
3734
3829
|
async save() {
|
|
3735
3830
|
const keys = await this.#level.keys().all();
|
|
3736
3831
|
const delKeys = keys.filter((key) => !this.#info[key]);
|
|
3737
|
-
const
|
|
3738
|
-
delKeys.forEach((key) =>
|
|
3832
|
+
const list3 = [];
|
|
3833
|
+
delKeys.forEach((key) => list3.push({ type: "del", key }));
|
|
3739
3834
|
Object.keys(this.#info).forEach((key) => {
|
|
3740
3835
|
const { type, expire } = this.#info[key];
|
|
3741
3836
|
const value = this.#str[key];
|
|
3742
|
-
|
|
3837
|
+
list3.push({ type: "put", key, value: JSON.stringify({ type, expire, value }) });
|
|
3743
3838
|
});
|
|
3744
|
-
await this.#level.batch(
|
|
3839
|
+
await this.#level.batch(list3);
|
|
3745
3840
|
return "OK";
|
|
3746
3841
|
}
|
|
3747
3842
|
};
|
|
@@ -3852,16 +3947,17 @@ __export(process_exports, {
|
|
|
3852
3947
|
processExit: () => processExit,
|
|
3853
3948
|
processHandler: () => processHandler
|
|
3854
3949
|
});
|
|
3855
|
-
|
|
3950
|
+
import axios4 from "axios";
|
|
3951
|
+
var exitStatus, tips, processHandler, checkProcess, processExit, request;
|
|
3856
3952
|
var init_process = __esm({
|
|
3857
3953
|
"src/core/internal/process.ts"() {
|
|
3858
3954
|
"use strict";
|
|
3859
3955
|
init_esm_shims();
|
|
3860
3956
|
init_listeners();
|
|
3861
3957
|
init_exec();
|
|
3862
|
-
init_pid();
|
|
3863
3958
|
init_common();
|
|
3864
3959
|
exitStatus = false;
|
|
3960
|
+
tips = (msg, isTrim = false) => `[process]${isTrim ? "" : " "}${msg}`;
|
|
3865
3961
|
processHandler = () => {
|
|
3866
3962
|
process.once("SIGHUP", (code) => processExit(code));
|
|
3867
3963
|
process.once("SIGINT", (code) => processExit(code));
|
|
@@ -3884,40 +3980,29 @@ var init_process = __esm({
|
|
|
3884
3980
|
if (process.env.pm_id) process.env.RUNTIME = "pm2";
|
|
3885
3981
|
};
|
|
3886
3982
|
checkProcess = async (port2) => {
|
|
3887
|
-
|
|
3888
|
-
const
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
method: "get",
|
|
3892
|
-
timeout: 300,
|
|
3893
|
-
headers: { Authorization: `Bearer ${process.env.HTTP_AUTH_KEY}` }
|
|
3894
|
-
});
|
|
3895
|
-
if (!data || data.status !== 200) return;
|
|
3896
|
-
if (((_a = data == null ? void 0 : data.data) == null ? void 0 : _a.ping) !== "pong") {
|
|
3897
|
-
const pid = await getPid(port2).catch(() => -0);
|
|
3898
|
-
logger.fatal(`\u7AEF\u53E3 ${port2} \u88AB\u8FDB\u7A0B\u5360\u7528\uFF0C\u8FDB\u7A0BID\uFF1A${pid}\uFF0C\u8BF7\u624B\u52A8\u5173\u95ED\u5BF9\u5E94\u8FDB\u7A0B\u6216\u89E3\u9664\u7AEF\u53E3\u5360\u7528`);
|
|
3983
|
+
const host2 = `http://127.0.0.1:${port2}/api/v1`;
|
|
3984
|
+
const ping = await request(host2, "/ping", "get", 300);
|
|
3985
|
+
if (!ping || !ping.success) {
|
|
3986
|
+
logger.debug(logger.green("\u6CA1\u6709\u68C0\u6D4B\u5230\u540E\u53F0\u8FDB\u7A0B~"));
|
|
3899
3987
|
return;
|
|
3900
3988
|
}
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
if (typeof result === "undefined") {
|
|
3907
|
-
logger.fatal(logger.red(`\u5F53\u524D\u5B58\u5728\u591A\u5F00Bot\u5360\u7528 ${port2}\u7AEF\u53E3\uFF0C\u8BF7\u66F4\u6362\u7AEF\u53E3\u6216\u8005\u5173\u95ED\u5BF9\u5E94Bot`));
|
|
3908
|
-
processExit(1);
|
|
3989
|
+
logger.error(logger.yellow(tips("\u68C0\u6D4B\u5230\u540E\u53F0\u8FDB\u7A0B \u6B63\u5728\u5173\u95ED...")));
|
|
3990
|
+
const exit = await request(host2, "/exit", "post", 500);
|
|
3991
|
+
if (!exit || !exit.success) {
|
|
3992
|
+
logger.fatal(logger.red(tips("\u540E\u53F0\u8FDB\u7A0B\u5173\u95ED\u5931\u8D25\uFF0C\u5982\u591A\u5F00Bot\u8BF7\u66F4\u6362\u7AEF\u53E3")));
|
|
3993
|
+
process.exit(1);
|
|
3909
3994
|
}
|
|
3910
3995
|
for (let i = 0; i < 100; i++) {
|
|
3911
|
-
const
|
|
3912
|
-
if (
|
|
3996
|
+
const ping2 = await request(host2, "/ping", "get", 300);
|
|
3997
|
+
if (ping2 && ping2.success) {
|
|
3913
3998
|
await sleep(50);
|
|
3914
3999
|
continue;
|
|
3915
4000
|
}
|
|
3916
|
-
logger.mark(logger.green("\u540E\u53F0\u8FDB\u7A0B\u5DF2\u5173\u95ED"));
|
|
4001
|
+
logger.mark(logger.green(tips("\u540E\u53F0\u8FDB\u7A0B\u5DF2\u5173\u95ED")));
|
|
3917
4002
|
return;
|
|
3918
4003
|
}
|
|
3919
|
-
logger.error(logger.red(`\u540E\u53F0\u8FDB\u7A0B\u5173\u95ED\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u6709\u8FDB\u7A0B\u6B63\u5728\u5360\u7528\u7AEF\u53E3 ${port2} `));
|
|
3920
|
-
|
|
4004
|
+
logger.error(logger.red(tips(`\u540E\u53F0\u8FDB\u7A0B\u5173\u95ED\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u6709\u8FDB\u7A0B\u6B63\u5728\u5360\u7528\u7AEF\u53E3 ${port2} `)));
|
|
4005
|
+
process.exit(1);
|
|
3921
4006
|
};
|
|
3922
4007
|
processExit = async (code) => {
|
|
3923
4008
|
try {
|
|
@@ -3925,7 +4010,7 @@ var init_process = __esm({
|
|
|
3925
4010
|
exitStatus = true;
|
|
3926
4011
|
const { redis: redis3, level: level2 } = await init_db2().then(() => db_exports);
|
|
3927
4012
|
await Promise.allSettled([redis3.save(), level2.close()]);
|
|
3928
|
-
logger.mark(`\u8FD0\u884C\u7ED3\u675F \u8FD0\u884C\u65F6\u95F4\uFF1A${uptime2()} \u9000\u51FA\u7801\uFF1A${code ?? "\u672A\u77E5"}`);
|
|
4013
|
+
logger.mark(tips(`\u8FD0\u884C\u7ED3\u675F \u8FD0\u884C\u65F6\u95F4\uFF1A${uptime2()} \u9000\u51FA\u7801\uFF1A${code ?? "\u672A\u77E5"}`));
|
|
3929
4014
|
if (process.env.pm_id) {
|
|
3930
4015
|
await exec(`pm2 delete ${process.env.pm_id}`);
|
|
3931
4016
|
}
|
|
@@ -3936,6 +4021,51 @@ var init_process = __esm({
|
|
|
3936
4021
|
process.exit();
|
|
3937
4022
|
}
|
|
3938
4023
|
};
|
|
4024
|
+
request = async (url, path18, method, timeout2) => {
|
|
4025
|
+
const client = axios4.create({
|
|
4026
|
+
baseURL: url,
|
|
4027
|
+
timeout: timeout2,
|
|
4028
|
+
headers: { Authorization: `Bearer ${process.env.HTTP_AUTH_KEY}` },
|
|
4029
|
+
validateStatus: () => true
|
|
4030
|
+
});
|
|
4031
|
+
try {
|
|
4032
|
+
const result = await client[method](path18);
|
|
4033
|
+
if (result.status === 200) {
|
|
4034
|
+
logger.info(
|
|
4035
|
+
tips(`[${method}] \u8BF7\u6C42\u6210\u529F:
|
|
4036
|
+
`, true) + `path: ${path18}
|
|
4037
|
+
body: ${JSON.stringify(result.data)}
|
|
4038
|
+
`
|
|
4039
|
+
);
|
|
4040
|
+
return { code: result.status, success: true };
|
|
4041
|
+
}
|
|
4042
|
+
if (result.status === 401) {
|
|
4043
|
+
logger.error(
|
|
4044
|
+
tips(`[${method}] \u9274\u6743\u5931\u8D25:
|
|
4045
|
+
`, true) + `path: ${path18}
|
|
4046
|
+
body: ${JSON.stringify(result.data)}
|
|
4047
|
+
`
|
|
4048
|
+
);
|
|
4049
|
+
return { code: result.status, success: false };
|
|
4050
|
+
}
|
|
4051
|
+
(path18 === "/ping" ? logger.debug : logger.error).call(
|
|
4052
|
+
logger,
|
|
4053
|
+
tips(`[${method}] \u8BF7\u6C42\u5931\u8D25:
|
|
4054
|
+
`, true) + `path: ${path18}
|
|
4055
|
+
body: ${JSON.stringify(result.data)}
|
|
4056
|
+
`
|
|
4057
|
+
);
|
|
4058
|
+
return { code: result.status, success: false };
|
|
4059
|
+
} catch (error) {
|
|
4060
|
+
logger.debug(
|
|
4061
|
+
tips(`[${method}] \u8BF7\u6C42\u5F02\u5E38:
|
|
4062
|
+
`, true) + `path: ${path18}
|
|
4063
|
+
error: ${(error == null ? void 0 : error.message) || "\u672A\u77E5\u9519\u8BEF"}
|
|
4064
|
+
`
|
|
4065
|
+
);
|
|
4066
|
+
return { code: 500, success: false };
|
|
4067
|
+
}
|
|
4068
|
+
};
|
|
3939
4069
|
}
|
|
3940
4070
|
});
|
|
3941
4071
|
|
|
@@ -4012,9 +4142,9 @@ var init_watcher = __esm({
|
|
|
4012
4142
|
*/
|
|
4013
4143
|
init() {
|
|
4014
4144
|
const isDev2 = process.env.NODE_ENV === "development";
|
|
4015
|
-
Object.values(cache9.index).forEach((
|
|
4016
|
-
if (!isDev2 &&
|
|
4017
|
-
|
|
4145
|
+
Object.values(cache9.index).forEach((pkg2) => {
|
|
4146
|
+
if (!isDev2 && pkg2.type !== "app") return;
|
|
4147
|
+
pkg2.allApps.forEach((dir) => this.watchDirs.add(dir));
|
|
4018
4148
|
});
|
|
4019
4149
|
setTimeout(() => {
|
|
4020
4150
|
this.startWatch();
|
|
@@ -4058,26 +4188,26 @@ var init_watcher = __esm({
|
|
|
4058
4188
|
const exts = isTsx() ? [".ts", ".js"] : [".js"];
|
|
4059
4189
|
if (!exts.includes(ext)) return;
|
|
4060
4190
|
const absPath2 = path11.resolve(file);
|
|
4061
|
-
const
|
|
4062
|
-
if (!
|
|
4191
|
+
const pkg2 = this.findPkgByFile(absPath2);
|
|
4192
|
+
if (!pkg2) return;
|
|
4063
4193
|
const relativePath = path11.relative(process.cwd(), file).replace(/\\/g, "/");
|
|
4064
|
-
logger.debug(`[hmr][${
|
|
4194
|
+
logger.debug(`[hmr][${pkg2.name}] \u6587\u4EF6${action}: ${relativePath}`);
|
|
4065
4195
|
if (action === "unlink") {
|
|
4066
4196
|
this.unloadPlugin(absPath2);
|
|
4067
|
-
logger.info(`[hmr][${
|
|
4197
|
+
logger.info(`[hmr][${pkg2.name}] \u5DF2\u5378\u8F7D: ${path11.basename(file)}`);
|
|
4068
4198
|
return;
|
|
4069
4199
|
}
|
|
4070
4200
|
if (action === "change") {
|
|
4071
4201
|
this.unloadPlugin(absPath2);
|
|
4072
4202
|
}
|
|
4073
4203
|
try {
|
|
4074
|
-
const result = await this.loader.importApp(
|
|
4075
|
-
this.loader.cachePlugin(result,
|
|
4204
|
+
const result = await this.loader.importApp(pkg2.name, absPath2, true);
|
|
4205
|
+
this.loader.cachePlugin(result, pkg2, absPath2);
|
|
4076
4206
|
this.loader.sort();
|
|
4077
4207
|
const actionText = action === "add" ? "\u65B0\u589E\u63D2\u4EF6" : "\u91CD\u8F7D\u5B8C\u6210";
|
|
4078
|
-
logger.info(`[hmr][${
|
|
4208
|
+
logger.info(`[hmr][${pkg2.name}] ${actionText}: ${path11.basename(file)}`);
|
|
4079
4209
|
} catch (error) {
|
|
4080
|
-
logger.error(`[hmr][${
|
|
4210
|
+
logger.error(`[hmr][${pkg2.name}] \u52A0\u8F7D\u5931\u8D25:`, error);
|
|
4081
4211
|
}
|
|
4082
4212
|
}
|
|
4083
4213
|
/**
|
|
@@ -4085,7 +4215,7 @@ var init_watcher = __esm({
|
|
|
4085
4215
|
*/
|
|
4086
4216
|
findPkgByFile(file) {
|
|
4087
4217
|
return Object.values(cache9.index).find(
|
|
4088
|
-
(
|
|
4218
|
+
(pkg2) => pkg2.apps.includes(file) || pkg2.allApps.some((dir) => file.startsWith(dir))
|
|
4089
4219
|
);
|
|
4090
4220
|
}
|
|
4091
4221
|
/**
|
|
@@ -4148,41 +4278,41 @@ var init_loader = __esm({
|
|
|
4148
4278
|
logger.info("\u52A0\u8F7D\u63D2\u4EF6\u4E2D...");
|
|
4149
4279
|
const allPromises = [];
|
|
4150
4280
|
const entryPromises = [];
|
|
4151
|
-
const
|
|
4152
|
-
debug("debug: getPlugins",
|
|
4153
|
-
await Promise.all(
|
|
4281
|
+
const list3 = await getPlugins("all", true);
|
|
4282
|
+
debug("debug: getPlugins", list3);
|
|
4283
|
+
await Promise.all(list3.map(async (pkg2) => {
|
|
4154
4284
|
var _a, _b, _c, _d, _e, _f;
|
|
4155
|
-
|
|
4156
|
-
cache9.index[
|
|
4285
|
+
pkg2.id = ++seq;
|
|
4286
|
+
cache9.index[pkg2.id] = pkg2;
|
|
4157
4287
|
const files = [];
|
|
4158
|
-
if (
|
|
4288
|
+
if (pkg2.type === "app") {
|
|
4159
4289
|
files.push("config", "data", "resources");
|
|
4160
|
-
} else if (Array.isArray((_a =
|
|
4161
|
-
files.push(...
|
|
4290
|
+
} else if (Array.isArray((_a = pkg2.pkgData.karin) == null ? void 0 : _a.files)) {
|
|
4291
|
+
files.push(...pkg2.pkgData.karin.files);
|
|
4162
4292
|
}
|
|
4163
|
-
await createPluginDir(
|
|
4164
|
-
debug("debug: createPluginDir",
|
|
4165
|
-
|
|
4166
|
-
const promise = this.importApp(
|
|
4293
|
+
await createPluginDir(pkg2.name, files);
|
|
4294
|
+
debug("debug: createPluginDir", pkg2.name, files);
|
|
4295
|
+
pkg2.apps.forEach((app2) => {
|
|
4296
|
+
const promise = this.importApp(pkg2.name, app2).then((result) => this.cachePlugin(result, pkg2, app2));
|
|
4167
4297
|
allPromises.push(promise);
|
|
4168
4298
|
});
|
|
4169
|
-
if (
|
|
4170
|
-
if (isTsx() && ((_c = (_b =
|
|
4171
|
-
const file = path12.join(
|
|
4299
|
+
if (pkg2.type !== "app") {
|
|
4300
|
+
if (isTsx() && ((_c = (_b = pkg2 == null ? void 0 : pkg2.pkgData) == null ? void 0 : _b.karin) == null ? void 0 : _c.main)) {
|
|
4301
|
+
const file = path12.join(pkg2.dir, pkg2.pkgData.karin.main);
|
|
4172
4302
|
if (fs14.existsSync(file)) {
|
|
4173
|
-
entryPromises.push(this.loaderMain(
|
|
4303
|
+
entryPromises.push(this.loaderMain(pkg2.name, file));
|
|
4174
4304
|
}
|
|
4175
4305
|
}
|
|
4176
|
-
if ((_d =
|
|
4177
|
-
const file = path12.join(
|
|
4306
|
+
if ((_d = pkg2 == null ? void 0 : pkg2.pkgData) == null ? void 0 : _d.main) {
|
|
4307
|
+
const file = path12.join(pkg2.dir, pkg2.pkgData.main);
|
|
4178
4308
|
if (fs14.existsSync(file)) {
|
|
4179
|
-
entryPromises.push(this.loaderMain(
|
|
4309
|
+
entryPromises.push(this.loaderMain(pkg2.name, file));
|
|
4180
4310
|
}
|
|
4181
4311
|
}
|
|
4182
4312
|
}
|
|
4183
|
-
if (
|
|
4184
|
-
const
|
|
4185
|
-
cache9.static.push(...
|
|
4313
|
+
if (pkg2.type !== "app" && ((_f = (_e = pkg2 == null ? void 0 : pkg2.pkgData) == null ? void 0 : _e.karin) == null ? void 0 : _f.static)) {
|
|
4314
|
+
const list4 = Array.isArray(pkg2.pkgData.karin.static) ? pkg2.pkgData.karin.static : [pkg2.pkgData.karin.static];
|
|
4315
|
+
cache9.static.push(...list4.map((file) => path12.resolve(pkg2.dir, file)));
|
|
4186
4316
|
}
|
|
4187
4317
|
}));
|
|
4188
4318
|
await Promise.all([...allPromises, ...entryPromises]);
|
|
@@ -4274,19 +4404,19 @@ var init_loader = __esm({
|
|
|
4274
4404
|
* @param result 插件导入结果
|
|
4275
4405
|
* @param info 插件信息
|
|
4276
4406
|
*/
|
|
4277
|
-
cachePlugin(result,
|
|
4407
|
+
cachePlugin(result, pkg2, app2) {
|
|
4278
4408
|
for (const key of Object.keys(result)) {
|
|
4279
4409
|
if (key === "default") continue;
|
|
4280
4410
|
if (typeof result[key] === "function") {
|
|
4281
4411
|
if (!isClass(result[key])) return;
|
|
4282
|
-
this.cacheClassPlugin(result[key],
|
|
4412
|
+
this.cacheClassPlugin(result[key], pkg2, app2, key);
|
|
4283
4413
|
return;
|
|
4284
4414
|
}
|
|
4285
4415
|
const data = result[key];
|
|
4286
4416
|
for (const val of Array.isArray(data) ? data : [data]) {
|
|
4287
4417
|
if (typeof val !== "object") continue;
|
|
4288
4418
|
if (!(val == null ? void 0 : val.pkg) || !val.file) continue;
|
|
4289
|
-
val.pkg =
|
|
4419
|
+
val.pkg = pkg2;
|
|
4290
4420
|
val.file = this.createFile(app2, val.file.type, key, val.file.name);
|
|
4291
4421
|
if (this.isType(val, "accept")) {
|
|
4292
4422
|
cache9.count.accept++;
|
|
@@ -4337,7 +4467,7 @@ var init_loader = __esm({
|
|
|
4337
4467
|
* @param app app文件绝对路径
|
|
4338
4468
|
* @param key 插件方法名称
|
|
4339
4469
|
*/
|
|
4340
|
-
cacheClassPlugin(Method,
|
|
4470
|
+
cacheClassPlugin(Method, pkg2, app2, key) {
|
|
4341
4471
|
var _a;
|
|
4342
4472
|
const command2 = new Method();
|
|
4343
4473
|
if (!command2.name) {
|
|
@@ -4352,7 +4482,7 @@ var init_loader = __esm({
|
|
|
4352
4482
|
if (!(v.fnc in command2)) return;
|
|
4353
4483
|
if (typeof v.reg !== "string" && !(v.reg instanceof RegExp)) return;
|
|
4354
4484
|
cache9.command.push({
|
|
4355
|
-
pkg:
|
|
4485
|
+
pkg: pkg2,
|
|
4356
4486
|
type: "class",
|
|
4357
4487
|
log: createLogger2(v.log, true),
|
|
4358
4488
|
adapter: v.adapter || [],
|
|
@@ -4384,6 +4514,7 @@ var init_loader = __esm({
|
|
|
4384
4514
|
});
|
|
4385
4515
|
|
|
4386
4516
|
// src/server/api/router.ts
|
|
4517
|
+
import express from "express";
|
|
4387
4518
|
import { Router } from "express";
|
|
4388
4519
|
var router;
|
|
4389
4520
|
var init_router = __esm({
|
|
@@ -4391,11 +4522,12 @@ var init_router = __esm({
|
|
|
4391
4522
|
"use strict";
|
|
4392
4523
|
init_esm_shims();
|
|
4393
4524
|
router = Router();
|
|
4525
|
+
router.use(express.json());
|
|
4394
4526
|
}
|
|
4395
4527
|
});
|
|
4396
4528
|
|
|
4397
4529
|
// src/server/utils/response.ts
|
|
4398
|
-
var createResponse, createSuccessResponse, createNotFoundResponse, createServerErrorResponse, createBadRequestResponse, createPayloadTooLargeResponse, createForbiddenResponse;
|
|
4530
|
+
var createResponse, createSuccessResponse, createUnauthorizedResponse, createNotFoundResponse, createServerErrorResponse, createBadRequestResponse, createPayloadTooLargeResponse, createForbiddenResponse;
|
|
4399
4531
|
var init_response = __esm({
|
|
4400
4532
|
"src/server/utils/response.ts"() {
|
|
4401
4533
|
"use strict";
|
|
@@ -4410,6 +4542,9 @@ var init_response = __esm({
|
|
|
4410
4542
|
createSuccessResponse = (res, data, message = "\u6210\u529F") => {
|
|
4411
4543
|
return createResponse(res, 200 /* OK */, data, message);
|
|
4412
4544
|
};
|
|
4545
|
+
createUnauthorizedResponse = (res, message = "\u672A\u767B\u5F55") => {
|
|
4546
|
+
return createResponse(res, 401 /* Unauthorized */, null, message);
|
|
4547
|
+
};
|
|
4413
4548
|
createNotFoundResponse = (res, message = "\u672A\u627E\u5230") => {
|
|
4414
4549
|
return createResponse(res, 404 /* NotFound */, null, message);
|
|
4415
4550
|
};
|
|
@@ -4428,32 +4563,29 @@ var init_response = __esm({
|
|
|
4428
4563
|
}
|
|
4429
4564
|
});
|
|
4430
4565
|
|
|
4431
|
-
// src/server/api/
|
|
4432
|
-
var
|
|
4433
|
-
var
|
|
4434
|
-
"src/server/api/
|
|
4566
|
+
// src/server/api/info.ts
|
|
4567
|
+
var wsOneBotSet, wsPuppeteerSet, pingRouter, statusRouter, infoRouter, systemStatusRealTimeHandler;
|
|
4568
|
+
var init_info = __esm({
|
|
4569
|
+
"src/server/api/info.ts"() {
|
|
4435
4570
|
"use strict";
|
|
4436
4571
|
init_esm_shims();
|
|
4437
4572
|
init_router();
|
|
4573
|
+
init_internal();
|
|
4438
4574
|
init_response();
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
"use strict";
|
|
4454
|
-
init_esm_shims();
|
|
4455
|
-
init_response();
|
|
4456
|
-
init_router();
|
|
4575
|
+
wsOneBotSet = /* @__PURE__ */ new Set();
|
|
4576
|
+
wsPuppeteerSet = /* @__PURE__ */ new Set();
|
|
4577
|
+
listeners.on("ws:connection:onebot", (socket) => {
|
|
4578
|
+
wsOneBotSet.add(socket);
|
|
4579
|
+
});
|
|
4580
|
+
listeners.on("ws:connection:puppeteer", (socket) => {
|
|
4581
|
+
wsPuppeteerSet.add(socket);
|
|
4582
|
+
});
|
|
4583
|
+
listeners.on("ws:close:onebot", (socket) => {
|
|
4584
|
+
wsOneBotSet.delete(socket);
|
|
4585
|
+
});
|
|
4586
|
+
listeners.on("ws:close:puppeteer", (socket) => {
|
|
4587
|
+
wsPuppeteerSet.delete(socket);
|
|
4588
|
+
});
|
|
4457
4589
|
pingRouter = (_req, res) => {
|
|
4458
4590
|
createSuccessResponse(
|
|
4459
4591
|
res,
|
|
@@ -4476,8 +4608,55 @@ var init_ping = __esm({
|
|
|
4476
4608
|
};
|
|
4477
4609
|
createSuccessResponse(res, data, "\u6210\u529F");
|
|
4478
4610
|
};
|
|
4611
|
+
infoRouter = async (_req, res) => {
|
|
4612
|
+
const wsOneBotInfo = Array.from(wsOneBotSet).map((ws) => {
|
|
4613
|
+
return {
|
|
4614
|
+
// 获取连接ws的信息
|
|
4615
|
+
readyState: ws.readyState,
|
|
4616
|
+
// 获取连接ws的信息
|
|
4617
|
+
url: ws.url,
|
|
4618
|
+
// 获取连接ws的信息
|
|
4619
|
+
protocol: ws.protocol
|
|
4620
|
+
};
|
|
4621
|
+
});
|
|
4622
|
+
const wsPuppeteerInfo = Array.from(wsPuppeteerSet).map((ws) => {
|
|
4623
|
+
return {
|
|
4624
|
+
// 获取连接ws的信息
|
|
4625
|
+
readyState: ws.readyState,
|
|
4626
|
+
// 获取连接ws的信息
|
|
4627
|
+
url: ws.url,
|
|
4628
|
+
// 获取连接ws的信息
|
|
4629
|
+
protocol: ws.protocol
|
|
4630
|
+
};
|
|
4631
|
+
});
|
|
4632
|
+
const wsInfo = {
|
|
4633
|
+
onebot: wsOneBotInfo,
|
|
4634
|
+
puppeteer: wsPuppeteerInfo
|
|
4635
|
+
};
|
|
4636
|
+
createSuccessResponse(res, wsInfo);
|
|
4637
|
+
};
|
|
4638
|
+
systemStatusRealTimeHandler = async (req, res) => {
|
|
4639
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
4640
|
+
res.setHeader("Connection", "keep-alive");
|
|
4641
|
+
const sendStatus = (status) => {
|
|
4642
|
+
try {
|
|
4643
|
+
res.write(`data: ${JSON.stringify(status)}
|
|
4644
|
+
|
|
4645
|
+
`);
|
|
4646
|
+
} catch (e) {
|
|
4647
|
+
console.error(`An error occurred when writing sendStatus data to client: ${e}`);
|
|
4648
|
+
}
|
|
4649
|
+
};
|
|
4650
|
+
statusListener.on("statusUpdate", sendStatus);
|
|
4651
|
+
req.on("close", () => {
|
|
4652
|
+
statusListener.off("statusUpdate", sendStatus);
|
|
4653
|
+
res.end();
|
|
4654
|
+
});
|
|
4655
|
+
};
|
|
4656
|
+
router.get("/status/ws", infoRouter);
|
|
4479
4657
|
router.get("/ping", pingRouter);
|
|
4480
|
-
router.get("/status", statusRouter);
|
|
4658
|
+
router.get("/status/karin", statusRouter);
|
|
4659
|
+
router.get("/status/system", systemStatusRealTimeHandler);
|
|
4481
4660
|
}
|
|
4482
4661
|
});
|
|
4483
4662
|
|
|
@@ -4523,14 +4702,24 @@ var init_middleware = __esm({
|
|
|
4523
4702
|
"use strict";
|
|
4524
4703
|
init_esm_shims();
|
|
4525
4704
|
await init_auth();
|
|
4705
|
+
init_response();
|
|
4526
4706
|
authMiddleware = async (req, res, next) => {
|
|
4707
|
+
logger.debug(
|
|
4708
|
+
`[express] \u6536\u5230\u8BF7\u6C42:
|
|
4709
|
+
method: ${req.method}
|
|
4710
|
+
ip: ${req.ip}
|
|
4711
|
+
path: ${req.path}
|
|
4712
|
+
headers: ${JSON.stringify(req.headers)}
|
|
4713
|
+
body: ${JSON.stringify(req.body)}
|
|
4714
|
+
`
|
|
4715
|
+
);
|
|
4527
4716
|
if (req.path.startsWith("/api")) {
|
|
4528
4717
|
if (req.path === "/api/v1/ping" || req.path.startsWith("/api/v1/console")) {
|
|
4529
4718
|
next();
|
|
4530
4719
|
return;
|
|
4531
4720
|
}
|
|
4532
4721
|
if (!auth.getAuth(req)) {
|
|
4533
|
-
res
|
|
4722
|
+
createUnauthorizedResponse(res, "\u9519\u8BEF\u7684token");
|
|
4534
4723
|
return;
|
|
4535
4724
|
}
|
|
4536
4725
|
}
|
|
@@ -4541,9 +4730,9 @@ var init_middleware = __esm({
|
|
|
4541
4730
|
|
|
4542
4731
|
// src/server/app.ts
|
|
4543
4732
|
import path13 from "node:path";
|
|
4544
|
-
import
|
|
4733
|
+
import express2 from "express";
|
|
4545
4734
|
import { createServer } from "node:http";
|
|
4546
|
-
var app, server, listen;
|
|
4735
|
+
var app, server, listen, web;
|
|
4547
4736
|
var init_app = __esm({
|
|
4548
4737
|
async "src/server/app.ts"() {
|
|
4549
4738
|
"use strict";
|
|
@@ -4551,21 +4740,34 @@ var init_app = __esm({
|
|
|
4551
4740
|
init_router();
|
|
4552
4741
|
init_internal();
|
|
4553
4742
|
await init_middleware();
|
|
4554
|
-
app =
|
|
4743
|
+
app = express2();
|
|
4555
4744
|
server = createServer(app);
|
|
4556
|
-
app.use(authMiddleware);
|
|
4557
|
-
app.use("/web", express.static(path13.join(process.cwd(), "web")));
|
|
4558
|
-
app.use("/web/*", express.static(path13.join(process.cwd(), "web")));
|
|
4559
|
-
app.use("/api/v1", router);
|
|
4560
4745
|
listen = (port2, host2) => {
|
|
4561
4746
|
server.listen(port2, host2, () => {
|
|
4562
4747
|
logger.info(`[server] express \u5DF2\u542F\u52A8 \u6B63\u5728\u76D1\u542C: http://${host2}:${port2}`);
|
|
4563
4748
|
});
|
|
4564
4749
|
listeners.once("online", () => {
|
|
4750
|
+
logger.info(`[server] webui \u5DF2\u542F\u52A8 \u6B63\u5728\u76D1\u542C: http://${host2}:${port2}/web`);
|
|
4565
4751
|
console.log(`[server] http\u9274\u6743token: ${logger.green(process.env.HTTP_AUTH_KEY)}`);
|
|
4566
4752
|
console.log(`[server] ws\u9274\u6743token: ${logger.green(process.env.WS_SERVER_AUTH_KEY)}`);
|
|
4567
4753
|
});
|
|
4568
4754
|
};
|
|
4755
|
+
web = () => {
|
|
4756
|
+
const webDir = path13.join(process.cwd(), "dist/web");
|
|
4757
|
+
const staticFiles = express2.static(webDir);
|
|
4758
|
+
app.use("/web", staticFiles);
|
|
4759
|
+
app.get("/web/*", (req, res) => {
|
|
4760
|
+
res.sendFile(path13.join(webDir, "index.html"));
|
|
4761
|
+
});
|
|
4762
|
+
listeners.once("online", () => {
|
|
4763
|
+
app.get("/", (req, res) => {
|
|
4764
|
+
res.redirect("/web");
|
|
4765
|
+
});
|
|
4766
|
+
});
|
|
4767
|
+
};
|
|
4768
|
+
app.use(authMiddleware);
|
|
4769
|
+
app.use("/api/v1", router);
|
|
4770
|
+
web();
|
|
4569
4771
|
}
|
|
4570
4772
|
});
|
|
4571
4773
|
|
|
@@ -4612,20 +4814,20 @@ var init_ip = __esm({
|
|
|
4612
4814
|
return false;
|
|
4613
4815
|
};
|
|
4614
4816
|
getRequestIp = (req) => {
|
|
4615
|
-
const
|
|
4817
|
+
const list3 = [];
|
|
4616
4818
|
const xForwardedFor = req.headers["x-forwarded-for"];
|
|
4617
4819
|
if (Array.isArray(xForwardedFor)) {
|
|
4618
|
-
|
|
4820
|
+
list3.push(...xForwardedFor);
|
|
4619
4821
|
} else if (typeof xForwardedFor === "string") {
|
|
4620
|
-
|
|
4822
|
+
list3.push(xForwardedFor);
|
|
4621
4823
|
}
|
|
4622
4824
|
const remoteAddress = req.socket.remoteAddress;
|
|
4623
4825
|
const ip = req.ip;
|
|
4624
4826
|
const hostname = req.hostname;
|
|
4625
|
-
if (ip)
|
|
4626
|
-
if (hostname)
|
|
4627
|
-
if (remoteAddress)
|
|
4628
|
-
return
|
|
4827
|
+
if (ip) list3.push(ip);
|
|
4828
|
+
if (hostname) list3.push(hostname);
|
|
4829
|
+
if (remoteAddress) list3.push(remoteAddress);
|
|
4830
|
+
return list3.filter(Boolean);
|
|
4629
4831
|
};
|
|
4630
4832
|
isLocalRequest = async (req) => {
|
|
4631
4833
|
const ips = getRequestIp(req);
|
|
@@ -4769,10 +4971,10 @@ var init_restart = __esm({
|
|
|
4769
4971
|
}
|
|
4770
4972
|
});
|
|
4771
4973
|
|
|
4772
|
-
// src/server/api/
|
|
4773
|
-
var restartRouter;
|
|
4774
|
-
var
|
|
4775
|
-
"src/server/api/
|
|
4974
|
+
// src/server/api/manage.ts
|
|
4975
|
+
var restartRouter, exitRouter;
|
|
4976
|
+
var init_manage = __esm({
|
|
4977
|
+
"src/server/api/manage.ts"() {
|
|
4776
4978
|
"use strict";
|
|
4777
4979
|
init_esm_shims();
|
|
4778
4980
|
init_router();
|
|
@@ -4782,20 +4984,816 @@ var init_restart2 = __esm({
|
|
|
4782
4984
|
createSuccessResponse(res, null, "\u6307\u4EE4\u53D1\u9001\u6210\u529F");
|
|
4783
4985
|
restartDirect();
|
|
4784
4986
|
};
|
|
4785
|
-
|
|
4987
|
+
exitRouter = async (_req, res) => {
|
|
4988
|
+
logger.mark("\u6536\u5230\u9000\u51FA\u8BF7\u6C42\uFF0C\u6B63\u5728\u9000\u51FA...");
|
|
4989
|
+
createSuccessResponse(res, null, "\u9000\u51FA\u6210\u529F");
|
|
4990
|
+
const { processExit: processExit2 } = await Promise.resolve().then(() => (init_process(), process_exports));
|
|
4991
|
+
await processExit2(0);
|
|
4992
|
+
};
|
|
4993
|
+
router.post("/exit", exitRouter);
|
|
4994
|
+
router.post("/restart", restartRouter);
|
|
4786
4995
|
}
|
|
4787
4996
|
});
|
|
4788
4997
|
|
|
4789
|
-
// src/server/
|
|
4790
|
-
var
|
|
4998
|
+
// src/server/utils/file.ts
|
|
4999
|
+
var getConfig, getAdapter, getGroups, getPrivates, getRender, getRedis, getPM2, getEnv, getFileList;
|
|
4791
5000
|
var init_file2 = __esm({
|
|
5001
|
+
async "src/server/utils/file.ts"() {
|
|
5002
|
+
"use strict";
|
|
5003
|
+
init_esm_shims();
|
|
5004
|
+
await init_config2();
|
|
5005
|
+
getConfig = () => {
|
|
5006
|
+
const cfg = config();
|
|
5007
|
+
return {
|
|
5008
|
+
name: "config",
|
|
5009
|
+
title: "\u57FA\u672C\u914D\u7F6E",
|
|
5010
|
+
description: "Bot\u57FA\u672C\u914D\u7F6E\u9009\u9879",
|
|
5011
|
+
type: "json",
|
|
5012
|
+
fields: [
|
|
5013
|
+
{
|
|
5014
|
+
key: "master",
|
|
5015
|
+
type: "string[]",
|
|
5016
|
+
title: "\u4E3B\u4EBA\u5217\u8868",
|
|
5017
|
+
description: "Bot\u7684\u4E3B\u4EBA\u5217\u8868",
|
|
5018
|
+
content: cfg.master
|
|
5019
|
+
},
|
|
5020
|
+
{
|
|
5021
|
+
key: "admin",
|
|
5022
|
+
type: "string[]",
|
|
5023
|
+
title: "\u7BA1\u7406\u5458\u5217\u8868",
|
|
5024
|
+
description: "Bot\u7684\u7BA1\u7406\u5458\u5217\u8868",
|
|
5025
|
+
content: cfg.admin
|
|
5026
|
+
},
|
|
5027
|
+
{
|
|
5028
|
+
key: "user.enable_list",
|
|
5029
|
+
type: "string[]",
|
|
5030
|
+
title: "\u7528\u6237\u767D\u540D\u5355",
|
|
5031
|
+
description: "\u5141\u8BB8\u4F7F\u7528Bot\u7684\u7528\u6237\u5217\u8868",
|
|
5032
|
+
content: cfg.user.enable_list
|
|
5033
|
+
},
|
|
5034
|
+
{
|
|
5035
|
+
key: "user.disable_list",
|
|
5036
|
+
type: "string[]",
|
|
5037
|
+
title: "\u7528\u6237\u9ED1\u540D\u5355",
|
|
5038
|
+
description: "\u7981\u6B62\u4F7F\u7528Bot\u7684\u7528\u6237\u5217\u8868",
|
|
5039
|
+
content: cfg.user.disable_list
|
|
5040
|
+
},
|
|
5041
|
+
{
|
|
5042
|
+
key: "friend.enable",
|
|
5043
|
+
type: "boolean",
|
|
5044
|
+
title: "\u542F\u7528\u597D\u53CB\u6D88\u606F",
|
|
5045
|
+
description: "\u662F\u5426\u542F\u7528\u597D\u53CB\u6D88\u606F\u4E8B\u4EF6",
|
|
5046
|
+
content: cfg.friend.enable
|
|
5047
|
+
},
|
|
5048
|
+
{
|
|
5049
|
+
key: "friend.enable_list",
|
|
5050
|
+
type: "string[]",
|
|
5051
|
+
title: "\u597D\u53CB\u767D\u540D\u5355",
|
|
5052
|
+
description: "\u5141\u8BB8\u4EA4\u4E92\u7684\u597D\u53CB\u5217\u8868",
|
|
5053
|
+
content: cfg.friend.enable_list
|
|
5054
|
+
},
|
|
5055
|
+
{
|
|
5056
|
+
key: "friend.disable_list",
|
|
5057
|
+
type: "string[]",
|
|
5058
|
+
title: "\u597D\u53CB\u9ED1\u540D\u5355",
|
|
5059
|
+
description: "\u7981\u6B62\u4EA4\u4E92\u7684\u597D\u53CB\u5217\u8868",
|
|
5060
|
+
content: cfg.friend.disable_list
|
|
5061
|
+
},
|
|
5062
|
+
{
|
|
5063
|
+
key: "friend.log_enable_list",
|
|
5064
|
+
type: "string[]",
|
|
5065
|
+
title: "\u597D\u53CB\u65E5\u5FD7\u767D\u540D\u5355",
|
|
5066
|
+
description: "\u5141\u8BB8\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u597D\u53CB\u6D88\u606F",
|
|
5067
|
+
content: cfg.friend.log_enable_list
|
|
5068
|
+
},
|
|
5069
|
+
{
|
|
5070
|
+
key: "friend.log_disable_list",
|
|
5071
|
+
type: "string[]",
|
|
5072
|
+
title: "\u597D\u53CB\u65E5\u5FD7\u9ED1\u540D\u5355",
|
|
5073
|
+
description: "\u4E0D\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u597D\u53CB\u6D88\u606F",
|
|
5074
|
+
content: cfg.friend.log_disable_list
|
|
5075
|
+
},
|
|
5076
|
+
{
|
|
5077
|
+
key: "group.enable",
|
|
5078
|
+
type: "boolean",
|
|
5079
|
+
title: "\u542F\u7528\u7FA4\u6D88\u606F",
|
|
5080
|
+
description: "\u662F\u5426\u542F\u7528\u7FA4\u6D88\u606F\u4E8B\u4EF6",
|
|
5081
|
+
content: cfg.group.enable
|
|
5082
|
+
},
|
|
5083
|
+
{
|
|
5084
|
+
key: "group.enable_list",
|
|
5085
|
+
type: "string[]",
|
|
5086
|
+
title: "\u7FA4\u767D\u540D\u5355",
|
|
5087
|
+
description: "\u5141\u8BB8\u4EA4\u4E92\u7684\u7FA4\u5217\u8868",
|
|
5088
|
+
content: cfg.group.enable_list
|
|
5089
|
+
},
|
|
5090
|
+
{
|
|
5091
|
+
key: "group.disable_list",
|
|
5092
|
+
type: "string[]",
|
|
5093
|
+
title: "\u7FA4\u9ED1\u540D\u5355",
|
|
5094
|
+
description: "\u7981\u6B62\u4EA4\u4E92\u7684\u7FA4\u5217\u8868",
|
|
5095
|
+
content: cfg.group.disable_list
|
|
5096
|
+
},
|
|
5097
|
+
{
|
|
5098
|
+
key: "group.log_enable_list",
|
|
5099
|
+
type: "string[]",
|
|
5100
|
+
title: "\u7FA4\u65E5\u5FD7\u767D\u540D\u5355",
|
|
5101
|
+
description: "\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u7FA4\u6D88\u606F",
|
|
5102
|
+
content: cfg.group.log_enable_list
|
|
5103
|
+
},
|
|
5104
|
+
{
|
|
5105
|
+
key: "group.log_disable_list",
|
|
5106
|
+
type: "string[]",
|
|
5107
|
+
title: "\u7FA4\u65E5\u5FD7\u9ED1\u540D\u5355",
|
|
5108
|
+
description: "\u4E0D\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u7FA4\u6D88\u606F",
|
|
5109
|
+
content: cfg.group.log_disable_list
|
|
5110
|
+
},
|
|
5111
|
+
{
|
|
5112
|
+
key: "directs.enable",
|
|
5113
|
+
type: "boolean",
|
|
5114
|
+
title: "\u542F\u7528\u79C1\u4FE1\u6D88\u606F",
|
|
5115
|
+
description: "\u662F\u5426\u542F\u7528\u79C1\u4FE1\u6D88\u606F\u4E8B\u4EF6",
|
|
5116
|
+
content: cfg.directs.enable
|
|
5117
|
+
},
|
|
5118
|
+
{
|
|
5119
|
+
key: "directs.enable_list",
|
|
5120
|
+
type: "string[]",
|
|
5121
|
+
title: "\u79C1\u4FE1\u767D\u540D\u5355",
|
|
5122
|
+
description: "\u5141\u8BB8\u79C1\u4FE1\u4EA4\u4E92\u7684\u7528\u6237\u5217\u8868",
|
|
5123
|
+
content: cfg.directs.enable_list
|
|
5124
|
+
},
|
|
5125
|
+
{
|
|
5126
|
+
key: "directs.disable_list",
|
|
5127
|
+
type: "string[]",
|
|
5128
|
+
title: "\u9891\u9053\u79C1\u4FE1\u9ED1\u540D\u5355",
|
|
5129
|
+
description: "\u7981\u6B62\u4F7F\u7528\u79C1\u4FE1\u4EA4\u4E92\u7684\u7528\u6237\u5217\u8868",
|
|
5130
|
+
content: cfg.directs.disable_list
|
|
5131
|
+
},
|
|
5132
|
+
{
|
|
5133
|
+
key: "directs.log_enable_list",
|
|
5134
|
+
type: "string[]",
|
|
5135
|
+
title: "\u9891\u9053\u79C1\u4FE1\u65E5\u5FD7\u767D\u540D\u5355",
|
|
5136
|
+
description: "\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u9891\u9053\u79C1\u4FE1\u6D88\u606F",
|
|
5137
|
+
content: cfg.directs.log_enable_list
|
|
5138
|
+
},
|
|
5139
|
+
{
|
|
5140
|
+
key: "directs.log_disable_list",
|
|
5141
|
+
type: "string[]",
|
|
5142
|
+
title: "\u9891\u9053\u79C1\u4FE1\u65E5\u5FD7\u9ED1\u540D\u5355",
|
|
5143
|
+
description: "\u4E0D\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u9891\u9053\u79C1\u4FE1\u6D88\u606F",
|
|
5144
|
+
content: cfg.directs.log_disable_list
|
|
5145
|
+
},
|
|
5146
|
+
{
|
|
5147
|
+
key: "guilds.enable",
|
|
5148
|
+
type: "boolean",
|
|
5149
|
+
title: "\u542F\u7528\u9891\u9053\u6D88\u606F",
|
|
5150
|
+
description: "\u662F\u5426\u542F\u7528\u9891\u9053\u6D88\u606F\u4E8B\u4EF6",
|
|
5151
|
+
content: cfg.guilds.enable
|
|
5152
|
+
},
|
|
5153
|
+
{
|
|
5154
|
+
key: "guilds.enable_list",
|
|
5155
|
+
type: "string[]",
|
|
5156
|
+
title: "\u9891\u9053\u767D\u540D\u5355",
|
|
5157
|
+
description: "\u5141\u8BB8\u4EA4\u4E92\u7684\u9891\u9053\u5217\u8868",
|
|
5158
|
+
content: cfg.guilds.enable_list
|
|
5159
|
+
},
|
|
5160
|
+
{
|
|
5161
|
+
key: "guilds.disable_list",
|
|
5162
|
+
type: "string[]",
|
|
5163
|
+
title: "\u9891\u9053\u9ED1\u540D\u5355",
|
|
5164
|
+
description: "\u7981\u6B62\u4EA4\u4E92\u7684\u9891\u9053\u5217\u8868",
|
|
5165
|
+
content: cfg.guilds.disable_list
|
|
5166
|
+
},
|
|
5167
|
+
{
|
|
5168
|
+
key: "guilds.log_enable_list",
|
|
5169
|
+
type: "string[]",
|
|
5170
|
+
title: "\u9891\u9053\u65E5\u5FD7\u767D\u540D\u5355",
|
|
5171
|
+
description: "\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u9891\u9053\u6D88\u606F",
|
|
5172
|
+
content: cfg.guilds.log_enable_list
|
|
5173
|
+
},
|
|
5174
|
+
{
|
|
5175
|
+
key: "guilds.log_disable_list",
|
|
5176
|
+
type: "string[]",
|
|
5177
|
+
title: "\u9891\u9053\u65E5\u5FD7\u9ED1\u540D\u5355",
|
|
5178
|
+
description: "\u4E0D\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u9891\u9053\u6D88\u606F",
|
|
5179
|
+
content: cfg.guilds.log_disable_list
|
|
5180
|
+
},
|
|
5181
|
+
{
|
|
5182
|
+
key: "channels.enable",
|
|
5183
|
+
type: "boolean",
|
|
5184
|
+
title: "\u542F\u7528\u5B50\u9891\u9053\u6D88\u606F",
|
|
5185
|
+
description: "\u662F\u5426\u542F\u7528\u5B50\u9891\u9053\u6D88\u606F\u4E8B\u4EF6",
|
|
5186
|
+
content: cfg.channels.enable
|
|
5187
|
+
},
|
|
5188
|
+
{
|
|
5189
|
+
key: "channels.enable_list",
|
|
5190
|
+
type: "string[]",
|
|
5191
|
+
title: "\u5B50\u9891\u9053\u6D88\u606F\u767D\u540D\u5355",
|
|
5192
|
+
description: "\u5141\u8BB8\u4EA4\u4E92\u7684\u5B50\u9891\u9053\u6D88\u606F\u5217\u8868",
|
|
5193
|
+
content: cfg.channels.enable_list
|
|
5194
|
+
},
|
|
5195
|
+
{
|
|
5196
|
+
key: "channels.disable_list",
|
|
5197
|
+
type: "string[]",
|
|
5198
|
+
title: "\u5B50\u9891\u9053\u6D88\u606F\u9ED1\u540D\u5355",
|
|
5199
|
+
description: "\u7981\u6B62\u4EA4\u4E92\u7684\u5B50\u9891\u9053\u6D88\u606F\u5217\u8868",
|
|
5200
|
+
content: cfg.channels.disable_list
|
|
5201
|
+
},
|
|
5202
|
+
{
|
|
5203
|
+
key: "channels.log_enable_list",
|
|
5204
|
+
type: "string[]",
|
|
5205
|
+
title: "\u5B50\u9891\u9053\u65E5\u5FD7\u767D\u540D\u5355",
|
|
5206
|
+
description: "\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u5B50\u9891\u9053\u6D88\u606F",
|
|
5207
|
+
content: cfg.channels.log_enable_list
|
|
5208
|
+
},
|
|
5209
|
+
{
|
|
5210
|
+
key: "channels.log_disable_list",
|
|
5211
|
+
type: "string[]",
|
|
5212
|
+
title: "\u5B50\u9891\u9053\u65E5\u5FD7\u9ED1\u540D\u5355",
|
|
5213
|
+
description: "\u4E0D\u6253\u5370\u5728\u63A7\u5236\u53F0\u7684\u5B50\u9891\u9053\u6D88\u606F",
|
|
5214
|
+
content: cfg.channels.log_disable_list
|
|
5215
|
+
}
|
|
5216
|
+
]
|
|
5217
|
+
};
|
|
5218
|
+
};
|
|
5219
|
+
getAdapter = () => {
|
|
5220
|
+
const adapterConfig = adapter();
|
|
5221
|
+
return {
|
|
5222
|
+
name: "adapter",
|
|
5223
|
+
title: "\u9002\u914D\u5668\u914D\u7F6E",
|
|
5224
|
+
description: "\u5404\u4E2A\u9002\u914D\u5668\u7684\u914D\u7F6E\u9009\u9879",
|
|
5225
|
+
type: "json",
|
|
5226
|
+
fields: [
|
|
5227
|
+
{
|
|
5228
|
+
key: "console.isLocal",
|
|
5229
|
+
type: "boolean",
|
|
5230
|
+
title: "\u672C\u5730\u8BBF\u95EE\u9650\u5236",
|
|
5231
|
+
description: "\u662F\u5426\u53EA\u5141\u8BB8\u672C\u5730\u8BBF\u95EE\u63A7\u5236\u53F0",
|
|
5232
|
+
content: adapterConfig.console.isLocal
|
|
5233
|
+
},
|
|
5234
|
+
{
|
|
5235
|
+
key: "console.token",
|
|
5236
|
+
type: "string",
|
|
5237
|
+
title: "\u63A7\u5236\u53F0\u4EE4\u724C",
|
|
5238
|
+
description: "\u975E\u672C\u5730\u8BBF\u95EE\u65F6\u7684\u9274\u6743\u4EE4\u724C",
|
|
5239
|
+
content: adapterConfig.console.token
|
|
5240
|
+
},
|
|
5241
|
+
{
|
|
5242
|
+
key: "console.host",
|
|
5243
|
+
type: "string",
|
|
5244
|
+
title: "\u8D44\u6E90\u5730\u5740",
|
|
5245
|
+
description: "\u63A7\u5236\u53F0\u6253\u5370\u7684\u8D44\u6E90\u5730\u5740",
|
|
5246
|
+
content: adapterConfig.console.host
|
|
5247
|
+
},
|
|
5248
|
+
{
|
|
5249
|
+
key: "onebot.ws_server.enable",
|
|
5250
|
+
type: "boolean",
|
|
5251
|
+
title: "\u542F\u7528\u53CD\u5411WS\u670D\u52A1\u5668",
|
|
5252
|
+
description: "\u662F\u5426\u542F\u7528OneBot\u53CD\u5411WebSocket\u670D\u52A1\u5668",
|
|
5253
|
+
content: adapterConfig.onebot.ws_server.enable
|
|
5254
|
+
},
|
|
5255
|
+
{
|
|
5256
|
+
key: "onebot.ws_server.timeout",
|
|
5257
|
+
type: "number",
|
|
5258
|
+
title: "\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4",
|
|
5259
|
+
description: "OneBot\u8BF7\u6C42\u7684\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09",
|
|
5260
|
+
content: adapterConfig.onebot.ws_server.timeout
|
|
5261
|
+
},
|
|
5262
|
+
{
|
|
5263
|
+
key: "onebot.ws_client",
|
|
5264
|
+
type: "array",
|
|
5265
|
+
title: "\u6B63\u5411WS\u5BA2\u6237\u7AEF\u914D\u7F6E",
|
|
5266
|
+
description: "OneBot\u6B63\u5411WebSocket\u5BA2\u6237\u7AEF\u914D\u7F6E\u5217\u8868",
|
|
5267
|
+
content: adapterConfig.onebot.ws_client.map((client, index4) => [
|
|
5268
|
+
{
|
|
5269
|
+
key: `onebot.ws_client.${index4}.enable`,
|
|
5270
|
+
type: "boolean",
|
|
5271
|
+
title: "\u542F\u7528\u72B6\u6001",
|
|
5272
|
+
description: "\u662F\u5426\u542F\u7528\u8BE5\u6B63\u5411WS\u8FDE\u63A5",
|
|
5273
|
+
content: client.enable
|
|
5274
|
+
},
|
|
5275
|
+
{
|
|
5276
|
+
key: `onebot.ws_client.${index4}.url`,
|
|
5277
|
+
type: "string",
|
|
5278
|
+
title: "WS\u5730\u5740",
|
|
5279
|
+
description: "\u6B63\u5411WebSocket\u8FDE\u63A5\u5730\u5740",
|
|
5280
|
+
content: client.url
|
|
5281
|
+
},
|
|
5282
|
+
{
|
|
5283
|
+
key: `onebot.ws_client.${index4}.token`,
|
|
5284
|
+
type: "string",
|
|
5285
|
+
title: "\u9274\u6743\u4EE4\u724C",
|
|
5286
|
+
description: "\u6B63\u5411WebSocket\u8FDE\u63A5\u7684\u9274\u6743\u4EE4\u724C",
|
|
5287
|
+
content: client.token
|
|
5288
|
+
}
|
|
5289
|
+
])
|
|
5290
|
+
},
|
|
5291
|
+
{
|
|
5292
|
+
key: "onebot.http_server",
|
|
5293
|
+
type: "array",
|
|
5294
|
+
title: "HTTP\u670D\u52A1\u5668\u914D\u7F6E",
|
|
5295
|
+
description: "OneBot HTTP\u670D\u52A1\u5668\u914D\u7F6E\u5217\u8868",
|
|
5296
|
+
content: adapterConfig.onebot.http_server.map((server2, index4) => [
|
|
5297
|
+
{
|
|
5298
|
+
key: `onebot.http_server.${index4}.enable`,
|
|
5299
|
+
type: "boolean",
|
|
5300
|
+
title: "\u542F\u7528\u72B6\u6001",
|
|
5301
|
+
description: "\u662F\u5426\u542F\u7528\u8BE5HTTP\u670D\u52A1",
|
|
5302
|
+
content: server2.enable
|
|
5303
|
+
},
|
|
5304
|
+
{
|
|
5305
|
+
key: `onebot.http_server.${index4}.self_id`,
|
|
5306
|
+
type: "string",
|
|
5307
|
+
title: "QQ\u53F7",
|
|
5308
|
+
description: "\u6B63\u5411HTTP\u670D\u52A1\u7684QQ\u53F7",
|
|
5309
|
+
content: server2.self_id
|
|
5310
|
+
},
|
|
5311
|
+
{
|
|
5312
|
+
key: `onebot.http_server.${index4}.url`,
|
|
5313
|
+
type: "string",
|
|
5314
|
+
title: "\u670D\u52A1\u5730\u5740",
|
|
5315
|
+
description: "HTTP\u670D\u52A1\u7684\u5730\u5740",
|
|
5316
|
+
content: server2.url
|
|
5317
|
+
},
|
|
5318
|
+
{
|
|
5319
|
+
key: `onebot.http_server.${index4}.token`,
|
|
5320
|
+
type: "string",
|
|
5321
|
+
title: "\u9274\u6743\u4EE4\u724C",
|
|
5322
|
+
description: "HTTP\u670D\u52A1\u7684\u9274\u6743\u4EE4\u724C",
|
|
5323
|
+
content: server2.token
|
|
5324
|
+
}
|
|
5325
|
+
])
|
|
5326
|
+
}
|
|
5327
|
+
]
|
|
5328
|
+
};
|
|
5329
|
+
};
|
|
5330
|
+
getGroups = () => {
|
|
5331
|
+
const cfg = groups();
|
|
5332
|
+
return {
|
|
5333
|
+
name: "groups",
|
|
5334
|
+
title: "\u7FA4\u804A\u3001\u9891\u9053\u4E8B\u4EF6\u914D\u7F6E",
|
|
5335
|
+
description: "\u7FA4\u804A\u3001\u9891\u9053\u4E8B\u4EF6\u914D\u7F6E",
|
|
5336
|
+
type: "json",
|
|
5337
|
+
fields: Object.entries(cfg).flatMap(([groupKey, value]) => [
|
|
5338
|
+
{
|
|
5339
|
+
key: `${groupKey}.cd`,
|
|
5340
|
+
type: "number",
|
|
5341
|
+
title: "\u5168\u90E8\u6D88\u606F\u51B7\u5374\u65F6\u95F4",
|
|
5342
|
+
description: "\u5355\u4F4D\u79D2\uFF0C0\u5219\u65E0\u9650\u5236",
|
|
5343
|
+
content: value.cd
|
|
5344
|
+
},
|
|
5345
|
+
{
|
|
5346
|
+
key: `${groupKey}.userCD`,
|
|
5347
|
+
type: "number",
|
|
5348
|
+
title: "\u7FA4\u804A\u4E2D\u6BCF\u4E2A\u7528\u6237\u7684\u51B7\u5374\u65F6\u95F4",
|
|
5349
|
+
description: "\u5355\u4F4D\u79D2\uFF0C0\u5219\u65E0\u9650\u5236\u3002\u6CE8\u610F\uFF0C\u5F00\u542F\u540E\u6240\u6709\u6D88\u606F\u90FD\u4F1A\u8FDBCD\uFF0C\u65E0\u8BBA\u662F\u5426\u89E6\u53D1\u63D2\u4EF6",
|
|
5350
|
+
content: value.userCD
|
|
5351
|
+
},
|
|
5352
|
+
{
|
|
5353
|
+
key: `${groupKey}.mode`,
|
|
5354
|
+
type: "number",
|
|
5355
|
+
title: "\u673A\u5668\u4EBA\u54CD\u5E94\u6A21\u5F0F",
|
|
5356
|
+
description: "0-\u6240\u6709 1-\u4EC5@\u673A\u5668\u4EBA 2-\u4EC5\u56DE\u5E94\u7BA1\u7406\u5458 3-\u4EC5\u56DE\u5E94\u522B\u540D 4-\u522B\u540D\u6216@\u673A\u5668\u4EBA 5-\u7BA1\u7406\u5458\u65E0\u9650\u5236\uFF0C\u6210\u5458\u522B\u540D\u6216@\u673A\u5668\u4EBA 6-\u4EC5\u56DE\u5E94\u4E3B\u4EBA",
|
|
5357
|
+
content: value.mode
|
|
5358
|
+
},
|
|
5359
|
+
{
|
|
5360
|
+
key: `${groupKey}.alias`,
|
|
5361
|
+
type: "string[]",
|
|
5362
|
+
title: "\u673A\u5668\u4EBA\u522B\u540D",
|
|
5363
|
+
description: "\u522B\u540D+\u6307\u4EE4\u89E6\u53D1\u673A\u5668\u4EBA",
|
|
5364
|
+
content: value.alias
|
|
5365
|
+
},
|
|
5366
|
+
{
|
|
5367
|
+
key: `${groupKey}.enable`,
|
|
5368
|
+
type: "string[]",
|
|
5369
|
+
title: "\u767D\u540D\u5355\u63D2\u4EF6\u3001\u529F\u80FD",
|
|
5370
|
+
description: "\u767D\u540D\u5355\u4E2D\u7684\u63D2\u4EF6\u3001\u529F\u80FD\u4F1A\u54CD\u5E94: `karin-plugin-test:app.js` `karin-plugin-test:\u6D4B\u8BD5\u8F6C\u53D1`",
|
|
5371
|
+
content: value.enable
|
|
5372
|
+
},
|
|
5373
|
+
{
|
|
5374
|
+
key: `${groupKey}.disable`,
|
|
5375
|
+
type: "string[]",
|
|
5376
|
+
title: "\u9ED1\u540D\u5355\u63D2\u4EF6\u3001\u529F\u80FD",
|
|
5377
|
+
description: "\u9ED1\u540D\u5355\u4E2D\u7684\u63D2\u4EF6\u3001\u529F\u80FD\u4E0D\u4F1A\u54CD\u5E94: `karin-plugin-test:app.js` `karin-plugin-test:\u6D4B\u8BD5\u8F6C\u53D1`",
|
|
5378
|
+
content: value.disable
|
|
5379
|
+
},
|
|
5380
|
+
{
|
|
5381
|
+
key: `${groupKey}.memberEnable`,
|
|
5382
|
+
type: "string[]",
|
|
5383
|
+
title: "\u6210\u5458\u542F\u7528\u5217\u8868",
|
|
5384
|
+
description: "\u7FA4\u3001\u9891\u9053\u6210\u5458\u5355\u72EC\u767D\u540D\u5355",
|
|
5385
|
+
content: value.memberEnable
|
|
5386
|
+
},
|
|
5387
|
+
{
|
|
5388
|
+
key: `${groupKey}.memberDisable`,
|
|
5389
|
+
type: "string[]",
|
|
5390
|
+
title: "\u6210\u5458\u7981\u7528\u5217\u8868",
|
|
5391
|
+
description: "\u7FA4\u3001\u9891\u9053\u6210\u5458\u5355\u72EC\u767D\u540D\u5355",
|
|
5392
|
+
content: value.memberDisable
|
|
5393
|
+
}
|
|
5394
|
+
])
|
|
5395
|
+
};
|
|
5396
|
+
};
|
|
5397
|
+
getPrivates = () => {
|
|
5398
|
+
const cfg = privates();
|
|
5399
|
+
return {
|
|
5400
|
+
name: "privates",
|
|
5401
|
+
title: "\u597D\u53CB\u3001\u9891\u9053\u79C1\u4FE1\u4E8B\u4EF6\u914D\u7F6E",
|
|
5402
|
+
description: "\u597D\u53CB\u3001\u9891\u9053\u79C1\u4FE1\u4E8B\u4EF6\u914D\u7F6E",
|
|
5403
|
+
type: "json",
|
|
5404
|
+
fields: Object.entries(cfg).flatMap(([groupKey, value]) => [
|
|
5405
|
+
{
|
|
5406
|
+
key: `${groupKey}.cd`,
|
|
5407
|
+
type: "number",
|
|
5408
|
+
title: "\u51B7\u5374\u65F6\u95F4",
|
|
5409
|
+
description: "\u5355\u4F4D\u79D2\uFF0C0\u5219\u65E0\u9650\u5236",
|
|
5410
|
+
content: value.cd
|
|
5411
|
+
},
|
|
5412
|
+
{
|
|
5413
|
+
key: `${groupKey}.mode`,
|
|
5414
|
+
type: "number",
|
|
5415
|
+
title: "\u673A\u5668\u4EBA\u54CD\u5E94\u6A21\u5F0F",
|
|
5416
|
+
description: "0-\u6240\u6709 2-\u4EC5\u56DE\u5E94\u7BA1\u7406\u5458 3-\u4EC5\u56DE\u5E94\u522B\u540D 5-\u7BA1\u7406\u5458\u65E0\u9650\u5236\uFF0C\u975E\u7BA1\u7406\u5458\u522B\u540D 6-\u4EC5\u56DE\u5E94\u4E3B\u4EBA",
|
|
5417
|
+
content: value.mode
|
|
5418
|
+
},
|
|
5419
|
+
{
|
|
5420
|
+
key: `${groupKey}.alias`,
|
|
5421
|
+
type: "string[]",
|
|
5422
|
+
title: "\u673A\u5668\u4EBA\u522B\u540D",
|
|
5423
|
+
description: "\u522B\u540D+\u6307\u4EE4\u89E6\u53D1\u673A\u5668\u4EBA",
|
|
5424
|
+
content: value.alias
|
|
5425
|
+
},
|
|
5426
|
+
{
|
|
5427
|
+
key: `${groupKey}.enable`,
|
|
5428
|
+
type: "string[]",
|
|
5429
|
+
title: "\u767D\u540D\u5355\u63D2\u4EF6\u3001\u529F\u80FD",
|
|
5430
|
+
description: "\u767D\u540D\u5355\u4E2D\u7684\u63D2\u4EF6\u3001\u529F\u80FD\u4F1A\u54CD\u5E94: `karin-plugin-test:app.js` `karin-plugin-test:\u6D4B\u8BD5\u8F6C\u53D1`",
|
|
5431
|
+
content: value.enable
|
|
5432
|
+
},
|
|
5433
|
+
{
|
|
5434
|
+
key: `${groupKey}.disable`,
|
|
5435
|
+
type: "string[]",
|
|
5436
|
+
title: "\u9ED1\u540D\u5355\u63D2\u4EF6\u3001\u529F\u80FD",
|
|
5437
|
+
description: "\u9ED1\u540D\u5355\u4E2D\u7684\u63D2\u4EF6\u3001\u529F\u80FD\u4E0D\u4F1A\u54CD\u5E94: `karin-plugin-test:app.js` `karin-plugin-test:\u6D4B\u8BD5\u8F6C\u53D1`",
|
|
5438
|
+
content: value.disable
|
|
5439
|
+
}
|
|
5440
|
+
])
|
|
5441
|
+
};
|
|
5442
|
+
};
|
|
5443
|
+
getRender = () => {
|
|
5444
|
+
const cfg = render();
|
|
5445
|
+
return {
|
|
5446
|
+
name: "render",
|
|
5447
|
+
title: "\u6E32\u67D3\u5668\u914D\u7F6E",
|
|
5448
|
+
description: "\u6E32\u67D3\u5668\u914D\u7F6E",
|
|
5449
|
+
type: "json",
|
|
5450
|
+
fields: [
|
|
5451
|
+
{
|
|
5452
|
+
key: "ws_server.enable",
|
|
5453
|
+
type: "boolean",
|
|
5454
|
+
title: "\u542F\u7528\u53CD\u5411WS\u670D\u52A1\u5668",
|
|
5455
|
+
description: "\u662F\u5426\u542F\u7528\u53CD\u5411WebSocket\u670D\u52A1\u5668",
|
|
5456
|
+
content: cfg.ws_server.enable
|
|
5457
|
+
},
|
|
5458
|
+
{
|
|
5459
|
+
key: "ws_client",
|
|
5460
|
+
type: "array",
|
|
5461
|
+
title: "\u6B63\u5411WS\u5BA2\u6237\u7AEF\u914D\u7F6E",
|
|
5462
|
+
description: "\u6B63\u5411WebSocket\u5BA2\u6237\u7AEF\u914D\u7F6E\u5217\u8868",
|
|
5463
|
+
content: cfg.ws_client.map((client, index4) => [
|
|
5464
|
+
{
|
|
5465
|
+
key: `ws_client.${index4}.enable`,
|
|
5466
|
+
type: "boolean",
|
|
5467
|
+
title: "\u542F\u7528\u72B6\u6001",
|
|
5468
|
+
description: "\u662F\u5426\u542F\u7528\u8BE5\u6B63\u5411WS\u8FDE\u63A5",
|
|
5469
|
+
content: client.enable
|
|
5470
|
+
},
|
|
5471
|
+
{
|
|
5472
|
+
key: `ws_client.${index4}.url`,
|
|
5473
|
+
type: "string",
|
|
5474
|
+
title: "WS\u5730\u5740",
|
|
5475
|
+
description: "\u6B63\u5411WebSocket\u8FDE\u63A5\u5730\u5740",
|
|
5476
|
+
content: client.url
|
|
5477
|
+
},
|
|
5478
|
+
{
|
|
5479
|
+
key: `ws_client.${index4}.token`,
|
|
5480
|
+
type: "string",
|
|
5481
|
+
title: "\u9274\u6743\u4EE4\u724C",
|
|
5482
|
+
description: "\u6B63\u5411WebSocket\u8FDE\u63A5\u7684\u9274\u6743\u4EE4\u724C",
|
|
5483
|
+
content: client.token
|
|
5484
|
+
}
|
|
5485
|
+
])
|
|
5486
|
+
},
|
|
5487
|
+
{
|
|
5488
|
+
key: "http_server",
|
|
5489
|
+
type: "array",
|
|
5490
|
+
title: "HTTP\u670D\u52A1\u5668\u914D\u7F6E",
|
|
5491
|
+
description: "HTTP\u670D\u52A1\u5668\u914D\u7F6E\u5217\u8868",
|
|
5492
|
+
content: cfg.http_server.map((server2, index4) => [
|
|
5493
|
+
{
|
|
5494
|
+
key: `http_server.${index4}.enable`,
|
|
5495
|
+
type: "boolean",
|
|
5496
|
+
title: "\u542F\u7528\u72B6\u6001",
|
|
5497
|
+
description: "\u662F\u5426\u542F\u7528\u8BE5HTTP\u670D\u52A1",
|
|
5498
|
+
content: server2.enable
|
|
5499
|
+
},
|
|
5500
|
+
{
|
|
5501
|
+
key: `http_server.${index4}.url`,
|
|
5502
|
+
type: "string",
|
|
5503
|
+
title: "\u670D\u52A1\u5730\u5740",
|
|
5504
|
+
description: "HTTP\u670D\u52A1\u7684\u5730\u5740",
|
|
5505
|
+
content: server2.url
|
|
5506
|
+
},
|
|
5507
|
+
{
|
|
5508
|
+
key: `http_server.${index4}.token`,
|
|
5509
|
+
type: "string",
|
|
5510
|
+
title: "\u9274\u6743\u4EE4\u724C",
|
|
5511
|
+
description: "HTTP\u670D\u52A1\u7684\u9274\u6743\u4EE4\u724C",
|
|
5512
|
+
content: server2.token
|
|
5513
|
+
}
|
|
5514
|
+
])
|
|
5515
|
+
}
|
|
5516
|
+
]
|
|
5517
|
+
};
|
|
5518
|
+
};
|
|
5519
|
+
getRedis = () => {
|
|
5520
|
+
const cfg = redis();
|
|
5521
|
+
return {
|
|
5522
|
+
name: "redis",
|
|
5523
|
+
title: "Redis\u914D\u7F6E",
|
|
5524
|
+
description: "Redis\u914D\u7F6E",
|
|
5525
|
+
type: "json",
|
|
5526
|
+
fields: [
|
|
5527
|
+
{
|
|
5528
|
+
key: "url",
|
|
5529
|
+
type: "string",
|
|
5530
|
+
title: "Redis\u5730\u5740",
|
|
5531
|
+
description: "Redis\u5730\u5740",
|
|
5532
|
+
content: cfg.url
|
|
5533
|
+
},
|
|
5534
|
+
{
|
|
5535
|
+
key: "username",
|
|
5536
|
+
type: "string",
|
|
5537
|
+
title: "Redis\u7528\u6237\u540D",
|
|
5538
|
+
description: "Redis\u7528\u6237\u540D",
|
|
5539
|
+
content: cfg.username
|
|
5540
|
+
},
|
|
5541
|
+
{
|
|
5542
|
+
key: "password",
|
|
5543
|
+
type: "string",
|
|
5544
|
+
title: "Redis\u5BC6\u7801",
|
|
5545
|
+
description: "Redis\u5BC6\u7801",
|
|
5546
|
+
content: cfg.password
|
|
5547
|
+
},
|
|
5548
|
+
{
|
|
5549
|
+
key: "database",
|
|
5550
|
+
type: "number",
|
|
5551
|
+
title: "Redis\u6570\u636E\u5E93",
|
|
5552
|
+
description: "Redis\u6570\u636E\u5E93",
|
|
5553
|
+
content: cfg.database
|
|
5554
|
+
}
|
|
5555
|
+
]
|
|
5556
|
+
};
|
|
5557
|
+
};
|
|
5558
|
+
getPM2 = () => {
|
|
5559
|
+
const cfg = pm2();
|
|
5560
|
+
return {
|
|
5561
|
+
name: "pm2",
|
|
5562
|
+
title: "PM2\u914D\u7F6E",
|
|
5563
|
+
description: "PM2\u914D\u7F6E",
|
|
5564
|
+
type: "json",
|
|
5565
|
+
fields: [
|
|
5566
|
+
{
|
|
5567
|
+
key: "lines",
|
|
5568
|
+
type: "number",
|
|
5569
|
+
title: "\u65E5\u5FD7\u884C\u6570",
|
|
5570
|
+
description: "\u65E5\u5FD7\u884C\u6570",
|
|
5571
|
+
content: cfg.lines
|
|
5572
|
+
},
|
|
5573
|
+
{
|
|
5574
|
+
key: "apps",
|
|
5575
|
+
type: "array",
|
|
5576
|
+
title: "PM2\u5E94\u7528\u914D\u7F6E",
|
|
5577
|
+
description: "PM2\u5E94\u7528\u914D\u7F6E",
|
|
5578
|
+
content: cfg.apps.map((app2, index4) => [
|
|
5579
|
+
{
|
|
5580
|
+
key: `apps.${index4}.name`,
|
|
5581
|
+
type: "string",
|
|
5582
|
+
title: "\u5E94\u7528\u540D\u79F0",
|
|
5583
|
+
description: "\u5E94\u7528\u540D\u79F0",
|
|
5584
|
+
content: app2.name
|
|
5585
|
+
},
|
|
5586
|
+
{
|
|
5587
|
+
key: `apps.${index4}.script`,
|
|
5588
|
+
type: "string",
|
|
5589
|
+
title: "\u5165\u53E3\u6587\u4EF6",
|
|
5590
|
+
description: "\u5165\u53E3\u6587\u4EF6",
|
|
5591
|
+
content: app2.script
|
|
5592
|
+
},
|
|
5593
|
+
{
|
|
5594
|
+
key: `apps.${index4}.autorestart`,
|
|
5595
|
+
type: "boolean",
|
|
5596
|
+
title: "\u81EA\u52A8\u91CD\u542F",
|
|
5597
|
+
description: "\u81EA\u52A8\u91CD\u542F",
|
|
5598
|
+
content: app2.autorestart
|
|
5599
|
+
},
|
|
5600
|
+
{
|
|
5601
|
+
key: `apps.${index4}.max_restarts`,
|
|
5602
|
+
type: "number",
|
|
5603
|
+
title: "\u6700\u5927\u91CD\u542F\u6B21\u6570",
|
|
5604
|
+
description: "\u6700\u5927\u91CD\u542F\u6B21\u6570",
|
|
5605
|
+
content: app2.max_restarts
|
|
5606
|
+
},
|
|
5607
|
+
{
|
|
5608
|
+
key: `apps.${index4}.max_memory_restart`,
|
|
5609
|
+
type: "string",
|
|
5610
|
+
title: "\u6700\u5927\u5185\u5B58\u91CD\u542F",
|
|
5611
|
+
description: "\u6700\u5927\u5185\u5B58\u91CD\u542F",
|
|
5612
|
+
content: app2.max_memory_restart
|
|
5613
|
+
},
|
|
5614
|
+
{
|
|
5615
|
+
key: `apps.${index4}.restart_delay`,
|
|
5616
|
+
type: "number",
|
|
5617
|
+
title: "\u91CD\u542F\u5EF6\u8FDF",
|
|
5618
|
+
description: "\u91CD\u542F\u5EF6\u8FDF",
|
|
5619
|
+
content: app2.restart_delay
|
|
5620
|
+
},
|
|
5621
|
+
{
|
|
5622
|
+
key: `apps.${index4}.merge_logs`,
|
|
5623
|
+
type: "boolean",
|
|
5624
|
+
title: "\u5408\u5E76\u65E5\u5FD7",
|
|
5625
|
+
description: "\u5408\u5E76\u65E5\u5FD7",
|
|
5626
|
+
content: app2.merge_logs
|
|
5627
|
+
},
|
|
5628
|
+
{
|
|
5629
|
+
key: `apps.${index4}.error_file`,
|
|
5630
|
+
type: "string",
|
|
5631
|
+
title: "\u9519\u8BEF\u65E5\u5FD7\u8DEF\u5F84",
|
|
5632
|
+
description: "\u9519\u8BEF\u65E5\u5FD7\u8DEF\u5F84",
|
|
5633
|
+
content: app2.error_file
|
|
5634
|
+
},
|
|
5635
|
+
{
|
|
5636
|
+
key: `apps.${index4}.out_file`,
|
|
5637
|
+
type: "string",
|
|
5638
|
+
title: "\u8F93\u51FA\u65E5\u5FD7\u8DEF\u5F84",
|
|
5639
|
+
description: "\u8F93\u51FA\u65E5\u5FD7\u8DEF\u5F84",
|
|
5640
|
+
content: app2.out_file
|
|
5641
|
+
}
|
|
5642
|
+
])
|
|
5643
|
+
}
|
|
5644
|
+
]
|
|
5645
|
+
};
|
|
5646
|
+
};
|
|
5647
|
+
getEnv = () => {
|
|
5648
|
+
const cfg = env();
|
|
5649
|
+
return {
|
|
5650
|
+
name: "env",
|
|
5651
|
+
title: "\u73AF\u5883\u53D8\u91CF\u914D\u7F6E",
|
|
5652
|
+
description: "\u73AF\u5883\u53D8\u91CF\u914D\u7F6E",
|
|
5653
|
+
type: "env",
|
|
5654
|
+
fields: [
|
|
5655
|
+
{
|
|
5656
|
+
key: "HTTP_ENABLE",
|
|
5657
|
+
type: "string",
|
|
5658
|
+
title: "\u542F\u7528HTTP",
|
|
5659
|
+
description: "\u662F\u5426\u542F\u7528HTTP",
|
|
5660
|
+
content: cfg.HTTP_ENABLE
|
|
5661
|
+
},
|
|
5662
|
+
{
|
|
5663
|
+
key: "HTTP_PORT",
|
|
5664
|
+
type: "string",
|
|
5665
|
+
title: "HTTP\u7AEF\u53E3",
|
|
5666
|
+
description: "HTTP\u7AEF\u53E3",
|
|
5667
|
+
content: cfg.HTTP_PORT
|
|
5668
|
+
},
|
|
5669
|
+
{
|
|
5670
|
+
key: "HTTP_HOST",
|
|
5671
|
+
type: "string",
|
|
5672
|
+
title: "HTTP\u5730\u5740",
|
|
5673
|
+
description: "HTTP\u5730\u5740",
|
|
5674
|
+
content: cfg.HTTP_HOST
|
|
5675
|
+
},
|
|
5676
|
+
{
|
|
5677
|
+
key: "HTTP_AUTH_KEY",
|
|
5678
|
+
type: "string",
|
|
5679
|
+
title: "HTTP\u9274\u6743\u79D8\u94A5",
|
|
5680
|
+
description: "HTTP\u9274\u6743\u79D8\u94A5",
|
|
5681
|
+
content: cfg.HTTP_AUTH_KEY
|
|
5682
|
+
},
|
|
5683
|
+
{
|
|
5684
|
+
key: "WS_SERVER_AUTH_KEY",
|
|
5685
|
+
type: "string",
|
|
5686
|
+
title: "ws_server\u9274\u6743\u79D8\u94A5",
|
|
5687
|
+
description: "ws_server\u9274\u6743\u79D8\u94A5",
|
|
5688
|
+
content: cfg.WS_SERVER_AUTH_KEY
|
|
5689
|
+
},
|
|
5690
|
+
{
|
|
5691
|
+
key: "REDIS_ENABLE",
|
|
5692
|
+
type: "string",
|
|
5693
|
+
title: "\u662F\u5426\u542F\u7528Redis",
|
|
5694
|
+
description: "\u662F\u5426\u542F\u7528Redis",
|
|
5695
|
+
content: cfg.REDIS_ENABLE
|
|
5696
|
+
},
|
|
5697
|
+
{
|
|
5698
|
+
key: "PM2_RESTART",
|
|
5699
|
+
type: "string",
|
|
5700
|
+
title: "\u91CD\u542F\u662F\u5426\u8C03\u7528pm2",
|
|
5701
|
+
description: "\u91CD\u542F\u662F\u5426\u8C03\u7528pm2",
|
|
5702
|
+
content: cfg.PM2_RESTART
|
|
5703
|
+
},
|
|
5704
|
+
{
|
|
5705
|
+
key: "LOG_LEVEL",
|
|
5706
|
+
type: "string",
|
|
5707
|
+
title: "\u65E5\u5FD7\u7B49\u7EA7",
|
|
5708
|
+
description: "\u65E5\u5FD7\u7B49\u7EA7",
|
|
5709
|
+
content: cfg.LOG_LEVEL
|
|
5710
|
+
},
|
|
5711
|
+
{
|
|
5712
|
+
key: "LOG_DAYS_TO_KEEP",
|
|
5713
|
+
type: "string",
|
|
5714
|
+
title: "\u65E5\u5FD7\u4FDD\u7559\u5929\u6570",
|
|
5715
|
+
description: "\u65E5\u5FD7\u4FDD\u7559\u5929\u6570",
|
|
5716
|
+
content: cfg.LOG_DAYS_TO_KEEP
|
|
5717
|
+
},
|
|
5718
|
+
{
|
|
5719
|
+
key: "LOG_MAX_LOG_SIZE",
|
|
5720
|
+
type: "string",
|
|
5721
|
+
title: "\u65E5\u5FD7\u6587\u4EF6\u6700\u5927\u5927\u5C0F",
|
|
5722
|
+
description: "\u65E5\u5FD7\u6587\u4EF6\u6700\u5927\u5927\u5C0F",
|
|
5723
|
+
content: cfg.LOG_MAX_LOG_SIZE
|
|
5724
|
+
},
|
|
5725
|
+
{
|
|
5726
|
+
key: "LOG_FNC_COLOR",
|
|
5727
|
+
type: "string",
|
|
5728
|
+
title: "logger.fnc\u989C\u8272",
|
|
5729
|
+
description: "logger.fnc\u989C\u8272",
|
|
5730
|
+
content: cfg.LOG_FNC_COLOR
|
|
5731
|
+
},
|
|
5732
|
+
{
|
|
5733
|
+
key: "RUNNER",
|
|
5734
|
+
type: "string",
|
|
5735
|
+
title: "\u8FD0\u884C\u5668",
|
|
5736
|
+
description: "\u8FD0\u884C\u5668",
|
|
5737
|
+
content: cfg.RUNNER
|
|
5738
|
+
},
|
|
5739
|
+
{
|
|
5740
|
+
key: "FFMPEG_PATH",
|
|
5741
|
+
type: "string",
|
|
5742
|
+
title: "ffmpeg\u8DEF\u5F84",
|
|
5743
|
+
description: "ffmpeg\u8DEF\u5F84",
|
|
5744
|
+
content: cfg.FFMPEG_PATH
|
|
5745
|
+
},
|
|
5746
|
+
{
|
|
5747
|
+
key: "FFPROBE_PATH",
|
|
5748
|
+
type: "string",
|
|
5749
|
+
title: "ffprobe\u8DEF\u5F84",
|
|
5750
|
+
description: "ffprobe\u8DEF\u5F84",
|
|
5751
|
+
content: cfg.FFPROBE_PATH
|
|
5752
|
+
},
|
|
5753
|
+
{
|
|
5754
|
+
key: "FFPLAY_PATH",
|
|
5755
|
+
type: "string",
|
|
5756
|
+
title: "ffplay\u8DEF\u5F84",
|
|
5757
|
+
description: "ffplay\u8DEF\u5F84",
|
|
5758
|
+
content: cfg.FFPLAY_PATH
|
|
5759
|
+
}
|
|
5760
|
+
]
|
|
5761
|
+
};
|
|
5762
|
+
};
|
|
5763
|
+
getFileList = (type) => {
|
|
5764
|
+
if (type === "config") return getConfig();
|
|
5765
|
+
if (type === "adapter") return getAdapter();
|
|
5766
|
+
if (type === "env") return getEnv();
|
|
5767
|
+
if (type === "pm2") return getPM2();
|
|
5768
|
+
if (type === "redis") return getRedis();
|
|
5769
|
+
if (type === "render") return getRender();
|
|
5770
|
+
if (type === "groups") return getGroups();
|
|
5771
|
+
if (type === "privates") return getPrivates();
|
|
5772
|
+
return [
|
|
5773
|
+
getConfig(),
|
|
5774
|
+
getAdapter(),
|
|
5775
|
+
getEnv(),
|
|
5776
|
+
getPM2(),
|
|
5777
|
+
getRedis(),
|
|
5778
|
+
getRender(),
|
|
5779
|
+
getGroups(),
|
|
5780
|
+
getPrivates()
|
|
5781
|
+
];
|
|
5782
|
+
};
|
|
5783
|
+
}
|
|
5784
|
+
});
|
|
5785
|
+
|
|
5786
|
+
// src/server/api/file.ts
|
|
5787
|
+
var list, nameMap, fileRouter, setFileRouter, getFileRouter, getFileFieldsRouter;
|
|
5788
|
+
var init_file3 = __esm({
|
|
4792
5789
|
async "src/server/api/file.ts"() {
|
|
4793
5790
|
"use strict";
|
|
4794
5791
|
init_esm_shims();
|
|
4795
5792
|
init_router();
|
|
5793
|
+
await init_file2();
|
|
4796
5794
|
await init_config();
|
|
4797
5795
|
init_response();
|
|
4798
|
-
|
|
5796
|
+
list = ["adapter", "config", "groups", "pm2", "privates", "redis", "render", "env"];
|
|
4799
5797
|
nameMap = {
|
|
4800
5798
|
adapter: "\u9002\u914D\u5668\u914D\u7F6E",
|
|
4801
5799
|
config: "\u57FA\u672C\u914D\u7F6E",
|
|
@@ -4803,10 +5801,11 @@ var init_file2 = __esm({
|
|
|
4803
5801
|
pm2: "pm2\u914D\u7F6E",
|
|
4804
5802
|
privates: "\u597D\u53CB\u548C\u9891\u9053\u79C1\u4FE1\u914D\u7F6E",
|
|
4805
5803
|
redis: "redis\u914D\u7F6E",
|
|
4806
|
-
render: "\u6E32\u67D3\u5668\u914D\u7F6E"
|
|
5804
|
+
render: "\u6E32\u67D3\u5668\u914D\u7F6E",
|
|
5805
|
+
env: "\u73AF\u5883\u53D8\u91CF\u914D\u7F6E"
|
|
4807
5806
|
};
|
|
4808
5807
|
fileRouter = async (_req, res) => {
|
|
4809
|
-
const files =
|
|
5808
|
+
const files = list.map((name) => ({
|
|
4810
5809
|
name,
|
|
4811
5810
|
title: nameMap[name]
|
|
4812
5811
|
}));
|
|
@@ -4814,24 +5813,29 @@ var init_file2 = __esm({
|
|
|
4814
5813
|
};
|
|
4815
5814
|
setFileRouter = async (req, res) => {
|
|
4816
5815
|
const { name, data } = req.body;
|
|
4817
|
-
if (!name || !data || !
|
|
4818
|
-
res
|
|
4819
|
-
return;
|
|
5816
|
+
if (!name || !data || !list.includes(name) || typeof data !== "object") {
|
|
5817
|
+
return createBadRequestResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
4820
5818
|
}
|
|
4821
5819
|
setYaml(name, data);
|
|
4822
5820
|
createSuccessResponse(res, null, "\u8BBE\u7F6E\u6210\u529F");
|
|
4823
5821
|
};
|
|
4824
5822
|
getFileRouter = async (req, res) => {
|
|
4825
5823
|
const { name } = req.body;
|
|
4826
|
-
if (!name || !
|
|
4827
|
-
res
|
|
4828
|
-
return createSuccessResponse(res, null, "\u83B7\u53D6\u6210\u529F");
|
|
5824
|
+
if (!name || !list.includes(name)) {
|
|
5825
|
+
return createBadRequestResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
4829
5826
|
}
|
|
4830
|
-
|
|
5827
|
+
const data = getYaml(name, "user");
|
|
5828
|
+
createSuccessResponse(res, data);
|
|
5829
|
+
};
|
|
5830
|
+
getFileFieldsRouter = async (req, res) => {
|
|
5831
|
+
const { name } = req.body;
|
|
5832
|
+
const fields = getFileList(name);
|
|
5833
|
+
createSuccessResponse(res, fields);
|
|
4831
5834
|
};
|
|
4832
|
-
router.
|
|
5835
|
+
router.post("/file", fileRouter);
|
|
4833
5836
|
router.post("/set_file", setFileRouter);
|
|
4834
5837
|
router.post("/get_file", getFileRouter);
|
|
5838
|
+
router.post("/get_file_fields", getFileFieldsRouter);
|
|
4835
5839
|
}
|
|
4836
5840
|
});
|
|
4837
5841
|
|
|
@@ -4846,7 +5850,83 @@ var init_login = __esm({
|
|
|
4846
5850
|
loginRouter = async (_req, res) => {
|
|
4847
5851
|
createSuccessResponse(res, null, "\u767B\u5F55\u6210\u529F");
|
|
4848
5852
|
};
|
|
4849
|
-
router.
|
|
5853
|
+
router.post("/login", loginRouter);
|
|
5854
|
+
}
|
|
5855
|
+
});
|
|
5856
|
+
|
|
5857
|
+
// src/server/api/log.ts
|
|
5858
|
+
import fs16 from "node:fs";
|
|
5859
|
+
import moment2 from "moment";
|
|
5860
|
+
import path15 from "node:path";
|
|
5861
|
+
var logRouter, activeConnections, getLogRouter;
|
|
5862
|
+
var init_log = __esm({
|
|
5863
|
+
async "src/server/api/log.ts"() {
|
|
5864
|
+
"use strict";
|
|
5865
|
+
init_esm_shims();
|
|
5866
|
+
init_root();
|
|
5867
|
+
init_router();
|
|
5868
|
+
await init_config2();
|
|
5869
|
+
init_response();
|
|
5870
|
+
logRouter = async (req, res) => {
|
|
5871
|
+
var _a;
|
|
5872
|
+
const level2 = (_a = req.body) == null ? void 0 : _a.level;
|
|
5873
|
+
const list3 = ["trace", "debug", "info", "warn", "error", "fatal"];
|
|
5874
|
+
if (!level2 || !list3.includes(level2)) {
|
|
5875
|
+
return createBadRequestResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
5876
|
+
}
|
|
5877
|
+
updateLevel(level2);
|
|
5878
|
+
createSuccessResponse(res, null, "\u6210\u529F");
|
|
5879
|
+
};
|
|
5880
|
+
activeConnections = 0;
|
|
5881
|
+
getLogRouter = async (req, res) => {
|
|
5882
|
+
const maxConnections = Number(process.env.LOG_API_MAX_CONNECTIONS) || 5;
|
|
5883
|
+
if (activeConnections >= maxConnections) {
|
|
5884
|
+
return createBadRequestResponse(res, "\u5F53\u524D\u8FDE\u63A5\u6570\u5DF2\u8FBE\u5230\u4E0A\u9650\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
5885
|
+
}
|
|
5886
|
+
activeConnections++;
|
|
5887
|
+
const date = req.query.date ? moment2(req.query.date) : moment2();
|
|
5888
|
+
if (!date.isValid()) {
|
|
5889
|
+
return createBadRequestResponse(res, "\u65E5\u671F\u683C\u5F0F\u9519\u8BEF");
|
|
5890
|
+
}
|
|
5891
|
+
const file = path15.join(logsPath, `logger.${date.format("YYYY-MM-DD")}.log`);
|
|
5892
|
+
if (!fs16.existsSync(file)) {
|
|
5893
|
+
return createBadRequestResponse(res, "\u65E5\u5FD7\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
5894
|
+
}
|
|
5895
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
5896
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
5897
|
+
res.setHeader("Connection", "keep-alive");
|
|
5898
|
+
res.setHeader("X-Accel-Buffering", "no");
|
|
5899
|
+
let position = 0;
|
|
5900
|
+
const tailFile = () => {
|
|
5901
|
+
fs16.stat(file, (err, stats) => {
|
|
5902
|
+
if (err) {
|
|
5903
|
+
logger.error("\u8BFB\u53D6\u65E5\u5FD7\u6587\u4EF6\u72B6\u6001\u9519\u8BEF:", err);
|
|
5904
|
+
return;
|
|
5905
|
+
}
|
|
5906
|
+
if (position > stats.size) {
|
|
5907
|
+
position = 0;
|
|
5908
|
+
}
|
|
5909
|
+
if (position < stats.size) {
|
|
5910
|
+
const stream2 = fs16.createReadStream(file, { start: position, encoding: "utf-8" });
|
|
5911
|
+
stream2.on("data", (data) => res.write(data));
|
|
5912
|
+
stream2.on("end", () => {
|
|
5913
|
+
position = stats.size;
|
|
5914
|
+
});
|
|
5915
|
+
stream2.on("error", (error) => {
|
|
5916
|
+
logger.error("\u8BFB\u53D6\u65E5\u5FD7\u6587\u4EF6\u9519\u8BEF:", error.message);
|
|
5917
|
+
});
|
|
5918
|
+
}
|
|
5919
|
+
});
|
|
5920
|
+
};
|
|
5921
|
+
tailFile();
|
|
5922
|
+
const interval = setInterval(tailFile, 1e3);
|
|
5923
|
+
req.on("close", () => {
|
|
5924
|
+
clearInterval(interval);
|
|
5925
|
+
activeConnections--;
|
|
5926
|
+
});
|
|
5927
|
+
};
|
|
5928
|
+
router.get("/log", getLogRouter);
|
|
5929
|
+
router.post("/log_level", logRouter);
|
|
4850
5930
|
}
|
|
4851
5931
|
});
|
|
4852
5932
|
|
|
@@ -4855,13 +5935,13 @@ var init_api = __esm({
|
|
|
4855
5935
|
async "src/server/api/index.ts"() {
|
|
4856
5936
|
"use strict";
|
|
4857
5937
|
init_esm_shims();
|
|
4858
|
-
|
|
4859
|
-
init_ping();
|
|
5938
|
+
init_info();
|
|
4860
5939
|
await init_root2();
|
|
4861
5940
|
await init_console();
|
|
4862
|
-
|
|
4863
|
-
await
|
|
5941
|
+
init_manage();
|
|
5942
|
+
await init_file3();
|
|
4864
5943
|
init_login();
|
|
5944
|
+
await init_log();
|
|
4865
5945
|
}
|
|
4866
5946
|
});
|
|
4867
5947
|
|
|
@@ -4883,18 +5963,27 @@ var init_ws = __esm({
|
|
|
4883
5963
|
}
|
|
4884
5964
|
throw error;
|
|
4885
5965
|
});
|
|
4886
|
-
wss.on("connection", (socket,
|
|
5966
|
+
wss.on("connection", (socket, request2) => {
|
|
4887
5967
|
var _a;
|
|
4888
|
-
debug(`wss:connection host: ${
|
|
4889
|
-
if (((_a =
|
|
4890
|
-
listeners.emit("ws:connection:onebot", socket,
|
|
5968
|
+
debug(`wss:connection host: ${request2.headers.host} url: ${request2.url}`);
|
|
5969
|
+
if (((_a = request2 == null ? void 0 : request2.headers) == null ? void 0 : _a.a) || request2.url === "/" || request2.url === "/onebot/v11/ws" || request2.url === "/onebot/v11/ws/") {
|
|
5970
|
+
listeners.emit("ws:connection:onebot", socket, request2);
|
|
5971
|
+
socket.on("close", (code, reason) => {
|
|
5972
|
+
listeners.emit("ws:close:onebot", socket, request2, code, reason);
|
|
5973
|
+
});
|
|
4891
5974
|
return;
|
|
4892
5975
|
}
|
|
4893
|
-
if (
|
|
4894
|
-
listeners.emit("ws:connection:puppeteer", socket,
|
|
5976
|
+
if (request2.url === "/puppeteer") {
|
|
5977
|
+
listeners.emit("ws:connection:puppeteer", socket, request2);
|
|
5978
|
+
socket.on("close", (code, reason) => {
|
|
5979
|
+
listeners.emit("ws:close:puppeteer", socket, request2, code, reason);
|
|
5980
|
+
});
|
|
4895
5981
|
return;
|
|
4896
5982
|
}
|
|
4897
|
-
listeners.emit("ws:connection", socket,
|
|
5983
|
+
listeners.emit("ws:connection", socket, request2);
|
|
5984
|
+
socket.on("close", (code, reason) => {
|
|
5985
|
+
listeners.emit("ws:close", socket, request2, code, reason);
|
|
5986
|
+
});
|
|
4898
5987
|
});
|
|
4899
5988
|
}
|
|
4900
5989
|
});
|
|
@@ -4905,6 +5994,7 @@ __export(server_exports, {
|
|
|
4905
5994
|
app: () => app,
|
|
4906
5995
|
listen: () => listen,
|
|
4907
5996
|
server: () => server,
|
|
5997
|
+
web: () => web,
|
|
4908
5998
|
wss: () => wss
|
|
4909
5999
|
});
|
|
4910
6000
|
var init_server = __esm({
|
|
@@ -5458,7 +6548,7 @@ var init_key = __esm({
|
|
|
5458
6548
|
});
|
|
5459
6549
|
|
|
5460
6550
|
// src/service/bot.ts
|
|
5461
|
-
var index,
|
|
6551
|
+
var index, list2, getBot, getAllBot, getAllBotList, getAllBotID, getBotCount, unregisterBot, registerBot, sendMsg;
|
|
5462
6552
|
var init_bot = __esm({
|
|
5463
6553
|
"src/service/bot.ts"() {
|
|
5464
6554
|
"use strict";
|
|
@@ -5469,38 +6559,38 @@ var init_bot = __esm({
|
|
|
5469
6559
|
init_common();
|
|
5470
6560
|
init_key();
|
|
5471
6561
|
index = 0;
|
|
5472
|
-
|
|
6562
|
+
list2 = [];
|
|
5473
6563
|
getBot = (id, isProtocol = false) => {
|
|
5474
6564
|
var _a, _b, _c;
|
|
5475
6565
|
try {
|
|
5476
6566
|
if (typeof id === "number") {
|
|
5477
|
-
return ((_a =
|
|
6567
|
+
return ((_a = list2.find((item) => item.index === id)) == null ? void 0 : _a.bot) || null;
|
|
5478
6568
|
}
|
|
5479
6569
|
if (isProtocol) {
|
|
5480
|
-
return ((_b =
|
|
6570
|
+
return ((_b = list2.find((item) => item.bot.adapter.protocol === id)) == null ? void 0 : _b.bot) || null;
|
|
5481
6571
|
}
|
|
5482
|
-
return ((_c =
|
|
6572
|
+
return ((_c = list2.find((item) => item.bot.selfId === id)) == null ? void 0 : _c.bot) || null;
|
|
5483
6573
|
} catch {
|
|
5484
6574
|
return null;
|
|
5485
6575
|
}
|
|
5486
6576
|
};
|
|
5487
6577
|
getAllBot = () => {
|
|
5488
|
-
return
|
|
6578
|
+
return list2.map((item) => item.bot);
|
|
5489
6579
|
};
|
|
5490
6580
|
getAllBotList = () => {
|
|
5491
|
-
return
|
|
6581
|
+
return list2;
|
|
5492
6582
|
};
|
|
5493
6583
|
getAllBotID = () => {
|
|
5494
|
-
return
|
|
6584
|
+
return list2.map((item) => item.bot.selfId);
|
|
5495
6585
|
};
|
|
5496
6586
|
getBotCount = () => {
|
|
5497
|
-
return
|
|
6587
|
+
return list2.length;
|
|
5498
6588
|
};
|
|
5499
6589
|
unregisterBot = (type, idOrIndex, address) => {
|
|
5500
6590
|
const findIndexAndRemove = (predicate) => {
|
|
5501
|
-
const index4 =
|
|
6591
|
+
const index4 = list2.findIndex(predicate);
|
|
5502
6592
|
if (index4 !== -1) {
|
|
5503
|
-
const [removed] =
|
|
6593
|
+
const [removed] = list2.splice(index4, 1);
|
|
5504
6594
|
logger.bot("info", removed.bot.selfId, `${logger.red("[service][\u5378\u8F7DBot]")} ${removed.bot.adapter.name}`);
|
|
5505
6595
|
return true;
|
|
5506
6596
|
}
|
|
@@ -5521,7 +6611,7 @@ var init_bot = __esm({
|
|
|
5521
6611
|
};
|
|
5522
6612
|
registerBot = (type, bot) => {
|
|
5523
6613
|
const id = ++index;
|
|
5524
|
-
|
|
6614
|
+
list2.push({ index: id, bot });
|
|
5525
6615
|
const sendForwardMsg = bot.sendForwardMsg;
|
|
5526
6616
|
bot.sendForwardMsg = async (contact3, elements, options) => {
|
|
5527
6617
|
return sendForwardMsg.call(bot, contact3, elements, options);
|
|
@@ -5665,13 +6755,13 @@ var init_cd = __esm({
|
|
|
5665
6755
|
return true;
|
|
5666
6756
|
};
|
|
5667
6757
|
noticeRequestCD = (ctx3, config2, key) => {
|
|
5668
|
-
const
|
|
6758
|
+
const list3 = [
|
|
5669
6759
|
"frientPoke",
|
|
5670
6760
|
"receiveLike",
|
|
5671
6761
|
"groupPoke",
|
|
5672
6762
|
"groupMessageReaction"
|
|
5673
6763
|
];
|
|
5674
|
-
if (!
|
|
6764
|
+
if (!list3.includes(ctx3.subEvent)) {
|
|
5675
6765
|
return true;
|
|
5676
6766
|
}
|
|
5677
6767
|
if (userCD[key]) {
|
|
@@ -5827,12 +6917,12 @@ var init_handler2 = __esm({
|
|
|
5827
6917
|
};
|
|
5828
6918
|
disableViaPluginWhitelist = (plugin, config2) => {
|
|
5829
6919
|
if (!config2.enable.length) return true;
|
|
5830
|
-
const
|
|
6920
|
+
const list3 = [
|
|
5831
6921
|
plugin.pkg.name,
|
|
5832
6922
|
`${plugin.pkg.name}:${plugin.file.basename}`,
|
|
5833
6923
|
`${plugin.pkg.name}:${plugin.file.method}`
|
|
5834
6924
|
];
|
|
5835
|
-
for (const item of
|
|
6925
|
+
for (const item of list3) {
|
|
5836
6926
|
if (config2.enable.includes(item)) {
|
|
5837
6927
|
return true;
|
|
5838
6928
|
}
|
|
@@ -5841,12 +6931,12 @@ var init_handler2 = __esm({
|
|
|
5841
6931
|
};
|
|
5842
6932
|
disableViaPluginBlacklist = (plugin, config2) => {
|
|
5843
6933
|
if (!config2.disable.length) return true;
|
|
5844
|
-
const
|
|
6934
|
+
const list3 = [
|
|
5845
6935
|
plugin.pkg.name,
|
|
5846
6936
|
`${plugin.pkg.name}:${plugin.file.basename}`,
|
|
5847
6937
|
`${plugin.pkg.name}:${plugin.file.method}`
|
|
5848
6938
|
];
|
|
5849
|
-
for (const item of
|
|
6939
|
+
for (const item of list3) {
|
|
5850
6940
|
if (config2.disable.includes(item)) {
|
|
5851
6941
|
return false;
|
|
5852
6942
|
}
|
|
@@ -5856,7 +6946,7 @@ var init_handler2 = __esm({
|
|
|
5856
6946
|
privateFilterEvent = (ctx3, config2, friend, cd) => {
|
|
5857
6947
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5858
6948
|
if (ctx3.isFriend) {
|
|
5859
|
-
if (!((_a = config2 == null ? void 0 : config2.
|
|
6949
|
+
if (!((_a = config2 == null ? void 0 : config2.friend) == null ? void 0 : _a.enable)) {
|
|
5860
6950
|
log(ctx3.userId, `\u5F53\u524D\u597D\u53CB\u4E8B\u4EF6\u672A\u542F\u7528: ${ctx3.eventId}`);
|
|
5861
6951
|
return false;
|
|
5862
6952
|
}
|
|
@@ -6564,6 +7654,7 @@ var init_notice = __esm({
|
|
|
6564
7654
|
});
|
|
6565
7655
|
|
|
6566
7656
|
// src/event/handler/request/groups.ts
|
|
7657
|
+
var groupRequestHandler;
|
|
6567
7658
|
var init_groups4 = __esm({
|
|
6568
7659
|
async "src/event/handler/request/groups.ts"() {
|
|
6569
7660
|
"use strict";
|
|
@@ -6572,10 +7663,22 @@ var init_groups4 = __esm({
|
|
|
6572
7663
|
await init_config2();
|
|
6573
7664
|
init_other();
|
|
6574
7665
|
init_handler2();
|
|
7666
|
+
groupRequestHandler = async (ctx3) => {
|
|
7667
|
+
const config2 = config();
|
|
7668
|
+
const group = getGroupCfg(ctx3.groupId, ctx3.selfId);
|
|
7669
|
+
initRole(ctx3, config2);
|
|
7670
|
+
initEmit(ctx3);
|
|
7671
|
+
initTips(ctx3);
|
|
7672
|
+
initPrint3(ctx3, "group", "\u7FA4\u8BF7\u6C42");
|
|
7673
|
+
const cd = noticeRequestCD(ctx3, group, ctx3.groupId);
|
|
7674
|
+
const filter = groupFilterEvent(ctx3, config2, group, cd);
|
|
7675
|
+
if (filter) deal(ctx3, group);
|
|
7676
|
+
};
|
|
6575
7677
|
}
|
|
6576
7678
|
});
|
|
6577
7679
|
|
|
6578
7680
|
// src/event/handler/request/private.ts
|
|
7681
|
+
var friendRequestHandler;
|
|
6579
7682
|
var init_private3 = __esm({
|
|
6580
7683
|
async "src/event/handler/request/private.ts"() {
|
|
6581
7684
|
"use strict";
|
|
@@ -6584,6 +7687,17 @@ var init_private3 = __esm({
|
|
|
6584
7687
|
init_other();
|
|
6585
7688
|
await init_config2();
|
|
6586
7689
|
init_handler2();
|
|
7690
|
+
friendRequestHandler = async (ctx3) => {
|
|
7691
|
+
const config2 = config();
|
|
7692
|
+
const friend = getFriendCfg(ctx3.userId, ctx3.selfId);
|
|
7693
|
+
initRole(ctx3, config2);
|
|
7694
|
+
initEmit(ctx3);
|
|
7695
|
+
initTips(ctx3);
|
|
7696
|
+
initPrint3(ctx3, "friend", "\u597D\u53CB\u8BF7\u6C42");
|
|
7697
|
+
const cd = noticeRequestCD(ctx3, friend, ctx3.userId);
|
|
7698
|
+
const filter = privateFilterEvent(ctx3, config2, friend, cd);
|
|
7699
|
+
if (filter) deal(ctx3, friend);
|
|
7700
|
+
};
|
|
6587
7701
|
}
|
|
6588
7702
|
});
|
|
6589
7703
|
|
|
@@ -6675,14 +7789,14 @@ var init_base2 = __esm({
|
|
|
6675
7789
|
/** @deprecated 已废弃,请使用 messageId */
|
|
6676
7790
|
message_id: ""
|
|
6677
7791
|
};
|
|
6678
|
-
const
|
|
7792
|
+
const request2 = this.#srcReply(message);
|
|
6679
7793
|
const { raw: raw2 } = createRawMessage(message);
|
|
6680
7794
|
if (this.isGroup) {
|
|
6681
7795
|
this.selfId !== "console" && logger.bot("info", this.selfId, `${logger.green(`Send Group ${this.contact.peer}: `)}${raw2.replace(/\n/g, "\\n")}`);
|
|
6682
7796
|
} else {
|
|
6683
7797
|
this.selfId !== "console" && logger.bot("info", this.selfId, `${logger.green(`Send private ${this.contact.peer}: `)}${raw2.replace(/\n/g, "\\n")}`);
|
|
6684
7798
|
}
|
|
6685
|
-
result = util4.types.isPromise(
|
|
7799
|
+
result = util4.types.isPromise(request2) ? await request2 : request2;
|
|
6686
7800
|
result.message_id = result.messageId;
|
|
6687
7801
|
if (recallMsg > 0 && result.messageId) {
|
|
6688
7802
|
setTimeout(() => {
|
|
@@ -8235,7 +9349,7 @@ var init_request2 = __esm({
|
|
|
8235
9349
|
});
|
|
8236
9350
|
|
|
8237
9351
|
// src/event/create/index.ts
|
|
8238
|
-
var createFriendMessage, createGroupMessage, createGroupTempMessage, createFriendIncreaseNotice, createPrivatePokeNotice, createPrivateRecallNotice, createGroupPokeNotice, createGroupRecallNotice, createGroupFileUploadedNotice, createGroupCardChangedNotice, createGroupHlightsChangedNotice, createGroupMemberAddNotice, createGroupMemberDelNotice, createGroupAdminChangedNotice, createGroupMemberBanNotice, createGroupMessageReactionNotice, createGroupLuckKingNotice, createGroupHonorChangedNotice;
|
|
9352
|
+
var createFriendMessage, createGroupMessage, createGroupTempMessage, createFriendIncreaseNotice, createPrivatePokeNotice, createPrivateRecallNotice, createGroupPokeNotice, createGroupRecallNotice, createGroupFileUploadedNotice, createGroupCardChangedNotice, createGroupHlightsChangedNotice, createGroupMemberAddNotice, createGroupMemberDelNotice, createGroupAdminChangedNotice, createGroupMemberBanNotice, createGroupMessageReactionNotice, createGroupLuckKingNotice, createGroupHonorChangedNotice, createGroupApplyRequest, createGroupInviteRequest, createPrivateApplyRequest;
|
|
8239
9353
|
var init_create = __esm({
|
|
8240
9354
|
async "src/event/create/index.ts"() {
|
|
8241
9355
|
"use strict";
|
|
@@ -8336,6 +9450,21 @@ var init_create = __esm({
|
|
|
8336
9450
|
groupNoticeHandler(event);
|
|
8337
9451
|
return event;
|
|
8338
9452
|
};
|
|
9453
|
+
createGroupApplyRequest = (options) => {
|
|
9454
|
+
const event = new GroupApplyRequest(options);
|
|
9455
|
+
groupRequestHandler(event);
|
|
9456
|
+
return event;
|
|
9457
|
+
};
|
|
9458
|
+
createGroupInviteRequest = (options) => {
|
|
9459
|
+
const event = new GroupInviteRequest(options);
|
|
9460
|
+
groupRequestHandler(event);
|
|
9461
|
+
return event;
|
|
9462
|
+
};
|
|
9463
|
+
createPrivateApplyRequest = (options) => {
|
|
9464
|
+
const event = new PrivateApplyRequest(options);
|
|
9465
|
+
friendRequestHandler(event);
|
|
9466
|
+
return event;
|
|
9467
|
+
};
|
|
8339
9468
|
}
|
|
8340
9469
|
});
|
|
8341
9470
|
|
|
@@ -8497,8 +9626,8 @@ var init_event = __esm({
|
|
|
8497
9626
|
});
|
|
8498
9627
|
|
|
8499
9628
|
// src/adapter/input/index.ts
|
|
8500
|
-
import
|
|
8501
|
-
import
|
|
9629
|
+
import fs17 from "node:fs";
|
|
9630
|
+
import path16 from "node:path";
|
|
8502
9631
|
var index2, botID, AdapterConsole, adapter2;
|
|
8503
9632
|
var init_input = __esm({
|
|
8504
9633
|
async "src/adapter/input/index.ts"() {
|
|
@@ -8545,8 +9674,8 @@ var init_input = __esm({
|
|
|
8545
9674
|
if (text2.startsWith("log")) {
|
|
8546
9675
|
const level2 = text2.replace(/^log/, "").trim();
|
|
8547
9676
|
if (level2) {
|
|
8548
|
-
const
|
|
8549
|
-
if (
|
|
9677
|
+
const list3 = ["trace", "debug", "info", "warn", "error", "fatal"];
|
|
9678
|
+
if (list3.includes(level2)) {
|
|
8550
9679
|
const { updateLevel: updateLevel2 } = await init_config().then(() => config_exports);
|
|
8551
9680
|
updateLevel2(level2);
|
|
8552
9681
|
logger.info(`\u65E5\u5FD7\u7B49\u7EA7\u5DF2\u66F4\u65B0\u4E3A: ${level2}`);
|
|
@@ -8623,15 +9752,15 @@ var init_input = __esm({
|
|
|
8623
9752
|
async getUrl(data, ext) {
|
|
8624
9753
|
const cfg = adapter();
|
|
8625
9754
|
const name = (++index2).toString();
|
|
8626
|
-
const file =
|
|
8627
|
-
await
|
|
9755
|
+
const file = path16.join(consolePath, `${name}${ext}`);
|
|
9756
|
+
await fs17.promises.writeFile(file, await buffer(data));
|
|
8628
9757
|
if (cfg.console.isLocal) {
|
|
8629
|
-
return `http://127.0.0.1:${process.env.HTTP_PORT}/console/${name}${ext}`;
|
|
9758
|
+
return `http://127.0.0.1:${process.env.HTTP_PORT}/api/v1/console/${name}${ext}`;
|
|
8630
9759
|
}
|
|
8631
9760
|
if (cfg.console.host) {
|
|
8632
|
-
return `${cfg.console.host}/console/${name}${ext}?token=${cfg.console.token}`;
|
|
9761
|
+
return `${cfg.console.host}/api/v1/console/${name}${ext}?token=${cfg.console.token}`;
|
|
8633
9762
|
}
|
|
8634
|
-
return `http://127.0.0.1:${process.env.HTTP_PORT}/console/${name}${ext}?token=${cfg.console.token}`;
|
|
9763
|
+
return `http://127.0.0.1:${process.env.HTTP_PORT}/api/v1/console/${name}${ext}?token=${cfg.console.token}`;
|
|
8635
9764
|
}
|
|
8636
9765
|
};
|
|
8637
9766
|
adapter2 = new AdapterConsole();
|
|
@@ -8640,7 +9769,7 @@ var init_input = __esm({
|
|
|
8640
9769
|
});
|
|
8641
9770
|
|
|
8642
9771
|
// src/adapter/render/admin/cache.ts
|
|
8643
|
-
var index3, cache10, registerRender, unregisterRender,
|
|
9772
|
+
var index3, cache10, registerRender, unregisterRender, getRender2, callRender, getRenderCount, getRenderList, renderHtml, renderMultiHtml, RenderCache, render2, Renderer;
|
|
8644
9773
|
var init_cache2 = __esm({
|
|
8645
9774
|
"src/adapter/render/admin/cache.ts"() {
|
|
8646
9775
|
"use strict";
|
|
@@ -8663,7 +9792,7 @@ var init_cache2 = __esm({
|
|
|
8663
9792
|
logger.mark(`[render] ${logger.yellow("\u5378\u8F7D\u6210\u529F")}: ${app2.id}`);
|
|
8664
9793
|
return true;
|
|
8665
9794
|
};
|
|
8666
|
-
|
|
9795
|
+
getRender2 = (id) => {
|
|
8667
9796
|
if (cache10.length === 0) throw new Error("[\u8C03\u7528\u6E32\u67D3\u5668\u5931\u8D25] \u6E32\u67D3\u5668\u5217\u8868\u4E3A\u7A7A");
|
|
8668
9797
|
if (!id) {
|
|
8669
9798
|
const app3 = cache10[Math.floor(Math.random() * cache10.length)];
|
|
@@ -8679,14 +9808,14 @@ var init_cache2 = __esm({
|
|
|
8679
9808
|
return app2;
|
|
8680
9809
|
};
|
|
8681
9810
|
callRender = async (options, id) => {
|
|
8682
|
-
const res =
|
|
9811
|
+
const res = getRender2(id);
|
|
8683
9812
|
const result = await res.render(Object.assign(options, { encoding: "base64" }));
|
|
8684
9813
|
return result;
|
|
8685
9814
|
};
|
|
8686
9815
|
getRenderCount = () => cache10.length;
|
|
8687
9816
|
getRenderList = () => {
|
|
8688
|
-
const
|
|
8689
|
-
return
|
|
9817
|
+
const list3 = cache10.map((app2) => app2);
|
|
9818
|
+
return list3;
|
|
8690
9819
|
};
|
|
8691
9820
|
renderHtml = (data) => {
|
|
8692
9821
|
return callRender({
|
|
@@ -8736,7 +9865,7 @@ var init_cache2 = __esm({
|
|
|
8736
9865
|
* @returns 渲染器实例
|
|
8737
9866
|
*/
|
|
8738
9867
|
App(id = "") {
|
|
8739
|
-
return
|
|
9868
|
+
return getRender2(id);
|
|
8740
9869
|
}
|
|
8741
9870
|
/**
|
|
8742
9871
|
* 调用标准渲染器
|
|
@@ -8767,8 +9896,8 @@ var init_cache2 = __esm({
|
|
|
8767
9896
|
});
|
|
8768
9897
|
|
|
8769
9898
|
// src/adapter/render/admin/template.ts
|
|
8770
|
-
import
|
|
8771
|
-
import
|
|
9899
|
+
import fs18 from "node:fs";
|
|
9900
|
+
import path17 from "node:path";
|
|
8772
9901
|
import chokidar4 from "chokidar";
|
|
8773
9902
|
import template from "art-template";
|
|
8774
9903
|
var cache11, watcherCache, renderTpl, getCacheData, getOutputPath, watch2;
|
|
@@ -8785,11 +9914,11 @@ var init_template = __esm({
|
|
|
8785
9914
|
if (options.file.startsWith("http")) {
|
|
8786
9915
|
throw TypeError("\u4ED6\u55B5\u7684 \u4E0D\u4F1A\u771F\u7684\u6709\u7B28\u6BD4\u4F20\u4E2Ahttp\u6765\u5F53\u505A\u6A21\u677F\u5427...");
|
|
8787
9916
|
}
|
|
8788
|
-
const file =
|
|
9917
|
+
const file = path17.resolve(options.file);
|
|
8789
9918
|
const tplData = getCacheData(file);
|
|
8790
9919
|
const renderData = template.render(tplData, options.data);
|
|
8791
9920
|
const outputPath = getOutputPath(options.file, renderData, options.name);
|
|
8792
|
-
|
|
9921
|
+
fs18.writeFileSync(outputPath, renderData);
|
|
8793
9922
|
delete options.data;
|
|
8794
9923
|
delete options.name;
|
|
8795
9924
|
options.file = `file://${outputPath}`;
|
|
@@ -8807,17 +9936,17 @@ var init_template = __esm({
|
|
|
8807
9936
|
if (CachingData) {
|
|
8808
9937
|
return CachingData;
|
|
8809
9938
|
}
|
|
8810
|
-
const tplData =
|
|
9939
|
+
const tplData = fs18.readFileSync(file, "utf-8");
|
|
8811
9940
|
watch2(file, tplData);
|
|
8812
9941
|
return tplData;
|
|
8813
9942
|
};
|
|
8814
9943
|
getOutputPath = (file, data, name) => {
|
|
8815
|
-
const extname =
|
|
8816
|
-
const basename =
|
|
8817
|
-
const fileDir =
|
|
8818
|
-
const filePath =
|
|
9944
|
+
const extname = path17.extname(file);
|
|
9945
|
+
const basename = path17.basename(file, extname);
|
|
9946
|
+
const fileDir = path17.join(htmlPath, name || "render");
|
|
9947
|
+
const filePath = path17.join(fileDir, `${basename}-${Date.now()}${extname}`);
|
|
8819
9948
|
existToMkdirSync(fileDir);
|
|
8820
|
-
|
|
9949
|
+
fs18.writeFileSync(filePath, data);
|
|
8821
9950
|
return filePath;
|
|
8822
9951
|
};
|
|
8823
9952
|
watch2 = async (file, data) => {
|
|
@@ -8826,7 +9955,7 @@ var init_template = __esm({
|
|
|
8826
9955
|
const watcher = chokidar4.watch(file);
|
|
8827
9956
|
watcherCache.set(file, watcher);
|
|
8828
9957
|
watcher.on("change", () => {
|
|
8829
|
-
cache11.set(file,
|
|
9958
|
+
cache11.set(file, fs18.readFileSync(file, "utf-8"));
|
|
8830
9959
|
logger.info(`[\u6587\u4EF6\u53D8\u52A8] html\u6A21\u677F\u53D1\u9001\u53D8\u52A8: ${file}`);
|
|
8831
9960
|
});
|
|
8832
9961
|
watcher.on("unlink", () => {
|
|
@@ -8873,7 +10002,7 @@ var init_static = __esm({
|
|
|
8873
10002
|
});
|
|
8874
10003
|
|
|
8875
10004
|
// src/adapter/render/connect/ws.ts
|
|
8876
|
-
import
|
|
10005
|
+
import fs19 from "node:fs";
|
|
8877
10006
|
import crypto from "node:crypto";
|
|
8878
10007
|
var WebSocketRender;
|
|
8879
10008
|
var init_ws2 = __esm({
|
|
@@ -8949,7 +10078,7 @@ var init_ws2 = __esm({
|
|
|
8949
10078
|
logger.warn(`[WebSocket] \u8BBF\u95EE\u7684\u8DEF\u5F84\u975E\u6CD5: echo: ${echo} data: ${JSON.stringify(data)}`);
|
|
8950
10079
|
return this.socket.send(JSON.stringify({ echo, status: "error", data: "\u975E\u6CD5\u7684\u8BBF\u95EE\u8DEF\u5F84" }));
|
|
8951
10080
|
}
|
|
8952
|
-
const fileData =
|
|
10081
|
+
const fileData = fs19.readFileSync(data.file);
|
|
8953
10082
|
return this.socket.send(JSON.stringify({ echo, status: "ok", data: fileData }));
|
|
8954
10083
|
}
|
|
8955
10084
|
render(data) {
|
|
@@ -9091,9 +10220,9 @@ var init_server2 = __esm({
|
|
|
9091
10220
|
WebSocketServerRenderer = class extends WebSocketRender {
|
|
9092
10221
|
/** 请求实例 */
|
|
9093
10222
|
request;
|
|
9094
|
-
constructor(socket,
|
|
10223
|
+
constructor(socket, request2) {
|
|
9095
10224
|
super(socket);
|
|
9096
|
-
this.request =
|
|
10225
|
+
this.request = request2;
|
|
9097
10226
|
}
|
|
9098
10227
|
connection() {
|
|
9099
10228
|
const cfg = render();
|
|
@@ -9115,8 +10244,8 @@ var init_server2 = __esm({
|
|
|
9115
10244
|
return true;
|
|
9116
10245
|
}
|
|
9117
10246
|
};
|
|
9118
|
-
listeners.on("ws:connection:puppeteer", (socket,
|
|
9119
|
-
const server2 = new WebSocketServerRenderer(socket,
|
|
10247
|
+
listeners.on("ws:connection:puppeteer", (socket, request2) => {
|
|
10248
|
+
const server2 = new WebSocketServerRenderer(socket, request2);
|
|
9120
10249
|
if (!server2.connection()) return;
|
|
9121
10250
|
server2.init();
|
|
9122
10251
|
});
|
|
@@ -9124,7 +10253,7 @@ var init_server2 = __esm({
|
|
|
9124
10253
|
});
|
|
9125
10254
|
|
|
9126
10255
|
// src/adapter/render/connect/http.ts
|
|
9127
|
-
import
|
|
10256
|
+
import axios5 from "axios";
|
|
9128
10257
|
import crypto3 from "node:crypto";
|
|
9129
10258
|
var createHttpRenderClient;
|
|
9130
10259
|
var init_http = __esm({
|
|
@@ -9145,17 +10274,17 @@ var init_http = __esm({
|
|
|
9145
10274
|
url = url.replace("/puppeteer", "");
|
|
9146
10275
|
const headers = { authorization: crypto3.createHash("md5").update(`Bearer ${token}`).digest("hex") };
|
|
9147
10276
|
try {
|
|
9148
|
-
const result = await
|
|
10277
|
+
const result = await axios5.get(`${url}/ping`, { timeout: 5e3 });
|
|
9149
10278
|
if (result.status !== 200 || String(result.data.status) !== "200") {
|
|
9150
10279
|
logger.error(`[render][http] \u521B\u5EFA\u6E32\u67D3\u5668\u5931\u8D25: \u65E0\u6CD5\u8FDE\u63A5 ${url}`);
|
|
9151
10280
|
}
|
|
9152
|
-
const auth2 = await
|
|
10281
|
+
const auth2 = await axios5.get(`${url}/auth`, { headers, timeout: 5e3 });
|
|
9153
10282
|
if (auth2.status !== 200 || String(auth2.data.status) !== "200") {
|
|
9154
10283
|
logger.error(`[render][http] \u521B\u5EFA\u6E32\u67D3\u5668\u5931\u8D25: \u9274\u6743\u9519\u8BEF ${url}`);
|
|
9155
10284
|
return;
|
|
9156
10285
|
}
|
|
9157
10286
|
} catch (error) {
|
|
9158
|
-
if (
|
|
10287
|
+
if (axios5.isAxiosError(error)) {
|
|
9159
10288
|
const { response } = error;
|
|
9160
10289
|
logger.error(`[render][http] \u521B\u5EFA\u6E32\u67D3\u5668\u5931\u8D25: ${response == null ? void 0 : response.status} ${response == null ? void 0 : response.statusText} - ${JSON.stringify((response == null ? void 0 : response.data) || "\u672A\u77E5\u9519\u8BEF")}`);
|
|
9161
10290
|
} else {
|
|
@@ -9166,13 +10295,13 @@ var init_http = __esm({
|
|
|
9166
10295
|
const index4 = registerRender("puppeteer", async (options) => {
|
|
9167
10296
|
var _a;
|
|
9168
10297
|
try {
|
|
9169
|
-
const result = await
|
|
10298
|
+
const result = await axios5.post(`${url}/puppeteer`, options, { headers });
|
|
9170
10299
|
if (result.status !== 200) {
|
|
9171
10300
|
throw new Error(`[render][http] \u6E32\u67D3\u5931\u8D25: ${result.status} ${result.statusText} - ${((_a = result.data) == null ? void 0 : _a.message) || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
9172
10301
|
}
|
|
9173
10302
|
return result.data;
|
|
9174
10303
|
} catch (error) {
|
|
9175
|
-
if (
|
|
10304
|
+
if (axios5.isAxiosError(error)) {
|
|
9176
10305
|
if (!error.response) {
|
|
9177
10306
|
unregisterRender(index4);
|
|
9178
10307
|
throw new Error(`[render][http] \u7F51\u7EDC\u8FDE\u63A5\u5931\u8D25: ${error.message}`);
|
|
@@ -9218,7 +10347,7 @@ __export(adapter_exports, {
|
|
|
9218
10347
|
Renderer: () => Renderer,
|
|
9219
10348
|
adapter: () => adapter2,
|
|
9220
10349
|
callRender: () => callRender,
|
|
9221
|
-
getRender: () =>
|
|
10350
|
+
getRender: () => getRender2,
|
|
9222
10351
|
getRenderCount: () => getRenderCount,
|
|
9223
10352
|
getRenderList: () => getRenderList,
|
|
9224
10353
|
registerRender: () => registerRender,
|
|
@@ -9655,8 +10784,8 @@ init_bot();
|
|
|
9655
10784
|
init_esm_shims();
|
|
9656
10785
|
init_internal();
|
|
9657
10786
|
init_bot();
|
|
9658
|
-
import { EventEmitter as
|
|
9659
|
-
var Other = class extends
|
|
10787
|
+
import { EventEmitter as EventEmitter4 } from "node:events";
|
|
10788
|
+
var Other = class extends EventEmitter4 {
|
|
9660
10789
|
/** 框架名称 */
|
|
9661
10790
|
name = "karin";
|
|
9662
10791
|
/**
|
|
@@ -9774,15 +10903,15 @@ var Other = class extends EventEmitter3 {
|
|
|
9774
10903
|
}
|
|
9775
10904
|
};
|
|
9776
10905
|
var events = () => {
|
|
9777
|
-
listeners.on("ws:connection", (socket,
|
|
9778
|
-
const key = `ws:connection:${
|
|
9779
|
-
debug(`on ws:connection host: ${
|
|
10906
|
+
listeners.on("ws:connection", (socket, request2) => {
|
|
10907
|
+
const key = `ws:connection:${request2.url || "/"}`;
|
|
10908
|
+
debug(`on ws:connection host: ${request2.headers.host} url: ${request2.url}`);
|
|
9780
10909
|
if (!other.listenerCount(key)) {
|
|
9781
10910
|
socket.close();
|
|
9782
|
-
logger.warn(`[server][webSocket] \u8FDE\u63A5\u65AD\u5F00 \u672A\u627E\u5230\u7ED1\u5B9A\u7684\u8DEF\u7531: ${
|
|
10911
|
+
logger.warn(`[server][webSocket] \u8FDE\u63A5\u65AD\u5F00 \u672A\u627E\u5230\u7ED1\u5B9A\u7684\u8DEF\u7531: ${request2.url || "/"}`);
|
|
9783
10912
|
return;
|
|
9784
10913
|
}
|
|
9785
|
-
other.emit(key, socket,
|
|
10914
|
+
other.emit(key, socket, request2);
|
|
9786
10915
|
});
|
|
9787
10916
|
listeners.on("file:change", (type, old, data) => {
|
|
9788
10917
|
other.emit("file:change", type, old, data);
|
|
@@ -9815,12 +10944,12 @@ var buttonHandle = async (reg, args) => {
|
|
|
9815
10944
|
const next = () => {
|
|
9816
10945
|
isnext = true;
|
|
9817
10946
|
};
|
|
9818
|
-
const
|
|
9819
|
-
if (
|
|
9820
|
-
if (Array.isArray(
|
|
9821
|
-
button3.push(...
|
|
10947
|
+
const list3 = await info.fnc(next, args);
|
|
10948
|
+
if (list3) {
|
|
10949
|
+
if (Array.isArray(list3)) {
|
|
10950
|
+
button3.push(...list3);
|
|
9822
10951
|
} else {
|
|
9823
|
-
button3.push(
|
|
10952
|
+
button3.push(list3);
|
|
9824
10953
|
}
|
|
9825
10954
|
}
|
|
9826
10955
|
if (!isnext) return button3;
|
|
@@ -10006,24 +11135,24 @@ var logs = (version, data, length = 1, reverse = false) => {
|
|
|
10006
11135
|
if (typeof length !== "number") {
|
|
10007
11136
|
throw new TypeError("\u63D0\u53D6\u957F\u5EA6\u5FC5\u987B\u4E3A\u6570\u5B57");
|
|
10008
11137
|
}
|
|
10009
|
-
const
|
|
10010
|
-
const keys = Object.keys(
|
|
11138
|
+
const list3 = parseChangelog(data);
|
|
11139
|
+
const keys = Object.keys(list3);
|
|
10011
11140
|
const index4 = keys.indexOf(version);
|
|
10012
11141
|
const start2 = reverse ? index4 - length : index4;
|
|
10013
11142
|
const end = reverse ? index4 : index4 + length;
|
|
10014
|
-
const versions = keys.slice(start2, end).map((key) =>
|
|
11143
|
+
const versions = keys.slice(start2, end).map((key) => list3[key] ? list3[key] : "");
|
|
10015
11144
|
return versions.join("");
|
|
10016
11145
|
};
|
|
10017
11146
|
var range = (data, startVersion, endVersion) => {
|
|
10018
|
-
const
|
|
10019
|
-
const keys = Object.keys(
|
|
11147
|
+
const list3 = parseChangelog(data);
|
|
11148
|
+
const keys = Object.keys(list3);
|
|
10020
11149
|
const start2 = keys.indexOf(startVersion);
|
|
10021
11150
|
const end = keys.indexOf(endVersion);
|
|
10022
11151
|
if (start2 > end) {
|
|
10023
|
-
const versions2 = keys.slice(end, start2).map((key) =>
|
|
11152
|
+
const versions2 = keys.slice(end, start2).map((key) => list3[key] ? list3[key] : "");
|
|
10024
11153
|
return versions2.join("");
|
|
10025
11154
|
}
|
|
10026
|
-
const versions = keys.slice(start2, end).map((key) =>
|
|
11155
|
+
const versions = keys.slice(start2, end).map((key) => list3[key] ? list3[key] : "");
|
|
10027
11156
|
return versions.join("");
|
|
10028
11157
|
};
|
|
10029
11158
|
var parseChangelog = (data) => {
|
|
@@ -10086,7 +11215,33 @@ __export(system_exports, {
|
|
|
10086
11215
|
});
|
|
10087
11216
|
init_esm_shims();
|
|
10088
11217
|
init_ip();
|
|
10089
|
-
|
|
11218
|
+
|
|
11219
|
+
// src/utils/system/pid.ts
|
|
11220
|
+
init_esm_shims();
|
|
11221
|
+
init_exec();
|
|
11222
|
+
|
|
11223
|
+
// src/utils/system/system.ts
|
|
11224
|
+
init_esm_shims();
|
|
11225
|
+
import os3 from "node:os";
|
|
11226
|
+
import fs20 from "node:fs";
|
|
11227
|
+
var isWin2 = os3.platform() === "win32";
|
|
11228
|
+
var isLinux2 = os3.platform() === "linux";
|
|
11229
|
+
var isMac2 = os3.platform() === "darwin";
|
|
11230
|
+
var isDocker = fs20.existsSync("/.dockerenv");
|
|
11231
|
+
var isRoot = os3.userInfo().uid === 0;
|
|
11232
|
+
|
|
11233
|
+
// src/utils/system/pid.ts
|
|
11234
|
+
var getPid = async (port2) => {
|
|
11235
|
+
const command2 = isWin2 ? `netstat -ano | findstr :${port2}` : `lsof -i:${port2} | grep LISTEN | awk '{print $2}'`;
|
|
11236
|
+
const { stdout } = await exec(command2);
|
|
11237
|
+
if (isWin2) {
|
|
11238
|
+
const pid = stdout.toString().split(/\s+/).filter(Boolean).pop();
|
|
11239
|
+
return Number(pid);
|
|
11240
|
+
}
|
|
11241
|
+
return Number(stdout);
|
|
11242
|
+
};
|
|
11243
|
+
|
|
11244
|
+
// src/utils/system/index.ts
|
|
10090
11245
|
init_exec();
|
|
10091
11246
|
init_time();
|
|
10092
11247
|
init_class();
|
|
@@ -10104,15 +11259,12 @@ var importModule = async (url, isRefresh = false) => {
|
|
|
10104
11259
|
}
|
|
10105
11260
|
};
|
|
10106
11261
|
|
|
10107
|
-
// src/utils/system/index.ts
|
|
10108
|
-
init_system();
|
|
10109
|
-
|
|
10110
11262
|
// src/utils/system/update.ts
|
|
10111
11263
|
init_esm_shims();
|
|
10112
11264
|
init_exec();
|
|
10113
11265
|
init_require();
|
|
10114
11266
|
init_list();
|
|
10115
|
-
import
|
|
11267
|
+
import fs21 from "node:fs";
|
|
10116
11268
|
var getPkg = (isForcibly = false) => {
|
|
10117
11269
|
return requireFile("package.json", { force: isForcibly });
|
|
10118
11270
|
};
|
|
@@ -10140,8 +11292,8 @@ var getPkgVersion = async (name) => {
|
|
|
10140
11292
|
const reg = new RegExp(`${name}@(\\d+\\.\\d+\\.\\d+)`, "gm");
|
|
10141
11293
|
const result = reg.exec(stdout.toString());
|
|
10142
11294
|
if (result == null ? void 0 : result[1]) return result[1];
|
|
10143
|
-
const
|
|
10144
|
-
return ((_b =
|
|
11295
|
+
const pkg2 = await getPkg();
|
|
11296
|
+
return ((_b = pkg2 == null ? void 0 : pkg2.dependencies) == null ? void 0 : _b[name]) || ((_c = pkg2 == null ? void 0 : pkg2.devDependencies) == null ? void 0 : _c[name]) || ((_d = pkg2 == null ? void 0 : pkg2.peerDependencies) == null ? void 0 : _d[name]);
|
|
10145
11297
|
};
|
|
10146
11298
|
var getRemotePkgVersion = async (name, tag = "latest") => {
|
|
10147
11299
|
var _a;
|
|
@@ -10181,32 +11333,32 @@ var updatePkg = async (name, tag = "latest") => {
|
|
|
10181
11333
|
var updateAllPkg = async () => {
|
|
10182
11334
|
const logger3 = (global == null ? void 0 : global.logger) || console;
|
|
10183
11335
|
try {
|
|
10184
|
-
const
|
|
10185
|
-
|
|
11336
|
+
const list3 = await getPlugins("npm", false);
|
|
11337
|
+
list3.push("node-karin");
|
|
10186
11338
|
const state = {};
|
|
10187
|
-
const
|
|
11339
|
+
const tips2 = ["\n------- \u66F4\u65B0npm\u63D2\u4EF6 --------"];
|
|
10188
11340
|
const cmd = ["pnpm up"];
|
|
10189
|
-
const
|
|
11341
|
+
const pkg2 = await getPkg();
|
|
10190
11342
|
const result = [];
|
|
10191
|
-
await Promise.all(
|
|
11343
|
+
await Promise.all(list3.map(async (name) => {
|
|
10192
11344
|
const local = await getPkgVersion(name);
|
|
10193
|
-
const remote = await getRemotePkgVersion(name) ||
|
|
11345
|
+
const remote = await getRemotePkgVersion(name) || pkg2.dependencies[name];
|
|
10194
11346
|
if (local === remote) {
|
|
10195
|
-
|
|
11347
|
+
tips2.push(`[${name}][\u65E0\u66F4\u65B0] ${local} => ${remote}`);
|
|
10196
11348
|
return;
|
|
10197
11349
|
}
|
|
10198
|
-
|
|
11350
|
+
tips2.push(`\u66F4\u65B0${name} ${local} => ${remote}`);
|
|
10199
11351
|
cmd.push(`${name}@${remote}`);
|
|
10200
11352
|
state[name] = { local, remote };
|
|
10201
11353
|
}));
|
|
10202
11354
|
if (cmd.length === 1) {
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
logger3.info(
|
|
11355
|
+
tips2.push("\u6CA1\u6709\u53EF\u66F4\u65B0\u7684\u63D2\u4EF6~");
|
|
11356
|
+
tips2.push("---------------------------");
|
|
11357
|
+
logger3.info(tips2.join("\n"));
|
|
10206
11358
|
return "\u6CA1\u6709\u53EF\u66F4\u65B0\u7684\u63D2\u4EF6~";
|
|
10207
11359
|
} else {
|
|
10208
|
-
|
|
10209
|
-
logger3.info(
|
|
11360
|
+
tips2.push("----------------------------");
|
|
11361
|
+
logger3.info(tips2.join("\n"));
|
|
10210
11362
|
}
|
|
10211
11363
|
const shell = cmd.join(" ");
|
|
10212
11364
|
logger3.info(`\u5F00\u59CB\u66F4\u65B0: ${shell}`);
|
|
@@ -10242,8 +11394,8 @@ var checkGitPluginUpdate = async (filePath, time2 = 120) => {
|
|
|
10242
11394
|
var _a;
|
|
10243
11395
|
const logger3 = (global == null ? void 0 : global.logger) || console;
|
|
10244
11396
|
try {
|
|
10245
|
-
if (!
|
|
10246
|
-
if (!
|
|
11397
|
+
if (!fs21.existsSync(filePath)) return { status: "error", data: new Error("\u8DEF\u5F84\u4E0D\u5B58\u5728") };
|
|
11398
|
+
if (!fs21.existsSync(`${filePath}/.git`)) return { status: "error", data: new Error("\u8BE5\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2Agit\u4ED3\u5E93") };
|
|
10247
11399
|
const timer = setTimeout(() => {
|
|
10248
11400
|
return { status: "failed", data: "\u6267\u884C\u8D85\u65F6" };
|
|
10249
11401
|
}, time2 * 1e3);
|
|
@@ -10267,11 +11419,11 @@ var checkGitPluginUpdate = async (filePath, time2 = 120) => {
|
|
|
10267
11419
|
}
|
|
10268
11420
|
};
|
|
10269
11421
|
var getCommit = async (options) => {
|
|
10270
|
-
const { path:
|
|
11422
|
+
const { path: path18, count: count3 = 1, hash, branch } = options;
|
|
10271
11423
|
let cmd = `git log -${count3} --format="[%ad]%s %n" --date="format:%m-%d %H:%M"`;
|
|
10272
11424
|
if (hash) cmd = `git log ${hash}..HEAD --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
|
|
10273
11425
|
if (branch) cmd = `git log -${count3} ${branch} --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
|
|
10274
|
-
const { stdout, error } = await exec(cmd, { cwd:
|
|
11426
|
+
const { stdout, error } = await exec(cmd, { cwd: path18 });
|
|
10275
11427
|
if (error) {
|
|
10276
11428
|
throw error;
|
|
10277
11429
|
}
|
|
@@ -10294,8 +11446,8 @@ var getTime = async (filePath) => {
|
|
|
10294
11446
|
var updateGitPlugin = async (filePath, cmd = "git pull", time2 = 120) => {
|
|
10295
11447
|
const logger3 = (global == null ? void 0 : global.logger) || console;
|
|
10296
11448
|
try {
|
|
10297
|
-
if (!
|
|
10298
|
-
if (!
|
|
11449
|
+
if (!fs21.existsSync(filePath)) return { status: "failed", data: "\u8DEF\u5F84\u4E0D\u5B58\u5728" };
|
|
11450
|
+
if (!fs21.existsSync(`${filePath}/.git`)) return { status: "failed", data: "\u8BE5\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2Agit\u4ED3\u5E93" };
|
|
10299
11451
|
const timer = setTimeout(() => {
|
|
10300
11452
|
return { status: "failed", data: "\u6267\u884C\u8D85\u65F6" };
|
|
10301
11453
|
}, time2 * 1e3);
|
|
@@ -10332,28 +11484,28 @@ var updateGitPlugin = async (filePath, cmd = "git pull", time2 = 120) => {
|
|
|
10332
11484
|
var updateAllGitPlugin = async (cmd = "git pull", time2 = 120) => {
|
|
10333
11485
|
try {
|
|
10334
11486
|
const logger3 = (global == null ? void 0 : global.logger) || console;
|
|
10335
|
-
const
|
|
10336
|
-
const
|
|
10337
|
-
if (!
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
logger3.info(
|
|
11487
|
+
const list3 = await getPlugins("git", false);
|
|
11488
|
+
const tips2 = ["\n------- \u66F4\u65B0git\u63D2\u4EF6 --------"];
|
|
11489
|
+
if (!list3.length) {
|
|
11490
|
+
tips2.push("\u6CA1\u6709\u53EF\u66F4\u65B0\u7684\u63D2\u4EF6~");
|
|
11491
|
+
tips2.push("----------------------------");
|
|
11492
|
+
logger3.info(tips2.join("\n"));
|
|
10341
11493
|
return "\u6CA1\u6709\u53EF\u66F4\u65B0\u7684\u63D2\u4EF6~";
|
|
10342
11494
|
}
|
|
10343
11495
|
const result = [];
|
|
10344
|
-
await Promise.allSettled(
|
|
11496
|
+
await Promise.allSettled(list3.map(async (name) => {
|
|
10345
11497
|
const filePath = `./plugins/${name}`;
|
|
10346
11498
|
const { status, data } = await updateGitPlugin(filePath, cmd, time2);
|
|
10347
11499
|
if (status === "ok") {
|
|
10348
|
-
|
|
11500
|
+
tips2.push(`[${name}][\u66F4\u65B0\u6210\u529F] ${data}`);
|
|
10349
11501
|
result.push(`[${name}][\u66F4\u65B0\u6210\u529F] ${data}`);
|
|
10350
11502
|
} else {
|
|
10351
|
-
|
|
11503
|
+
tips2.push(`[${name}][\u66F4\u65B0\u5931\u8D25] ${data}`);
|
|
10352
11504
|
result.push(`[${name}][\u66F4\u65B0\u5931\u8D25] ${data}`);
|
|
10353
11505
|
}
|
|
10354
11506
|
}));
|
|
10355
|
-
|
|
10356
|
-
logger3.info(
|
|
11507
|
+
tips2.push("----------------------------");
|
|
11508
|
+
logger3.info(tips2.join("\n"));
|
|
10357
11509
|
return result.join("\n");
|
|
10358
11510
|
} catch (error) {
|
|
10359
11511
|
logger.error(error);
|
|
@@ -10556,18 +11708,18 @@ init_esm_shims();
|
|
|
10556
11708
|
// src/adapter/onebot/core/convert.ts
|
|
10557
11709
|
init_esm_shims();
|
|
10558
11710
|
init_message2();
|
|
10559
|
-
import
|
|
10560
|
-
var buildError = (selfId, action,
|
|
11711
|
+
import fs22 from "node:fs";
|
|
11712
|
+
var buildError = (selfId, action, request2, error) => {
|
|
10561
11713
|
if (error) {
|
|
10562
11714
|
const err = JSON.stringify(error, null, 2).replace(/\\n/g, "\n");
|
|
10563
11715
|
return new Error(`[${selfId}][sendApi] \u8BF7\u6C42\u9519\u8BEF:
|
|
10564
11716
|
action: ${action}
|
|
10565
|
-
params: ${
|
|
11717
|
+
params: ${request2}
|
|
10566
11718
|
error: ${err}}`);
|
|
10567
11719
|
}
|
|
10568
11720
|
logger.error(`[${selfId}][sendApi][\u8BF7\u6C42\u9519\u8BEF]:
|
|
10569
11721
|
action: ${action}
|
|
10570
|
-
params: ${
|
|
11722
|
+
params: ${request2}`);
|
|
10571
11723
|
};
|
|
10572
11724
|
function AdapterConvertKarin(data) {
|
|
10573
11725
|
const elements = [];
|
|
@@ -10619,9 +11771,9 @@ function AdapterConvertKarin(data) {
|
|
|
10619
11771
|
}
|
|
10620
11772
|
var fileToBase64 = (file, url) => {
|
|
10621
11773
|
if (!url || !file.startsWith("file://")) return file;
|
|
10622
|
-
const
|
|
11774
|
+
const list3 = ["127.0.0.1", "localhost"];
|
|
10623
11775
|
const link = new URL(url);
|
|
10624
|
-
return
|
|
11776
|
+
return list3.includes(link.hostname) ? file : `base64://${fs22.readFileSync(file.replace("file://", "")).toString("base64")}`;
|
|
10625
11777
|
};
|
|
10626
11778
|
var KarinConvertAdapter = (data, onebot) => {
|
|
10627
11779
|
var _a, _b, _c;
|
|
@@ -10732,7 +11884,7 @@ var createMessage = (event, bot) => {
|
|
|
10732
11884
|
debug("onebot:createMessage", event);
|
|
10733
11885
|
const time2 = event.time;
|
|
10734
11886
|
if (event.message_type === "private") {
|
|
10735
|
-
if (event.sub_type === "friend") {
|
|
11887
|
+
if (event.sub_type === "friend" || event.sub_type === "other") {
|
|
10736
11888
|
const userId = event.sender.user_id + "";
|
|
10737
11889
|
const contact3 = contactFriend(userId);
|
|
10738
11890
|
const sender2 = senderFriend(
|
|
@@ -10772,7 +11924,9 @@ var createMessage = (event, bot) => {
|
|
|
10772
11924
|
time: time2,
|
|
10773
11925
|
srcReply: (elements) => bot.sendMsg(contact3, elements)
|
|
10774
11926
|
});
|
|
11927
|
+
return;
|
|
10775
11928
|
}
|
|
11929
|
+
logger.warn(`[AdapterOneBot] \u6536\u5230\u672A\u77E5\u7684\u79C1\u804A\u4E8B\u4EF6: ${JSON.stringify(event)}`);
|
|
10776
11930
|
return;
|
|
10777
11931
|
}
|
|
10778
11932
|
if (event.message_type === "group" && event.sub_type === "normal") {
|
|
@@ -11130,7 +12284,75 @@ var createNotice = (event, bot) => {
|
|
|
11130
12284
|
}
|
|
11131
12285
|
logger.warn(`[AdapterOneBot] \u6536\u5230\u672A\u77E5\u4E8B\u4EF6: ${JSON.stringify(event)}`);
|
|
11132
12286
|
};
|
|
12287
|
+
|
|
12288
|
+
// src/adapter/onebot/create/request.ts
|
|
12289
|
+
init_esm_shims();
|
|
12290
|
+
init_event();
|
|
12291
|
+
await init_create();
|
|
11133
12292
|
var createRequest = (event, bot) => {
|
|
12293
|
+
const time2 = event.time;
|
|
12294
|
+
const userId = event.user_id + "";
|
|
12295
|
+
if (event.request_type === "friend" /* Friend */) {
|
|
12296
|
+
const contact3 = contactFriend(userId);
|
|
12297
|
+
createPrivateApplyRequest({
|
|
12298
|
+
bot,
|
|
12299
|
+
time: time2,
|
|
12300
|
+
contact: contact3,
|
|
12301
|
+
rawEvent: event,
|
|
12302
|
+
subEvent: "friendApply",
|
|
12303
|
+
eventId: `request:${event.flag}`,
|
|
12304
|
+
sender: senderFriend(userId, ""),
|
|
12305
|
+
srcReply: (elements) => bot.sendMsg(contact3, elements),
|
|
12306
|
+
content: {
|
|
12307
|
+
applierId: userId,
|
|
12308
|
+
message: event.comment,
|
|
12309
|
+
flag: event.flag
|
|
12310
|
+
}
|
|
12311
|
+
});
|
|
12312
|
+
return;
|
|
12313
|
+
}
|
|
12314
|
+
if (event.request_type === "group" /* Group */ && event.sub_type === "add") {
|
|
12315
|
+
const groupId = event.group_id + "";
|
|
12316
|
+
const contact3 = contactGroup(groupId);
|
|
12317
|
+
createGroupApplyRequest({
|
|
12318
|
+
bot,
|
|
12319
|
+
time: time2,
|
|
12320
|
+
contact: contact3,
|
|
12321
|
+
rawEvent: event,
|
|
12322
|
+
subEvent: "groupApply",
|
|
12323
|
+
eventId: `request:${event.flag}`,
|
|
12324
|
+
sender: senderGroup(userId, "member"),
|
|
12325
|
+
srcReply: (elements) => bot.sendMsg(contact3, elements),
|
|
12326
|
+
content: {
|
|
12327
|
+
applierId: userId,
|
|
12328
|
+
inviterId: "",
|
|
12329
|
+
reason: event.comment,
|
|
12330
|
+
flag: event.flag,
|
|
12331
|
+
groupId
|
|
12332
|
+
}
|
|
12333
|
+
});
|
|
12334
|
+
return;
|
|
12335
|
+
}
|
|
12336
|
+
if (event.request_type === "group" /* Group */ && event.sub_type === "invite") {
|
|
12337
|
+
const groupId = event.group_id + "";
|
|
12338
|
+
const contact3 = contactGroup(groupId);
|
|
12339
|
+
createGroupInviteRequest({
|
|
12340
|
+
bot,
|
|
12341
|
+
time: time2,
|
|
12342
|
+
contact: contact3,
|
|
12343
|
+
rawEvent: event,
|
|
12344
|
+
subEvent: "groupInvite",
|
|
12345
|
+
eventId: `request:${event.flag}`,
|
|
12346
|
+
sender: senderGroup(userId, "member"),
|
|
12347
|
+
srcReply: (elements) => bot.sendMsg(contact3, elements),
|
|
12348
|
+
content: {
|
|
12349
|
+
inviterId: userId,
|
|
12350
|
+
flag: event.flag
|
|
12351
|
+
}
|
|
12352
|
+
});
|
|
12353
|
+
return;
|
|
12354
|
+
}
|
|
12355
|
+
logger.warn(`[AdapterOneBot] \u6536\u5230\u672A\u77E5\u4E8B\u4EF6: ${JSON.stringify(event)}`);
|
|
11134
12356
|
};
|
|
11135
12357
|
|
|
11136
12358
|
// src/adapter/onebot/core/base.ts
|
|
@@ -11898,8 +13120,8 @@ var AdapterOneBot = class extends AdapterBase {
|
|
|
11898
13120
|
* @returns 群成员列表数组
|
|
11899
13121
|
*/
|
|
11900
13122
|
async getGroupMemberList(groupId, refresh) {
|
|
11901
|
-
const
|
|
11902
|
-
return
|
|
13123
|
+
const list3 = await this.sendApi("get_group_member_list" /* getGroupMemberList */, { group_id: Number(groupId), no_cache: refresh });
|
|
13124
|
+
return list3.map((v) => {
|
|
11903
13125
|
const targetId = v.user_id + "";
|
|
11904
13126
|
return {
|
|
11905
13127
|
...v,
|
|
@@ -12058,7 +13280,7 @@ var AdapterOneBot = class extends AdapterBase {
|
|
|
12058
13280
|
* @returns EssenceMessageBody对象
|
|
12059
13281
|
*/
|
|
12060
13282
|
async getGroupHighlights(groupId, page, pageSize) {
|
|
12061
|
-
const
|
|
13283
|
+
const list3 = [];
|
|
12062
13284
|
const res = await this.sendApi("get_essence_msg_list" /* getEssenceMsgList */, { group_id: Number(groupId) });
|
|
12063
13285
|
for (const v of res) {
|
|
12064
13286
|
const { message_seq: messageSeq, elements } = await this.getMsg({
|
|
@@ -12068,7 +13290,7 @@ var AdapterOneBot = class extends AdapterBase {
|
|
|
12068
13290
|
}, v.message_id + "");
|
|
12069
13291
|
const senderId = v.sender_id + "";
|
|
12070
13292
|
const operatorId = v.operator_id + "";
|
|
12071
|
-
|
|
13293
|
+
list3.push({
|
|
12072
13294
|
/** 群ID */
|
|
12073
13295
|
groupId,
|
|
12074
13296
|
/** 发送者Id */
|
|
@@ -12107,7 +13329,7 @@ var AdapterOneBot = class extends AdapterBase {
|
|
|
12107
13329
|
json_elements: JSON.stringify(elements)
|
|
12108
13330
|
});
|
|
12109
13331
|
}
|
|
12110
|
-
return
|
|
13332
|
+
return list3;
|
|
12111
13333
|
}
|
|
12112
13334
|
/**
|
|
12113
13335
|
* 精华消息
|
|
@@ -12367,7 +13589,10 @@ var WsAdapterOneBot11 = class extends AdapterOneBot {
|
|
|
12367
13589
|
this.socket.on("message", (rawData) => {
|
|
12368
13590
|
const str = rawData.toString();
|
|
12369
13591
|
const json3 = JSON.parse(str);
|
|
12370
|
-
const data =
|
|
13592
|
+
const data = {
|
|
13593
|
+
...json3,
|
|
13594
|
+
self_id: this.selfId
|
|
13595
|
+
};
|
|
12371
13596
|
if (json3.echo) {
|
|
12372
13597
|
logger.bot("debug", this.selfId, `Api\u8C03\u7528\u56DE\u5E94: ${str}`);
|
|
12373
13598
|
return this.socket.emit(json3.echo, json3);
|
|
@@ -12391,25 +13616,24 @@ var WsAdapterOneBot11 = class extends AdapterOneBot {
|
|
|
12391
13616
|
async setBotInfo() {
|
|
12392
13617
|
const info = await this.sendApi("get_login_info" /* getLoginInfo */, {});
|
|
12393
13618
|
this.account.name = info.nickname;
|
|
12394
|
-
this.account.selfId = info.user_id + "";
|
|
12395
13619
|
this.account.avatar = `https://q1.qlogo.cn/g?b=qq&s=0&nk=${info.user_id}`;
|
|
12396
13620
|
}
|
|
12397
13621
|
async sendApi(action, params, time2 = 120) {
|
|
12398
13622
|
if (!time2) time2 = config_exports2.timeout();
|
|
12399
13623
|
const echo = ++this.seq + "";
|
|
12400
|
-
const
|
|
12401
|
-
logger.bot("debug", this.selfId, `\u53D1\u9001Api\u8BF7\u6C42 ${action}: ${
|
|
13624
|
+
const request2 = JSON.stringify({ echo, action, params });
|
|
13625
|
+
logger.bot("debug", this.selfId, `\u53D1\u9001Api\u8BF7\u6C42 ${action}: ${request2}`);
|
|
12402
13626
|
return new Promise((resolve, reject) => {
|
|
12403
13627
|
const timeoutId = setTimeout(() => {
|
|
12404
|
-
reject(buildError(this.selfId, action,
|
|
13628
|
+
reject(buildError(this.selfId, action, request2, "\u8BF7\u6C42\u8D85\u65F6"));
|
|
12405
13629
|
}, time2 * 1e3);
|
|
12406
|
-
this.socket.send(
|
|
13630
|
+
this.socket.send(request2);
|
|
12407
13631
|
this.socket.once(echo, (data) => {
|
|
12408
13632
|
clearTimeout(timeoutId);
|
|
12409
13633
|
if (data.status === "ok") {
|
|
12410
13634
|
resolve(data.data);
|
|
12411
13635
|
} else {
|
|
12412
|
-
reject(buildError(this.selfId, action,
|
|
13636
|
+
reject(buildError(this.selfId, action, request2, data));
|
|
12413
13637
|
}
|
|
12414
13638
|
});
|
|
12415
13639
|
});
|
|
@@ -12418,7 +13642,7 @@ var WsAdapterOneBot11 = class extends AdapterOneBot {
|
|
|
12418
13642
|
|
|
12419
13643
|
// src/adapter/onebot/connect/http.ts
|
|
12420
13644
|
init_esm_shims();
|
|
12421
|
-
import
|
|
13645
|
+
import axios6 from "axios";
|
|
12422
13646
|
init_listeners();
|
|
12423
13647
|
init_bot();
|
|
12424
13648
|
var HttpAdapterOneBot11 = class extends AdapterOneBot {
|
|
@@ -12477,20 +13701,20 @@ var HttpAdapterOneBot11 = class extends AdapterOneBot {
|
|
|
12477
13701
|
}
|
|
12478
13702
|
async sendApi(action, params, time2 = 120) {
|
|
12479
13703
|
if (!time2) time2 = config_exports2.timeout();
|
|
12480
|
-
const
|
|
12481
|
-
logger.bot("debug", this.selfId, `\u53D1\u9001Api\u8BF7\u6C42 ${action}: ${
|
|
13704
|
+
const request2 = JSON.stringify(params);
|
|
13705
|
+
logger.bot("debug", this.selfId, `\u53D1\u9001Api\u8BF7\u6C42 ${action}: ${request2}`);
|
|
12482
13706
|
try {
|
|
12483
13707
|
const headers = this.#token ? { Authorization: `Bearer ${this.#token}` } : {};
|
|
12484
|
-
const { data } = await
|
|
13708
|
+
const { data } = await axios6.post(`${this.adapter.address}/${action}`, params, { headers, timeout: time2 * 1e3 });
|
|
12485
13709
|
if (data.status === "ok") {
|
|
12486
13710
|
return data.data;
|
|
12487
13711
|
}
|
|
12488
|
-
throw buildError(this.selfId, action,
|
|
13712
|
+
throw buildError(this.selfId, action, request2, data);
|
|
12489
13713
|
} catch (error) {
|
|
12490
|
-
if (
|
|
12491
|
-
throw buildError(this.selfId, action,
|
|
13714
|
+
if (axios6.isAxiosError(error) && error.code === "ECONNABORTED") {
|
|
13715
|
+
throw buildError(this.selfId, action, request2, "\u8BF7\u6C42\u8D85\u65F6");
|
|
12492
13716
|
}
|
|
12493
|
-
buildError(this.selfId, action,
|
|
13717
|
+
buildError(this.selfId, action, request2);
|
|
12494
13718
|
throw error;
|
|
12495
13719
|
}
|
|
12496
13720
|
}
|
|
@@ -12539,10 +13763,10 @@ var AdapterServerOneBot11 = class extends WsAdapterOneBot11 {
|
|
|
12539
13763
|
socket;
|
|
12540
13764
|
/** 请求实例 */
|
|
12541
13765
|
request;
|
|
12542
|
-
constructor(socket,
|
|
13766
|
+
constructor(socket, request2) {
|
|
12543
13767
|
super(socket);
|
|
12544
13768
|
this.socket = socket;
|
|
12545
|
-
this.request =
|
|
13769
|
+
this.request = request2;
|
|
12546
13770
|
}
|
|
12547
13771
|
async init() {
|
|
12548
13772
|
const url = `ws://${this.request.headers.host}${this.request.url}`;
|
|
@@ -12578,8 +13802,8 @@ var AdapterServerOneBot11 = class extends WsAdapterOneBot11 {
|
|
|
12578
13802
|
|
|
12579
13803
|
// src/adapter/onebot/index.ts
|
|
12580
13804
|
var createServer2 = async () => {
|
|
12581
|
-
listeners.on("ws:connection:onebot", (socket,
|
|
12582
|
-
new AdapterServerOneBot11(socket,
|
|
13805
|
+
listeners.on("ws:connection:onebot", (socket, request2) => {
|
|
13806
|
+
new AdapterServerOneBot11(socket, request2).init();
|
|
12583
13807
|
});
|
|
12584
13808
|
listeners.once("online", () => {
|
|
12585
13809
|
logger.info(`[server] onebot: ${logger.green(`ws://127.0.0.1:${process.env.HTTP_PORT}`)}`);
|
|
@@ -12674,6 +13898,9 @@ init_esm_shims();
|
|
|
12674
13898
|
// src/types/config/list.ts
|
|
12675
13899
|
init_esm_shims();
|
|
12676
13900
|
|
|
13901
|
+
// src/types/config/env.ts
|
|
13902
|
+
init_esm_shims();
|
|
13903
|
+
|
|
12677
13904
|
// src/types/event/index.ts
|
|
12678
13905
|
init_esm_shims();
|
|
12679
13906
|
|
|
@@ -12910,7 +14137,7 @@ export {
|
|
|
12910
14137
|
getPlugins,
|
|
12911
14138
|
getRelPath,
|
|
12912
14139
|
getRemotePkgVersion,
|
|
12913
|
-
getRender,
|
|
14140
|
+
getRender2 as getRender,
|
|
12914
14141
|
getRenderCount,
|
|
12915
14142
|
getRenderList,
|
|
12916
14143
|
getRequestIp,
|
|
@@ -13008,6 +14235,7 @@ export {
|
|
|
13008
14235
|
urlToPath,
|
|
13009
14236
|
watch,
|
|
13010
14237
|
watchAndMerge,
|
|
14238
|
+
web,
|
|
13011
14239
|
write,
|
|
13012
14240
|
writeJson,
|
|
13013
14241
|
writeJsonSync,
|