node-karin 0.12.13 → 0.12.15

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 (59) hide show
  1. package/lib/adapter/input/index.d.ts +1 -1
  2. package/lib/adapter/input/index.js +1 -1
  3. package/lib/adapter/onebot/11/event.js +90 -84
  4. package/lib/adapter/onebot/11/index.d.ts +89 -127
  5. package/lib/adapter/onebot/11/index.js +192 -254
  6. package/lib/cli/index.js +2 -2
  7. package/lib/core/init/config.js +1 -1
  8. package/lib/core/karin/karin.d.ts +21 -30
  9. package/lib/core/karin/karin.js +7 -9
  10. package/lib/core/listener/listener.js +11 -11
  11. package/lib/core/plugin/base.d.ts +7 -21
  12. package/lib/core/plugin/base.js +2 -6
  13. package/lib/core/plugin/loader.d.ts +5 -15
  14. package/lib/core/plugin/loader.js +5 -15
  15. package/lib/core/server/server.js +4 -4
  16. package/lib/event/handler/base.d.ts +1 -3
  17. package/lib/event/handler/base.js +1 -3
  18. package/lib/event/handler/message.js +9 -3
  19. package/lib/event/handler/notice.js +38 -32
  20. package/lib/event/handler/request.js +6 -6
  21. package/lib/index.d.ts +6 -0
  22. package/lib/index.js +6 -0
  23. package/lib/modules.d.ts +2 -2
  24. package/lib/modules.js +3 -2
  25. package/lib/types/adapter/accept.d.ts +24 -0
  26. package/lib/types/adapter/accept.js +1 -0
  27. package/lib/types/adapter/api.d.ts +88 -264
  28. package/lib/types/adapter/base.d.ts +3 -3
  29. package/lib/types/config/config.d.ts +4 -12
  30. package/lib/types/element/element.d.ts +119 -349
  31. package/lib/types/element/qqbot.d.ts +4 -12
  32. package/lib/types/event/contact.d.ts +6 -12
  33. package/lib/types/event/event.d.ts +59 -163
  34. package/lib/types/event/message.d.ts +11 -31
  35. package/lib/types/event/message.js +10 -12
  36. package/lib/types/event/notice.d.ts +118 -325
  37. package/lib/types/event/notice.js +8 -10
  38. package/lib/types/event/request.d.ts +29 -66
  39. package/lib/types/event/request.js +8 -10
  40. package/lib/types/event/sender.d.ts +7 -21
  41. package/lib/types/index.d.ts +1 -0
  42. package/lib/types/index.js +1 -0
  43. package/lib/types/onebot11/api.d.ts +49 -49
  44. package/lib/types/onebot11/event.d.ts +131 -347
  45. package/lib/types/onebot11/params.d.ts +184 -456
  46. package/lib/types/onebot11/response.d.ts +159 -381
  47. package/lib/types/onebot11/segment.d.ts +25 -75
  48. package/lib/types/onebot11/sender.d.ts +13 -39
  49. package/lib/types/plugin/app.d.ts +7 -11
  50. package/lib/types/plugin/plugin.d.ts +55 -165
  51. package/lib/types/render/render.d.ts +16 -48
  52. package/lib/utils/common/common.js +4 -2
  53. package/lib/utils/config/config.js +1 -1
  54. package/lib/utils/core/logger.js +3 -3
  55. package/lib/utils/core/segment.d.ts +28 -59
  56. package/lib/utils/core/segment.js +26 -30
  57. package/lib/utils/tools/restart.d.ts +3 -3
  58. package/lib/utils/tools/restart.js +5 -5
  59. package/package.json +1 -2
@@ -1,106 +1,62 @@
1
- export type ElementType = 'text' | 'at' | 'face' | 'bubble_face' | 'reply' | 'image' | 'video' | 'basketball' | 'dice' | 'rps' | 'poke' | 'music' | 'weather' | 'location' | 'share' | 'gift' | 'market_face' | 'forward' | 'contact' | 'json' | 'xml' | 'file' | 'markdown' | 'markdown_tpl' | 'keyboard' | 'node' | 'rows' | 'record' | 'long_msg' | 'raw' | 'passive_reply';
1
+ export type ElementType = 'text' | 'at' | 'face' | 'bubble_face' | 'reply' | 'image' | 'video' | 'basketball' | 'dice' | 'rps' | 'poke' | 'music' | 'weather' | 'location' | 'share' | 'gift' | 'market_face' | 'forward' | 'contact' | 'json' | 'xml' | 'file' | 'markdown' | 'markdown_tpl' | 'keyboard' | 'node' | 'rows' | 'record' | 'long_msg' | 'raw' | 'pasmsg';
2
2
  export interface Element {
3
- /**
4
- * - 元素类型
5
- */
3
+ /** 元素类型 */
6
4
  type: ElementType;
7
5
  }
