node-karin 0.3.8 → 0.4.1

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.
Files changed (54) hide show
  1. package/lib/adapter/onebot/onebot11.d.ts +3 -5
  2. package/lib/adapter/onebot/onebot11.js +4 -1
  3. package/lib/core/karin.d.ts +45 -4
  4. package/lib/core/karin.js +52 -1
  5. package/lib/core/listener.d.ts +2 -2
  6. package/lib/core/listener.js +1 -0
  7. package/lib/core/plugin.app.d.ts +4 -1
  8. package/lib/core/plugin.app.js +3 -3
  9. package/lib/core/plugin.d.ts +8 -2
  10. package/lib/core/plugin.loader.d.ts +11 -4
  11. package/lib/core/plugin.loader.js +49 -12
  12. package/lib/db/index.d.ts +2 -4
  13. package/lib/db/index.js +2 -4
  14. package/lib/db/level.d.ts +1 -0
  15. package/lib/db/level.js +1 -0
  16. package/lib/db/redis.d.ts +2 -41
  17. package/lib/db/redis.js +2 -3
  18. package/lib/event/event.d.ts +7 -3
  19. package/lib/event/event.handler.d.ts +7 -6
  20. package/lib/event/event.handler.js +5 -0
  21. package/lib/event/event.js +5 -0
  22. package/lib/event/index.js +2 -2
  23. package/lib/event/message.handler.d.ts +3 -3
  24. package/lib/event/message.handler.js +8 -11
  25. package/lib/event/notice.d.ts +4 -4
  26. package/lib/event/notice.handler.d.ts +17 -0
  27. package/lib/event/notice.handler.js +203 -0
  28. package/lib/event/request.d.ts +4 -4
  29. package/lib/event/request.handler.d.ts +17 -0
  30. package/lib/event/request.handler.js +109 -0
  31. package/lib/event/request.js +1 -0
  32. package/lib/event/review.handler.js +12 -24
  33. package/lib/index.d.ts +5 -66
  34. package/lib/index.js +0 -1
  35. package/lib/render/client.d.ts +0 -1
  36. package/lib/render/server.d.ts +0 -2
  37. package/lib/types/adapter.d.ts +2 -3
  38. package/lib/types/api.d.ts +295 -0
  39. package/lib/types/api.js +1 -0
  40. package/lib/types/event.d.ts +127 -241
  41. package/lib/types/index.d.ts +1 -0
  42. package/lib/types/index.js +1 -0
  43. package/lib/types/plugin.d.ts +4 -5
  44. package/lib/utils/button.d.ts +2 -2
  45. package/lib/utils/common.d.ts +1 -2
  46. package/lib/utils/config.d.ts +3 -4
  47. package/lib/utils/config.js +17 -3
  48. package/lib/utils/exec.d.ts +3 -3
  49. package/lib/utils/ffmpeg.d.ts +3 -3
  50. package/lib/utils/handler.d.ts +6 -13
  51. package/lib/utils/handler.js +3 -1
  52. package/lib/utils/segment.d.ts +6 -6
  53. package/package.json +16 -17
  54. package/lib/utils/kritor-proto.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- import { EventType, PluginType } from '../types/index.js';
1
+ import { EventType, PluginType, PluginApps } from '../types/index.js';
2
2
  /**
3
3
  * 事件处理器类
4
4
  */
