node-karin 1.0.1 → 1.0.3

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # 更新日志
2
2
 
3
+ ## [1.0.3](https://github.com/KarinJS/Karin/compare/node-karin-v1.0.2...node-karin-v1.0.3) (2025-01-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * registerBot ws_client ([a9d7905](https://github.com/KarinJS/Karin/commit/a9d7905b5c0c739eb1e8c64beafb658a3c12c64d))
9
+
10
+ ## [1.0.2](https://github.com/KarinJS/Karin/compare/node-karin-v1.0.1...node-karin-v1.0.2) (2025-01-15)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * build types error ([f732ca3](https://github.com/KarinJS/Karin/commit/f732ca38155f08adefed7a9f8d42d373a9fc9cc7))
16
+ * ci ([56b3823](https://github.com/KarinJS/Karin/commit/56b382335d63577078e5aa8572d6238c63caf3e9))
17
+ * tips ([9f67525](https://github.com/KarinJS/Karin/commit/9f67525d592094532a3a29fe1f3de41bc1ec1936))
18
+ * version ([1b15d0b](https://github.com/KarinJS/Karin/commit/1b15d0b6c1583a8abc674b97cd746aac97b918c1))
19
+ * 导出 ([33b0683](https://github.com/KarinJS/Karin/commit/33b06831c3c4e6679edb3353962d88d7e2cb4d9b))
20
+
3
21
  ## [1.0.1](https://github.com/KarinJS/Karin/compare/node-karin-v1.0.0...node-karin-v1.0.1) (2025-01-15)
4
22
 
5
23
 
@@ -9,8 +9,8 @@
9
9
  "max_memory_restart": "1G",
10
10
  "restart_delay": 2000,
11
11
  "merge_logs": true,
12
- "error_file": "./logs/pm2_error.log",
13
- "out_file": "./logs/pm2_out.log"
12
+ "error_file": "./@karinjs/logs/pm2_error.log",
13
+ "out_file": "./@karinjs/logs/pm2_out.log"
14
14
  }
15
15
  ]
16
16
  }
@@ -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"),
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"),
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { EventEmitter } from 'node:events';
1
2
  import chalk from 'chalk';
2
3
  import { Configuration, Logger as Logger$1 } from 'log4js';
3
4
  import { Level } from 'level';
@@ -6275,7 +6276,7 @@ interface SendMsgOptions$1 {
6275
6276
  }
6276
6277
  /**
6277
6278
  * 发送主动消息
6278
- * @param uid Bot的uid
6279
+ * @param selfId Bot的id
6279
6280
  * @param contact 目标信息
6280
6281
  * @param elements 消息内容
6281
6282
  * @param options 消息选项
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(process.cwd(), "logs"));
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
- list4[key] = setStr((data == null ? void 0 : data[key]) || defData[key]);
111
- return;
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: "./logs/pm2_error.log",
652
- out_file: "./logs/pm2_out.log"
656
+ error_file: "./@karinjs/logs/pm2_error.log",
657
+ out_file: "./@karinjs/logs/pm2_out.log"
653
658
  }
654
659
  ]
655
660
  },
@@ -2897,7 +2902,7 @@ var init_level = __esm({
2897
2902
  import { Level as Level2 } from "level";
2898
2903
  import lodash4 from "lodash";
2899
2904
  import moment from "moment";
2900
- import EventEmitter2 from "node:events";
2905
+ import { EventEmitter as EventEmitter2 } from "node:events";
2901
2906
  var RedisClient;
2902
2907
  var init_mock = __esm({
2903
2908
  "src/core/db/redis/mock.ts"() {
@@ -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
- listeners.once("online", () => {
5488
- if (type === "webSocketClient") {
5489
- logger.bot("info", bot.selfId, `${tips("\u6B63\u5411webSocket")} ${bot.account.name}: ${bot.adapter.address}`);
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
  /** 日期后缀 */
@@ -9479,7 +9472,7 @@ init_bot();
9479
9472
  init_esm_shims();
9480
9473
  init_internal();
9481
9474
  init_bot();
9482
- import { EventEmitter as EventEmitter3 } from "events";
9475
+ import { EventEmitter as EventEmitter3 } from "node:events";
9483
9476
  var Other = class extends EventEmitter3 {
9484
9477
  /** 框架名称 */
9485
9478
  name = "karin";
@@ -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, "\u8FDE\u63A5\u5173\u95ED");
12368
+ logger.bot("info", this.selfId, `\u8FDE\u63A5\u5173\u95ED: ${url}`);
12376
12369
  });
12377
12370
  }
12378
12371
  /**
@@ -12404,13 +12397,14 @@ var createServer2 = async () => {
12404
12397
  listeners.once("online", () => {
12405
12398
  logger.info(`[server] onebot: ${logger.green(`ws://127.0.0.1:${process.env.HTTP_PORT}`)}`);
12406
12399
  logger.info(`[server] onebot: ${logger.green(`ws://127.0.0.1:${process.env.HTTP_PORT}/onebot/v11/ws`)}`);
12400
+ logger.info(`[server] onebot: ${logger.green(`ws://127.0.0.1:${process.env.HTTP_PORT}/puppeteer`)}`);
12407
12401
  });
12408
12402
  };
12409
12403
  var createClient2 = async () => {
12410
12404
  const cfg = adapter();
12411
12405
  if (!cfg.onebot.ws_client || !Array.isArray(cfg.onebot.ws_client)) return;
12412
12406
  for (const item of cfg.onebot.ws_client) {
12413
- if (!(item == null ? void 0 : item.enable) || !(item == null ? void 0 : item.url) || !(item == null ? void 0 : item.token)) continue;
12407
+ if (!(item == null ? void 0 : item.enable) || !(item == null ? void 0 : item.url)) continue;
12414
12408
  AdapterClientOneBot11.init(item.url, item.token);
12415
12409
  }
12416
12410
  };
@@ -12419,7 +12413,7 @@ var createHttp = async () => {
12419
12413
  if (!cfg.onebot.http_server || !Array.isArray(cfg.onebot.http_server)) return;
12420
12414
  for (const data of cfg.onebot.http_server) {
12421
12415
  try {
12422
- if (!(data == null ? void 0 : data.enable) || !(data == null ? void 0 : data.url) || !(data == null ? void 0 : data.token) || !(data == null ? void 0 : data.self_id)) continue;
12416
+ if (!(data == null ? void 0 : data.enable) || !(data == null ? void 0 : data.url) || !(data == null ? void 0 : data.self_id)) continue;
12423
12417
  if (!(data == null ? void 0 : data.self_id) || !(data == null ? void 0 : data.url) || !(data == null ? void 0 : data.url.startsWith("http"))) {
12424
12418
  logger.bot("error", data.self_id, "\u8BF7\u914D\u7F6E\u6B63\u786E\u7684 onebot http \u4FE1\u606F");
12425
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(process.cwd(), "logs"));
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"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",
@@ -106,6 +106,10 @@
106
106
  "types": "./dist/cli/index.d.ts",
107
107
  "require": "./dist/cli/index.cjs"
108
108
  },
109
+ "./root": {
110
+ "import": "./dist/root.js",
111
+ "types": "./dist/root.d.ts"
112
+ },
109
113
  "./template": {
110
114
  "import": "./dist/module/art-template.js",
111
115
  "types": "./dist/module/art-template.d.ts",