8
- /**
9
- * - 文本元素
10
- */
6
+ /** 文本元素 */
11
7
  export interface TextElement extends Element {
12
8
  type: 'text';
13
- /**
14
- * - 文本内容
15
- */
9
+ /** 文本内容 */
16
10
  text: string;
17
11
  }
18
- /**
19
- * - At元素
20
- */
12
+ /** At元素 */
21
13
  export interface AtElement extends Element {
22
14
  type: 'at';
23
- /**
24
- * - At的uid
25
- */
15
+ /** At的uid */
26
16
  uid: string;
27
- /**
28
- * - At的uin
29
- */
17
+ /** At的uin */
30
18
  uin?: string;
31
- /**
32
- * - At的名称
33
- */
19
+ /** At的名称 */
34
20
  name?: string;
35
21
  }
36
- /**
37
- * - 表情元素
38
- */
22
+ /** 表情元素 */
39
23
  export interface FaceElement extends Element {
40
24
  type: 'face';
41
- /**
42
- * - 表情ID
43
- */
25
+ /** 表情ID */
44
26
  id: number;
45
- /**
46
- * - 是否大表情,默认不是
47
- */
27
+ /** 是否大表情,默认不是 */
48
28
  is_big?: boolean;
49
- /**
50
- * - 未知字段
51
- */
29
+ /** 未知字段 */
52
30
  result?: number;
53
31
  }
54
- /**
55
- * - 弹射表情元素
56
- */
32
+ /** 弹射表情元素 */
57
33
  export interface BubbleFaceElement extends Element {
58
34
  type: 'bubble_face';
59
- /**
60
- * - 表情ID
61
- */
35
+ /** 表情ID */
62
36
  id: number;
63
- /**
64
- * - 表情数量
65
- */
37
+ /** 表情数量 */
66
38
  count: number;
67
39
  }
68
- /**
69
- * - 回复元素
70
- */
40
+ /** 回复元素 */
71
41
  export interface ReplyElement extends Element {
72
42
  type: 'reply';
73
- /**
74
- * - 回复的消息ID
75
- */
43
+ /** 回复的消息ID */
76
44
  message_id: string;
77
45
  }
78
- /**
79
- * - 图片元素
80
- */
46
+ /** 图片元素 */
81
47
  export interface ImageElement extends Element {
82
48
  type: 'image';
83
- /**
84
- * - 图片url、路径或者base64
85
- */
49
+ /** 图片url、路径或者base64 */
86
50
  file: string;
87
- /**
88
- * - 图片名称
89
- */
51
+ /** 图片名称 */
90
52
  name?: string;
91
- /**
92
- * - 图片MD5
93
- */
53
+ /** 图片MD5 */
94
54
  md5?: string;
95
55
  /** 图片子类型 */
96
56
  sub_type?: string;
97
- /**
98
- * - 图片宽度
99
- */
57
+ /** 图片宽度 */
100
58
  width?: number;
101
- /**
102
- * - 图片高度
103
- */
59
+ /** 图片高度 */
104
60
  height?: number;
105
61
  /**
106
62
  * - show: 展示图片
@@ -109,321 +65,183 @@ export interface ImageElement extends Element {
109
65
  */
110
66
  file_type: 'show' | 'flash' | 'original';
111
67
  }
112
- /**
113
- * - 语音元素
114
- */
68
+ /** 语音元素 */
115
69
  export interface RecordElement extends Element {
116
70
  type: 'record';
117
- /**
118
- * - 语音文件url、路径或者base64
119
- */
71
+ /** 语音文件url、路径或者base64 */
120
72
  file: string;
121
- /**
122
- * - 是否为魔法语音
123
- */
73
+ /** 是否为魔法语音 */
124
74
  magic: boolean;
125
- /**
126
- * - 语音md5
127
- */
75
+ /** 语音md5 */
128
76
  md5?: string;
129
- /**
130
- * - 语音名称
131
- */
77
+ /** 语音名称 */
132
78
  name?: string;
133
79
  }
