node-karin 1.10.13 → 1.10.14

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,12 @@
1
1
  # 更新日志
2
2
 
3
+ ## [1.10.14](https://github.com/KarinJS/Karin/compare/core-v1.10.13...core-v1.10.14) (2025-06-30)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * onebot 声明周期事件错误 ([7bf0152](https://github.com/KarinJS/Karin/commit/7bf0152fc1d807ea46a1f0998da78403c0883acf))
9
+
3
10
  ## [1.10.13](https://github.com/KarinJS/Karin/compare/core-v1.10.12...core-v1.10.13) (2025-06-30)
4
11
 
5
12
 
package/dist/index.d.ts CHANGED
@@ -15914,6 +15914,7 @@ declare class OneBotWsServer extends OneBotWsBase {
15914
15914
  /** 请求对象 */
15915
15915
  private _request;
15916
15916
  constructor(socket: WebSocket, request: IncomingMessage, options: OneBotWsServerOptions$1);
15917
+ init(): Promise<void>;
15917
15918
  /**
15918
15919
  * 更新socket
15919
15920
  */
package/dist/index.mjs CHANGED
@@ -5219,18 +5219,14 @@ var init_dist2 = __esm({
5219
5219
  * 关闭连接
5220
5220
  */
5221
5221
  close() {
5222
- try {
5223
- this._manualClosed = true;
5224
- this._socket.close();
5225
- this.emit(
5226
- "close",
5227
- 1002
5228
- /* MANUAL_CLOSE */
5229
- );
5230
- setTimeout(() => this.removeAllListeners(), 200);
5231
- } finally {
5232
- this._manualClosed = false;
5233
- }
5222
+ this._manualClosed = true;
5223
+ this._socket.close();
5224
+ this.emit(
5225
+ "close",
5226
+ 1002
5227
+ /* MANUAL_CLOSE */
5228
+ );
5229
+ this.removeAllListeners();
5234
5230
  }
5235
5231
  /**
5236
5232
  * 更新socket
@@ -5440,6 +5436,7 @@ var init_dist2 = __esm({
5440
5436
  * @returns 是否重连成功
5441
5437
  */
5442
5438
  async reconnect(url, options = this._options) {
5439
+ this._manualClosed = false;
5443
5440
  this._options = this.getOptions(options);
5444
5441
  const _socket = oneBotWsClientManager.createWebSocket(url, options);
5445
5442
  this.setSocket(_socket)();
@@ -5462,13 +5459,7 @@ var init_dist2 = __esm({
5462
5459
  });
5463
5460
  this._socket.on("close", () => {
5464
5461
  if (this._setSocket) return;
5465
- if (this._manualClosed) {
5466
- this.#close(
5467
- 1002
5468
- /* MANUAL_CLOSE */
5469
- );
5470
- return;
5471
- }
5462
+ if (this._manualClosed) return;
5472
5463
  if (this._options.autoReconnect) {
5473
5464
  if (isConnected) {
5474
5465
  this.#close(
@@ -5540,7 +5531,10 @@ var init_dist2 = __esm({
5540
5531
  super(socket, options);
5541
5532
  this._options = this.getOptions(options);
5542
5533
  this._request = request22;
5534
+ }
5535
+ async init() {
5543
5536
  this._setupEventListeners();
5537
+ await super.init();
5544
5538
  }
5545
5539
  /**
5546
5540
  * 关闭之前的一些操作
@@ -5590,15 +5584,13 @@ var init_dist2 = __esm({
5590
5584
  */
5591
5585
  _setupEventListeners() {
5592
5586
  this?._socket?.removeAllListeners();
5587
+ this.emit(
5588
+ "open"
5589
+ /* OPEN */
5590
+ );
5593
5591
  this._socket.on("close", () => {
5594
5592
  if (this._setSocket) return;
5595
- if (this._manualClosed) {
5596
- this.#close(
5597
- 1002
5598
- /* MANUAL_CLOSE */
5599
- );
5600
- return;
5601
- }
5593
+ if (this._manualClosed) return;
5602
5594
  this.#close(
5603
5595
  1001
5604
5596
  /* ERROR */
@@ -18817,6 +18809,10 @@ var init_create2 = __esm({
18817
18809
  adapter3.adapter.address = url;
18818
18810
  adapter3.adapter.communication = "webSocketServer";
18819
18811
  adapter3.account.selfId = String(request3.headers["x-self-id"]);
18812
+ onebot.on(OneBotEventKey.OPEN, async () => {
18813
+ logger.debug(`[OneBot] \u670D\u52A1\u7AEF\u8FDE\u63A5\u6210\u529F: ${url}`);
18814
+ adapter3.registerBot();
18815
+ });
18820
18816
  onebot.on(OneBotEventKey.CLOSE, async (type) => {
18821
18817
  adapter3.unregisterBot();
18822
18818
  if (type === OneBotCloseType.MANUAL_CLOSE) {
@@ -18824,6 +18820,15 @@ var init_create2 = __esm({
18824
18820
  }
18825
18821
  return logger.error(`${loggerPrefix} \u8FDE\u63A5\u65AD\u5F00: ${url}`);
18826
18822
  });
18823
+ onebot.on(OneBotEventKey.ERROR, async (args) => {
18824
+ if (args.type === OneBotErrorType.AUTH_FAILED) {
18825
+ return logger.error(`${loggerPrefix} \u9274\u6743\u5931\u8D25: ${args.error.message}`);
18826
+ }
18827
+ if (args.type === OneBotErrorType.AUTH_INVALID_FORMAT) {
18828
+ return logger.error(`${loggerPrefix} \u9274\u6743\u5934\u683C\u5F0F\u9519\u8BEF: ${args.error.message}`);
18829
+ }
18830
+ return logger.error(new Error(`${loggerPrefix} \u53D1\u751F\u9519\u8BEF:`, { cause: args.error }));
18831
+ });
18827
18832
  await adapter3.init();
18828
18833
  cacheMap.wsServer.set(url, adapter3);
18829
18834
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.10.13",
3
+ "version": "1.10.14",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",
package/README.md DELETED
@@ -1,95 +0,0 @@
1
- ![karin](https://socialify.git.ci/karinjs/karin/image?description=1&font=Bitter&forks=1&issues=1&language=1&logo=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F162426977%3Fs%3D200%26v%3D4&name=1&owner=1&pulls=1&stargazers=1&theme=Auto)
2
-
3
- ## 项目介绍
4
-
5
- `karin`(卡琳)是一款灵活、现代、极易扩展的 Node.js 插件化应用框架,专为开发者打造,助你轻松构建属于自己的高效工具链和自动化服务。
6
-
7
- ✨ **主要特性**:
8
- - ~~插件化架构,支持热插拔,生态丰富~~
9
- - 一行命令即可初始化项目,快速上手
10
- - 丰富的 Web UI(基于 React + HeroUI),颜值与功能并存
11
- - 支持多种自动化场景、任务调度、依赖管理
12
- - 轻松集成第三方服务,打造属于你的"数字助理"
13
- - 社区活跃,持续更新,文档完善
14
-
15
- > 🦄 让开发变得像魔法一样有趣!
16
-
17
- ## 🚀 稳定长期维护
18
-
19
- 自 `1.8.0` 版本起,Karin 已进入**稳定长期维护阶段**。我们承诺持续修复 bug、优化体验,并欢迎社区力量共同完善生态。
20
-
21
- ## 快速开始
22
-
23
- [📚 查看最新文档](https://karin.fun/)
24
-
25
- 一键初始化:`pnpm create karin`
26
-
27
- > 当前文档可能存在滞后性,欢迎加入交流群(967068507)一起玩耍、提建议!
28
-
29
- ## 温馨提示
30
-
31
- > Karin 现已稳定,放心食用!遇到问题欢迎提 Issue 或加群讨论,我们会持续优化。
32
-
33
- ## 文档站说明
34
-
35
- 我们提供多个文档站点供您访问,解决可能出现的访问困难:
36
-
37
- - **主文档站**: [https://karin.fun](https://karin.fun) (基于 GitHub Pages)
38
- - **镜像站点**:
39
- - 憨憨镜像: [https://karin.hanhanz.top](https://karin.hanhanz.top) (**推荐访问**)
40
- - Vercel 镜像: [https://docs.karin.fun](https://docs.karin.fun) (**推荐访问**)
41
- - Deno 镜像: [https://karin.deno.dev](https://karin.deno.dev) (**推荐访问**)
42
-
43
- > 💡 主文档站托管在 GitHub 上,如访问不畅,推荐使用 Deno 镜像站
44
-
45
- ## 鸣谢
46
-
47
- - webui: [bietiaop](https://github.com/bietiaop)
48
- - docs: [ikenxuan](https://github.com/ikenxuan)
49
- - name: [fuqiuluo](https://github.com/fuqiuluo)
50
-
51
- > 🧙‍♂️ 感谢三位大佬的魔法加持!
52
-
53
- ### 贡献者
54
-
55
- > 🌟 星光闪烁,你们的智慧如同璀璨的夜空。感谢所有为 **Karin** 做出贡献的人!
56
-
57
- [![贡献者](https://contributors-img.web.app/image?repo=KarinJS/Karin)](https://github.com/KarinJS/Karin/graphs/contributors)
58
-
59
- ![Alt](https://repobeats.axiom.co/api/embed/aaaa2759c8885691443a4d80e5753f975d4f250e.svg "Repobeats analytics image")
60
-
61
- ---
62
-
63
- 🎉 **加入我们,让 Karin 成为你开发路上的贴心伙伴!**
64
-
65
- ## 常见问题
66
-
67
- - 文档没看懂?[点我提问](https://github.com/KarinJS/Karin/issues) 或加群 967068507
68
- - 插件不会写?欢迎参考[插件开发文档](https://karin.fun/plugins/)
69
- - 遇到 bug?大胆提 Issue,我们超快响应!
70
-
71
- ## 如何参与贡献(PR)
72
-
73
- 1. Fork 本仓库,创建你的分支
74
- 2. 提交你的更改,附上简要说明
75
- 3. 发起 Pull Request,耐心等待 Review
76
- 4. 你的名字将出现在贡献者列表,收获一份开源荣誉!
77
-
78
- > 💡 欢迎任何形式的贡献,无论是代码、文档、建议还是灵感!
79
-
80
- ## Issue 指南
81
-
82
- - 提交前请先搜索是否有类似问题
83
- - 尽量提供详细的复现步骤、环境信息和截图
84
- - 标题简明扼要,正文描述清晰
85
- - 遇到安全相关问题请私信维护者
86
-
87
- ## 开源协议
88
-
89
- 本项目基于 [MIT License](./LICENSE) 开源,欢迎自由使用、修改和分发。
90
-
91
- > 📢 记得给个 Star 支持我们,你的支持是我们最大的动力!
92
-
93
- ## 更新日志
94
-
95
- 我们定期发布更新,查看 [CHANGELOG](https://github.com/KarinJS/Karin/releases) 了解最新变化。