node-karin 0.12.15 → 0.12.17

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 (45) hide show
  1. package/lib/adapter/input/index.d.ts +1 -3
  2. package/lib/adapter/input/index.js +2 -4
  3. package/lib/adapter/onebot/11/event.d.ts +3 -9
  4. package/lib/adapter/onebot/11/event.js +7 -13
  5. package/lib/adapter/onebot/11/index.d.ts +21 -58
  6. package/lib/adapter/onebot/11/index.js +22 -59
  7. package/lib/cli/index.d.ts +5 -15
  8. package/lib/cli/index.js +6 -16
  9. package/lib/core/karin/karin.d.ts +8 -2
  10. package/lib/core/karin/karin.js +7 -3
  11. package/lib/core/listener/listener.d.ts +5 -15
  12. package/lib/core/listener/listener.js +5 -13
  13. package/lib/core/plugin/loader.d.ts +10 -16
  14. package/lib/core/plugin/loader.js +18 -15
  15. package/lib/core/server/server.d.ts +3 -9
  16. package/lib/core/server/server.js +3 -9
  17. package/lib/event/handler/base.d.ts +13 -24
  18. package/lib/event/handler/base.js +25 -24
  19. package/lib/event/handler/message.d.ts +8 -24
  20. package/lib/event/handler/message.js +11 -24
  21. package/lib/event/handler/notice.d.ts +3 -9
  22. package/lib/event/handler/notice.js +6 -9
  23. package/lib/event/handler/request.d.ts +3 -9
  24. package/lib/event/handler/request.js +6 -9
  25. package/lib/event/handler/review.d.ts +7 -21
  26. package/lib/event/handler/review.js +7 -21
  27. package/lib/index.d.ts +1 -2
  28. package/lib/index.js +1 -2
  29. package/lib/types/adapter/base.d.ts +21 -63
  30. package/lib/types/config/config.d.ts +65 -195
  31. package/lib/types/event/contact.d.ts +5 -9
  32. package/lib/types/event/event.d.ts +15 -30
  33. package/lib/types/event/message.d.ts +6 -15
  34. package/lib/types/event/message.js +2 -0
  35. package/lib/types/event/notice.d.ts +1 -0
  36. package/lib/types/event/notice.js +2 -0
  37. package/lib/types/event/request.d.ts +1 -0
  38. package/lib/types/event/request.js +2 -0
  39. package/lib/types/plugin/app.d.ts +13 -15
  40. package/lib/types/plugin/plugin.d.ts +22 -39
  41. package/lib/utils/index.d.ts +1 -0
  42. package/lib/utils/index.js +1 -0
  43. package/lib/utils/tools/yaml.d.ts +15 -0
  44. package/lib/utils/tools/yaml.js +43 -0
  45. package/package.json +1 -1
@@ -1,7 +1,5 @@
1
1
  import { KarinAdapter, Contact, KarinElement, LoggerLevel } from '../../types/index.js';