134
- /**
135
- * - 视频元素
136
- */
80
+ /** 视频元素 */
137
81
  export interface VideoElement extends Element {
138
82
  type: 'video';
139
- /**
140
- * - 视频文件url、路径或者base64
141
- */
83
+ /** 视频文件url、路径或者base64 */
142
84
  file: string;
143
- /**
144
- * - 视频md5
145
- */
85
+ /** 视频md5 */
146
86
  md5?: string;
147
- /**
148
- * - 视频名称
149
- */
87
+ /** 视频名称 */
150
88
  name?: string;
151
89
  }
152
- /**
153
- * - 篮球元素
154
- */
90
+ /** 篮球元素 */
155
91
  export interface BasketballElement extends Element {
156
92
  type: 'basketball';
157
- /**
158
- * - 篮球ID
159
- */
93
+ /** 篮球ID */
160
94
  id: number;
161
95
  }
162
- /**
163
- * - 骰子元素
164
- */
96
+ /** 骰子元素 */
165
97
  export interface DiceElement extends Element {
166
98
  type: 'dice';
167
- /**
168
- * - 骰子ID
169
- */
99
+ /** 骰子ID */
170
100
  id: number;
171
101
  }
172
- /**
173
- * - 石头剪刀布元素
174
- */
102
+ /** 石头剪刀布元素 */
175
103
  export interface RpsElement extends Element {
176
104
  type: 'rps';
177
- /**
178
- * - 石头剪刀布ID
179
- */
105
+ /** 石头剪刀布ID */
180
106
  id: number;
181
107
  }
182
- /**
183
- * - 戳一戳元素
184
- */
108
+ /** 戳一戳元素 */
185
109
  export interface PokeElement extends Element {
186
110
  type: 'poke';
187
- /**
188
- * - 戳一戳ID
189
- */
111
+ /** 戳一戳ID */
190
112
  id: number;
191
- /**
192
- * - 戳一戳类型
193
- */
113
+ /** 戳一戳类型 */
194
114
  poke_type: number;
195
- /**
196
- * - 戳一戳强度(1-5 默认1)
197
- */
115
+ /** 戳一戳强度(1-5 默认1) */
198
116
  strength: number;
199
117
  }
200
- /**
201
- * - 自定义音乐元素
202
- */
118
+ /** 自定义音乐元素 */
203
119
  export interface CustomMusicElemen {
204
120
  type: 'music';
205
- /**
206
- * - 音乐平台
207
- */
121
+ /** 音乐平台 */
208
122
  platform: 'QQ' | 'netease' | 'custom';
209
- /**
210
- * - 跳转链接
211
- */
123
+ /** 跳转链接 */
212
124
  url: string;
213
- /**
214
- * - 音乐音频链接
215
- */
125
+ /** 音乐音频链接 */
216
126
  audio: string;
217
- /**
218
- * - 标题
219
- */
127
+ /** 标题 */
220
128
  title: string;
221
- /**
222
- * - 歌手
223
- */
129
+ /** 歌手 */
224
130
  author: string;
225
- /**
226
- * - 封面
227
- */
131
+ /** 封面 */
228
132
  pic: string;
229
133
  id: string;
230
134
  }
231
135
  export interface MusicElement extends Element {
232
136
  type: 'music';
233
- /**
234
- * - 音乐平台
235
- */
137
+ /** 音乐平台 */
236
138
  platform: 'QQ' | 'netease' | 'custom';
237
- /**
238
- * - 音乐ID
239
- */
139
+ /** 音乐ID */
240
140
  id: string;
241
141
  }
242
- /**
243
- * - 天气元素
244
- */
142
+ /** 天气元素 */
245
143
  export interface WeatherElement extends Element {
246
144
  type: 'weather';
247
- /**
248
- * - 城市名称
249
- */
145
+ /** 城市名称 */
250
146
  city: string;
251
- /**
252
- * - 城市代码
253
- */
147
+ /** 城市代码 */
254
148
  code: string;
255
149
  }