@@ -8,21 +8,14 @@ export declare const handler: {
8
8
  * @param index 插件索引
9
9
  * @param Class 插件类
10
10
  */
11
- add(index: string, Class: PluginType): void;
11
+ add(index: string, Class: PluginType | PluginApps): void;
12
12
  /**
13
13
  * 删除事件处理器
14
14
  * 如果不传参数则删除所有处理器
15
+ * @param index 插件索引
16
+ * @param key 事件键
15
17
  */
16
- del({ index, key }: {
17
- /**
18
- * 插件索引
19
- */
20
- index: string | '';
21
- /**
22
- * 事件键
23
- */
24
- key: string | '';
25
- }): boolean;
18
+ del(index?: string, key?: string): boolean;
26
19
  /**
27
20
  * 调用事件处理器
28
21
  * @param key 事件键
@@ -30,7 +23,7 @@ export declare const handler: {
30
23
  */
31
24
  call(key: string, args: {
32
25
  [key: string]: any;
33
- e?: import("../index.js").KarinMessage | undefined;
26
+ e?: EventType<unknown>;
34
27
  }): Promise<any>;
35
28
  /**
36
29
  * 检查是否存在指定键的事件处理器
@@ -24,8 +24,10 @@ export const handler = new (class EventHandler {
24
24
  /**
25
25
  * 删除事件处理器
26
26
  * 如果不传参数则删除所有处理器
27
+ * @param index 插件索引
28
+ * @param key 事件键
27
29
  */
28
- del ({ index = '', key = '' }) {
30
+ del (index = '', key = '') {
29
31
  /** 无参 */
30
32
  if (!key && !index) {
31
33
  loader.handlerIds = {}
@@ -45,7 +45,7 @@ export declare const segment: {
45
45
  /**
46
46
  * - 图片类型,show: 展示图片,flash: 闪照,original: 原图
47
47
  */
48
- file_type?: 'show' | 'flash' | 'original';
48
+ file_type?: "show" | "flash" | "original";
49
49
  /**
50
50
  * - 图片名称
51
51
  */
@@ -136,7 +136,7 @@ export declare const segment: {
136
136
  * @param id - 音乐ID
137
137
  * @returns {MusicElement} 音乐元素
138
138
  */
139
- music(platform: 'QQ' | 'netease' | 'custom', id: string): MusicElement;
139
+ music(platform: "QQ" | "netease" | "custom", id: string): MusicElement;
140
140
  /**
141
141
  * 天气
142
142
  * @param city - 城市名称
@@ -190,7 +190,7 @@ export declare const segment: {
190
190
  * @param peer - 被推荐人的QQ号或者被推荐群的群号
191
191
  * @returns {ContactElement} 分享名片元素
192
192
  */
193
- contact(scene: 'group' | 'friend', peer: string): ContactElement;
193
+ contact(scene: "group" | "friend", peer: string): ContactElement;
194
194
  /**
195
195
  * JSON
196
196
  * @param data - JSON序列化过的字符串
@@ -260,9 +260,9 @@ export declare const segment: {
260
260
  * @param data - 按钮数据
261
261
  * @returns {ButtonElement} 按钮元素
262
262
  */
263
- button(data: ButtonElement['data']): ButtonElement;
264
- rows(data: Array<ButtonElement['data']>): {
265
- type: 'rows';
263
+ button(data: ButtonElement["data"]): ButtonElement;
264
+ rows(data: Array<ButtonElement["data"]>): {
265
+ type: "rows";
266
266
  rows: Array<ButtonElement>;
267
267
  };
268
268
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.3.8",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",
@@ -39,11 +39,11 @@
39
39
  "scripts": {
40
40
  "app": "node .",
41
41
  "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix && npm run cp",
42
- "cp": "cp ./lib/modules.d.ts ./modules.d.ts && cp ./lib/modules.js ./modules.js && cp ./src/utils/kritor-proto.d.ts ./lib/utils/kritor-proto.d.ts",
42
+ "cp": "cp ./lib/modules.d.ts ./modules.d.ts && cp ./lib/modules.js ./modules.js",
43
43
  "delete": "pm2 delete ./config/config/pm2.yaml",
44
44
  "dev": "tsx ./lib/index.js --dev",
45
45
  "fix": "eslint lib/**/*.js --fix",
46
- "fix:all": "eslint lib/**/*.js --fix && eslint src/**/*.ts --fix",
46
+ "fix:all": "eslint lib/**/*.js --fix && eslint lib/**/*.ts --fix",
47
47
  "init": "node lib/tools/install.js",
48
48
  "init:dev": "node lib/tools/install.js",
49
49
  "init:pack": "node lib/tools/install.js",
@@ -54,8 +54,7 @@
54
54
  "sort:pack": "npx sort-package-json",
55
55
  "start": "pm2 start ./config/config/pm2.yaml && pm2 monit",
56
56
  "stop": "pm2 delete ./config/config/pm2.yaml",
57
- "uninstall": "node lib/tools/uninstall.js",
58
- "ver": "node lib/tools/updateVersion.js"
57
+ "uninstall": "node lib/tools/uninstall.js"
59
58
  },
60
59
  "dependencies": {
61
60
  "@grpc/grpc-js": "1.10.10",
@@ -65,7 +64,7 @@
65
64
  "chalk": "5.3.0",
66
65
  "chokidar": "3.6.0",
67
66
  "express": "4.19.2",
68
- "kritor-proto": "^0.0.6",
67
+ "kritor-proto": "^1.0.1",
69
68
  "level": "8.0.1",
70
69
  "lodash": "4.17.21",
71
70
  "log4js": "6.9.1",
@@ -76,17 +75,17 @@
76
75
  "yaml": "2.4.1"
77
76
  },
78
77
  "devDependencies": {
79
- "@types/express": "^4.17.21",
80
- "@types/lodash": "^4.17.5",
81
- "@types/node": "^20.14.8",
82
- "@types/node-schedule": "^2.1.7",
83
- "@types/ws": "8.5.10",
84
- "eslint": "9.5.0",
85
- "neostandard": "^0.9.0",
86
- "sort-package-json": "^2.10.0",
87
- "tsc-alias": "^1.8.10",
88
- "tsx": "^4.15.7",
89
- "typescript": "^4.9.5"
78
+ "@types/express": "latest",
79
+ "@types/lodash": "latest",
80
+ "@types/node": "latest",
81
+ "@types/node-schedule": "latest",
82
+ "@types/ws": "latest",
83
+ "eslint": "latest",
84
+ "neostandard": "latest",
85
+ "sort-package-json": "latest",
86
+ "tsc-alias": "latest",
87
+ "tsx": "latest",
88
+ "typescript": "latest"
90
89
  },
91
90
  "bundledDependencies": [
92
91
  "@types/express",
@@ -1 +0,0 @@
1
- declare module 'kritor-proto'