2
- /**
3
- * 标准输入输出适配器
4
- */
2
+ /** 标准输入输出适配器 */
5
3
  export declare class AdapterInput implements KarinAdapter {
6
4
  #private;
7
5
  token: string;
@@ -4,9 +4,7 @@ import { listener } from '../../core/index.js';
4
4
  import { config, common, YamlEditor, logger } from '../../utils/index.js';
5
5
  import { KarinMessage } from '../../types/index.js';
6
6
  const { enable, msgToFile, token: oldToken, ip } = config.Config.AdapterInput;
7
- /**
8
- * 标准输入输出适配器
9
- */
7
+ /** 标准输入输出适配器 */
10
8
  export class AdapterInput {
11
9
  token;
12
10
  socket;
@@ -88,7 +86,7 @@ export class AdapterInput {
88
86
  contact: {
89
87
  scene: "friend" /* Scene.Private */,
90
88
  peer: 'input',
91
- sub_peer: '',
89
+ sub_peer: null,
92
90
  },
93
91
  raw_event: { data: elements },
94
92
  };
@@ -8,17 +8,11 @@ export declare class OB11Event {
8
8
  * - @param data ob11相关标准数据
9
9
  */
10
10
  event(data: OB11EventAll): void;
11
- /**
12
- * 元事件
13
- */
11
+ /** 元事件 */
14
12
  metaEvent(data: OB11MetaEvent): void;
15
- /**
16
- * 消息事件
17
- */
13
+ /** 消息事件 */
18
14
  messageEvent(data: OB11MessageEvent): void;
19
- /**
20
- * 通知事件
21
- */
15
+ /** 通知事件 */
22
16
  noticeEvent(data: OB11NoticeEvent): void;
23
17
  /** 请求事件 */
24
18
  requestEvent(data: OB11RequestEvent): void;
@@ -28,9 +28,7 @@ export class OB11Event {
28
28
  this.adapter.logger('info', `未知事件:${JSON.stringify(data)}`);
29
29
  }
30
30
  }
31
- /**
32
- * 元事件
33
- */
31
+ /** 元事件 */
34
32
  metaEvent(data) {
35
33
  if (data.meta_event_type === 'heartbeat') {
36
34
  this.adapter.logger('trace', `[心跳]:${JSON.stringify(data.status)}`);
@@ -45,9 +43,7 @@ export class OB11Event {
45
43
  this.adapter.logger('debug', `[生命周期]:${typeMap[subType]}`);
46
44
  }
47
45
  }
48
- /**
49
- * 消息事件
50
- */
46
+ /** 消息事件 */
51
47
  messageEvent(data) {
52
48
  const message = {
53
49
  event: "message" /* EventType.Message */,
@@ -70,7 +66,7 @@ export class OB11Event {
70
66
  contact: {
71
67
  scene: data.message_type === 'private' ? "friend" /* Scene.Private */ : "group" /* Scene.Group */,
72
68
  peer: data.message_type === 'private' ? data.sender.user_id : data.group_id,
73
- sub_peer: '',
69
+ sub_peer: null,
74
70
  },
75
71
  group_id: data.message_type === 'group' ? data.group_id : '',
76
72
  raw_message: '',
@@ -80,9 +76,7 @@ export class OB11Event {
80
76
  e.replyCallback = async (elements) => await this.adapter.SendMessage(e.contact, elements);
81
77
  karin.emit('adapter.message', e);
82
78
  }
83
- /**
84
- * 通知事件
85
- */
79
+ /** 通知事件 */
86
80
  noticeEvent(data) {
87
81
  const time = data.time;
88
82
  const selfId = data.self_id + '';
@@ -99,7 +93,7 @@ export class OB11Event {
99
93
  const contact = {
100
94
  scene: 'group_id' in data ? "group" /* Scene.Group */ : "friend" /* Scene.Private */,
101
95
  peer: 'group_id' in data ? data.group_id : data.user_id,
102
- sub_peer: '',
96
+ sub_peer: null,
103
97
  };
104
98
  switch (data.notice_type) {
105
99
  // 群文件上传
@@ -410,7 +404,7 @@ export class OB11Event {
410
404
  contact: {
411
405
  scene: "friend" /* Scene.Private */,
412
406
  peer: data.user_id + '',
413
- sub_peer: '',
407
+ sub_peer: null,
414
408
  },
415
409
  sender: {
416
410
  uid: data.user_id + '',
@@ -441,7 +435,7 @@ export class OB11Event {
441
435
  contact: {
442
436
  scene: "group" /* Scene.Group */,
443
437
  peer: data.group_id + '',
444
- sub_peer: '',
438
+ sub_peer: null,
445
439
  },
446
440
  sender: {
447
441
  uid: data.user_id + '',
@@ -15,9 +15,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
15
15
  adapter: KarinAdapter['adapter'];
16
16
  version: KarinAdapter['version'];
17
17
  constructor();
18
- /**
19
- * 反向ws初始化
20
- */
18
+ /** 反向ws初始化 */
21
19
  server(socket: WebSocket, request: IncomingMessage): Promise<void>;
22
20
  /**
23
21
  * 正向ws初始化
@@ -26,9 +24,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
26
24
  client(connect: string): Promise<void>;
27
25
  init(data: OB11EventAll): boolean;
28
26
  get self_id(): string;
29
- /**
30
- * 获取当前登录号信息
31
- */
27
+ /** 获取当前登录号信息 */
32
28
  getSelf(): Promise<void>;
33
29
  /**
34
30
  * onebot11转karin
@@ -40,9 +36,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
40
36
  * @param data karin格式消息
41
37
  */
42
38
  KarinConvertAdapter(data: Array<KarinElement>): OB11Segment[];
43
- /**
44
- * 专属当前Bot的日志打印方法
45
- */
39
+ /** 专属当前Bot的日志打印方法 */
46
40
  logger(level: LoggerLevel, ...args: any[]): void;
47
41
  /**
48
42
  * 获取头像url
@@ -104,6 +98,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
104
98
  contact: {
105
99
  scene: Scene;
106
100
  peer: string;
101
+ sub_peer: null;
107
102
  };
108
103
  sender: {
109
104
  uid: string;
@@ -124,7 +119,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
124
119
  contact: {
125
120
  scene: Scene;
126
121
  peer: string;
127
- sub_peer: string;
122
+ sub_peer: null;
128
123
  };
129
124
  sender: {
130
125
  uid: string;
@@ -194,9 +189,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
194
189
  * @param special_title - 专属头衔
195
190
  */
196
191
  SetGroupUniqueTitle(groupId: string, targetId: string, uniqueTitle: string): Promise<false | undefined>;
197
- /**
198
- * 获取登录号信息
199
- */
192
+ /** 获取登录号信息 */
200
193
  GetCurrentAccount(): Promise<{
201
194
  account_uid: string;
202
195
  account_uin: string;
@@ -238,31 +231,19 @@ export declare class AdapterOneBot11 implements KarinAdapter {
238
231
  */
239
232
  sex: "unknown" | "male" | "female";
240
233
  ext: {
241
- /**
242
- * 大会员
243
- */
234
+ /** 大会员 */
244
235
  big_vip: undefined;
245
- /**
246
- * 好莱坞/腾讯视频会员
247
- */
236
+ /** 好莱坞/腾讯视频会员 */
248
237
  hollywood_vip: undefined;
249
- /**
250
- * QQ会员
251
- */
238
+ /** QQ会员 */
252
239
  qq_vip: undefined;
253
- /**
254
- * QQ超级会员
255
- */
240
+ /** QQ超级会员 */
256
241
  super_vip: undefined;
257
- /**
258
- * 是否已经赞过
259
- */
242
+ /** 是否已经赞过 */
260
243
  voted: undefined;
261
244
  };
262
245
  }[]>;
263
- /**
264
- * 获取好友列表
265
- */
246
+ /** 获取好友列表 */
266
247
  GetFriendList(): Promise<{
267
248
  /** 用户UID */
268
249
  uid: string;
@@ -295,25 +276,15 @@ export declare class AdapterOneBot11 implements KarinAdapter {
295
276
  */
296
277
  sex: "unknown" | "male" | "female";
297
278
  ext: {
298
- /**
299
- * 大会员
300
- */
279
+ /** 大会员 */
301
280
  big_vip: undefined;
302
- /**
303
- * 好莱坞/腾讯视频会员
304
- */
281
+ /** 好莱坞/腾讯视频会员 */
305
282
  hollywood_vip: undefined;
306
- /**
307
- * QQ会员
308
- */
283
+ /** QQ会员 */
309
284
  qq_vip: undefined;
310
- /**
311
- * QQ超级会员
312
- */
285
+ /** QQ超级会员 */
313
286
  super_vip: undefined;
314
- /**
315
- * 是否已经赞过
316
- */
287
+ /** 是否已经赞过 */
317
288
  voted: undefined;
318
289
  };
319
290
  }[]>;
@@ -323,9 +294,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
323
294
  * @param noCache - 是否不使用缓存
324
295
  */
325
296
  GetGroupInfo(_groupId: string, noCache?: boolean): Promise<GroupInfo>;
326
- /**
327
- * 获取群列表
328
- */
297
+ /** 获取群列表 */
329
298
  GetGroupList(): Promise<{
330
299
  group_id: string;
331
300
  group_name: string;
@@ -383,9 +352,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
383
352
  unfriendly: boolean;
384
353
  card_changeable: boolean;
385
354
  }[]>;
386
- /**
387
- * 获取群荣誉信息
388
- */
355
+ /** 获取群荣誉信息 */
389
356
  GetGroupHonor(groupId: string, refresh?: boolean): Promise<GroupHonorInfo[]>;
390
357
  /**
391
358
  * 对消息进行表情回应
@@ -394,9 +361,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
394
361
  * @param faceId - 表情ID
395
362
  */
396
363
  ReactMessageWithEmoji(contact: Contact, messageId: string, faceId: number, isSet?: boolean): Promise<boolean>;
397
- /**
398
- * 获取版本信息
399
- */
364
+ /** 获取版本信息 */
400
365
  GetVersion(): Promise<{
401
366
  name: string;
402
367
  app_name: string;
@@ -404,9 +369,7 @@ export declare class AdapterOneBot11 implements KarinAdapter {
404
369
  protocol: string;
405
370
  }>;
406
371
  DownloadForwardMessage(resId: string): Promise<any>;
407
- /**
408
- * 精华消息
409
- */
372
+ /** 精华消息 */
410
373
  GetEssenceMessageList(groupId: string, page: number, pageSize: number): Promise<EssenceMessageBody[]>;
411
374
  /**
412
375
  * 上传群文件
@@ -21,9 +21,7 @@ export class AdapterOneBot11 {
21
21
  this.adapter = { id: 'QQ', name: 'OneBot11', type: 'ws', sub_type: 'internal', start_time: Date.now(), connect: '', index: 0 };
22
22
  this.version = { name: '', app_name: '', version: '' };
23
23
  }
24
- /**
25
- * 反向ws初始化
26
- */
24
+ /** 反向ws初始化 */
27
25
  async server(socket, request) {
28
26
  this.socket = socket;
29
27
  const selfId = String(request.headers['x-self-id']);
@@ -96,9 +94,7 @@ export class AdapterOneBot11 {
96
94
  get self_id() {
97
95
  return this.account.uid || this.account.uin;
98
96
  }
99
- /**
100
- * 获取当前登录号信息
101
- */
97
+ /** 获取当前登录号信息 */
102
98
  async getSelf() {
103
99
  const data = await this.GetCurrentAccount();
104
100
  try {
@@ -137,9 +133,7 @@ export class AdapterOneBot11 {
137
133
  KarinConvertAdapter(data) {
138
134
  return KarinConvertAdapter(data, this);
139
135
  }
140
- /**
141
- * 专属当前Bot的日志打印方法
142
- */
136
+ /** 专属当前Bot的日志打印方法 */
143
137
  logger(level, ...args) {
144
138
  logger.bot(level, this.account.uid || this.account.uin, ...args);
145
139
  }
@@ -272,6 +266,7 @@ export class AdapterOneBot11 {
272
266
  contact: {
273
267
  scene: res.message_type === 'group' ? "group" /* Scene.Group */ : "friend" /* Scene.Private */,
274
268
  peer: contact.peer, // 这里可能不准确 传入是什么就返回什么
269
+ sub_peer: null,
275
270
  },
276
271
  sender: {
277
272
  uid: res.sender.user_id,
@@ -316,7 +311,7 @@ export class AdapterOneBot11 {
316
311
  contact: {
317
312
  scene,
318
313
  peer: '',
319
- sub_peer: '',
314
+ sub_peer: null,
320
315
  },
321
316
  sender: {
322
317
  uid: '',
@@ -467,9 +462,7 @@ export class AdapterOneBot11 {
467
462
  return false;
468
463
  }
469
464
  }
470
- /**
471
- * 获取登录号信息
472
- */
465
+ /** 获取登录号信息 */
473
466
  async GetCurrentAccount() {
474
467
  const res = await this.SendApi("get_login_info" /* OB11Api.getLoginInfo */);
475
468
  return {
@@ -518,33 +511,21 @@ export class AdapterOneBot11 {
518
511
  */
519
512
  sex: res.sex,
520
513
  ext: {
521
- /**
522
- * 大会员
523
- */
514
+ /** 大会员 */
524
515
  big_vip: undefined,
525
- /**
526
- * 好莱坞/腾讯视频会员
527
- */
516
+ /** 好莱坞/腾讯视频会员 */
528
517
  hollywood_vip: undefined,
529
- /**
530
- * QQ会员
531
- */
518
+ /** QQ会员 */
532
519
  qq_vip: undefined,
533
- /**
534
- * QQ超级会员
535
- */
520
+ /** QQ超级会员 */
536
521
  super_vip: undefined,
537
- /**
538
- * 是否已经赞过
539
- */
522
+ /** 是否已经赞过 */
540
523
  voted: undefined,
541
524
  },
542
525
  },
543
526
  ];
544
527
  }
545
- /**
546
- * 获取好友列表
547
- */
528
+ /** 获取好友列表 */
548
529
  async GetFriendList() {
549
530
  const friendList = await this.SendApi("get_friend_list" /* OB11Api.getFriendList */);
550
531
  return friendList.map(v => {
@@ -581,25 +562,15 @@ export class AdapterOneBot11 {
581
562
  */
582
563
  sex: v.sex,
583
564
  ext: {
584
- /**
585
- * 大会员
586
- */
565
+ /** 大会员 */
587
566
  big_vip: undefined,
588
- /**
589
- * 好莱坞/腾讯视频会员
590
- */
567
+ /** 好莱坞/腾讯视频会员 */
591
568
  hollywood_vip: undefined,
592
- /**
593
- * QQ会员
594
- */
569
+ /** QQ会员 */
595
570
  qq_vip: undefined,
596
- /**
597
- * QQ超级会员
598
- */
571
+ /** QQ超级会员 */
599
572
  super_vip: undefined,
600
- /**
601
- * 是否已经赞过
602
- */
573
+ /** 是否已经赞过 */
603
574
  voted: undefined,
604
575
  },
605
576
  };
@@ -626,9 +597,7 @@ export class AdapterOneBot11 {
626
597
  owner: '',
627
598
  };
628
599
  }
629
- /**
630
- * 获取群列表
631
- */
600
+ /** 获取群列表 */
632
601
  async GetGroupList() {
633
602
  const groupList = await this.SendApi("get_group_list" /* OB11Api.getGroupList */);
634
603
  return groupList.map(v => {
@@ -703,9 +672,7 @@ export class AdapterOneBot11 {
703
672
  };
704
673
  });
705
674
  }
706
- /**
707
- * 获取群荣誉信息
708
- */
675
+ /** 获取群荣誉信息 */
709
676
  async GetGroupHonor(groupId, refresh = false) {
710
677
  const groupHonor = await this.SendApi("get_group_honor_info" /* OB11Api.getGroupHonorInfo */, { group_id: Number(groupId), type: 'all' });
711
678
  const result = [];
@@ -786,9 +753,7 @@ export class AdapterOneBot11 {
786
753
  return false;
787
754
  }
788
755
  }
789
- /**
790
- * 获取版本信息
791
- */
756
+ /** 获取版本信息 */
792
757
  async GetVersion() {
793
758
  const res = await this.SendApi("get_version_info" /* OB11Api.getVersionInfo */);
794
759
  return {
@@ -801,14 +766,12 @@ export class AdapterOneBot11 {
801
766
  async DownloadForwardMessage(resId) {
802
767
  throw new Error('Method not implemented.');
803
768
  }
804
- /**
805
- * 精华消息
806
- */
769
+ /** 精华消息 */
807
770
  async GetEssenceMessageList(groupId, page, pageSize) {
808
771
  const list = [];
809
772
  const res = await this.SendApi("get_essence_msg_list" /* OB11Api.getEssenceMsgList */, { group_id: Number(groupId) });
810
773
  for (const v of res) {
811
- const { message_seq: messageSeq, elements } = await this.GetMessage({ scene: "group" /* Scene.Group */, peer: groupId }, v.message_id + '');
774
+ const { message_seq: messageSeq, elements } = await this.GetMessage({ scene: "group" /* Scene.Group */, peer: groupId, sub_peer: null }, v.message_id + '');
812
775
  list.push({
813
776
  /** 群ID */
814
777
  group_id: groupId,
@@ -40,25 +40,15 @@ export declare class KarinCli {
40
40
  * @param runner - 运行器
41
41
  */
42
42
  start(mode: Mode, lang: Lang, runner: Runner): void;
43
- /**
44
- * pm2重启
45
- */
43
+ /** pm2重启 */
46
44
  restart(): Promise<void>;
47
- /**
48
- * pm2启动
49
- */
45
+ /** pm2启动 */
50
46
  pm2(): Promise<void>;
51
- /**
52
- * pm2结束进程
53
- */
47
+ /** pm2结束进程 */
54
48
  stop(): Promise<void>;
55
- /**
56
- * pm2查看日志
57
- */
49
+ /** pm2查看日志 */
58
50
  log(): Promise<void>;
59
- /**
60
- * 更新依赖
61
- */
51
+ /** 更新依赖 */
62
52
  update(): Promise<void>;
63
53
  /**
64
54
  * 获取指定包的本地版本
package/lib/cli/index.js CHANGED
@@ -98,9 +98,7 @@ export class KarinCli {
98
98
  return this.start(mode, lang, runner);
99
99
  });
100
100
  }
101
- /**
102
- * pm2重启
103
- */
101
+ /** pm2重启 */
104
102
  async restart() {
105
103
  const pm2Cfg = this.getConfigData('pm2');
106
104
  const serverCfg = this.getConfigData('server');
@@ -116,9 +114,7 @@ export class KarinCli {
116
114
  console.log('pm2服务已重启');
117
115
  process.exit(0);
118
116
  }
119
- /**
120
- * pm2启动
121
- */
117
+ /** pm2启动 */
122
118
  async pm2() {
123
119
  console.log('pm2启动中...');
124
120
  const filePath = this.getConfigPath('pm2');
@@ -136,9 +132,7 @@ export class KarinCli {
136
132
  console.log('pm2服务已启动 可执行 【npx karin log】 查看日志');
137
133
  process.exit(0);
138
134
  }
139
- /**
140
- * pm2结束进程
141
- */
135
+ /** pm2结束进程 */
142
136
  async stop() {
143
137
  console.log('pm2服务停止中...');
144
138
  const pm2Cfg = this.getConfigData('pm2');
@@ -154,9 +148,7 @@ export class KarinCli {
154
148
  console.log('pm2服务已停止');
155
149
  process.exit(0);
156
150
  }
157
- /**
158
- * pm2查看日志
159
- */
151
+ /** pm2查看日志 */
160
152
  async log() {
161
153
  const pm2Cfg = this.getConfigData('pm2');
162
154
  const serverCfg = this.getConfigData('server');
@@ -167,9 +159,7 @@ export class KarinCli {
167
159
  const type = res ? res.pm_id : pm2Cfg?.apps[0]?.name || 'Karin';
168
160
  spawn(cmd, ['logs', type, '--lines', lines], { stdio: 'inherit', shell: true, cwd: process.cwd() });
169
161
  }
170
- /**
171
- * 更新依赖
172
- */
162
+ /** 更新依赖 */
173
163
  async update() {
174
164
  const list = await getNpmPlugins(false);
175
165
  list.push('node-karin');
@@ -186,7 +176,7 @@ export class KarinCli {
186
176
  return;
187
177
  }
188
178
  console.log(`[依赖更新] ${item} 当前版本: ${local} 最新版本: ${remote}`);
189
- await this.exec(`${cmd} ${item}@latest`);
179
+ await this.exec(`${cmd} ${item}@${remote}`);
190
180
  console.log(`[依赖更新] ${item} 更新完成~`);
191
181
  }
192
182
  catch (error) {
@@ -1,4 +1,4 @@
1
- import { Contact, KarinElement, KarinMessage, KarinRenderType, RenderResult, AllMessageSubType, CommandInfo, TaskInfo, HandlerInfo, UseInfo, UseMapType, AppType, ButtonInfo, Permission, AcceptDict } from '../../types/index.js';
1
+ import { Scene, Contact, KarinElement, KarinMessage, KarinRenderType, RenderResult, AllMessageSubType, CommandInfo, TaskInfo, HandlerInfo, UseInfo, UseMapType, AppType, ButtonInfo, Permission, AcceptDict, KarinAdapter } from '../../types/index.js';
2
2
  import { Listeners } from '../listener/listener.js';
3
3
  export type FncFunction = (e: KarinMessage) => Promise<boolean>;
4
4
  export type FncElement = string | KarinElement | Array<KarinElement>;
@@ -16,6 +16,10 @@ export interface Options {
16
16
  * @default false
17
17
  */
18
18
  log?: boolean | Function;
19
+ /** 只有对应的适配器才会生效 */
20
+ adapter?: Array<KarinAdapter['adapter']['name']>;
21
+ /** 指定的适配器无效 */
22
+ notAdapter?: Array<KarinAdapter['adapter']['name']>;
19
23
  }
20
24
  export interface OptionsCommand extends Options {
21
25
  /** 监听事件 */
@@ -104,7 +108,7 @@ export declare class Karin extends Listeners {
104
108
  * @param peer - 频道id
105
109
  * @param subPeer - 子频道id
106
110
  */
107
- contactGuild(peer: Contact['peer'], subPeer: string): Contact;
111
+ contactGuild(peer: string, subPeer: string): Contact<Scene.Guild>;
108
112
  /**
109
113
  * 快速渲染
110
114
  * @param file - 文件路径、http地址
@@ -147,6 +151,8 @@ export declare class Karin extends Listeners {
147
151
  name: string;
148
152
  rank: number;
149
153
  type: AppType;
154
+ adapter: string[];
155
+ notAdapter: string[];
150
156
  };
151
157
  /**
152
158
  * 中间件
@@ -53,6 +53,8 @@ export class Karin extends Listeners {
53
53
  rank: options.priority || 10000,
54
54
  reg,
55
55
  type: "command" /* AppType.Command */,
56
+ adapter: options.adapter || [],
57
+ notAdapter: options.notAdapter || [],
56
58
  };
57
59
  }
58
60
  /**
@@ -104,7 +106,7 @@ export class Karin extends Listeners {
104
106
  * @param peer - 群号或者用户id
105
107
  * @param subPeer - 子id
106
108
  */
107
- contact(scene, peer, subPeer) {
109
+ contact(scene, peer, subPeer = null) {
108
110
  return { scene, peer, sub_peer: subPeer };
109
111
  }
110
112
  /**
@@ -112,14 +114,14 @@ export class Karin extends Listeners {
112
114
  * @param peer - 群号
113
115
  */
114
116
  contactGroup(peer) {
115
- return { scene: "group" /* Scene.Group */, peer };
117
+ return { scene: "group" /* Scene.Group */, peer, sub_peer: null };
116
118
  }
117
119
  /**
118
120
  * 构建friend_contact
119
121
  * @param peer - 用户id
120
122
  */
121
123
  contactFriend(peer) {
122
- return { scene: "friend" /* Scene.Private */, peer };
124
+ return { scene: "friend" /* Scene.Private */, peer, sub_peer: null };
123
125
  }
124
126
  /**
125
127
  * 构建guild_contact
@@ -185,6 +187,8 @@ export class Karin extends Listeners {
185
187
  name: options?.name || "accept" /* AppType.Accept */,
186
188
  rank: options?.priority || 10000,
187
189
  type: "accept" /* AppType.Accept */,
190
+ adapter: options?.adapter || [],
191
+ notAdapter: options?.notAdapter || [],
188
192
  };
189
193
  }
190
194
  /**