256
- /**
257
- * - 位置元素
258
- */
150
+ /** 位置元素 */
259
151
  export interface LocationElement extends Element {
260
152
  type: 'location';
261
- /**
262
- * - 纬度
263
- */
153
+ /** 纬度 */
264
154
  lat: number;
265
- /**
266
- * - 经度
267
- */
155
+ /** 经度 */
268
156
  lon: number;
269
- /**
270
- * - 标题
271
- */
157
+ /** 标题 */
272
158
  title: string;
273
- /**
274
- * - 地址
275
- */
159
+ /** 地址 */
276
160
  address: string;
277
161
  }
278
- /**
279
- * - 分享元素
280
- */
162
+ /** 分享元素 */
281
163
  export interface ShareElement extends Element {
282
164
  type: 'share';
283
- /**
284
- * - 分享链接
285
- */
165
+ /** 分享链接 */
286
166
  url: string;
287
- /**
288
- * - 分享标题
289
- */
167
+ /** 分享标题 */
290
168
  title: string;
291
- /**
292
- * - 分享内容
293
- */
169
+ /** 分享内容 */
294
170
  content: string;
295
- /**
296
- * - 分享图片
297
- */
171
+ /** 分享图片 */
298
172
  image: string;
299
173
  }
300
- /**
301
- * - 礼物元素
302
- */
174
+ /** 礼物元素 */
303
175
  export interface GiftElement extends Element {
304
176
  type: 'gift';
305
- /**
306
- * - QQ 号
307
- */
177
+ /** QQ 号 */
308
178
  qq: number;
309
- /**
310
- * - 礼物ID
311
- */
179
+ /** 礼物ID */
312
180
  id: number;
313
181
  }
314
- /**
315
- * - 商城表情元素
316
- */
182
+ /** 商城表情元素 */
317
183
  export interface MarketFaceElement extends Element {
318
184
  type: 'market_face';
319
185
  id: string;
320
186
  }
321
- /**
322
- * - 转发元素
323
- */
187
+ /** 转发元素 */
324
188
  export interface ForwardElement extends Element {
325
189
  type: 'forward';
326
- /**
327
- * - 资源ID
328
- */
190
+ /** 资源ID */
329
191
  res_id: string;
330
- /**
331
- * - 序列号(可能不对?)
332
- */
192
+ /** 序列号(可能不对?) */
333
193
  uniseq: string;
334
- /**
335
- * - 摘要
336
- */
194
+ /** 摘要 */
337
195
  summary: string;
338
- /**
339
- * - 描述
340
- */
196
+ /** 描述 */
341
197
  description: string;
342
198
  }
343
- /**
344
- * - 分享名片
345
- */
199
+ /** 分享名片 */
346
200
  export interface ContactElement extends Element {
347
201
  type: 'contact';
348
- /**
349
- * - 分享类型
350
- */
202
+ /** 分享类型 */
351
203
  scene: 'group' | 'friend';
352
- /**
353
- * - 被推荐人的QQ号或者被推荐群的群号
354
- */
204
+ /** 被推荐人的QQ号或者被推荐群的群号 */
355
205
  peer: string;
356
206
  }
357
- /**
358
- * - JSON元素
359
- */
207
+ /** JSON元素 */
360
208
  export interface JsonElement extends Element {
361
209
  type: 'json';
362
- /**
363
- * - JSON序列化过的字符串
364
- */
210
+ /** JSON序列化过的字符串 */
365
211
  data: string;
366
212
  }
367
- /**
368
- * - XML元素
369
- */
213
+ /** XML元素 */
370
214
  export interface XmlElement extends Element {
371
215
  type: 'xml';
372
- /**
373
- * - XML字符串
374
- */
216
+ /** XML字符串 */
375
217
  data: string;
376
218
  }
