node-karin 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/default/config/pm2.json +2 -2
- package/dist/cli/index.cjs +2 -1
- package/dist/cli/index.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -24
- package/dist/root.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [1.0.4](https://github.com/KarinJS/Karin/compare/node-karin-v1.0.3...node-karin-v1.0.4) (2025-01-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### 🐛 Bug Fixes
|
|
7
|
+
|
|
8
|
+
* test ci ([437350f](https://github.com/KarinJS/Karin/commit/437350f3376af7bc7f3fca6e51e8c6d846f1d798))
|
|
9
|
+
|
|
10
|
+
## [1.0.3](https://github.com/KarinJS/Karin/compare/node-karin-v1.0.2...node-karin-v1.0.3) (2025-01-15)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* registerBot ws_client ([a9d7905](https://github.com/KarinJS/Karin/commit/a9d7905b5c0c739eb1e8c64beafb658a3c12c64d))
|
|
16
|
+
|
|
3
17
|
## [1.0.2](https://github.com/KarinJS/Karin/compare/node-karin-v1.0.1...node-karin-v1.0.2) (2025-01-15)
|
|
4
18
|
|
|
5
19
|
|
package/default/config/pm2.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"max_memory_restart": "1G",
|
|
10
10
|
"restart_delay": 2000,
|
|
11
11
|
"merge_logs": true,
|
|
12
|
-
"error_file": "
|
|
13
|
-
"out_file": "
|
|
12
|
+
"error_file": "./@karinjs/logs/pm2_error.log",
|
|
13
|
+
"out_file": "./@karinjs/logs/pm2_out.log"
|
|
14
14
|
}
|
|
15
15
|
]
|
|
16
16
|
}
|
package/dist/cli/index.cjs
CHANGED
|
@@ -103,8 +103,8 @@ var dir = process.env.INIT_CWD || process.cwd();
|
|
|
103
103
|
var pkgDir = url.fileURLToPath(new url.URL("../..", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
104
104
|
var createDir = () => {
|
|
105
105
|
const list = [
|
|
106
|
-
path2__default.default.join(dir, "logs"),
|
|
107
106
|
path2__default.default.join(dir, "plugins", "karin-plugin-example"),
|
|
107
|
+
path2__default.default.join(dir, "@karinjs", "logs"),
|
|
108
108
|
path2__default.default.join(dir, "@karinjs", "config"),
|
|
109
109
|
path2__default.default.join(dir, "@karinjs", "data"),
|
|
110
110
|
path2__default.default.join(dir, "@karinjs", "temp", "console"),
|
|
@@ -259,6 +259,7 @@ var modifyPackageJson = () => {
|
|
|
259
259
|
const pkg = fs2__default.default.readFileSync(path2__default.default.join(dir, "package.json"), "utf-8");
|
|
260
260
|
const data = JSON.parse(pkg);
|
|
261
261
|
data.type = "module";
|
|
262
|
+
if (!data.scripts) data.scripts = {};
|
|
262
263
|
data.scripts.karin = "karin";
|
|
263
264
|
const list = [
|
|
264
265
|
"app",
|
package/dist/cli/index.js
CHANGED
|
@@ -94,8 +94,8 @@ var dir = process.env.INIT_CWD || process.cwd();
|
|
|
94
94
|
var pkgDir = fileURLToPath(new URL$1("../..", import.meta.url));
|
|
95
95
|
var createDir = () => {
|
|
96
96
|
const list = [
|
|
97
|
-
path2.join(dir, "logs"),
|
|
98
97
|
path2.join(dir, "plugins", "karin-plugin-example"),
|
|
98
|
+
path2.join(dir, "@karinjs", "logs"),
|
|
99
99
|
path2.join(dir, "@karinjs", "config"),
|
|
100
100
|
path2.join(dir, "@karinjs", "data"),
|
|
101
101
|
path2.join(dir, "@karinjs", "temp", "console"),
|
|
@@ -250,6 +250,7 @@ var modifyPackageJson = () => {
|
|
|
250
250
|
const pkg = fs2.readFileSync(path2.join(dir, "package.json"), "utf-8");
|
|
251
251
|
const data = JSON.parse(pkg);
|
|
252
252
|
data.type = "module";
|
|
253
|
+
if (!data.scripts) data.scripts = {};
|
|
253
254
|
data.scripts.karin = "karin";
|
|
254
255
|
const list = [
|
|
255
256
|
"app",
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var init_root = __esm({
|
|
|
45
45
|
dbPath = Object.freeze(path.join(dataPath, "db"));
|
|
46
46
|
levelPath = Object.freeze(path.join(dbPath, "level"));
|
|
47
47
|
redisLevelPath = Object.freeze(path.join(dbPath, "redis-level"));
|
|
48
|
-
logsPath = Object.freeze(path.join(
|
|
48
|
+
logsPath = Object.freeze(path.join(basePath, "logs"));
|
|
49
49
|
htmlPath = Object.freeze(path.join(tempPath, "html"));
|
|
50
50
|
pm2Path = Object.freeze(path.join(configPath, "pm2.yaml"));
|
|
51
51
|
consolePath = Object.freeze(path.join(tempPath, "console"));
|
|
@@ -107,8 +107,13 @@ var init_tools = __esm({
|
|
|
107
107
|
const list4 = {};
|
|
108
108
|
await Promise.all(Object.keys(defData).map(async (key) => {
|
|
109
109
|
if (Array.isArray(data == null ? void 0 : data[key])) {
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
if (data == null ? void 0 : data[key].every((v) => typeof v !== "object")) {
|
|
111
|
+
list4[key] = setStr((data == null ? void 0 : data[key]) || defData[key]);
|
|
112
|
+
return;
|
|
113
|
+
} else {
|
|
114
|
+
list4[key] = (data == null ? void 0 : data[key]) || defData[key];
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
112
117
|
}
|
|
113
118
|
if (NODE_TYPES.includes(typeof (data == null ? void 0 : data[key]))) {
|
|
114
119
|
list4[key] = (data == null ? void 0 : data[key]) ?? defData[key];
|
|
@@ -648,8 +653,8 @@ var init_default = __esm({
|
|
|
648
653
|
max_memory_restart: "1G",
|
|
649
654
|
restart_delay: 2e3,
|
|
650
655
|
merge_logs: true,
|
|
651
|
-
error_file: "
|
|
652
|
-
out_file: "
|
|
656
|
+
error_file: "./@karinjs/logs/pm2_error.log",
|
|
657
|
+
out_file: "./@karinjs/logs/pm2_out.log"
|
|
653
658
|
}
|
|
654
659
|
]
|
|
655
660
|
},
|
|
@@ -5458,7 +5463,6 @@ var init_bot = __esm({
|
|
|
5458
5463
|
registerBot = (type, bot) => {
|
|
5459
5464
|
const id = ++index;
|
|
5460
5465
|
list3.push({ index: id, bot });
|
|
5461
|
-
const tips = (str) => logger.green(`[\u6CE8\u518CBot][${str}]`);
|
|
5462
5466
|
const sendForwardMsg = bot.sendForwardMsg;
|
|
5463
5467
|
bot.sendForwardMsg = async (contact3, elements, options) => {
|
|
5464
5468
|
return sendForwardMsg.call(bot, contact3, elements, options);
|
|
@@ -5484,20 +5488,9 @@ var init_bot = __esm({
|
|
|
5484
5488
|
await level2.del(key);
|
|
5485
5489
|
}
|
|
5486
5490
|
}, 10);
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
} else if (type === "other") {
|
|
5491
|
-
bot.adapter.address = "internal://127.0.0.1";
|
|
5492
|
-
logger.bot("info", bot.selfId, `${tips("internal")} ${bot.account.name}`);
|
|
5493
|
-
} else if (type === "http") {
|
|
5494
|
-
logger.bot("info", bot.selfId, `${tips("HTTP")} ${bot.account.name}: ${bot.adapter.address}`);
|
|
5495
|
-
} else if (type === "webSocketServer") {
|
|
5496
|
-
logger.bot("info", bot.selfId, `${tips("\u53CD\u5411WebSocket")} ${bot.account.name}: ${bot.adapter.address}`);
|
|
5497
|
-
} else if (type === "grpc") {
|
|
5498
|
-
logger.bot("info", bot.selfId, `${tips("gRPC")} ${bot.account.name}: ${bot.adapter.address}`);
|
|
5499
|
-
}
|
|
5500
|
-
});
|
|
5491
|
+
setTimeout(() => {
|
|
5492
|
+
logger.bot("info", bot.selfId, `${logger.green("[registerBot]")}[${bot.adapter.name}]: ${bot.account.name} ${bot.adapter.address}`);
|
|
5493
|
+
}, 1e3);
|
|
5501
5494
|
return id;
|
|
5502
5495
|
};
|
|
5503
5496
|
sendMsg = async (selfId, contact3, elements, options = { recallMsg: 0, retryCount: 1, retry_count: 1 }) => {
|
|
@@ -9136,7 +9129,7 @@ var initLogger = (options = {}) => {
|
|
|
9136
9129
|
/** 输出到文件 */
|
|
9137
9130
|
type: "file",
|
|
9138
9131
|
/** 日志文件名 */
|
|
9139
|
-
filename: "logs/logger",
|
|
9132
|
+
filename: "@karinjs/logs/logger",
|
|
9140
9133
|
/** 日期后缀 */
|
|
9141
9134
|
pattern: "yyyy-MM-dd.log",
|
|
9142
9135
|
/** 日期后缀 */
|
|
@@ -12372,7 +12365,7 @@ var AdapterServerOneBot11 = class extends WsAdapterOneBot11 {
|
|
|
12372
12365
|
this.socket.on("close", () => {
|
|
12373
12366
|
this.socket.removeAllListeners();
|
|
12374
12367
|
unregisterBot("index", this.adapter.index);
|
|
12375
|
-
logger.bot("info", this.selfId,
|
|
12368
|
+
logger.bot("info", this.selfId, `\u8FDE\u63A5\u5173\u95ED: ${url}`);
|
|
12376
12369
|
});
|
|
12377
12370
|
}
|
|
12378
12371
|
/**
|
|
@@ -12411,7 +12404,7 @@ var createClient2 = async () => {
|
|
|
12411
12404
|
const cfg = adapter();
|
|
12412
12405
|
if (!cfg.onebot.ws_client || !Array.isArray(cfg.onebot.ws_client)) return;
|
|
12413
12406
|
for (const item of cfg.onebot.ws_client) {
|
|
12414
|
-
if (!(item == null ? void 0 : item.enable) || !(item == null ? void 0 : item.url)
|
|
12407
|
+
if (!(item == null ? void 0 : item.enable) || !(item == null ? void 0 : item.url)) continue;
|
|
12415
12408
|
AdapterClientOneBot11.init(item.url, item.token);
|
|
12416
12409
|
}
|
|
12417
12410
|
};
|
|
@@ -12420,7 +12413,7 @@ var createHttp = async () => {
|
|
|
12420
12413
|
if (!cfg.onebot.http_server || !Array.isArray(cfg.onebot.http_server)) return;
|
|
12421
12414
|
for (const data of cfg.onebot.http_server) {
|
|
12422
12415
|
try {
|
|
12423
|
-
if (!(data == null ? void 0 : data.enable) || !(data == null ? void 0 : data.url) || !(data == null ? void 0 : data.
|
|
12416
|
+
if (!(data == null ? void 0 : data.enable) || !(data == null ? void 0 : data.url) || !(data == null ? void 0 : data.self_id)) continue;
|
|
12424
12417
|
if (!(data == null ? void 0 : data.self_id) || !(data == null ? void 0 : data.url) || !(data == null ? void 0 : data.url.startsWith("http"))) {
|
|
12425
12418
|
logger.bot("error", data.self_id, "\u8BF7\u914D\u7F6E\u6B63\u786E\u7684 onebot http \u4FE1\u606F");
|
|
12426
12419
|
continue;
|
package/dist/root.js
CHANGED
|
@@ -17,7 +17,7 @@ var resourcePath = Object.freeze(path.join(basePath, "resource"));
|
|
|
17
17
|
var dbPath = Object.freeze(path.join(dataPath, "db"));
|
|
18
18
|
var levelPath = Object.freeze(path.join(dbPath, "level"));
|
|
19
19
|
var redisLevelPath = Object.freeze(path.join(dbPath, "redis-level"));
|
|
20
|
-
var logsPath = Object.freeze(path.join(
|
|
20
|
+
var logsPath = Object.freeze(path.join(basePath, "logs"));
|
|
21
21
|
var htmlPath = Object.freeze(path.join(tempPath, "html"));
|
|
22
22
|
var pm2Path = Object.freeze(path.join(configPath, "pm2.yaml"));
|
|
23
23
|
var consolePath = Object.freeze(path.join(tempPath, "console"));
|