node-karin 0.0.3 → 0.1.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.
Files changed (105) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +57 -57
  3. package/config/defSet/App.yaml +37 -37
  4. package/config/defSet/config.yaml +43 -43
  5. package/config/defSet/group.yaml +18 -18
  6. package/config/defSet/pm2.yaml +21 -21
  7. package/config/defSet/server.yaml +42 -42
  8. package/config/view/App.yaml +74 -74
  9. package/config/view/config.yaml +100 -100
  10. package/config/view/group.yaml +62 -62
  11. package/config/view/pm2.yaml +41 -41
  12. package/config/view/redis.yaml +25 -25
  13. package/config/view/server.yaml +93 -93
  14. package/lib/adapter/onebot/onebot11.d.ts +430 -430
  15. package/lib/adapter/onebot/onebot11.js +1265 -1302
  16. package/lib/core/init.js +4 -4
  17. package/lib/core/karin.d.ts +72 -72
  18. package/lib/core/karin.js +51 -51
  19. package/lib/core/listener.d.ts +121 -121
  20. package/lib/core/listener.js +178 -178
  21. package/lib/core/plugin.app.d.ts +15 -15
  22. package/lib/core/plugin.app.js +18 -18
  23. package/lib/core/plugin.d.ts +182 -182
  24. package/lib/core/plugin.js +132 -132
  25. package/lib/core/plugin.loader.d.ts +149 -149
  26. package/lib/core/plugin.loader.js +451 -451
  27. package/lib/core/server.d.ts +26 -26
  28. package/lib/core/server.js +209 -209
  29. package/lib/db/level.d.ts +20 -20
  30. package/lib/db/level.js +36 -36
  31. package/lib/db/redis.d.ts +41 -41
  32. package/lib/db/redis.js +131 -131
  33. package/lib/db/redis_level.d.ts +113 -113
  34. package/lib/db/redis_level.js +274 -274
  35. package/lib/event/event.d.ts +138 -138
  36. package/lib/event/event.handler.d.ts +29 -29
  37. package/lib/event/event.handler.js +138 -138
  38. package/lib/event/event.js +120 -120
  39. package/lib/event/message.d.ts +102 -102
  40. package/lib/event/message.handler.d.ts +25 -25
  41. package/lib/event/message.handler.js +237 -237
  42. package/lib/event/message.js +69 -69
  43. package/lib/event/notice.d.ts +49 -49
  44. package/lib/event/notice.js +14 -14
  45. package/lib/event/request.d.ts +49 -49
  46. package/lib/event/request.js +14 -14
  47. package/lib/event/review.handler.d.ts +54 -54
  48. package/lib/event/review.handler.js +374 -374
  49. package/lib/index.d.ts +23 -23
  50. package/lib/index.js +39 -40
  51. package/lib/renderer/app.d.ts +53 -53
  52. package/lib/renderer/app.js +88 -88
  53. package/lib/renderer/base.d.ts +30 -30
  54. package/lib/renderer/base.js +68 -68
  55. package/lib/renderer/client.d.ts +30 -30
  56. package/lib/renderer/client.js +155 -155
  57. package/lib/renderer/http.d.ts +19 -19
  58. package/lib/renderer/http.js +50 -50
  59. package/lib/renderer/server.d.ts +42 -42
  60. package/lib/renderer/server.js +110 -110
  61. package/lib/renderer/wormhole.d.ts +1 -1
  62. package/lib/renderer/wormhole.js +154 -154
  63. package/lib/types/adapter.d.ts +575 -575
  64. package/lib/types/adapter.js +1 -1
  65. package/lib/types/config.d.ts +327 -327
  66. package/lib/types/config.js +1 -1
  67. package/lib/types/element.d.ts +576 -576
  68. package/lib/types/element.js +1 -1
  69. package/lib/types/index.d.ts +8 -8
  70. package/lib/types/index.js +8 -8
  71. package/lib/types/logger.d.ts +109 -109
  72. package/lib/types/logger.js +1 -1
  73. package/lib/types/onebots11.d.ts +1371 -1371
  74. package/lib/types/onebots11.js +1 -1
  75. package/lib/types/plugin.d.ts +282 -282
  76. package/lib/types/plugin.js +1 -1
  77. package/lib/types/render.d.ts +111 -111
  78. package/lib/types/render.js +1 -1
  79. package/lib/types/reply.d.ts +40 -40
  80. package/lib/types/reply.js +1 -1
  81. package/lib/types/types.d.ts +898 -898
  82. package/lib/types/types.js +1 -1
  83. package/lib/utils/YamlEditor.d.ts +62 -62
  84. package/lib/utils/YamlEditor.js +197 -197
  85. package/lib/utils/button.d.ts +49 -49
  86. package/lib/utils/button.js +75 -75
  87. package/lib/utils/common.d.ts +123 -123
  88. package/lib/utils/common.js +396 -396
  89. package/lib/utils/config.d.ts +72 -72
  90. package/lib/utils/config.js +254 -254
  91. package/lib/utils/exec.d.ts +22 -22
  92. package/lib/utils/exec.js +36 -36
  93. package/lib/utils/ffmpeg.d.ts +12 -12
  94. package/lib/utils/ffmpeg.js +25 -25
  95. package/lib/utils/handler.d.ts +76 -76
  96. package/lib/utils/handler.js +98 -98
  97. package/lib/utils/logger.d.ts +3 -3
  98. package/lib/utils/logger.js +104 -104
  99. package/lib/utils/segment.d.ts +276 -276
  100. package/lib/utils/segment.js +420 -420
  101. package/lib/utils/update.d.ts +69 -69
  102. package/lib/utils/update.js +145 -145
  103. package/lib/utils/updateVersion.d.ts +33 -33
  104. package/lib/utils/updateVersion.js +140 -140
  105. package/package.json +92 -91
