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.
- package/lib/adapter/input/index.d.ts +1 -1
- package/lib/adapter/input/index.js +1 -1
- package/lib/adapter/onebot/11/event.js +90 -84
- package/lib/adapter/onebot/11/index.d.ts +89 -127
- package/lib/adapter/onebot/11/index.js +192 -254
- package/lib/cli/index.js +2 -2
- package/lib/core/init/config.js +1 -1
- package/lib/core/karin/karin.d.ts +21 -30
- package/lib/core/karin/karin.js +7 -9
- package/lib/core/listener/listener.js +11 -11
- package/lib/core/plugin/base.d.ts +7 -21
- package/lib/core/plugin/base.js +2 -6
- package/lib/core/plugin/loader.d.ts +5 -15
- package/lib/core/plugin/loader.js +5 -15
- package/lib/core/server/server.js +4 -4
- package/lib/event/handler/base.d.ts +1 -3
- package/lib/event/handler/base.js +1 -3
- package/lib/event/handler/message.js +9 -3
- package/lib/event/handler/notice.js +38 -32
- package/lib/event/handler/request.js +6 -6
- package/lib/index.d.ts +6 -0
- package/lib/index.js +6 -0
- package/lib/modules.d.ts +2 -2
- package/lib/modules.js +3 -2
- package/lib/types/adapter/accept.d.ts +24 -0
- package/lib/types/adapter/accept.js +1 -0
- package/lib/types/adapter/api.d.ts +88 -264
- package/lib/types/adapter/base.d.ts +3 -3
- package/lib/types/config/config.d.ts +4 -12
- package/lib/types/element/element.d.ts +119 -349
- package/lib/types/element/qqbot.d.ts +4 -12
- package/lib/types/event/contact.d.ts +6 -12
- package/lib/types/event/event.d.ts +59 -163
- package/lib/types/event/message.d.ts +11 -31
- package/lib/types/event/message.js +10 -12
- package/lib/types/event/notice.d.ts +118 -325
- package/lib/types/event/notice.js +8 -10
- package/lib/types/event/request.d.ts +29 -66
- package/lib/types/event/request.js +8 -10
- package/lib/types/event/sender.d.ts +7 -21
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/onebot11/api.d.ts +49 -49
- package/lib/types/onebot11/event.d.ts +131 -347
- package/lib/types/onebot11/params.d.ts +184 -456
- package/lib/types/onebot11/response.d.ts +159 -381
- package/lib/types/onebot11/segment.d.ts +25 -75
- package/lib/types/onebot11/sender.d.ts +13 -39
- package/lib/types/plugin/app.d.ts +7 -11
- package/lib/types/plugin/plugin.d.ts +55 -165
- package/lib/types/render/render.d.ts +16 -48
- package/lib/utils/common/common.js +4 -2
- package/lib/utils/config/config.js +1 -1
- package/lib/utils/core/logger.js +3 -3
- package/lib/utils/core/segment.d.ts +28 -59
- package/lib/utils/core/segment.js +26 -30
- package/lib/utils/tools/restart.d.ts +3 -3
- package/lib/utils/tools/restart.js +5 -5
- package/package.json +1 -2
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* - OneBot11消息类型枚举
|
|
3
|
-
*/
|
|
1
|
+
/** OneBot11消息类型枚举 */
|
|
4
2
|
export declare const enum OB11SegmentType {
|
|
5
3
|
Text = "text",
|
|
6
4
|
Face = "face",
|
|
@@ -29,27 +27,21 @@ export declare const enum OB11SegmentType {
|
|
|
29
27
|
export interface Segment {
|
|
30
28
|
type: OB11SegmentType;
|
|
31
29
|
}
|
|
32
|
-
/**
|
|
33
|
-
* - 纯文本
|
|
34
|
-
*/
|
|
30
|
+
/** 纯文本 */
|
|
35
31
|
export interface TextSegment extends Segment {
|
|
36
32
|
type: OB11SegmentType.Text;
|
|
37
33
|
data: {
|
|
38
34
|
text: string;
|
|
39
35
|
};
|
|
40
36
|
}
|
|
41
|
-
/**
|
|
42
|
-
* - QQ表情
|
|
43
|
-
*/
|
|
37
|
+
/** QQ表情 */
|
|
44
38
|
export interface FaceSegment extends Segment {
|
|
45
39
|
type: OB11SegmentType.Face;
|
|
46
40
|
data: {
|
|
47
41
|
id: string;
|
|
48
42
|
};
|
|
49
43
|
}
|
|
50
|
-
/**
|
|
51
|
-
* - 图片消息段
|
|
52
|
-
*/
|
|
44
|
+
/** 图片消息段 */
|
|
53
45
|
export interface ImageSegment extends Segment {
|
|
54
46
|
type: OB11SegmentType.Image;
|
|
55
47
|
data: {
|
|
@@ -61,9 +53,7 @@ export interface ImageSegment extends Segment {
|
|
|
61
53
|
timeout?: number;
|
|
62
54
|
};
|
|
63
55
|
}
|
|
64
|
-
/**
|
|
65
|
-
* - 语音消息段
|
|
66
|
-
*/
|
|
56
|
+
/** 语音消息段 */
|
|
67
57
|
export interface RecordSegment extends Segment {
|
|
68
58
|
type: OB11SegmentType.Record;
|
|
69
59
|
data: {
|
|
@@ -75,9 +65,7 @@ export interface RecordSegment extends Segment {
|
|
|
75
65
|
timeout?: number;
|
|
76
66
|
};
|
|
77
67
|
}
|
|
78
|
-
/**
|
|
79
|
-
* - 短视频消息段
|
|
80
|
-
*/
|
|
68
|
+
/** 短视频消息段 */
|
|
81
69
|
export interface VideoSegment extends Segment {
|
|
82
70
|
type: OB11SegmentType.Video;
|
|
83
71
|
data: {
|
|
@@ -88,9 +76,7 @@ export interface VideoSegment extends Segment {
|
|
|
88
76
|
timeout?: number;
|
|
89
77
|
};
|
|
90
78
|
}
|
|
91
|
-
/**
|
|
92
|
-
* - @某人消息段
|
|
93
|
-
*/
|
|
79
|
+
/** @某人消息段 */
|
|
94
80
|
export interface AtSegment extends Segment {
|
|
95
81
|
type: OB11SegmentType.At;
|
|
96
82
|
data: {
|
|
@@ -98,30 +84,22 @@ export interface AtSegment extends Segment {
|
|
|
98
84
|
name?: string;
|
|
99
85
|
};
|
|
100
86
|
}
|
|
101
|
-
/**
|
|
102
|
-
* - 猜拳魔法表情消息段
|
|
103
|
-
*/
|
|
87
|
+
/** 猜拳魔法表情消息段 */
|
|
104
88
|
export interface RpsSegment extends Segment {
|
|
105
89
|
type: OB11SegmentType.Rps;
|
|
106
90
|
data: {};
|
|
107
91
|
}
|
|
108
|
-
/**
|
|
109
|
-
* - 掷骰子魔法表情消息段
|
|
110
|
-
*/
|
|
92
|
+
/** 掷骰子魔法表情消息段 */
|
|
111
93
|
export interface DiceSegment extends Segment {
|
|
112
94
|
type: OB11SegmentType.Dice;
|
|
113
95
|
data: {};
|
|
114
96
|
}
|
|
115
|
-
/**
|
|
116
|
-
* - 窗口抖动(戳一戳)消息段
|
|
117
|
-
*/
|
|
97
|
+
/** 窗口抖动(戳一戳)消息段 */
|
|
118
98
|
export interface ShakeSegment extends Segment {
|
|
119
99
|
type: OB11SegmentType.Shake;
|
|
120
100
|
data: {};
|
|
121
101
|
}
|
|
122
|
-
/**
|
|
123
|
-
* - 戳一戳消息段
|
|
124
|
-
*/
|
|
102
|
+
/** 戳一戳消息段 */
|
|
125
103
|
export interface PokeSegment extends Segment {
|
|
126
104
|
type: OB11SegmentType.Poke;
|
|
127
105
|
data: {
|
|
@@ -130,18 +108,14 @@ export interface PokeSegment extends Segment {
|
|
|
130
108
|
name?: string;
|
|
131
109
|
};
|
|
132
110
|
}
|
|
133
|
-
/**
|
|
134
|
-
* - 匿名发消息消息段
|
|
135
|
-
*/
|
|
111
|
+
/** 匿名发消息消息段 */
|
|
136
112
|
export interface AnonymousSegment extends Segment {
|
|
137
113
|
type: OB11SegmentType.Anonymous;
|
|
138
114
|
data: {
|
|
139
115
|
ignore?: 0 | 1;
|
|
140
116
|
};
|
|
141
117
|
}
|
|
142
|
-
/**
|
|
143
|
-
* - 链接分享消息段
|
|
144
|
-
*/
|
|
118
|
+
/** 链接分享消息段 */
|
|
145
119
|
export interface ShareSegment extends Segment {
|
|
146
120
|
type: OB11SegmentType.Share;
|
|
147
121
|
data: {
|
|
@@ -151,9 +125,7 @@ export interface ShareSegment extends Segment {
|
|
|
151
125
|
image?: string;
|
|
152
126
|
};
|
|
153
127
|
}
|
|
154
|
-
/**
|
|
155
|
-
* - 推荐好友/群消息段
|
|
156
|
-
*/
|
|
128
|
+
/** 推荐好友/群消息段 */
|
|
157
129
|
export interface ContactSegment extends Segment {
|
|
158
130
|
type: OB11SegmentType.Contact;
|
|
159
131
|
data: {
|
|
@@ -161,9 +133,7 @@ export interface ContactSegment extends Segment {
|
|
|
161
133
|
id: string;
|
|
162
134
|
};
|
|
163
135
|
}
|
|
164
|
-
/**
|
|
165
|
-
* - 位置消息段
|
|
166
|
-
*/
|
|
136
|
+
/** 位置消息段 */
|
|
167
137
|
export interface LocationSegment extends Segment {
|
|
168
138
|
type: OB11SegmentType.Location;
|
|
169
139
|
data: {
|
|
@@ -173,9 +143,7 @@ export interface LocationSegment extends Segment {
|
|
|
173
143
|
content?: string;
|
|
174
144
|
};
|
|
175
145
|
}
|
|
176
|
-
/**
|
|
177
|
-
* - 音乐分享消息段
|
|
178
|
-
*/
|
|
146
|
+
/** 音乐分享消息段 */
|
|
179
147
|
export interface MusicSegment extends Segment {
|
|
180
148
|
type: OB11SegmentType.Music;
|
|
181
149
|
data: {
|
|
@@ -183,9 +151,7 @@ export interface MusicSegment extends Segment {
|
|
|
183
151
|
id: string;
|
|
184
152
|
};
|
|
185
153
|
}
|
|
186
|
-
/**
|
|
187
|
-
* - 音乐自定义分享消息段
|
|
188
|
-
*/
|
|
154
|
+
/** 音乐自定义分享消息段 */
|
|
189
155
|
export interface CustomMusicSegment extends Segment {
|
|
190
156
|
type: OB11SegmentType.MusicCustom;
|
|
191
157
|
data: {
|
|
@@ -197,9 +163,7 @@ export interface CustomMusicSegment extends Segment {
|
|
|
197
163
|
image?: string;
|
|
198
164
|
};
|
|
199
165
|
}
|
|
200
|
-
/**
|
|
201
|
-
* - 回复消息段
|
|
202
|
-
*/
|
|
166
|
+
/** 回复消息段 */
|
|
203
167
|
export interface ReplySegment extends Segment {
|
|
204
168
|
type: OB11SegmentType.Reply;
|
|
205
169
|
data: {
|
|
@@ -212,49 +176,37 @@ export interface FileSegment extends Segment {
|
|
|
212
176
|
file: string;
|
|
213
177
|
};
|
|
214
178
|
}
|
|
215
|
-
/**
|
|
216
|
-
* - 合并转发消息段
|
|
217
|
-
*/
|
|
179
|
+
/** 合并转发消息段 */
|
|
218
180
|
export interface ForwardSegment extends Segment {
|
|
219
181
|
type: OB11SegmentType.Forward;
|
|
220
182
|
data: {
|
|
221
183
|
id: string;
|
|
222
184
|
};
|
|
223
185
|
}
|
|
224
|
-
/**
|
|
225
|
-
* - 合并转发节点消息段
|
|
226
|
-
*/
|
|
186
|
+
/** 合并转发节点消息段 */
|
|
227
187
|
export interface NodeSegment extends Segment {
|
|
228
188
|
type: OB11SegmentType.Node;
|
|
229
189
|
data: {
|
|
230
190
|
id: string;
|
|
231
191
|
};
|
|
232
192
|
}
|
|
233
|
-
/**
|
|
234
|
-
* - XML消息段
|
|
235
|
-
*/
|
|
193
|
+
/** XML消息段 */
|
|
236
194
|
export interface XmlSegment extends Segment {
|
|
237
195
|
type: OB11SegmentType.Xml;
|
|
238
196
|
data: {
|
|
239
197
|
data: string;
|
|
240
198
|
};
|
|
241
199
|
}
|
|
242
|
-
/**
|
|
243
|
-
* - JSON消息段
|
|
244
|
-
*/
|
|
200
|
+
/** JSON消息段 */
|
|
245
201
|
export interface JsonSegment extends Segment {
|
|
246
202
|
type: OB11SegmentType.Json;
|
|
247
203
|
data: {
|
|
248
204
|
data: string;
|
|
249
205
|
};
|
|
250
206
|
}
|
|
251
|
-
/**
|
|
252
|
-
* - OneBot11消息段
|
|
253
|
-
*/
|
|
207
|
+
/** OneBot11消息段 */
|
|
254
208
|
export type OB11SegmentBase = TextSegment | FaceSegment | ImageSegment | RecordSegment | VideoSegment | AtSegment | RpsSegment | DiceSegment | ShakeSegment | PokeSegment | AnonymousSegment | ShareSegment | ContactSegment | LocationSegment | MusicSegment | CustomMusicSegment | ReplySegment | ForwardSegment | NodeSegment | XmlSegment | JsonSegment;
|
|
255
|
-
/**
|
|
256
|
-
* - 合并转发自定义节点消息段
|
|
257
|
-
*/
|
|
209
|
+
/** 合并转发自定义节点消息段 */
|
|
258
210
|
export interface CustomNodeSegment extends Segment {
|
|
259
211
|
type: OB11SegmentType.NodeCustom;
|
|
260
212
|
data: {
|
|
@@ -263,7 +215,5 @@ export interface CustomNodeSegment extends Segment {
|
|
|
263
215
|
content: OB11SegmentBase[];
|
|
264
216
|
};
|
|
265
217
|
}
|
|
266
|
-
/**
|
|
267
|
-
* - OneBot11消息段
|
|
268
|
-
*/
|
|
218
|
+
/** OneBot11消息段 */
|
|
269
219
|
export type OB11Segment = OB11SegmentBase | CustomNodeSegment;
|
|
@@ -1,59 +1,33 @@
|
|
|
1
1
|
export type OB11Sex = 'male' | 'female' | 'unknown';
|
|
2
2
|
export type OB11Role = 'owner' | 'admin' | 'member' | '';
|
|
3
3
|
export interface PrivateSender {
|
|
4
|
-
/**
|
|
5
|
-
* - 发送者 QQ 号
|
|
6
|
-
*/
|
|
4
|
+
/** 发送者 QQ 号 */
|
|
7
5
|
user_id: string;
|
|
8
|
-
/**
|
|
9
|
-
* - 昵称 不存在则为空字符串
|
|
10
|
-
*/
|
|
6
|
+
/** 昵称 不存在则为空字符串 */
|
|
11
7
|
nickname: string;
|
|
12
|
-
/**
|
|
13
|
-
* - 性别
|
|
14
|
-
*/
|
|
8
|
+
/** 性别 */
|
|
15
9
|
sex?: OB11Sex;
|
|
16
|
-
/**
|
|
17
|
-
* - 年龄
|
|
18
|
-
*/
|
|
10
|
+
/** 年龄 */
|
|
19
11
|
age?: number;
|
|
20
12
|
}
|
|
21
13
|
export interface GroupSender {
|
|
22
|
-
/**
|
|
23
|
-
* - 发送者 QQ 号
|
|
24
|
-
*/
|
|
14
|
+
/** 发送者 QQ 号 */
|
|
25
15
|
user_id: string;
|
|
26
|
-
/**
|
|
27
|
-
* - 昵称 不存在则为空字符串
|
|
28
|
-
*/
|
|
16
|
+
/** 昵称 不存在则为空字符串 */
|
|
29
17
|
nickname: string;
|
|
30
|
-
/**
|
|
31
|
-
* - 性别
|
|
32
|
-
*/
|
|
18
|
+
/** 性别 */
|
|
33
19
|
sex?: OB11Sex;
|
|
34
|
-
/**
|
|
35
|
-
* - 年龄
|
|
36
|
-
*/
|
|
20
|
+
/** 年龄 */
|
|
37
21
|
age?: number;
|
|
38
|
-
/**
|
|
39
|
-
* - 群名片/备注
|
|
40
|
-
*/
|
|
22
|
+
/** 群名片/备注 */
|
|
41
23
|
card?: string;
|
|
42
|
-
/**
|
|
43
|
-
* - 地区
|
|
44
|
-
*/
|
|
24
|
+
/** 地区 */
|
|
45
25
|
area?: string;
|
|
46
|
-
/**
|
|
47
|
-
* - 成员等级
|
|
48
|
-
*/
|
|
26
|
+
/** 成员等级 */
|
|
49
27
|
level?: string;
|
|
50
|
-
/**
|
|
51
|
-
* - 角色 不存在则为空字符串
|
|
52
|
-
*/
|
|
28
|
+
/** 角色 不存在则为空字符串 */
|
|
53
29
|
role: OB11Role;
|
|
54
|
-
/**
|
|
55
|
-
* - 专属头衔
|
|
56
|
-
*/
|
|
30
|
+
/** 专属头衔 */
|
|
57
31
|
title?: string;
|
|
58
32
|
}
|
|
59
33
|
export type ob11Sender = PrivateSender | GroupSender;
|
|
@@ -49,15 +49,11 @@ export interface HandlerInfo extends Omit<AppBase, 'log'> {
|
|
|
49
49
|
key: string;
|
|
50
50
|
/** 实现方法 */
|
|
51
51
|
fn: (
|
|
52
|
-
/**
|
|
53
|
-
* - 自定义参数 由调用方传递
|
|
54
|
-
*/
|
|
52
|
+
/** 自定义参数 由调用方传递 */
|
|
55
53
|
args: {
|
|
56
54
|
[key: string]: any;
|
|
57
55
|
},
|
|
58
|
-
/**
|
|
59
|
-
* - 停止循环函数 调用后则不再继续执行下一个处理器
|
|
60
|
-
*/
|
|
56
|
+
/** 停止循环函数 调用后则不再继续执行下一个处理器 */
|
|
61
57
|
next: (msg?: string) => void) => Promise<any>;
|
|
62
58
|
}
|
|
63
59
|
/** button规则集类型 */
|
|
@@ -89,7 +85,7 @@ e: KarinMessageType,
|
|
|
89
85
|
/** 是否继续执行下一个中间件 */
|
|
90
86
|
next: () => void,
|
|
91
87
|
/** 是否退出此条消息 不再执行匹配插件 */
|
|
92
|
-
exit: () => void) => Promise<
|
|
88
|
+
exit: () => void) => Promise<void>;
|
|
93
89
|
/**
|
|
94
90
|
* 回复消息前 中间件实现方法
|
|
95
91
|
*/
|
|
@@ -101,7 +97,7 @@ element: KarinElement[],
|
|
|
101
97
|
/** 是否继续执行下一个中间件 */
|
|
102
98
|
next: () => void,
|
|
103
99
|
/** 是否不发送此条消息 */
|
|
104
|
-
exit: () => void) => Promise<
|
|
100
|
+
exit: () => void) => Promise<void>;
|
|
105
101
|
/**
|
|
106
102
|
* 发送主动消息前 中间件实现方法
|
|
107
103
|
*/
|
|
@@ -115,7 +111,7 @@ element: KarinElement[],
|
|
|
115
111
|
/** 是否继续执行下一个中间件 */
|
|
116
112
|
next: () => void,
|
|
117
113
|
/** 是否不发送此条消息 */
|
|
118
|
-
exit: () => void) => Promise<
|
|
114
|
+
exit: () => void) => Promise<void>;
|
|
119
115
|
/**
|
|
120
116
|
* 发送合并转发前 中间件实现方法
|
|
121
117
|
*/
|
|
@@ -127,7 +123,7 @@ elements: Array<NodeElement>,
|
|
|
127
123
|
/** 是否继续执行下一个中间件 */
|
|
128
124
|
next: () => void,
|
|
129
125
|
/** 是否不发送此条消息 */
|
|
130
|
-
exit: () => void) => Promise<
|
|
126
|
+
exit: () => void) => Promise<void>;
|
|
131
127
|
/**
|
|
132
128
|
* 消息事件没有找到任何匹配的插件触发 中间件实现方法
|
|
133
129
|
*/
|
|
@@ -137,7 +133,7 @@ e: KarinMessageType,
|
|
|
137
133
|
/** 是否继续执行下一个中间件 */
|
|
138
134
|
next: () => void,
|
|
139
135
|
/** 是否退出此条消息 不再执行匹配插件 */
|
|
140
|
-
exit: () => void) => Promise<
|
|
136
|
+
exit: () => void) => Promise<void>;
|
|
141
137
|
/** use规则集类型 */
|
|
142
138
|
export interface UseInfo<T extends keyof UseMapType = keyof UseMapType> extends Omit<AppBase, 'log'> {
|
|
143
139
|
type: `${AppType.Use}`;
|
|
@@ -191,93 +191,53 @@ export interface stateArrType {
|
|
|
191
191
|
type: 'ctx';
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
/**
|
|
195
|
-
* - 插件规则
|
|
196
|
-
*/
|
|
194
|
+
/** 插件规则 */
|
|
197
195
|
export interface PluginRule {
|
|
198
|
-
/**
|
|
199
|
-
* - 命令正则
|
|
200
|
-
*/
|
|
196
|
+
/** 命令正则 */
|
|
201
197
|
reg: string | RegExp;
|
|
202
|
-
/**
|
|
203
|
-
* - 命令执行方法名称
|
|
204
|
-
*/
|
|
198
|
+
/** 命令执行方法名称 */
|
|
205
199
|
fnc: string | Function;
|
|
206
|
-
/**
|
|
207
|
-
* - 监听子事件
|
|
208
|
-
*/
|
|
200
|
+
/** 监听子事件 */
|
|
209
201
|
event?: AllMessageSubType;
|
|
210
|
-
/**
|
|
211
|
-
* - 优先级 默认为10000
|
|
212
|
-
*/
|
|
202
|
+
/** 优先级 默认为10000 */
|
|
213
203
|
priority?: number;
|
|
214
204
|
/**
|
|
215
205
|
* 权限
|
|
216
206
|
*/
|
|
217
207
|
permission?: `${Permission}`;
|
|
218
|
-
/**
|
|
219
|
-
* - 打印日志 默认为true
|
|
220
|
-
*/
|
|
208
|
+
/** 打印日志 默认为true */
|
|
221
209
|
log?: boolean | Function;
|
|
222
210
|
}
|
|
223
|
-
/**
|
|
224
|
-
* - 定时任务规则
|
|
225
|
-
*/
|
|
211
|
+
/** 定时任务规则 */
|
|
226
212
|
export interface PluginTask {
|
|
227
|
-
/**
|
|
228
|
-
* - 任务名称
|
|
229
|
-
*/
|
|
213
|
+
/** 任务名称 */
|
|
230
214
|
name: string;
|
|
231
|
-
/**
|
|
232
|
-
* - cron表达式
|
|
233
|
-
*/
|
|
215
|
+
/** cron表达式 */
|
|
234
216
|
cron: string;
|
|
235
|
-
/**
|
|
236
|
-
* - 执行方法名称或对应函数
|
|
237
|
-
*/
|
|
217
|
+
/** 执行方法名称或对应函数 */
|
|
238
218
|
fnc: string | Function;
|
|
239
|
-
/**
|
|
240
|
-
* - 是否显示执行日志 默认为true
|
|
241
|
-
*/
|
|
219
|
+
/** 是否显示执行日志 默认为true */
|
|
242
220
|
log: boolean | Function;
|
|
243
|
-
/**
|
|
244
|
-
* - 停止函数
|
|
245
|
-
*/
|
|
221
|
+
/** 停止函数 */
|
|
246
222
|
schedule?: schedule.Job;
|
|
247
223
|
}
|
|
248
|
-
/**
|
|
249
|
-
* - 按钮规则
|
|
250
|
-
*/
|
|
224
|
+
/** 按钮规则 */
|
|
251
225
|
export interface PluginButton {
|
|
252
|
-
/**
|
|
253
|
-
* - 按钮命令正则
|
|
254
|
-
*/
|
|
226
|
+
/** 按钮命令正则 */
|
|
255
227
|
reg: string | RegExp;
|
|
256
|
-
/**
|
|
257
|
-
* - 执行方法名称
|
|
258
|
-
*/
|
|
228
|
+
/** 执行方法名称 */
|
|
259
229
|
fnc: string | Function;
|
|
260
230
|
}
|
|
261
|
-
/**
|
|
262
|
-
* - handler规则
|
|
263
|
-
*/
|
|
231
|
+
/** handler规则 */
|
|
264
232
|
export interface PluginHandler {
|
|
265
|
-
/**
|
|
266
|
-
* - handler支持的事件key
|
|
267
|
-
*/
|
|
233
|
+
/** handler支持的事件key */
|
|
268
234
|
key: string;
|
|
269
|
-
/**
|
|
270
|
-
* - handler的处理方法名称
|
|
271
|
-
*/
|
|
235
|
+
/** handler的处理方法名称 */
|
|
272
236
|
fnc: string | Function;
|
|
273
|
-
/**
|
|
274
|
-
* - handler优先级 不填默认为主优先度
|
|
275
|
-
*/
|
|
237
|
+
/** handler优先级 不填默认为主优先度 */
|
|
276
238
|
priority: number;
|
|
277
239
|
}
|
|
278
|
-
/**
|
|
279
|
-
* - 插件信息
|
|
280
|
-
*/
|
|
240
|
+
/** 插件信息 */
|
|
281
241
|
export interface AppInfo {
|
|
282
242
|
/**
|
|
283
243
|
* - 插件根目录名称
|
|
@@ -287,156 +247,86 @@ export interface AppInfo {
|
|
|
287
247
|
* - karin-plugin-example/dist/apps
|
|
288
248
|
*/
|
|
289
249
|
dir: dirName;
|
|
290
|
-
/**
|
|
291
|
-
* - 插件名称 例如: index.js index.ts
|
|
292
|
-
*/
|
|
250
|
+
/** 插件名称 例如: index.js index.ts */
|
|
293
251
|
name: fileName;
|
|
294
252
|
}
|
|
295
|
-
/**
|
|
296
|
-
* - 定义一个条件类型,根据是否存在accept方法来决定类型
|
|
297
|
-
*/
|
|
253
|
+
/** 定义一个条件类型,根据是否存在accept方法来决定类型 */
|
|
298
254
|
export type EType<T> = T extends {
|
|
299
255
|
accept: (e: KarinNoticeType | KarinRequestType) => Promise<void>;
|
|
300
256
|
} ? KarinNoticeType | KarinRequestType : KarinMessageType;
|
|
301
|
-
/**
|
|
302
|
-
* - 插件基类
|
|
303
|
-
*/
|
|
257
|
+
/** 插件基类 */
|
|
304
258
|
export interface PluginType {
|
|
305
|
-
/**
|
|
306
|
-
* - 插件名称
|
|
307
|
-
*/
|
|
259
|
+
/** 插件名称 */
|
|
308
260
|
name: string;
|
|
309
|
-
/**
|
|
310
|
-
* - 插件描述
|
|
311
|
-
*/
|
|
261
|
+
/** 插件描述 */
|
|
312
262
|
desc: string;
|
|
313
|
-
/**
|
|
314
|
-
* - 监听事件 默认为message
|
|
315
|
-
*/
|
|
263
|
+
/** 监听事件 默认为message */
|
|
316
264
|
event: AllMessageSubType;
|
|
317
|
-
/**
|
|
318
|
-
* - 优先级 默认为10000
|
|
319
|
-
*/
|
|
265
|
+
/** 优先级 默认为10000 */
|
|
320
266
|
priority: number;
|
|
321
|
-
/**
|
|
322
|
-
* - 定时任务
|
|
323
|
-
*/
|
|
267
|
+
/** 定时任务 */
|
|
324
268
|
task: Array<PluginTask>;
|
|
325
|
-
/**
|
|
326
|
-
* - 命令规则
|
|
327
|
-
*/
|
|
269
|
+
/** 命令规则 */
|
|
328
270
|
rule: Array<PluginRule>;
|
|
329
|
-
/**
|
|
330
|
-
* - handler
|
|
331
|
-
*/
|
|
271
|
+
/** handler */
|
|
332
272
|
handler: Array<PluginHandler>;
|
|
333
|
-
/**
|
|
334
|
-
* - 用户ID 一般上下文使用
|
|
335
|
-
*/
|
|
273
|
+
/** 用户ID 一般上下文使用 */
|
|
336
274
|
userId?: number;
|
|
337
|
-
/**
|
|
338
|
-
* - 上下文超时
|
|
339
|
-
*/
|
|
275
|
+
/** 上下文超时 */
|
|
340
276
|
timeout: NodeJS.Timeout | undefined;
|
|
341
|
-
/**
|
|
342
|
-
* - 上报事件
|
|
343
|
-
*/
|
|
277
|
+
/** 上报事件 */
|
|
344
278
|
e: EType<this>;
|
|
345
279
|
init?: () => Promise<any>;
|
|
346
|
-
/**
|
|
347
|
-
* - 快速回复
|
|
348
|
-
*/
|
|
280
|
+
/** 快速回复 */
|
|
349
281
|
reply: Reply;
|
|
350
|
-
/**
|
|
351
|
-
* - 快速回复内部方法 由适配器实现
|
|
352
|
-
*/
|
|
282
|
+
/** 快速回复内部方法 由适配器实现 */
|
|
353
283
|
replyCallback: replyCallback;
|
|
354
|
-
/**
|
|
355
|
-
* - 快速回复合并转发
|
|
356
|
-
*/
|
|
284
|
+
/** 快速回复合并转发 */
|
|
357
285
|
replyForward: replyForward;
|
|
358
|
-
/**
|
|
359
|
-
* - 构建上下文键
|
|
360
|
-
*/
|
|
286
|
+
/** 构建上下文键 */
|
|
361
287
|
conKey: () => string;
|
|
362
|
-
/**
|
|
363
|
-
* - 设置上下文状态
|
|
364
|
-
*/
|
|
288
|
+
/** 设置上下文状态 */
|
|
365
289
|
setContext: (
|
|
366
|
-
/**
|
|
367
|
-
* - 执行方法名称
|
|
368
|
-
*/
|
|
290
|
+
/** 执行方法名称 */
|
|
369
291
|
fnc: string,
|
|
370
|
-
/**
|
|
371
|
-
* - 超时后是否回复
|
|
372
|
-
*/
|
|
292
|
+
/** 超时后是否回复 */
|
|
373
293
|
reply?: boolean,
|
|
374
|
-
/**
|
|
375
|
-
* - 下文超时时间 默认120秒
|
|
376
|
-
*/
|
|
294
|
+
/** 下文超时时间 默认120秒 */
|
|
377
295
|
time?: number) => void;
|
|
378
|
-
/**
|
|
379
|
-
* - 获取上下文状态
|
|
380
|
-
*/
|
|
296
|
+
/** 获取上下文状态 */
|
|
381
297
|
getContext: () => stateArrType[string];
|
|
382
|
-
/**
|
|
383
|
-
* - accept标准方法 给通知、请求事件使用
|
|
384
|
-
*/
|
|
298
|
+
/** accept标准方法 给通知、请求事件使用 */
|
|
385
299
|
accept?(e: KarinNoticeType | KarinRequestType): Promise<void>;
|
|
386
300
|
}
|
|
387
|
-
/**
|
|
388
|
-
* - Apps
|
|
389
|
-
*/
|
|
301
|
+
/** Apps */
|
|
390
302
|
export interface PluginApps {
|
|
391
|
-
/**
|
|
392
|
-
* - 插件文件信息
|
|
393
|
-
*/
|
|
303
|
+
/** 插件文件信息 */
|
|
394
304
|
file: AppInfo & {
|
|
395
|
-
/**
|
|
396
|
-
* - 插件类型
|
|
397
|
-
*/
|
|
305
|
+
/** 插件类型 */
|
|
398
306
|
type: 'function' | 'class';
|
|
399
|
-
/**
|
|
400
|
-
* - 插件方法
|
|
401
|
-
*/
|
|
307
|
+
/** 插件方法 */
|
|
402
308
|
Fnc: '' | (new () => PluginType);
|
|
403
309
|
};
|
|
404
|
-
/**
|
|
405
|
-
* - 插件名称
|
|
406
|
-
*/
|
|
310
|
+
/** 插件名称 */
|
|
407
311
|
name: string;
|
|
408
|
-
/**
|
|
409
|
-
* - 插件事件
|
|
410
|
-
*/
|
|
312
|
+
/** 插件事件 */
|
|
411
313
|
event: AllListenEvent;
|
|
412
314
|
/**
|
|
413
315
|
* - 插件优先级
|
|
414
316
|
* @default 10000
|
|
415
317
|
*/
|
|
416
318
|
priority: number;
|
|
417
|
-
/**
|
|
418
|
-
* - accept函数
|
|
419
|
-
*/
|
|
319
|
+
/** accept函数 */
|
|
420
320
|
accept: boolean | Function;
|
|
421
|
-
/**
|
|
422
|
-
* - accept函数触发是否打印日志
|
|
423
|
-
*/
|
|
321
|
+
/** accept函数触发是否打印日志 */
|
|
424
322
|
log: boolean;
|
|
425
|
-
/**
|
|
426
|
-
* - 命令规则
|
|
427
|
-
*/
|
|
323
|
+
/** 命令规则 */
|
|
428
324
|
rule: Array<PluginRule>;
|
|
429
|
-
/**
|
|
430
|
-
* - 定时任务
|
|
431
|
-
*/
|
|
325
|
+
/** 定时任务 */
|
|
432
326
|
task: Array<PluginTask>;
|
|
433
|
-
/**
|
|
434
|
-
* - 按钮
|
|
435
|
-
*/
|
|
327
|
+
/** 按钮 */
|
|
436
328
|
button: Array<PluginButton>;
|
|
437
|
-
/**
|
|
438
|
-
* - handler
|
|
439
|
-
*/
|
|
329
|
+
/** handler */
|
|
440
330
|
handler: Array<PluginHandler>;
|
|
441
331
|
}
|
|
442
332
|
/**
|