377
- /**
378
- * - 文件元素
379
- */
219
+ /** 文件元素 */
380
220
  export interface FileElement extends Element {
381
221
  type: 'file';
382
- /**
383
- * - 文件URL、路径或者base64
384
- */
222
+ /** 文件URL、路径或者base64 */
385
223
  file: string;
386
- /**
387
- * - 文件名称
388
- */
224
+ /** 文件名称 */
389
225
  name?: string;
390
- /**
391
- * - 文件大小
392
- */
226
+ /** 文件大小 */
393
227
  size?: number;
394
- /**
395
- * - 文件过期时间
396
- */
228
+ /** 文件过期时间 */
397
229
  expire_time?: number;
398
- /**
399
- * - 文件ID
400
- */
230
+ /** 文件ID */
401
231
  id?: string;
402
- /**
403
- * - 文件URL
404
- */
232
+ /** 文件URL */
405
233
  url?: string;
406
- /**
407
- * - 文件大小?
408
- */
234
+ /** 文件大小? */
409
235
  biz?: number;
410
- /**
411
- * - 文件子ID
412
- */
236
+ /** 文件子ID */
413
237
  sub_id?: string;
414
- /**
415
- * - 文件MD5
416
- */
238
+ /** 文件MD5 */
417
239
  md5?: string;
418
240
  }