@@ -1 +1 @@
1
- export {}
1
+ export {}
@@ -1,282 +1,282 @@
1
- /// <reference types="node" />
2
- import schedule from 'node-schedule';
3
- import { KarinNodeElement } from './element.js';
4
- import { Reply, replyCallback } from './reply.js';
5
- import { E, Event, Permission, SubEvent } from './types.js';
6
- /**
7
- * - 插件根目录名称
8
- * - 例如: karin-plugin-example
9
- * - 例如: karin-plugin-example/apps
10
- */
11
- export type dirName = `karin-plugin-${string}`;
12
- /**
13
- * - 插件名称
14
- * - 例如: index.js index.ts
15
- */
16
- export type fileName = `${string}.js` | `${string}.ts`;
17
- /**
18
- * - 插件规则
19
- */
20
- export interface PluginRule {
21
- /**
22
- * - 命令正则
23
- */
24
- reg: RegExp;
25
- /**
26
- * - 命令执行方法名称
27
- */
28
- fnc: string | Function;
29
- /**
30
- * - 子事件
31
- */
32
- event?: Event | `${Event}.${SubEvent}`;
33
- /**
34
- * 权限
35
- */
36
- permission?: Permission;
37
- /**
38
- * - 打印日志 默认为true
39
- */
40
- log?: boolean | Function;
41
- }
42
- /**
43
- * - 定时任务规则
44
- */
45
- export interface PluginTask {
46
- /**
47
- * - 任务名称
48
- */
49
- name: string;
50
- /**
51
- * - cron表达式
52
- */
53
- cron: string;
54
- /**
55
- * - 执行方法名称或对应函数
56
- */
57
- fnc: string | Function;
58
- /**
59
- * - 是否显示执行日志 默认为true
60
- */
61
- log: boolean | Function;
62
- /**
63
- * - 停止函数
64
- */
65
- schedule?: schedule.Job;
66
- }
67
- /**
68
- * - 按钮规则
69
- */
70
- export interface PluginButton {
71
- /**
72
- * - 按钮命令正则
73
- */
74
- reg: string;
75
- /**
76
- * - 执行方法名称
77
- */
78
- fnc: string;
79
- /**
80
- * - 优先级 不填默认为主优先度
81
- */
82
- priority: number;
83
- }
84
- /**
85
- * - handler规则
86
- */
87
- export interface PluginHandler {
88
- /**
89
- * - handler支持的事件key
90
- */
91
- key: string;
92
- /**
93
- * - handler的处理方法名称
94
- */
95
- fnc: string;
96
- /**
97
- * - handler优先级 不填默认为主优先度
98
- */
99
- priority: number;
100
- }
101
- /**
102
- * - 插件信息
103
- */
104
- export interface AppInfo {
105
- /**
106
- * - 插件根目录名称
107
- * - karin-plugin-example
108
- * - karin-plugin-example/apps
109
- * - karin-plugin-example/src/apps
110
- * - karin-plugin-example/dist/apps
111
- */
112
- dir: dirName;
113
- /**
114
- * - 插件名称 例如: index.js index.ts
115
- */
116
- name: fileName;
117
- }
118
- /**
119
- * - 插件基类
120
- */
121
- export interface Plugin {
122
- /**
123
- * - 插件名称
124
- */
125
- name: string;
126
- /**
127
- * - 插件描述
128
- * @deprecated 请使用desc
129
- */
130
- dsc: string;
131
- /**
132
- * - 插件描述
133
- */
134
- desc: string;
135
- /**
136
- * - 监听事件 默认为message
137
- */
138
- event: Event | `${Event}.${SubEvent}`;
139
- /**
140
- * - 优先级 默认为5000
141
- */
142
- priority: number;
143
- /**
144
- * - 定时任务
145
- */
146
- task: Array<PluginTask>;
147
- /**
148
- * - 命令规则
149
- */
150
- rule: Array<PluginRule>;
151
- /**
152
- * - 按钮
153
- */
154
- button: Array<PluginButton>;
155
- /**
156
- * - handler
157
- */
158
- handler: Array<PluginHandler>;
159
- /**
160
- * - 用户ID 一般上下文使用
161
- */
162
- userId?: number;
163
- /**
164
- * - 上下文超时
165
- */
166
- timeout: NodeJS.Timeout | undefined;
167
- /**
168
- * - 上报事件
169
- */
170
- e: E;
171
- /**
172
- * - 快速回复
173
- */
174
- reply: Reply;
175
- /**
176
- * - 快速回复内部方法 由适配器实现
177
- */
178
- replyCallback: replyCallback;
179
- /**
180
- * - 快速回复合并转发
181
- */
182
- replyForward: (msg: KarinNodeElement[]) => Promise<{
183
- message_id?: string;
184
- }>;
185
- /**
186
- * - 构建上下文键
187
- */
188
- conKey: () => string;
189
- /**
190
- * - 设置上下文状态
191
- */
192
- setContext: (
193
- /**
194
- * - 执行方法名称
195
- */
196
- fnc: string,
197
- /**
198
- * - 超时后是否回复
199
- */
200
- reply?: boolean,
201
- /**
202
- * - 下文超时时间 默认120秒
203
- */
204
- time?: number) => void;
205
- /**
206
- * - 获取上下文状态
207
- */
208
- getContext: () => {
209
- /**
210
- * - 插件实例
211
- */
212
- plugin: Plugin;
213
- /**
214
- * - 执行方法名称
215
- */
216
- fnc: string;
217
- };
218
- /**
219
- * - accept标准方法 给通知、请求事件使用
220
- */
221
- accept?(e: E): Promise<void>;
222
- }
223
- /**
224
- * 上下文状态
225
- */
226
- export interface stateArr {
227
- [key: string]: {
228
- plugin: Plugin;
229
- fnc: string;
230
- };
231
- }
232
- /**
233
- * - Apps
234
- */
235
- export interface PluginApps {
236
- /**
237
- * - 插件文件信息
238
- */
239
- file: AppInfo & {
240
- /**
241
- * - 插件类型
242
- */
243
- type: 'function' | 'class';
244
- /**
245
- * - 插件方法
246
- */
247
- Fnc: '' | (new () => Plugin);
248
- };
249
- /**
250
- * - 插件名称
251
- */
252
- name: string;
253
- /**
254
- * - 插件事件
255
- */
256
- event: Event | `${Event}.${SubEvent}`;
257
- /**
258
- * - 插件优先级
259
- * @default 10000
260
- */
261
- priority: number;
262
- /**
263
- * - accept函数存在
264
- */
265
- accept: boolean;
266
- /**
267
- * - 命令规则
268
- */
269
- rule: Array<PluginRule>;
270
- /**
271
- * - 定时任务
272
- */
273
- task: Array<PluginTask>;
274
- /**
275
- * - 按钮
276
- */
277
- button: Array<PluginButton>;
278
- /**
279
- * - handler
280
- */
281
- handler: Array<PluginHandler>;
282
- }
1
+ /// <reference types="node" />
2
+ import schedule from 'node-schedule';
3
+ import { KarinNodeElement } from './element.js';
4
+ import { Reply, replyCallback } from './reply.js';
5
+ import { E, Event, Permission, SubEvent } from './types.js';
6
+ /**
7
+ * - 插件根目录名称
8
+ * - 例如: karin-plugin-example
9
+ * - 例如: karin-plugin-example/apps
10
+ */
11
+ export type dirName = `karin-plugin-${string}`;
12
+ /**
13
+ * - 插件名称
14
+ * - 例如: index.js index.ts
15
+ */
16
+ export type fileName = `${string}.js` | `${string}.ts`;
17
+ /**
18
+ * - 插件规则
19
+ */
20
+ export interface PluginRule {
21
+ /**
22
+ * - 命令正则
23
+ */
24
+ reg: RegExp;
25
+ /**
26
+ * - 命令执行方法名称
27
+ */
28
+ fnc: string | Function;
29
+ /**
30
+ * - 子事件
31
+ */
32
+ event?: Event | `${Event}.${SubEvent}`;
33
+ /**
34
+ * 权限
35
+ */
36
+ permission?: Permission;
37
+ /**
38
+ * - 打印日志 默认为true
39
+ */
40
+ log?: boolean | Function;
41
+ }
42
+ /**
43
+ * - 定时任务规则
44
+ */
45
+ export interface PluginTask {
46
+ /**
47
+ * - 任务名称
48
+ */
49
+ name: string;
50
+ /**
51
+ * - cron表达式
52
+ */
53
+ cron: string;
54
+ /**
55
+ * - 执行方法名称或对应函数
56
+ */
57
+ fnc: string | Function;
58
+ /**
59
+ * - 是否显示执行日志 默认为true
60
+ */
61
+ log: boolean | Function;
62
+ /**
63
+ * - 停止函数
64
+ */
65
+ schedule?: schedule.Job;
66
+ }
67
+ /**
68
+ * - 按钮规则
69
+ */
70
+ export interface PluginButton {
71
+ /**
72
+ * - 按钮命令正则
73
+ */
74
+ reg: string;
75
+ /**
76
+ * - 执行方法名称
77
+ */
78
+ fnc: string;
79
+ /**
80
+ * - 优先级 不填默认为主优先度
81
+ */
82
+ priority: number;
83
+ }
84
+ /**
85
+ * - handler规则
86
+ */
87
+ export interface PluginHandler {
88
+ /**
89
+ * - handler支持的事件key
90
+ */
91
+ key: string;
92
+ /**
93
+ * - handler的处理方法名称
94
+ */
95
+ fnc: string;
96
+ /**
97
+ * - handler优先级 不填默认为主优先度
98
+ */
99
+ priority: number;
100
+ }
101
+ /**
102
+ * - 插件信息
103
+ */
104
+ export interface AppInfo {
105
+ /**
106
+ * - 插件根目录名称
107
+ * - karin-plugin-example
108
+ * - karin-plugin-example/apps
109
+ * - karin-plugin-example/src/apps
110
+ * - karin-plugin-example/dist/apps
111
+ */
112
+ dir: dirName;
113
+ /**
114
+ * - 插件名称 例如: index.js index.ts
115
+ */
116
+ name: fileName;
117
+ }
118
+ /**
119
+ * - 插件基类
120
+ */
121
+ export interface Plugin {
122
+ /**
123
+ * - 插件名称
124
+ */
125
+ name: string;
126
+ /**
127
+ * - 插件描述
128
+ * @deprecated 请使用desc
129
+ */
130
+ dsc: string;
131
+ /**
132
+ * - 插件描述
133
+ */
134
+ desc: string;
135
+ /**
136
+ * - 监听事件 默认为message
137
+ */
138
+ event: Event | `${Event}.${SubEvent}`;
139
+ /**
140
+ * - 优先级 默认为5000
141
+ */
142
+ priority: number;
143
+ /**
144
+ * - 定时任务
145
+ */
146
+ task: Array<PluginTask>;
147
+ /**
148
+ * - 命令规则
149
+ */
150
+ rule: Array<PluginRule>;
151
+ /**
152
+ * - 按钮
153
+ */
154
+ button: Array<PluginButton>;
155
+ /**
156
+ * - handler
157
+ */
158
+ handler: Array<PluginHandler>;
159
+ /**
160
+ * - 用户ID 一般上下文使用
161
+ */
162
+ userId?: number;
163
+ /**
164
+ * - 上下文超时
165
+ */
166
+ timeout: NodeJS.Timeout | undefined;
167
+ /**
168
+ * - 上报事件
169
+ */
170
+ e: E;
171
+ /**
172
+ * - 快速回复
173
+ */
174
+ reply: Reply;
175
+ /**
176
+ * - 快速回复内部方法 由适配器实现
177
+ */
178
+ replyCallback: replyCallback;
179
+ /**
180
+ * - 快速回复合并转发
181
+ */
182
+ replyForward: (msg: KarinNodeElement[]) => Promise<{
183
+ message_id?: string;
184
+ }>;
185
+ /**
186
+ * - 构建上下文键
187
+ */
188
+ conKey: () => string;
189
+ /**
190
+ * - 设置上下文状态
191
+ */
192
+ setContext: (
193
+ /**
194
+ * - 执行方法名称
195
+ */
196
+ fnc: string,
197
+ /**
198
+ * - 超时后是否回复
199
+ */
200
+ reply?: boolean,
201
+ /**
202
+ * - 下文超时时间 默认120秒
203
+ */
204
+ time?: number) => void;
205
+ /**
206
+ * - 获取上下文状态
207
+ */
208
+ getContext: () => {
209
+ /**
210
+ * - 插件实例
211
+ */
212
+ plugin: Plugin;
213
+ /**
214
+ * - 执行方法名称
215
+ */
216
+ fnc: string;
217
+ };
218
+ /**
219
+ * - accept标准方法 给通知、请求事件使用
220
+ */
221
+ accept?(e: E): Promise<void>;
222
+ }
223
+ /**
224
+ * 上下文状态
225
+ */
226
+ export interface stateArr {
227
+ [key: string]: {
228
+ plugin: Plugin;
229
+ fnc: string;
230
+ };
231
+ }
232
+ /**
233
+ * - Apps
234
+ */
235
+ export interface PluginApps {
236
+ /**
237
+ * - 插件文件信息
238
+ */
239
+ file: AppInfo & {
240
+ /**
241
+ * - 插件类型
242
+ */
243
+ type: 'function' | 'class';
244
+ /**
245
+ * - 插件方法
246
+ */
247
+ Fnc: '' | (new () => Plugin);
248
+ };
249
+ /**
250
+ * - 插件名称
251
+ */
252
+ name: string;
253
+ /**
254
+ * - 插件事件
255
+ */
256
+ event: Event | `${Event}.${SubEvent}`;
257
+ /**
258
+ * - 插件优先级
259
+ * @default 10000
260
+ */
261
+ priority: number;
262
+ /**
263
+ * - accept函数存在
264
+ */
265
+ accept: boolean;
266
+ /**
267
+ * - 命令规则
268
+ */
269
+ rule: Array<PluginRule>;
270
+ /**
271
+ * - 定时任务
272
+ */
273
+ task: Array<PluginTask>;
274
+ /**
275
+ * - 按钮
276
+ */
277
+ button: Array<PluginButton>;
278
+ /**
279
+ * - handler
280
+ */
281
+ handler: Array<PluginHandler>;
282
+ }
@@ -1 +1 @@
1
- export {}
1
+ export {}