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.
- package/lib/adapter/onebot/onebot11.d.ts +3 -5
- package/lib/adapter/onebot/onebot11.js +4 -1
- package/lib/core/karin.d.ts +45 -4
- package/lib/core/karin.js +52 -1
- package/lib/core/listener.d.ts +2 -2
- package/lib/core/listener.js +1 -0
- package/lib/core/plugin.app.d.ts +4 -1
- package/lib/core/plugin.app.js +3 -3
- package/lib/core/plugin.d.ts +8 -2
- package/lib/core/plugin.loader.d.ts +11 -4
- package/lib/core/plugin.loader.js +49 -12
- package/lib/db/index.d.ts +2 -4
- package/lib/db/index.js +2 -4
- package/lib/db/level.d.ts +1 -0
- package/lib/db/level.js +1 -0
- package/lib/db/redis.d.ts +2 -41
- package/lib/db/redis.js +2 -3
- package/lib/event/event.d.ts +7 -3
- package/lib/event/event.handler.d.ts +7 -6
- package/lib/event/event.handler.js +5 -0
- package/lib/event/event.js +5 -0
- package/lib/event/index.js +2 -2
- package/lib/event/message.handler.d.ts +3 -3
- package/lib/event/message.handler.js +8 -11
- package/lib/event/notice.d.ts +4 -4
- package/lib/event/notice.handler.d.ts +17 -0
- package/lib/event/notice.handler.js +203 -0
- package/lib/event/request.d.ts +4 -4
- package/lib/event/request.handler.d.ts +17 -0
- package/lib/event/request.handler.js +109 -0
- package/lib/event/request.js +1 -0
- package/lib/event/review.handler.js +12 -24
- package/lib/index.d.ts +5 -66
- package/lib/index.js +0 -1
- package/lib/render/client.d.ts +0 -1
- package/lib/render/server.d.ts +0 -2
- package/lib/types/adapter.d.ts +2 -3
- package/lib/types/api.d.ts +295 -0
- package/lib/types/api.js +1 -0
- package/lib/types/event.d.ts +127 -241
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/plugin.d.ts +4 -5
- package/lib/utils/button.d.ts +2 -2
- package/lib/utils/common.d.ts +1 -2
- package/lib/utils/config.d.ts +3 -4
- package/lib/utils/config.js +17 -3
- package/lib/utils/exec.d.ts +3 -3
- package/lib/utils/ffmpeg.d.ts +3 -3
- package/lib/utils/handler.d.ts +6 -13
- package/lib/utils/handler.js +3 -1
- package/lib/utils/segment.d.ts +6 -6
- package/package.json +16 -17
- package/lib/utils/kritor-proto.d.ts +0 -1
package/lib/types/event.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { KarinAdapter } from './adapter.js';
|
|
1
2
|
import { KarinElement } from './element.js';
|
|
2
|
-
import {
|
|
3
|
+
import { Reply, replyCallback } from './reply.js';
|
|
3
4
|
/**
|
|
4
5
|
* - 事件类型
|
|
5
6
|
*/
|
|
@@ -8,10 +9,6 @@ export type Event = 'message' | 'notice' | 'request' | 'meta_event' | 'message_s
|
|
|
8
9
|
* - 事件来源
|
|
9
10
|
*/
|
|
10
11
|
export type Scene = 'group' | 'private' | 'guild' | 'nearby' | 'stranger' | 'stranger_from_group';
|
|
11
|
-
/**
|
|
12
|
-
* - 事件子类型
|
|
13
|
-
*/
|
|
14
|
-
export type SubEvent = 'group_message' | 'friend_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group' | 'friend_poke' | 'friend_recall' | 'friend_file_uploaded' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_ban' | 'group_sign' | 'group_whole_ban' | 'group_file_uploaded' | 'friend_apply' | 'group_apply' | 'invited_group';
|
|
15
12
|
/**
|
|
16
13
|
* - 类型映射
|
|
17
14
|
*/
|
|
@@ -19,12 +16,13 @@ export type EventToSubEvent = {
|
|
|
19
16
|
message: 'group_message' | 'friend_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
|
|
20
17
|
notice: 'friend_poke' | 'friend_recall' | 'friend_file_uploaded' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_ban' | 'group_sign' | 'group_whole_ban' | 'group_file_uploaded' | 'group_message_reaction';
|
|
21
18
|
request: 'friend_apply' | 'group_apply' | 'invited_group';
|
|
22
|
-
meta_event: 'group_message' | 'friend_message' | 'guild_message';
|
|
19
|
+
meta_event: 'group_message' | 'friend_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
|
|
20
|
+
message_sent: 'group_message' | 'friend_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
|
|
23
21
|
};
|
|
24
22
|
/**
|
|
25
|
-
* -
|
|
23
|
+
* - 事件子类型
|
|
26
24
|
*/
|
|
27
|
-
export type
|
|
25
|
+
export type SubEvent = EventToSubEvent['message'] | EventToSubEvent['notice'] | EventToSubEvent['request'];
|
|
28
26
|
/**
|
|
29
27
|
* - 权限类型
|
|
30
28
|
*/
|
|
@@ -74,7 +72,7 @@ export interface Sender {
|
|
|
74
72
|
/**
|
|
75
73
|
* - 通知事件类型
|
|
76
74
|
*/
|
|
77
|
-
export interface
|
|
75
|
+
export interface NoticeType {
|
|
78
76
|
/**
|
|
79
77
|
* - 私聊戳一戳
|
|
80
78
|
*/
|
|
@@ -520,10 +518,6 @@ export interface NoticeTytpe {
|
|
|
520
518
|
is_set: boolean;
|
|
521
519
|
};
|
|
522
520
|
}
|
|
523
|
-
/**
|
|
524
|
-
* - 通知事件泛型
|
|
525
|
-
*/
|
|
526
|
-
export type NoticeEvent<E extends keyof NoticeTytpe> = E extends keyof NoticeTytpe ? NoticeTytpe[E] : never;
|
|
527
521
|
/**
|
|
528
522
|
* - 请求事件类型
|
|
529
523
|
*/
|
|
@@ -593,315 +587,207 @@ export interface RequestType {
|
|
|
593
587
|
};
|
|
594
588
|
}
|
|
595
589
|
/**
|
|
596
|
-
* -
|
|
597
|
-
*/
|
|
598
|
-
export type RequestEvent<E extends keyof RequestType> = E extends keyof RequestType ? RequestType[E] : never;
|
|
599
|
-
/**
|
|
600
|
-
* - 转发、历史消息返回的结构
|
|
590
|
+
* - 事件基类
|
|
601
591
|
*/
|
|
602
|
-
export interface
|
|
603
|
-
/**
|
|
604
|
-
* - 消息发送时间
|
|
605
|
-
*/
|
|
606
|
-
time: number;
|
|
607
|
-
/**
|
|
608
|
-
* - 消息ID
|
|
609
|
-
*/
|
|
610
|
-
message_id: string;
|
|
611
|
-
/**
|
|
612
|
-
* - 消息序列号
|
|
613
|
-
*/
|
|
614
|
-
message_seq: number;
|
|
592
|
+
export interface KarinEventType {
|
|
615
593
|
/**
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
594
|
+
* - 机器人ID 请尽量使用UID
|
|
595
|
+
*/
|
|
596
|
+
self_id: string;
|
|
619
597
|
/**
|
|
620
|
-
* -
|
|
598
|
+
* - 用户ID
|
|
621
599
|
*/
|
|
622
|
-
|
|
600
|
+
user_id: string;
|
|
623
601
|
/**
|
|
624
|
-
* -
|
|
625
|
-
|
|
626
|
-
elements: Array<KarinElement>;
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* - 精华消息返回的结构
|
|
630
|
-
*/
|
|
631
|
-
export interface EssenceMessageBody {
|
|
632
|
-
/**
|
|
633
|
-
* - 群ID
|
|
602
|
+
* - 群ID 仅在群聊中存在
|
|
603
|
+
* @default ''
|
|
634
604
|
*/
|
|
635
605
|
group_id: string;
|
|
636
606
|
/**
|
|
637
|
-
* -
|
|
607
|
+
* - 事件类型
|
|
638
608
|
*/
|
|
639
|
-
|
|
609
|
+
event: Event;
|
|
640
610
|
/**
|
|
641
|
-
* -
|
|
611
|
+
* - 事件子类型
|
|
642
612
|
*/
|
|
643
|
-
|
|
613
|
+
sub_event: EventToSubEvent[Event];
|
|
644
614
|
/**
|
|
645
|
-
* -
|
|
615
|
+
* - 事件ID
|
|
646
616
|
*/
|
|
647
|
-
|
|
617
|
+
event_id: string;
|
|
648
618
|
/**
|
|
649
|
-
* -
|
|
619
|
+
* - 事件触发时间戳
|
|
650
620
|
*/
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* - 操作者uin
|
|
654
|
-
*/
|
|
655
|
-
operator_uin: string;
|
|
656
|
-
/**
|
|
657
|
-
* - 操作者昵称
|
|
658
|
-
*/
|
|
659
|
-
operator_nick: string;
|
|
660
|
-
/**
|
|
661
|
-
* - 操作时间
|
|
662
|
-
*/
|
|
663
|
-
operation_time: number;
|
|
664
|
-
/**
|
|
665
|
-
* - 消息时间
|
|
666
|
-
*/
|
|
667
|
-
message_time: number;
|
|
668
|
-
/**
|
|
669
|
-
* - 消息ID
|
|
670
|
-
*/
|
|
671
|
-
message_id: string;
|
|
672
|
-
/**
|
|
673
|
-
* - 消息序列号
|
|
674
|
-
*/
|
|
675
|
-
message_seq: string;
|
|
676
|
-
/**
|
|
677
|
-
* - 被设置的精华消息元素文本
|
|
678
|
-
*/
|
|
679
|
-
json_elements: string;
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* - QQ好友信息
|
|
683
|
-
*/
|
|
684
|
-
export interface FriendInfo {
|
|
685
|
-
/**
|
|
686
|
-
* - 用户UID
|
|
687
|
-
*/
|
|
688
|
-
uid: string;
|
|
689
|
-
/**
|
|
690
|
-
* - 用户UIN
|
|
691
|
-
*/
|
|
692
|
-
uin: string;
|
|
693
|
-
/**
|
|
694
|
-
* - qid
|
|
695
|
-
*/
|
|
696
|
-
qid: string;
|
|
697
|
-
/**
|
|
698
|
-
* - 名称
|
|
699
|
-
*/
|
|
700
|
-
nick: string;
|
|
701
|
-
/**
|
|
702
|
-
* - 备注
|
|
703
|
-
*/
|
|
704
|
-
remark?: string;
|
|
621
|
+
time: number;
|
|
705
622
|
/**
|
|
706
|
-
* -
|
|
623
|
+
* - 事件联系人信息
|
|
707
624
|
*/
|
|
708
|
-
|
|
625
|
+
contact: contact;
|
|
709
626
|
/**
|
|
710
|
-
* -
|
|
627
|
+
* - 事件发送者信息
|
|
711
628
|
*/
|
|
712
|
-
|
|
629
|
+
sender: Sender;
|
|
713
630
|
/**
|
|
714
|
-
* -
|
|
631
|
+
* - 是否为主人
|
|
632
|
+
* @default false
|
|
715
633
|
*/
|
|
716
|
-
|
|
634
|
+
isMaster: boolean;
|
|
717
635
|
/**
|
|
718
|
-
* -
|
|
636
|
+
* - 是否为管理员
|
|
637
|
+
* @default false
|
|
719
638
|
*/
|
|
720
|
-
|
|
639
|
+
isAdmin: boolean;
|
|
721
640
|
/**
|
|
722
|
-
* -
|
|
641
|
+
* - 是否为私聊
|
|
642
|
+
* @default false
|
|
723
643
|
*/
|
|
724
|
-
|
|
644
|
+
isPrivate: boolean;
|
|
725
645
|
/**
|
|
726
|
-
* -
|
|
727
|
-
*
|
|
646
|
+
* - 是否为群聊
|
|
647
|
+
* @default false
|
|
728
648
|
*/
|
|
729
|
-
|
|
649
|
+
isGroup: boolean;
|
|
730
650
|
/**
|
|
731
|
-
* -
|
|
732
|
-
*
|
|
651
|
+
* - 是否为频道
|
|
652
|
+
* @default false
|
|
733
653
|
*/
|
|
734
|
-
|
|
735
|
-
ext?: {
|
|
736
|
-
/**
|
|
737
|
-
* 大会员
|
|
738
|
-
*/
|
|
739
|
-
big_vip?: boolean;
|
|
740
|
-
/**
|
|
741
|
-
* 好莱坞/腾讯视频会员
|
|
742
|
-
*/
|
|
743
|
-
hollywood_vip?: boolean;
|
|
744
|
-
/**
|
|
745
|
-
* QQ会员
|
|
746
|
-
*/
|
|
747
|
-
qq_vip?: boolean;
|
|
748
|
-
/**
|
|
749
|
-
* QQ超级会员
|
|
750
|
-
*/
|
|
751
|
-
super_vip?: boolean;
|
|
752
|
-
/**
|
|
753
|
-
* 是否已经赞过
|
|
754
|
-
*/
|
|
755
|
-
voted?: boolean;
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* - QQ群信息
|
|
760
|
-
*/
|
|
761
|
-
export interface GroupInfo {
|
|
654
|
+
isGuild: boolean;
|
|
762
655
|
/**
|
|
763
|
-
* -
|
|
656
|
+
* - 是否为群临时会话
|
|
657
|
+
* @default false
|
|
764
658
|
*/
|
|
765
|
-
|
|
659
|
+
isGroupTemp: boolean;
|
|
766
660
|
/**
|
|
767
|
-
* -
|
|
661
|
+
* - 日志函数字符串
|
|
768
662
|
*/
|
|
769
|
-
|
|
663
|
+
logFnc: string;
|
|
770
664
|
/**
|
|
771
|
-
* -
|
|
665
|
+
* - 日志用户字符串
|
|
772
666
|
*/
|
|
773
|
-
|
|
667
|
+
logText: string;
|
|
774
668
|
/**
|
|
775
|
-
* -
|
|
669
|
+
* - 存储器 由开发者自行调用
|
|
776
670
|
*/
|
|
777
|
-
|
|
671
|
+
store: Map<string, any>;
|
|
778
672
|
/**
|
|
779
|
-
* -
|
|
673
|
+
* - 标准含义是代表原始事件文本,在karin是指经过karin处理后的事件文本
|
|
780
674
|
*/
|
|
781
|
-
|
|
675
|
+
raw_message: string;
|
|
782
676
|
/**
|
|
783
|
-
* -
|
|
677
|
+
* - 回复函数
|
|
784
678
|
*/
|
|
785
|
-
|
|
679
|
+
reply: Reply;
|
|
786
680
|
/**
|
|
787
|
-
* -
|
|
681
|
+
* - 回复函数 由适配器实现,开发者不应该直接调用
|
|
788
682
|
*/
|
|
789
|
-
|
|
683
|
+
replyCallback: replyCallback;
|
|
790
684
|
/**
|
|
791
|
-
* -
|
|
685
|
+
* - bot实现
|
|
792
686
|
*/
|
|
793
|
-
|
|
687
|
+
bot: KarinAdapter;
|
|
794
688
|
}
|
|
795
689
|
/**
|
|
796
|
-
* -
|
|
690
|
+
* - 消息事件基类
|
|
797
691
|
*/
|
|
798
|
-
export interface
|
|
799
|
-
/**
|
|
800
|
-
* - 用户UID
|
|
801
|
-
*/
|
|
802
|
-
uid: string;
|
|
692
|
+
export interface KarinMessageEvent extends KarinEventType {
|
|
803
693
|
/**
|
|
804
|
-
* -
|
|
694
|
+
* - 消息体
|
|
805
695
|
*/
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* - 用户昵称
|
|
809
|
-
*/
|
|
810
|
-
nick: string;
|
|
696
|
+
event: 'message' | 'message_sent';
|
|
811
697
|
/**
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
698
|
+
* - 消息ID
|
|
699
|
+
*/
|
|
700
|
+
message_id: string;
|
|
815
701
|
/**
|
|
816
|
-
* -
|
|
702
|
+
* - 消息序列号
|
|
817
703
|
*/
|
|
818
|
-
|
|
704
|
+
message_seq?: string;
|
|
819
705
|
/**
|
|
820
|
-
* -
|
|
706
|
+
* - 原始消息文本
|
|
821
707
|
*/
|
|
822
|
-
|
|
708
|
+
raw_message: string;
|
|
823
709
|
/**
|
|
824
|
-
* -
|
|
710
|
+
* - 消息体元素
|
|
825
711
|
*/
|
|
826
|
-
|
|
712
|
+
elements: Array<KarinElement>;
|
|
827
713
|
/**
|
|
828
|
-
* -
|
|
714
|
+
* - 框架处理后的文本
|
|
829
715
|
*/
|
|
830
|
-
|
|
716
|
+
msg: string;
|
|
831
717
|
/**
|
|
832
|
-
* -
|
|
718
|
+
* - 图片数组
|
|
833
719
|
*/
|
|
834
|
-
|
|
720
|
+
image: Array<string>;
|
|
835
721
|
/**
|
|
836
|
-
* -
|
|
722
|
+
* - AT数组
|
|
837
723
|
*/
|
|
838
|
-
|
|
724
|
+
at: Array<string>;
|
|
839
725
|
/**
|
|
840
|
-
* -
|
|
726
|
+
* - 是否AT机器人
|
|
841
727
|
*/
|
|
842
|
-
|
|
728
|
+
atBot: boolean;
|
|
843
729
|
/**
|
|
844
|
-
* -
|
|
730
|
+
* - 是否AT全体
|
|
845
731
|
*/
|
|
846
|
-
|
|
732
|
+
atAll: boolean;
|
|
847
733
|
/**
|
|
848
|
-
* -
|
|
734
|
+
* - 文件元素
|
|
849
735
|
*/
|
|
850
|
-
|
|
736
|
+
file: object;
|
|
851
737
|
/**
|
|
852
|
-
* -
|
|
738
|
+
* - 引用消息ID
|
|
853
739
|
*/
|
|
854
|
-
|
|
740
|
+
reply_id: string;
|
|
855
741
|
/**
|
|
856
|
-
* -
|
|
742
|
+
* - 消息别名
|
|
857
743
|
*/
|
|
858
|
-
|
|
744
|
+
alias: string;
|
|
859
745
|
}
|
|
860
746
|
/**
|
|
861
|
-
*
|
|
747
|
+
* - 基础通知事件接口,包含所有共同属性
|
|
862
748
|
*/
|
|
863
|
-
export interface
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
*/
|
|
883
|
-
avatar: string;
|
|
884
|
-
/**
|
|
885
|
-
* - 荣誉id
|
|
886
|
-
*/
|
|
887
|
-
id: number;
|
|
888
|
-
/**
|
|
889
|
-
* - 荣誉描述
|
|
890
|
-
*/
|
|
891
|
-
description: string;
|
|
749
|
+
export interface KarinNoticeEventBase extends KarinEventType {
|
|
750
|
+
event: 'notice';
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* - 辅助类型,用于生成 KarinNoticeEvent 的联合类型
|
|
754
|
+
*/
|
|
755
|
+
export type NoticeEvent<T extends keyof NoticeType> = KarinNoticeEventBase & {
|
|
756
|
+
sub_event: T;
|
|
757
|
+
content: NoticeType[T];
|
|
758
|
+
};
|
|
759
|
+
/**
|
|
760
|
+
* - 通知事件基类
|
|
761
|
+
*/
|
|
762
|
+
export type KarinNoticeEvent = NoticeEvent<'friend_poke'> | NoticeEvent<'friend_recall'> | NoticeEvent<'friend_file_uploaded'> | NoticeEvent<'group_poke'> | NoticeEvent<'group_card_changed'> | NoticeEvent<'group_member_unique_title_changed'> | NoticeEvent<'group_essence_changed'> | NoticeEvent<'group_recall'> | NoticeEvent<'group_member_increase'> | NoticeEvent<'group_member_decrease'> | NoticeEvent<'group_admin_changed'> | NoticeEvent<'group_member_ban'> | NoticeEvent<'group_sign'> | NoticeEvent<'group_whole_ban'> | NoticeEvent<'group_file_uploaded'> | NoticeEvent<'group_message_reaction'>;
|
|
763
|
+
/**
|
|
764
|
+
* - 请求事件基类
|
|
765
|
+
*/
|
|
766
|
+
export interface KarinRequestEventBase extends KarinEventType {
|
|
767
|
+
event: 'request';
|
|
892
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* - 辅助类型,用于生成 KarinRequestEvent 的联合类型
|
|
771
|
+
*/
|
|
772
|
+
export type RequestEvent<T extends keyof RequestType> = KarinRequestEventBase & {
|
|
773
|
+
sub_event: T;
|
|
774
|
+
content: RequestType[T];
|
|
775
|
+
};
|
|
776
|
+
/**
|
|
777
|
+
* - 请求事件基类
|
|
778
|
+
*/
|
|
779
|
+
export type KarinRequestEvent = RequestEvent<'friend_apply'> | RequestEvent<'group_apply'> | RequestEvent<'invited_group'>;
|
|
893
780
|
export interface EMap {
|
|
894
|
-
message:
|
|
895
|
-
notice:
|
|
896
|
-
request:
|
|
897
|
-
message_sent:
|
|
781
|
+
message: KarinMessageEvent;
|
|
782
|
+
notice: KarinNoticeEvent;
|
|
783
|
+
request: KarinRequestEvent;
|
|
784
|
+
message_sent: KarinMessageEvent;
|
|
898
785
|
meta_event: any;
|
|
899
786
|
}
|
|
900
|
-
export type
|
|
901
|
-
export type EType = KarinMessage | KarinNotice | KarinRequest;
|
|
787
|
+
export type EType = KarinMessageEvent | KarinNoticeEvent | KarinRequestEvent;
|
|
902
788
|
/**
|
|
903
789
|
* 根据accept函数是否存在来决定e的类型
|
|
904
790
|
*/
|
|
905
791
|
export type EventType<T> = T extends {
|
|
906
|
-
accept: (e:
|
|
907
|
-
} ?
|
|
792
|
+
accept: (e: KarinNoticeEvent | KarinRequestEvent) => Promise<void>;
|
|
793
|
+
} ? KarinNoticeEvent | KarinRequestEvent : KarinMessageEvent;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import schedule from 'node-schedule';
|
|
3
2
|
import { KarinNodeElement } from './element.js';
|
|
4
3
|
import { Reply, replyCallback } from './reply.js';
|
|
5
|
-
import { EventType, Event, Permission, SubEvent } from './event.js';
|
|
4
|
+
import { EventType, Event, Permission, SubEvent, KarinMessageEvent, KarinNoticeEvent, KarinRequestEvent } from './event.js';
|
|
6
5
|
/**
|
|
7
6
|
* - 插件根目录名称
|
|
8
7
|
* - 例如: karin-plugin-example
|
|
@@ -88,7 +87,7 @@ export interface PluginHandler {
|
|
|
88
87
|
/**
|
|
89
88
|
* - handler的处理方法名称
|
|
90
89
|
*/
|
|
91
|
-
fnc: string;
|
|
90
|
+
fnc: string | Function;
|
|
92
91
|
/**
|
|
93
92
|
* - handler优先级 不填默认为主优先度
|
|
94
93
|
*/
|
|
@@ -164,7 +163,7 @@ export interface PluginType {
|
|
|
164
163
|
* - 上报事件
|
|
165
164
|
* - 根据上报中的event字段来获取e的事件类型
|
|
166
165
|
*/
|
|
167
|
-
e:
|
|
166
|
+
e: KarinMessageEvent | KarinNoticeEvent | KarinRequestEvent;
|
|
168
167
|
/**
|
|
169
168
|
* - 快速回复
|
|
170
169
|
*/
|
|
@@ -259,7 +258,7 @@ export interface PluginApps {
|
|
|
259
258
|
/**
|
|
260
259
|
* - accept函数存在
|
|
261
260
|
*/
|
|
262
|
-
accept: boolean;
|
|
261
|
+
accept: boolean | Function;
|
|
263
262
|
/**
|
|
264
263
|
* - 命令规则
|
|
265
264
|
*/
|
package/lib/utils/button.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const button: (e:
|
|
1
|
+
import { KarinMessageEvent } from '../types/index.js';
|
|
2
|
+
export declare const button: (e: KarinMessageEvent) => Promise<any>;
|
package/lib/utils/common.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { AxiosRequestConfig } from 'axios';
|
|
3
2
|
import { Readable } from 'stream';
|
|
4
3
|
import { fs } from '../modules.js';
|
|
@@ -26,7 +25,7 @@ export declare const common: {
|
|
|
26
25
|
* @param type 请求类型
|
|
27
26
|
* @param param axios参数
|
|
28
27
|
*/
|
|
29
|
-
axios(url: string, type?:
|
|
28
|
+
axios(url: string, type?: "get" | "post", param?: AxiosRequestConfig): Promise<any | null>;
|
|
30
29
|
/**
|
|
31
30
|
* 递归创建目录
|
|
32
31
|
* @param dirname - 要创建的文件夹路径
|
package/lib/utils/config.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const config: {
|
|
|
21
21
|
/**
|
|
22
22
|
* 超时时间
|
|
23
23
|
*/
|
|
24
|
-
timeout(type?:
|
|
24
|
+
timeout(type?: "ws" | "grpc"): number;
|
|
25
25
|
/**
|
|
26
26
|
* Redis 配置
|
|
27
27
|
* 采用实时读取优化性能
|
|
@@ -29,7 +29,6 @@ export declare const config: {
|
|
|
29
29
|
readonly redis: Redis;
|
|
30
30
|
/**
|
|
31
31
|
* 主人列表
|
|
32
|
-
* @returns {string[]}
|
|
33
32
|
*/
|
|
34
33
|
readonly master: string[];
|
|
35
34
|
/**
|
|
@@ -58,14 +57,14 @@ export declare const config: {
|
|
|
58
57
|
/**
|
|
59
58
|
* 获取配置yaml
|
|
60
59
|
*/
|
|
61
|
-
getYaml(type:
|
|
60
|
+
getYaml(type: "defSet" | "config", name: string, isWatch?: boolean): any;
|
|
62
61
|
/**
|
|
63
62
|
* 监听配置文件
|
|
64
63
|
* @param {'defSet'|'config'} type 类型
|
|
65
64
|
* @param {string} name 文件名称 不带后缀
|
|
66
65
|
* @param {string} file 文件路径
|
|
67
66
|
*/
|
|
68
|
-
watch(type:
|
|
67
|
+
watch(type: "defSet" | "config", name: string, file: string): Promise<true | undefined>;
|
|
69
68
|
change_App(): Promise<void>;
|
|
70
69
|
change_config(): Promise<void>;
|
|
71
70
|
change_group(): Promise<void>;
|
package/lib/utils/config.js
CHANGED
|
@@ -90,7 +90,6 @@ export const config = new (class Cfg {
|
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* 主人列表
|
|
93
|
-
* @returns {string[]}
|
|
94
93
|
*/
|
|
95
94
|
get master () {
|
|
96
95
|
return this.Config.master || []
|
|
@@ -130,9 +129,24 @@ export const config = new (class Cfg {
|
|
|
130
129
|
const config = this.getYaml('config', 'config', true)
|
|
131
130
|
const defSet = this.getYaml('defSet', 'config', false)
|
|
132
131
|
const data = { ...defSet, ...config }
|
|
132
|
+
const Config = {
|
|
133
|
+
...data,
|
|
134
|
+
WhiteList: {
|
|
135
|
+
users: data.WhiteList.users.map((i) => String(i)),
|
|
136
|
+
groups: data.WhiteList.groups.map((i) => String(i)),
|
|
137
|
+
GroupMsgLog: data.WhiteList.GroupMsgLog.map((i) => String(i)),
|
|
138
|
+
},
|
|
139
|
+
BlackList: {
|
|
140
|
+
users: data.BlackList.users.map((i) => String(i)),
|
|
141
|
+
groups: data.BlackList.groups.map((i) => String(i)),
|
|
142
|
+
GroupMsgLog: data.BlackList.GroupMsgLog.map((i) => String(i)),
|
|
143
|
+
},
|
|
144
|
+
master: data.master.map((i) => String(i)),
|
|
145
|
+
admin: data.admin.map((i) => String(i)),
|
|
146
|
+
}
|
|
133
147
|
/** 缓存 */
|
|
134
|
-
this.change.set(key,
|
|
135
|
-
return
|
|
148
|
+
this.change.set(key, Config)
|
|
149
|
+
return Config
|
|
136
150
|
}
|
|
137
151
|
|
|
138
152
|
/**
|
package/lib/utils/exec.d.ts
CHANGED
|
@@ -11,12 +11,12 @@ export declare const exec: (cmd: string, log?: boolean, options?: {
|
|
|
11
11
|
/**
|
|
12
12
|
* - 执行状态
|
|
13
13
|
*/
|
|
14
|
-
status:
|
|
14
|
+
status: "ok" | "failed";
|
|
15
15
|
/**
|
|
16
16
|
* - 错误信息
|
|
17
17
|
*/
|
|
18
18
|
error: Error | null;
|
|
19
|
-
stdout: string |
|
|
20
|
-
stderr: string |
|
|
19
|
+
stdout: string | "";
|
|
20
|
+
stderr: string | "";
|
|
21
21
|
}>;
|
|
22
22
|
export default exec;
|
package/lib/utils/ffmpeg.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export default function ffmpeg(): Promise<false | ((cmd: string, log?: boolean,
|
|
|
5
5
|
cwd: string;
|
|
6
6
|
encoding: string;
|
|
7
7
|
}) => Promise<{
|
|
8
|
-
status: "
|
|
8
|
+
status: "ok" | "failed";
|
|
9
9
|
error: Error | null;
|
|
10
|
-
stdout: string;
|
|
11
|
-
stderr: string;
|
|
10
|
+
stdout: string | "";
|
|
11
|
+
stderr: string | "";
|
|
12
12
|
}>)>;
|