419
- /**
420
- * - 原生 Markdown 元素
421
- */
241
+ /** 原生 Markdown 元素 */
422
242
  export interface RawMarkdownElement extends Element {
423
243
  type: 'markdown';
424
- /**
425
- * - 原生markdown内容
426
- */
244
+ /** 原生markdown内容 */
427
245
  content: string;
428
246
  config?: {
429
247
  /** 未知的参数 */
@@ -432,67 +250,43 @@ export interface RawMarkdownElement extends Element {
432
250
  token: string;
433
251
  };
434
252
  }
435
- /**
436
- * - 模板 Markdown 元素
437
- */
253
+ /** 模板 Markdown 元素 */
438
254
  export interface TplMarkdownElement extends Element {
439
255
  type: 'markdown_tpl';
440
- /**
441
- * - 模板ID
442
- */
256
+ /** 模板ID */
443
257
  custom_template_id: string;
444
- /**
445
- * - 模板参数
446
- */
258
+ /** 模板参数 */
447
259
  params: Array<{
448
- /**
449
- * - 模板参数键名称
450
- */
260
+ /** 模板参数键名称 */
451
261
  key: string;
452
- /**
453
- * - 模板参数值
454
- */
262
+ /** 模板参数值 */
455
263
  values: Array<string>;
456
264
  }>;
457
265
  }
458
- /**
459
- * - Markdown 元素
460
- */
266
+ /** Markdown 元素 */
461
267
  export interface MarkdownElement extends Element {
462
268
  type: 'markdown';
463
- /**
464
- * - Markdown内容
465
- */
269
+ /** Markdown内容 */
466
270
  content: string;
467
271
  }
468
272
  /**
469
273
  * 单个按钮结构 这是karin的按钮结构 与qqbot的不同
470
274
  */
471
275
  export interface Button {
472
- /**
473
- * - 按钮显示文本
474
- */
276
+ /** 按钮显示文本 */
475
277
  text: string;
476
- /**
477
- * - 按钮类型 不建议使用 此为预留字段
478
- */
278
+ /** 按钮类型 不建议使用 此为预留字段 */
479
279
  type?: number;
480
280
  /**
481
281
  * - 是否为回调按钮
482
282
  * @default false
483
283
  */
484
284
  callback?: boolean;
485
- /**
486
- * - 跳转按钮
487
- */
285
+ /** 跳转按钮 */
488
286
  link?: string;
489
- /**
490
- * - 操作相关的数据
491
- */
287
+ /** 操作相关的数据 */
492
288
  data?: string;
493
- /**
494
- * - 按钮点击后显示的文字,不传为text
495
- */
289
+ /** 按钮点击后显示的文字,不传为text */
496
290
  show?: string;
497
291
  /**
498
292
  * 按钮样式
@@ -503,60 +297,38 @@ export interface Button {
503
297
  * - 4-白色填充
504
298
  */
505
299
  style?: number;
506
- /**
507
- * - 点击按钮后直接自动发送 data
508
- */
300
+ /** 点击按钮后直接自动发送 data */
509
301
  enter?: boolean;
510
- /**
511
- * - 指令是否带引用回复本消息
512
- */
302
+ /** 指令是否带引用回复本消息 */
513
303
  reply?: boolean;
514
- /**
515
- * - 是否仅群管理员可操作
516
- */
304
+ /** 是否仅群管理员可操作 */
517
305
  admin?: boolean;
518
- /**
519
- * - 有权限点击的用户UID列表 群聊、私聊
520
- */
306
+ /** 有权限点击的用户UID列表 群聊、私聊 */
521
307
  list?: string[];
522
- /**
523
- * - 有权限点击的用户UID列表 频道
524
- */
308
+ /** 有权限点击的用户UID列表 频道 */
525
309
  role?: string[];
526
- /**
527
- * - 客户端不支持本 action 的时候,弹出的 toast 文案
528
- */
310
+ /** 客户端不支持本 action 的时候,弹出的 toast 文案 */
529
311
  tips?: string;
530
312
  }
531
- /**
532
- * - 按钮 构建单行多个按钮
533
- */
313
+ /** 按钮 构建单行多个按钮 */
534
314
  export interface ButtonElement {
535
315
  type: 'button';
536
316
  data: Array<Button>;
537
317
  }
538
- /**
539
- * - 按钮组 构建多行多个按钮
540
- */
318
+ /** 按钮组 构建多行多个按钮 */
541
319
  export interface KeyBoardElement extends Element {
542
320
  type: 'keyboard';
543
321
  rows: Array<Array<Button>>;
544
322
  }
545
- /**
546
- * - 长消息元素
547
- */
323
+ /** 长消息元素 */
548
324
  export interface LongMsgElement extends Element {
549
325
  type: 'long_msg';
550
- /**
551
- * - 消息ID
552
- */
326
+ /** 消息ID */
553
327
  id: string;
554
328
  }
555
- /**
556
- * - 回复被动消息 键入此字段代表此条消息为被动消息
557
- */
558
- export interface PassiveElement extends Element {
559
- type: 'passive_reply';
329
+ /** 回复被动消息 键入此字段代表此条消息为被动消息 */
330
+ export interface PasmsgElement extends Element {
331
+ type: 'pasmsg';
560
332
  id: string;
561
333
  }
562
334
  /**
@@ -566,10 +338,8 @@ export interface RawElement extends Element {
566
338
  type: 'raw';
567
339
  data: any;
568
340
  }
569
- export type KarinElement = TextElement | AtElement | FaceElement | BubbleFaceElement | ReplyElement | ImageElement | VideoElement | BasketballElement | DiceElement | RpsElement | PokeElement | MusicElement | WeatherElement | LocationElement | ShareElement | GiftElement | MarketFaceElement | ForwardElement | ContactElement | JsonElement | XmlElement | FileElement | ButtonElement | KeyBoardElement | RecordElement | LongMsgElement | TplMarkdownElement | RawMarkdownElement | RawElement | PassiveElement;
570
- /**
571
- * - 构建自定义转发节点 此元素仅可通过专用接口发送 不支持混合发送
572
- */
341
+ export type KarinElement = TextElement | AtElement | FaceElement | BubbleFaceElement | ReplyElement | ImageElement | VideoElement | BasketballElement | DiceElement | RpsElement | PokeElement | MusicElement | WeatherElement | LocationElement | ShareElement | GiftElement | MarketFaceElement | ForwardElement | ContactElement | JsonElement | XmlElement | FileElement | ButtonElement | KeyBoardElement | RecordElement | LongMsgElement | TplMarkdownElement | RawMarkdownElement | RawElement | PasmsgElement;
342
+ /** 构建自定义转发节点 此元素仅可通过专用接口发送 不支持混合发送 */
573
343
  export interface NodeElement extends Element {
574
344
  type: 'node';
575
345
  id?: string;
@@ -9,21 +9,13 @@ export interface RawMarkdownType {
9
9
  * 模板Markdown消息结构
10
10
  */
11
11
  export interface TplMarkdownType {
12
- /**
13
- * - 模板ID
14
- */
12
+ /** 模板ID */
15
13
  custom_template_id: string;
16
- /**
17
- * - 模板参数
18
- */
14
+ /** 模板参数 */
19
15
  params: Array<{
20
- /**
21
- * - 模板参数键名称
22
- */
16
+ /** 模板参数键名称 */
23
17
  key: string;
24
- /**
25
- * - 模板参数值
26
- */
18
+ /** 模板参数值 */
27
19
  values: Array<string>;
28
20
  }>;
29
21
  }