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