napcat-sdk 0.1.1 → 0.1.2
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/dist/index.cjs +116 -162
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +264 -293
- package/dist/index.d.mts +264 -293
- package/dist/index.mjs +116 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
- package/readme.md +70 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,65 +1,48 @@
|
|
|
1
|
-
//#region package.d.ts
|
|
2
|
-
declare let name$1: string;
|
|
3
|
-
declare let type: string;
|
|
4
|
-
declare let version$1: string;
|
|
5
|
-
declare let packageManager: string;
|
|
6
|
-
declare let description: string;
|
|
7
|
-
declare let keywords: string[];
|
|
8
|
-
declare let homepage: string;
|
|
9
|
-
declare let files: string[];
|
|
10
|
-
declare namespace bugs {
|
|
11
|
-
let url: string;
|
|
12
|
-
}
|
|
13
|
-
declare namespace repository {
|
|
14
|
-
let type_1: string;
|
|
15
|
-
export { type_1 as type };
|
|
16
|
-
let url_1: string;
|
|
17
|
-
export { url_1 as url };
|
|
18
|
-
export let directory: string;
|
|
19
|
-
}
|
|
20
|
-
declare namespace scripts {
|
|
21
|
-
let dev: string;
|
|
22
|
-
let build: string;
|
|
23
|
-
}
|
|
24
|
-
declare let exports: {
|
|
25
|
-
".": {
|
|
26
|
-
require: string;
|
|
27
|
-
import: string;
|
|
28
|
-
types: string;
|
|
29
|
-
};
|
|
30
|
-
"./package.json": string;
|
|
31
|
-
};
|
|
32
|
-
declare let author: string;
|
|
33
|
-
declare let license: string;
|
|
34
|
-
declare let devDependencies: {
|
|
35
|
-
"@types/node": string;
|
|
36
|
-
tsdown: string;
|
|
37
|
-
typescript: string;
|
|
38
|
-
};
|
|
39
|
-
declare namespace dependencies {
|
|
40
|
-
let mitt: string;
|
|
41
|
-
}
|
|
42
|
-
declare namespace __json_default_export {
|
|
43
|
-
export { name$1 as name, type, version$1 as version, packageManager, description, keywords, homepage, files, bugs, repository, scripts, exports, author, license, devDependencies, dependencies };
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
1
|
//#region src/logger.d.ts
|
|
47
|
-
type LogLevel =
|
|
2
|
+
type LogLevel = "fatal" | "error" | "warn" | "info" | "debug" | "trace";
|
|
48
3
|
type Logger = Record<LogLevel, (...args: unknown[]) => void>;
|
|
4
|
+
declare const noop: () => void;
|
|
49
5
|
declare const ABSTRACT_LOGGER: Logger;
|
|
50
6
|
declare const CONSOLE_LOGGER: Logger;
|
|
51
7
|
//#endregion
|
|
52
|
-
//#region src/
|
|
8
|
+
//#region src/types.d.ts
|
|
9
|
+
interface MiokiOptions {
|
|
10
|
+
/** NapCat 访问令牌 */
|
|
11
|
+
token: string;
|
|
12
|
+
/** NapCat 服务器协议,默认为 ws */
|
|
13
|
+
protocol?: "ws" | "wss";
|
|
14
|
+
/** NapCat 服务器主机,默认为 localhost */
|
|
15
|
+
host?: string;
|
|
16
|
+
/** NapCat 服务器端口,默认为 3333 */
|
|
17
|
+
port?: number;
|
|
18
|
+
/** 日志记录器,默认为控制台日志记录器 */
|
|
19
|
+
logger?: Logger;
|
|
20
|
+
}
|
|
21
|
+
type OptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T];
|
|
22
|
+
type OptionalProps<T> = Pick<T, OptionalKeys<T>>;
|
|
23
|
+
type ExtractByType<T, K$1> = T extends {
|
|
24
|
+
type: K$1;
|
|
25
|
+
} ? T : never;
|
|
26
|
+
interface EventMap extends OneBotEventMap {
|
|
27
|
+
/** WebSocket 连接已打开 */
|
|
28
|
+
"ws.open": void;
|
|
29
|
+
/** WebSocket 连接已关闭 */
|
|
30
|
+
"ws.close": void;
|
|
31
|
+
/** WebSocket 连接发生错误 */
|
|
32
|
+
"ws.error": Event;
|
|
33
|
+
/** 收到 WebSocket 消息 */
|
|
34
|
+
"ws.message": any;
|
|
35
|
+
}
|
|
53
36
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
* 媒体消息的通用属性
|
|
38
|
+
*/
|
|
56
39
|
interface MediaProps {
|
|
57
40
|
/** 媒体文件的 URL 地址 */
|
|
58
41
|
url: string;
|
|
59
42
|
/** 媒体文件的本地路径 */
|
|
60
43
|
path: string;
|
|
61
44
|
/** 媒体文件名或特殊标识 */
|
|
62
|
-
file: (string & {}) |
|
|
45
|
+
file: (string & {}) | "marketface";
|
|
63
46
|
/** 媒体文件 ID */
|
|
64
47
|
file_id: string;
|
|
65
48
|
/** 媒体文件大小(字节) */
|
|
@@ -69,31 +52,31 @@ interface MediaProps {
|
|
|
69
52
|
}
|
|
70
53
|
/** 接收的纯文本消息段 */
|
|
71
54
|
interface RecvTextElement {
|
|
72
|
-
type:
|
|
55
|
+
type: "text";
|
|
73
56
|
/** 文本内容 */
|
|
74
57
|
text: string;
|
|
75
58
|
}
|
|
76
59
|
/** 接收的 @ 消息段 */
|
|
77
60
|
interface RecvAtElement {
|
|
78
|
-
type:
|
|
61
|
+
type: "at";
|
|
79
62
|
/** 被 @ 的 QQ 号,'all' 表示 @全体成员 */
|
|
80
|
-
qq:
|
|
63
|
+
qq: "all" | (string & {});
|
|
81
64
|
}
|
|
82
65
|
/** 接收的回复消息段 */
|
|
83
66
|
interface RecvReplyElement {
|
|
84
|
-
type:
|
|
67
|
+
type: "reply";
|
|
85
68
|
/** 被回复的消息 ID */
|
|
86
69
|
id: string;
|
|
87
70
|
}
|
|
88
71
|
/** 接收的 QQ 表情消息段 */
|
|
89
72
|
interface RecvFaceElement {
|
|
90
|
-
type:
|
|
73
|
+
type: "face";
|
|
91
74
|
/** QQ 表情 ID */
|
|
92
75
|
id: number;
|
|
93
76
|
}
|
|
94
77
|
/** 接收的图片消息段 */
|
|
95
78
|
interface RecvImageElement extends MediaProps {
|
|
96
|
-
type:
|
|
79
|
+
type: "image";
|
|
97
80
|
/** 图片摘要/描述 */
|
|
98
81
|
summary?: string;
|
|
99
82
|
/** 图片子类型 */
|
|
@@ -101,43 +84,43 @@ interface RecvImageElement extends MediaProps {
|
|
|
101
84
|
}
|
|
102
85
|
/** 接收的语音消息段 */
|
|
103
86
|
interface RecvRecordElement extends MediaProps {
|
|
104
|
-
type:
|
|
87
|
+
type: "record";
|
|
105
88
|
}
|
|
106
89
|
/** 接收的视频消息段 */
|
|
107
90
|
interface RecvVideoElement extends MediaProps {
|
|
108
|
-
type:
|
|
91
|
+
type: "video";
|
|
109
92
|
}
|
|
110
93
|
/** 接收的猜拳消息段 */
|
|
111
94
|
interface RecvRpsElement {
|
|
112
|
-
type:
|
|
95
|
+
type: "rps";
|
|
113
96
|
/** 猜拳结果:1-石头, 2-剪刀, 3-布 */
|
|
114
97
|
result: string;
|
|
115
98
|
}
|
|
116
99
|
/** 接收的掷骰子消息段 */
|
|
117
100
|
interface RecvDiceElement {
|
|
118
|
-
type:
|
|
101
|
+
type: "dice";
|
|
119
102
|
/** 骰子点数:1-6 */
|
|
120
103
|
result: string;
|
|
121
104
|
}
|
|
122
105
|
/** 接收的窗口抖动消息段(戳一戳) */
|
|
123
106
|
interface RecvShakeElement {
|
|
124
|
-
type:
|
|
107
|
+
type: "shake";
|
|
125
108
|
}
|
|
126
109
|
/** 接收的戳一戳消息段 */
|
|
127
110
|
interface RecvPokeElement {
|
|
128
|
-
type:
|
|
111
|
+
type: "poke";
|
|
129
112
|
}
|
|
130
113
|
/** 接收的分享链接消息段 */
|
|
131
114
|
interface RecvShareElement {
|
|
132
|
-
type:
|
|
115
|
+
type: "share";
|
|
133
116
|
}
|
|
134
117
|
/** 接收的位置消息段 */
|
|
135
118
|
interface RecvLocationElement {
|
|
136
|
-
type:
|
|
119
|
+
type: "location";
|
|
137
120
|
}
|
|
138
121
|
/** 接收的合并转发消息段 */
|
|
139
122
|
interface RecvForwardElement {
|
|
140
|
-
type:
|
|
123
|
+
type: "forward";
|
|
141
124
|
/** 合并转发消息 ID */
|
|
142
125
|
id: string;
|
|
143
126
|
/** 合并转发消息内容 */
|
|
@@ -145,48 +128,48 @@ interface RecvForwardElement {
|
|
|
145
128
|
}
|
|
146
129
|
/** 接收的 JSON 消息段 */
|
|
147
130
|
interface RecvJsonElement {
|
|
148
|
-
type:
|
|
131
|
+
type: "json";
|
|
149
132
|
/** JSON 数据字符串 */
|
|
150
133
|
data: string;
|
|
151
134
|
}
|
|
152
135
|
/** 接收的文件消息段 */
|
|
153
136
|
interface RecvFileElement extends MediaProps {
|
|
154
|
-
type:
|
|
137
|
+
type: "file";
|
|
155
138
|
}
|
|
156
139
|
/** 接收的 Markdown 消息段 */
|
|
157
140
|
interface RecvMarkdownElement {
|
|
158
|
-
type:
|
|
141
|
+
type: "markdown";
|
|
159
142
|
}
|
|
160
143
|
/** 接收的小程序消息段 */
|
|
161
144
|
interface RecvLightAppElement {
|
|
162
|
-
type:
|
|
145
|
+
type: "lightapp";
|
|
163
146
|
}
|
|
164
147
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
148
|
+
* 接收的消息段类型联合
|
|
149
|
+
* @description 表示从 QQ 接收到的所有可能的消息段类型
|
|
150
|
+
*/
|
|
168
151
|
type RecvElement = RecvTextElement | RecvAtElement | RecvReplyElement | RecvFaceElement | RecvImageElement | RecvRecordElement | RecvVideoElement | RecvRpsElement | RecvDiceElement | RecvShakeElement | RecvPokeElement | RecvShareElement | RecvLocationElement | RecvForwardElement | RecvJsonElement | RecvFileElement | RecvMarkdownElement | RecvLightAppElement;
|
|
169
152
|
/** 发送的纯文本消息段 */
|
|
170
153
|
interface SendTextElement {
|
|
171
|
-
type:
|
|
154
|
+
type: "text";
|
|
172
155
|
/** 文本内容 */
|
|
173
156
|
text: string;
|
|
174
157
|
}
|
|
175
158
|
/** 发送的 @ 消息段 */
|
|
176
159
|
interface SendAtElement {
|
|
177
|
-
type:
|
|
160
|
+
type: "at";
|
|
178
161
|
/** 被 @ 的 QQ 号,'all' 表示 @全体成员 */
|
|
179
|
-
qq:
|
|
162
|
+
qq: "all" | (string & {}) | number;
|
|
180
163
|
}
|
|
181
164
|
/** 发送的回复消息段 */
|
|
182
165
|
interface SendReplyElement {
|
|
183
|
-
type:
|
|
166
|
+
type: "reply";
|
|
184
167
|
/** 被回复的消息 ID */
|
|
185
168
|
id: string;
|
|
186
169
|
}
|
|
187
170
|
/** 发送的商城表情消息段 */
|
|
188
171
|
interface SendMfaceElement {
|
|
189
|
-
type:
|
|
172
|
+
type: "mface";
|
|
190
173
|
/** 表情 ID */
|
|
191
174
|
id: number;
|
|
192
175
|
/** 表情 key */
|
|
@@ -200,19 +183,19 @@ interface SendMfaceElement {
|
|
|
200
183
|
}
|
|
201
184
|
/** 发送的 QQ 表情消息段 */
|
|
202
185
|
interface SendFaceElement {
|
|
203
|
-
type:
|
|
186
|
+
type: "face";
|
|
204
187
|
/** QQ 表情 ID */
|
|
205
188
|
id: number;
|
|
206
189
|
}
|
|
207
190
|
/** 发送的大表情消息段 */
|
|
208
191
|
interface SendBfaceElement {
|
|
209
|
-
type:
|
|
192
|
+
type: "bface";
|
|
210
193
|
/** 大表情 ID */
|
|
211
194
|
id: number;
|
|
212
195
|
}
|
|
213
196
|
/** 发送的图片消息段 */
|
|
214
197
|
interface SendImageElement {
|
|
215
|
-
type:
|
|
198
|
+
type: "image";
|
|
216
199
|
/** 图片文件,支持 file:// / http:// / base64:// 协议 */
|
|
217
200
|
file: string;
|
|
218
201
|
/** 图片文件名 */
|
|
@@ -224,7 +207,7 @@ interface SendImageElement {
|
|
|
224
207
|
}
|
|
225
208
|
/** 发送的视频消息段 */
|
|
226
209
|
interface SendVideoElement {
|
|
227
|
-
type:
|
|
210
|
+
type: "video";
|
|
228
211
|
/** 视频文件,支持 file:// / http:// / base64:// 协议 */
|
|
229
212
|
file: string;
|
|
230
213
|
/** 视频文件名 */
|
|
@@ -234,7 +217,7 @@ interface SendVideoElement {
|
|
|
234
217
|
}
|
|
235
218
|
/** 发送的语音消息段 */
|
|
236
219
|
interface SendRecordElement {
|
|
237
|
-
type:
|
|
220
|
+
type: "record";
|
|
238
221
|
/** 语音文件,支持 file:// / http:// / base64:// 协议 */
|
|
239
222
|
file: string;
|
|
240
223
|
/** 语音文件名 */
|
|
@@ -242,29 +225,29 @@ interface SendRecordElement {
|
|
|
242
225
|
}
|
|
243
226
|
/** 发送的推荐好友/群消息段 */
|
|
244
227
|
interface SendContactElement {
|
|
245
|
-
type:
|
|
228
|
+
type: "contact";
|
|
246
229
|
/** 推荐类型:qq-好友, group-群 */
|
|
247
|
-
sub_type:
|
|
230
|
+
sub_type: "qq" | "group";
|
|
248
231
|
/** 被推荐的 QQ 号或群号 */
|
|
249
232
|
id: string;
|
|
250
233
|
}
|
|
251
234
|
/** 发送的戳一戳消息段 */
|
|
252
235
|
interface SendPokeElement {
|
|
253
|
-
type:
|
|
236
|
+
type: "poke";
|
|
254
237
|
}
|
|
255
238
|
/** 发送的音乐分享消息段 - 平台音乐 */
|
|
256
239
|
interface SendPlatformMusicElement {
|
|
257
|
-
type:
|
|
240
|
+
type: "music";
|
|
258
241
|
/** 音乐平台 */
|
|
259
|
-
platform:
|
|
242
|
+
platform: "qq" | "163" | "kugou" | "migu" | "kuwo";
|
|
260
243
|
/** 音乐 ID */
|
|
261
244
|
id: string;
|
|
262
245
|
}
|
|
263
246
|
/** 发送的音乐分享消息段 - 自定义音乐 */
|
|
264
247
|
interface SendCustomMusicElement {
|
|
265
|
-
type:
|
|
248
|
+
type: "music";
|
|
266
249
|
/** 自定义音乐标识 */
|
|
267
|
-
platform:
|
|
250
|
+
platform: "custom";
|
|
268
251
|
/** 跳转链接 URL */
|
|
269
252
|
url: string;
|
|
270
253
|
/** 音频链接 URL */
|
|
@@ -280,13 +263,13 @@ interface SendCustomMusicElement {
|
|
|
280
263
|
type SendMusicElement = SendPlatformMusicElement | SendCustomMusicElement;
|
|
281
264
|
/** 发送的合并转发消息段 */
|
|
282
265
|
interface SendForwardElement {
|
|
283
|
-
type:
|
|
266
|
+
type: "forward";
|
|
284
267
|
/** 合并转发消息 ID */
|
|
285
268
|
id: string;
|
|
286
269
|
}
|
|
287
270
|
/** 发送的合并转发节点 - 引用已有消息 */
|
|
288
271
|
interface SendNodeRefElement {
|
|
289
|
-
type:
|
|
272
|
+
type: "node";
|
|
290
273
|
/** 发送者 QQ 号(可选) */
|
|
291
274
|
user_id?: string;
|
|
292
275
|
/** 发送者昵称(可选) */
|
|
@@ -296,27 +279,27 @@ interface SendNodeRefElement {
|
|
|
296
279
|
}
|
|
297
280
|
/** 发送的合并转发节点 - 自定义内容 */
|
|
298
281
|
interface SendNodeContentElement {
|
|
299
|
-
type:
|
|
282
|
+
type: "node";
|
|
300
283
|
/** 发送者 QQ 号(可选) */
|
|
301
284
|
user_id?: string;
|
|
302
285
|
/** 发送者昵称(可选) */
|
|
303
286
|
nickname?: string;
|
|
304
287
|
/** 自定义消息内容 */
|
|
305
288
|
content: Exclude<SendElement, {
|
|
306
|
-
type:
|
|
289
|
+
type: "node";
|
|
307
290
|
}>[];
|
|
308
291
|
}
|
|
309
292
|
/** 发送的合并转发节点消息段 */
|
|
310
293
|
type SendNodeElement = SendNodeRefElement | SendNodeContentElement;
|
|
311
294
|
/** 发送的 JSON 消息段 */
|
|
312
295
|
interface SendJsonElement {
|
|
313
|
-
type:
|
|
296
|
+
type: "json";
|
|
314
297
|
/** JSON 数据字符串 */
|
|
315
298
|
data: string;
|
|
316
299
|
}
|
|
317
300
|
/** 发送的文件消息段 */
|
|
318
301
|
interface SendFileElement {
|
|
319
|
-
type:
|
|
302
|
+
type: "file";
|
|
320
303
|
/** 文件,支持 file:// / http:// / base64:// 协议 */
|
|
321
304
|
file: string;
|
|
322
305
|
/** 文件名 */
|
|
@@ -324,33 +307,56 @@ interface SendFileElement {
|
|
|
324
307
|
}
|
|
325
308
|
/** 发送的 Markdown 消息段 */
|
|
326
309
|
interface SendMarkdownElement {
|
|
327
|
-
type:
|
|
310
|
+
type: "markdown";
|
|
328
311
|
}
|
|
329
312
|
/** 发送的小程序消息段 */
|
|
330
313
|
interface SendLightAppElement {
|
|
331
|
-
type:
|
|
314
|
+
type: "lightapp";
|
|
332
315
|
}
|
|
333
316
|
/**
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
317
|
+
* 发送的消息段类型联合
|
|
318
|
+
* @description 表示可以发送给 QQ 的所有可能的消息段类型
|
|
319
|
+
*/
|
|
337
320
|
type SendElement = SendTextElement | SendAtElement | SendReplyElement | SendMfaceElement | SendFaceElement | SendBfaceElement | SendImageElement | SendVideoElement | SendRecordElement | SendContactElement | SendPokeElement | SendMusicElement | SendForwardElement | SendNodeElement | SendJsonElement | SendFileElement | SendMarkdownElement | SendLightAppElement;
|
|
321
|
+
/**
|
|
322
|
+
* 将消息段类型包装为 OneBot 标准格式
|
|
323
|
+
* @description 将 { type, ...data } 转换为 { type, data: { ...data } } 格式
|
|
324
|
+
*/
|
|
325
|
+
type WrapData<T extends {
|
|
326
|
+
type: string;
|
|
327
|
+
}> = {
|
|
328
|
+
type: T["type"];
|
|
329
|
+
data: Omit<T, "type">;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* 将 OneBot 标准格式展开为扁平格式
|
|
333
|
+
* @description 将 { type, data: { ...data } } 转换为 { type, ...data } 格式
|
|
334
|
+
*/
|
|
335
|
+
type FlattenData<T extends {
|
|
336
|
+
type: string;
|
|
337
|
+
}> = T extends {
|
|
338
|
+
data: infer U;
|
|
339
|
+
} ? U & {
|
|
340
|
+
type: T["type"];
|
|
341
|
+
} : never;
|
|
342
|
+
/** 标准化后的发送消息段(OneBot 标准格式) */
|
|
343
|
+
type NormalizedElementToSend = WrapData<SendElement>;
|
|
338
344
|
/** 可发送的消息类型,可以是字符串或消息段 */
|
|
339
345
|
type Sendable = string | SendElement;
|
|
340
346
|
/** 上报事件类型 */
|
|
341
|
-
type PostType =
|
|
347
|
+
type PostType = "meta_event" | "message" | "message_sent" | "notice" | "request";
|
|
342
348
|
/** 元事件类型 */
|
|
343
|
-
type MetaEventType =
|
|
349
|
+
type MetaEventType = "heartbeat" | "lifecycle";
|
|
344
350
|
/** 消息类型 */
|
|
345
|
-
type MessageType =
|
|
351
|
+
type MessageType = "private" | "group";
|
|
346
352
|
/** 通知类型 */
|
|
347
|
-
type NoticeType =
|
|
353
|
+
type NoticeType = "friend" | "group" | "client";
|
|
348
354
|
/** 通知子类型 */
|
|
349
|
-
type NoticeSubType =
|
|
355
|
+
type NoticeSubType = "increase" | "decrease" | "recall" | "poke" | "like" | "input" | "admin" | "ban" | "title" | "card" | "upload" | "reaction" | "essence";
|
|
350
356
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
357
|
+
* 事件基础类型
|
|
358
|
+
* @description 所有事件的基础结构,包含时间戳、机器人 QQ 号和事件类型
|
|
359
|
+
*/
|
|
354
360
|
type EventBase<T extends PostType, U$1 extends object> = U$1 & {
|
|
355
361
|
/** 事件发生的 Unix 时间戳 */
|
|
356
362
|
time: number;
|
|
@@ -360,17 +366,17 @@ type EventBase<T extends PostType, U$1 extends object> = U$1 & {
|
|
|
360
366
|
post_type: T;
|
|
361
367
|
};
|
|
362
368
|
/**
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
type MetaEventBase<T extends MetaEventType, U$1 extends object> = EventBase<
|
|
369
|
+
* 元事件基础类型
|
|
370
|
+
* @description 元事件表示 OneBot 实现本身的状态变化
|
|
371
|
+
*/
|
|
372
|
+
type MetaEventBase<T extends MetaEventType, U$1 extends object> = EventBase<"meta_event", U$1 & {
|
|
367
373
|
meta_event_type: T;
|
|
368
374
|
}>;
|
|
369
375
|
/**
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
type HeartbeatMetaEvent = MetaEventBase<
|
|
376
|
+
* 心跳元事件
|
|
377
|
+
* @description 定期发送的心跳事件,用于确认连接状态
|
|
378
|
+
*/
|
|
379
|
+
type HeartbeatMetaEvent = MetaEventBase<"heartbeat", {
|
|
374
380
|
/** 状态信息 */
|
|
375
381
|
status: {
|
|
376
382
|
/** 是否在线 */
|
|
@@ -382,12 +388,12 @@ type HeartbeatMetaEvent = MetaEventBase<'heartbeat', {
|
|
|
382
388
|
interval: number;
|
|
383
389
|
}>;
|
|
384
390
|
/**
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
type LifecycleMetaEvent = MetaEventBase<
|
|
391
|
+
* 生命周期元事件
|
|
392
|
+
* @description OneBot 实现的生命周期事件
|
|
393
|
+
*/
|
|
394
|
+
type LifecycleMetaEvent = MetaEventBase<"lifecycle", {
|
|
389
395
|
/** 生命周期子类型 */
|
|
390
|
-
sub_type:
|
|
396
|
+
sub_type: "connect";
|
|
391
397
|
}>;
|
|
392
398
|
/** 元事件联合类型 */
|
|
393
399
|
type MetaEvent = HeartbeatMetaEvent | LifecycleMetaEvent;
|
|
@@ -404,9 +410,9 @@ type ReactionAction = (id: string) => Promise<void>;
|
|
|
404
410
|
/** 撤回消息的函数类型 */
|
|
405
411
|
type Recall = () => Promise<void>;
|
|
406
412
|
/**
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
413
|
+
* 群信息接口
|
|
414
|
+
* @description 包含群的基本信息和常用操作方法
|
|
415
|
+
*/
|
|
410
416
|
interface Group {
|
|
411
417
|
/** 群号 */
|
|
412
418
|
group_id: number;
|
|
@@ -442,11 +448,11 @@ interface Group {
|
|
|
442
448
|
/** 发送群消息 */
|
|
443
449
|
sendMsg: SendMsg;
|
|
444
450
|
}
|
|
445
|
-
type GroupWithInfo = Group & Awaited<ReturnType<Group[
|
|
451
|
+
type GroupWithInfo = Group & Awaited<ReturnType<Group["getInfo"]>>;
|
|
446
452
|
/**
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
453
|
+
* 好友信息接口
|
|
454
|
+
* @description 包含好友的基本信息和常用操作方法
|
|
455
|
+
*/
|
|
450
456
|
interface Friend {
|
|
451
457
|
/** 好友 QQ 号 */
|
|
452
458
|
user_id: number;
|
|
@@ -542,12 +548,12 @@ interface Friend {
|
|
|
542
548
|
login_days: number;
|
|
543
549
|
}>;
|
|
544
550
|
}
|
|
545
|
-
type FriendWithInfo = Friend & Awaited<ReturnType<Friend[
|
|
551
|
+
type FriendWithInfo = Friend & Awaited<ReturnType<Friend["getInfo"]>>;
|
|
546
552
|
/**
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
type MessageEventBase<T extends MessageType, U$1 extends object> = EventBase<
|
|
553
|
+
* 消息事件基础类型
|
|
554
|
+
* @description 所有消息事件的基础结构
|
|
555
|
+
*/
|
|
556
|
+
type MessageEventBase<T extends MessageType, U$1 extends object> = EventBase<"message", U$1 & {
|
|
551
557
|
/** 消息 ID */
|
|
552
558
|
message_id: number;
|
|
553
559
|
/** 消息类型 */
|
|
@@ -566,14 +572,14 @@ type MessageEventBase<T extends MessageType, U$1 extends object> = EventBase<'me
|
|
|
566
572
|
reply: Reply;
|
|
567
573
|
}>;
|
|
568
574
|
/**
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
type PrivateMessageEvent = MessageEventBase<
|
|
575
|
+
* 私聊消息事件
|
|
576
|
+
* @description 包含好友私聊、群临时会话等私聊消息
|
|
577
|
+
*/
|
|
578
|
+
type PrivateMessageEvent = MessageEventBase<"private", {
|
|
573
579
|
/** 发送者 QQ 号 */
|
|
574
580
|
user_id: number;
|
|
575
581
|
/** 私聊子类型:friend-好友, group-群临时会话, group_self-群中自己发送, other-其他 */
|
|
576
|
-
sub_type:
|
|
582
|
+
sub_type: "friend" | "group" | "group_self" | "other";
|
|
577
583
|
/** 接收者 QQ 号 */
|
|
578
584
|
target_id: number;
|
|
579
585
|
/** 好友信息对象 */
|
|
@@ -587,10 +593,10 @@ type PrivateMessageEvent = MessageEventBase<'private', {
|
|
|
587
593
|
};
|
|
588
594
|
}>;
|
|
589
595
|
/**
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
type GroupMessageEvent = MessageEventBase<
|
|
596
|
+
* 群消息事件
|
|
597
|
+
* @description 群聊中的消息事件
|
|
598
|
+
*/
|
|
599
|
+
type GroupMessageEvent = MessageEventBase<"group", {
|
|
594
600
|
/** 群号 */
|
|
595
601
|
group_id: number;
|
|
596
602
|
/** 群名称 */
|
|
@@ -598,7 +604,7 @@ type GroupMessageEvent = MessageEventBase<'group', {
|
|
|
598
604
|
/** 发送者 QQ 号 */
|
|
599
605
|
user_id: number;
|
|
600
606
|
/** 群消息子类型:normal-普通消息, notice-通知消息 */
|
|
601
|
-
sub_type:
|
|
607
|
+
sub_type: "normal" | "notice";
|
|
602
608
|
/** 撤回该消息的方法 */
|
|
603
609
|
recall: Recall;
|
|
604
610
|
/** 添加消息表态的方法 */
|
|
@@ -616,33 +622,33 @@ type GroupMessageEvent = MessageEventBase<'group', {
|
|
|
616
622
|
/** 发送者群名片 */
|
|
617
623
|
card: string;
|
|
618
624
|
/** 发送者群角色:owner-群主, admin-管理员, member-普通成员 */
|
|
619
|
-
role:
|
|
625
|
+
role: "owner" | "admin" | "member";
|
|
620
626
|
};
|
|
621
627
|
}>;
|
|
622
628
|
/** 消息事件联合类型 */
|
|
623
629
|
type MessageEvent = PrivateMessageEvent | GroupMessageEvent;
|
|
624
630
|
/**
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
type ToMessageSent<T extends MessageEvent> = Omit<T,
|
|
629
|
-
post_type:
|
|
631
|
+
* 将消息事件转换为发送消息事件类型
|
|
632
|
+
* @description 用于表示机器人自己发送的消息事件
|
|
633
|
+
*/
|
|
634
|
+
type ToMessageSent<T extends MessageEvent> = Omit<T, "post_type" | "group" | "friend" | "reply"> & {
|
|
635
|
+
post_type: "message_sent";
|
|
630
636
|
};
|
|
631
637
|
/**
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
type NoticeEventBase<T extends NoticeType, U$1 extends object> = EventBase<
|
|
638
|
+
* 通知事件基础类型
|
|
639
|
+
* @description 所有通知事件的基础结构
|
|
640
|
+
*/
|
|
641
|
+
type NoticeEventBase<T extends NoticeType, U$1 extends object> = EventBase<"notice", U$1 & {
|
|
636
642
|
/** 通知类型 */
|
|
637
643
|
notice_type: T;
|
|
638
644
|
/** 原始通知类型 */
|
|
639
645
|
original_notice_type: string;
|
|
640
646
|
}>;
|
|
641
647
|
/**
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
type GroupNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<
|
|
648
|
+
* 群通知事件基础类型
|
|
649
|
+
* @description 所有群相关通知事件的基础结构
|
|
650
|
+
*/
|
|
651
|
+
type GroupNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<"group", U$1 & {
|
|
646
652
|
/** 通知子类型 */
|
|
647
653
|
sub_type: T;
|
|
648
654
|
/** 群号 */
|
|
@@ -653,10 +659,10 @@ type GroupNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeE
|
|
|
653
659
|
group: Group;
|
|
654
660
|
}>;
|
|
655
661
|
/**
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
type FriendNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<
|
|
662
|
+
* 好友通知事件基础类型
|
|
663
|
+
* @description 所有好友相关通知事件的基础结构
|
|
664
|
+
*/
|
|
665
|
+
type FriendNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<"friend", U$1 & {
|
|
660
666
|
/** 通知子类型 */
|
|
661
667
|
sub_type: T;
|
|
662
668
|
/** 相关用户 QQ 号 */
|
|
@@ -665,16 +671,16 @@ type FriendNoticeEventBase<T extends NoticeSubType, U$1 extends object> = Notice
|
|
|
665
671
|
friend: Friend;
|
|
666
672
|
}>;
|
|
667
673
|
/** 好友增加通知事件 */
|
|
668
|
-
type FriendIncreaseNoticeEvent = FriendNoticeEventBase<
|
|
674
|
+
type FriendIncreaseNoticeEvent = FriendNoticeEventBase<"increase", {}>;
|
|
669
675
|
/** 好友减少通知事件 */
|
|
670
|
-
type FriendDecreaseNoticeEvent = FriendNoticeEventBase<
|
|
676
|
+
type FriendDecreaseNoticeEvent = FriendNoticeEventBase<"decrease", {}>;
|
|
671
677
|
/** 好友消息撤回通知事件 */
|
|
672
|
-
type FriendRecallNoticeEvent = FriendNoticeEventBase<
|
|
678
|
+
type FriendRecallNoticeEvent = FriendNoticeEventBase<"recall", {
|
|
673
679
|
/** 被撤回的消息 ID */
|
|
674
680
|
message_id: number;
|
|
675
681
|
}>;
|
|
676
682
|
/** 好友戳一戳通知事件 */
|
|
677
|
-
type FriendPokeNoticeEvent = FriendNoticeEventBase<
|
|
683
|
+
type FriendPokeNoticeEvent = FriendNoticeEventBase<"poke", {
|
|
678
684
|
/** 被戳者 QQ 号 */
|
|
679
685
|
target_id: number;
|
|
680
686
|
/** 发送者 QQ 号 */
|
|
@@ -683,7 +689,7 @@ type FriendPokeNoticeEvent = FriendNoticeEventBase<'poke', {
|
|
|
683
689
|
raw_info: any[];
|
|
684
690
|
}>;
|
|
685
691
|
/** 好友点赞通知事件 */
|
|
686
|
-
type FriendLikeNoticeEvent = FriendNoticeEventBase<
|
|
692
|
+
type FriendLikeNoticeEvent = FriendNoticeEventBase<"like", {
|
|
687
693
|
/** 操作者 QQ 号 */
|
|
688
694
|
operator_id: number;
|
|
689
695
|
/** 操作者昵称 */
|
|
@@ -692,7 +698,7 @@ type FriendLikeNoticeEvent = FriendNoticeEventBase<'like', {
|
|
|
692
698
|
times: number;
|
|
693
699
|
}>;
|
|
694
700
|
/** 好友输入状态通知事件 */
|
|
695
|
-
type FriendInputNoticeEvent = FriendNoticeEventBase<
|
|
701
|
+
type FriendInputNoticeEvent = FriendNoticeEventBase<"input", {
|
|
696
702
|
/** 状态文本 */
|
|
697
703
|
status_text: string;
|
|
698
704
|
/** 事件类型 */
|
|
@@ -701,54 +707,54 @@ type FriendInputNoticeEvent = FriendNoticeEventBase<'input', {
|
|
|
701
707
|
/** 好友通知事件联合类型 */
|
|
702
708
|
type FriendNoticeEvent = FriendIncreaseNoticeEvent | FriendDecreaseNoticeEvent | FriendRecallNoticeEvent | FriendPokeNoticeEvent | FriendLikeNoticeEvent | FriendInputNoticeEvent;
|
|
703
709
|
/** 群成员增加通知事件 */
|
|
704
|
-
type GroupIncreaseNoticeEvent = GroupNoticeEventBase<
|
|
710
|
+
type GroupIncreaseNoticeEvent = GroupNoticeEventBase<"increase", {
|
|
705
711
|
/** 操作者 QQ 号(如邀请者) */
|
|
706
712
|
operator_id: number;
|
|
707
713
|
/** 加入类型:invite-邀请, add-主动加群, approve-管理员审批 */
|
|
708
|
-
actions_type:
|
|
714
|
+
actions_type: "invite" | "add" | "approve";
|
|
709
715
|
}>;
|
|
710
716
|
/** 群成员减少通知事件 */
|
|
711
|
-
type GroupDecreaseNoticeEvent = GroupNoticeEventBase<
|
|
717
|
+
type GroupDecreaseNoticeEvent = GroupNoticeEventBase<"decrease", {
|
|
712
718
|
/** 操作者 QQ 号 */
|
|
713
719
|
operator_id: number;
|
|
714
720
|
/** 离开类型:kick-被踢, leave-主动退出 */
|
|
715
|
-
actions_type:
|
|
721
|
+
actions_type: "kick" | "leave";
|
|
716
722
|
}>;
|
|
717
723
|
/** 群管理员变动通知事件 */
|
|
718
|
-
type GroupAdminNoticeEvent = GroupNoticeEventBase<
|
|
724
|
+
type GroupAdminNoticeEvent = GroupNoticeEventBase<"admin", {
|
|
719
725
|
/** 操作类型:set-设置管理员, unset-取消管理员 */
|
|
720
|
-
action_type:
|
|
726
|
+
action_type: "set" | "unset";
|
|
721
727
|
}>;
|
|
722
728
|
/** 群禁言通知事件 */
|
|
723
|
-
type GroupBanNoticeEvent = GroupNoticeEventBase<
|
|
729
|
+
type GroupBanNoticeEvent = GroupNoticeEventBase<"ban", {
|
|
724
730
|
/** 禁言时长(秒),0 表示解除禁言 */
|
|
725
731
|
duration: number;
|
|
726
732
|
/** 操作类型:ban-禁言, lift_ban-解除禁言 */
|
|
727
|
-
action_type:
|
|
733
|
+
action_type: "ban" | "lift_ban";
|
|
728
734
|
/** 操作者 QQ 号 */
|
|
729
735
|
operator_id: number;
|
|
730
736
|
}>;
|
|
731
737
|
/** 群名片变动通知事件 */
|
|
732
|
-
type GroupCardNoticeEvent = GroupNoticeEventBase<
|
|
738
|
+
type GroupCardNoticeEvent = GroupNoticeEventBase<"card", {
|
|
733
739
|
/** 新名片 */
|
|
734
740
|
card_new: string;
|
|
735
741
|
/** 旧名片 */
|
|
736
742
|
card_old: string;
|
|
737
743
|
}>;
|
|
738
744
|
/** 群戳一戳通知事件 */
|
|
739
|
-
type GroupPokeNoticeEvent = GroupNoticeEventBase<
|
|
745
|
+
type GroupPokeNoticeEvent = GroupNoticeEventBase<"poke", {
|
|
740
746
|
/** 被戳者 QQ 号 */
|
|
741
747
|
target_id: number;
|
|
742
748
|
/** 原始信息 */
|
|
743
749
|
raw_info: any[];
|
|
744
750
|
}>;
|
|
745
751
|
/** 群头衔变动通知事件 */
|
|
746
|
-
type GroupTitleNoticeEvent = GroupNoticeEventBase<
|
|
752
|
+
type GroupTitleNoticeEvent = GroupNoticeEventBase<"title", {
|
|
747
753
|
/** 新头衔 */
|
|
748
754
|
title: string;
|
|
749
755
|
}>;
|
|
750
756
|
/** 群文件上传通知事件 */
|
|
751
|
-
type GroupUploadNoticeEvent = GroupNoticeEventBase<
|
|
757
|
+
type GroupUploadNoticeEvent = GroupNoticeEventBase<"upload", {
|
|
752
758
|
/** 上传的文件信息 */
|
|
753
759
|
file: {
|
|
754
760
|
/** 文件 ID */
|
|
@@ -762,7 +768,7 @@ type GroupUploadNoticeEvent = GroupNoticeEventBase<'upload', {
|
|
|
762
768
|
};
|
|
763
769
|
}>;
|
|
764
770
|
/** 群消息表态变动通知事件 */
|
|
765
|
-
type GroupReactionNoticeEvent = GroupNoticeEventBase<
|
|
771
|
+
type GroupReactionNoticeEvent = GroupNoticeEventBase<"reaction", {
|
|
766
772
|
/** 相关消息 ID */
|
|
767
773
|
message_id: number;
|
|
768
774
|
/** 表态列表 */
|
|
@@ -776,7 +782,7 @@ type GroupReactionNoticeEvent = GroupNoticeEventBase<'reaction', {
|
|
|
776
782
|
is_add: boolean;
|
|
777
783
|
}>;
|
|
778
784
|
/** 群精华消息变动通知事件 */
|
|
779
|
-
type GroupEssenceNoticeEvent = GroupNoticeEventBase<
|
|
785
|
+
type GroupEssenceNoticeEvent = GroupNoticeEventBase<"essence", {
|
|
780
786
|
/** 原消息发送者 QQ 号 */
|
|
781
787
|
sender_id: number;
|
|
782
788
|
/** 相关消息 ID */
|
|
@@ -784,10 +790,10 @@ type GroupEssenceNoticeEvent = GroupNoticeEventBase<'essence', {
|
|
|
784
790
|
/** 操作者 QQ 号 */
|
|
785
791
|
operator_id: number;
|
|
786
792
|
/** 操作类型:add-添加精华, remove-移除精华 */
|
|
787
|
-
action_type:
|
|
793
|
+
action_type: "add" | "remove";
|
|
788
794
|
}>;
|
|
789
795
|
/** 群消息撤回通知事件 */
|
|
790
|
-
type GroupRecallNoticeEvent = GroupNoticeEventBase<
|
|
796
|
+
type GroupRecallNoticeEvent = GroupNoticeEventBase<"recall", {
|
|
791
797
|
/** 被撤回的消息 ID */
|
|
792
798
|
message_id: number;
|
|
793
799
|
/** 操作者 QQ 号 */
|
|
@@ -798,10 +804,10 @@ type GroupNoticeEvent = GroupIncreaseNoticeEvent | GroupDecreaseNoticeEvent | Gr
|
|
|
798
804
|
/** 通知事件联合类型 */
|
|
799
805
|
type NoticeEvent = GroupNoticeEvent | FriendNoticeEvent;
|
|
800
806
|
/**
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
type RequestEventBase<T extends string, U$1 extends object> = EventBase<
|
|
807
|
+
* 请求事件基础类型
|
|
808
|
+
* @description 所有请求事件的基础结构
|
|
809
|
+
*/
|
|
810
|
+
type RequestEventBase<T extends string, U$1 extends object> = EventBase<"request", U$1 & {
|
|
805
811
|
/** 请求类型 */
|
|
806
812
|
request_type: T;
|
|
807
813
|
/** 请求者 QQ 号 */
|
|
@@ -812,153 +818,124 @@ type RequestEventBase<T extends string, U$1 extends object> = EventBase<'request
|
|
|
812
818
|
comment: string;
|
|
813
819
|
}>;
|
|
814
820
|
/** 好友添加请求事件 */
|
|
815
|
-
type FriendRequestEvent = RequestEventBase<
|
|
821
|
+
type FriendRequestEvent = RequestEventBase<"friend", {}>;
|
|
816
822
|
/** 加群请求事件(他人申请加入群) */
|
|
817
|
-
type GroupAddRequestEvent = RequestEventBase<
|
|
823
|
+
type GroupAddRequestEvent = RequestEventBase<"group", {
|
|
818
824
|
/** 群号 */
|
|
819
825
|
group_id: number;
|
|
820
826
|
/** 请求子类型:add-主动加群 */
|
|
821
|
-
sub_type:
|
|
827
|
+
sub_type: "add";
|
|
822
828
|
}>;
|
|
823
829
|
/** 邀请入群请求事件(他人邀请机器人入群) */
|
|
824
|
-
type GroupInviteRequestEvent = RequestEventBase<
|
|
830
|
+
type GroupInviteRequestEvent = RequestEventBase<"group", {
|
|
825
831
|
/** 群号 */
|
|
826
832
|
group_id: number;
|
|
827
833
|
/** 请求子类型:invite-被邀请 */
|
|
828
|
-
sub_type:
|
|
834
|
+
sub_type: "invite";
|
|
829
835
|
}>;
|
|
830
836
|
/** 群请求事件联合类型 */
|
|
831
837
|
type GroupRequestEvent = GroupAddRequestEvent | GroupInviteRequestEvent;
|
|
832
838
|
/** 请求事件联合类型 */
|
|
833
839
|
type RequestEvent = FriendRequestEvent | GroupRequestEvent;
|
|
834
840
|
/**
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
841
|
+
* OneBot 事件映射表
|
|
842
|
+
* @description 定义了所有事件名称与对应事件类型的映射关系
|
|
843
|
+
*/
|
|
838
844
|
interface OneBotEventMap {
|
|
839
845
|
/** 元事件,通常与 OneBot 服务端状态相关 */
|
|
840
846
|
meta_event: MetaEvent;
|
|
841
847
|
/** 元事件 - 心跳事件,确认服务端在线状态 */
|
|
842
|
-
|
|
848
|
+
"meta_event.heartbeat": HeartbeatMetaEvent;
|
|
843
849
|
/** 元事件 - 生命周期,服务端状态变化 */
|
|
844
|
-
|
|
850
|
+
"meta_event.lifecycle": LifecycleMetaEvent;
|
|
845
851
|
/** 元事件 - 生命周期 - 连接成功 */
|
|
846
|
-
|
|
852
|
+
"meta_event.lifecycle.connect": LifecycleMetaEvent;
|
|
847
853
|
/** 消息事件,包含私聊和群消息 */
|
|
848
854
|
message: MessageEvent;
|
|
849
855
|
/** 消息事件 - 私聊消息 */
|
|
850
|
-
|
|
856
|
+
"message.private": PrivateMessageEvent;
|
|
851
857
|
/** 消息事件 - 私聊消息 - 好友私聊 */
|
|
852
|
-
|
|
858
|
+
"message.private.friend": PrivateMessageEvent;
|
|
853
859
|
/** 消息事件 - 私聊消息 - 群临时会话 */
|
|
854
|
-
|
|
860
|
+
"message.private.group": PrivateMessageEvent;
|
|
855
861
|
/** 消息事件 - 群消息 */
|
|
856
|
-
|
|
862
|
+
"message.group": GroupMessageEvent;
|
|
857
863
|
/** 消息事件 - 群消息 - 普通消息 */
|
|
858
|
-
|
|
864
|
+
"message.group.normal": GroupMessageEvent;
|
|
859
865
|
message_sent: ToMessageSent<MessageEvent>;
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
866
|
+
"message_sent.private": ToMessageSent<PrivateMessageEvent>;
|
|
867
|
+
"message_sent.private.friend": ToMessageSent<PrivateMessageEvent>;
|
|
868
|
+
"message_sent.private.group": ToMessageSent<PrivateMessageEvent>;
|
|
869
|
+
"message_sent.group": ToMessageSent<GroupMessageEvent>;
|
|
870
|
+
"message_sent.group.normal": ToMessageSent<GroupMessageEvent>;
|
|
865
871
|
/** 请求事件 */
|
|
866
872
|
request: RequestEvent;
|
|
867
873
|
/** 请求事件 - 好友请求 */
|
|
868
|
-
|
|
874
|
+
"request.friend": FriendRequestEvent;
|
|
869
875
|
/** 请求事件 - 群请求 */
|
|
870
|
-
|
|
876
|
+
"request.group": GroupRequestEvent;
|
|
871
877
|
/** 请求事件 - 他人加群请求,当机器人是群主或管理员时收到 */
|
|
872
|
-
|
|
878
|
+
"request.group.add": GroupAddRequestEvent;
|
|
873
879
|
/** 请求事件 - 邀请加群请求,他人邀请机器人加入群时收到 */
|
|
874
|
-
|
|
880
|
+
"request.group.invite": GroupInviteRequestEvent;
|
|
875
881
|
/** 通知事件 */
|
|
876
882
|
notice: NoticeEvent;
|
|
877
883
|
/** 通知事件 - 好友相关通知 */
|
|
878
|
-
|
|
884
|
+
"notice.friend": FriendNoticeEvent;
|
|
879
885
|
/** 通知事件 - 好友增加 */
|
|
880
|
-
|
|
886
|
+
"notice.friend.increase": FriendIncreaseNoticeEvent;
|
|
881
887
|
/** 通知事件 - 好友减少 */
|
|
882
|
-
|
|
888
|
+
"notice.friend.decrease": FriendDecreaseNoticeEvent;
|
|
883
889
|
/** 通知事件 - 好友备注变更 */
|
|
884
|
-
|
|
890
|
+
"notice.friend.recall": FriendRecallNoticeEvent;
|
|
885
891
|
/** 通知事件 - 好友戳一戳 */
|
|
886
|
-
|
|
892
|
+
"notice.friend.poke": FriendPokeNoticeEvent;
|
|
887
893
|
/** 通知事件 - 好友点赞 */
|
|
888
|
-
|
|
894
|
+
"notice.friend.like": FriendLikeNoticeEvent;
|
|
889
895
|
/** 通知事件 - 好友输入状态 */
|
|
890
|
-
|
|
896
|
+
"notice.friend.input": FriendInputNoticeEvent;
|
|
891
897
|
/** 通知事件 - 群相关通知 */
|
|
892
|
-
|
|
898
|
+
"notice.group": GroupNoticeEvent;
|
|
893
899
|
/** 通知事件 - 群成员增加 */
|
|
894
|
-
|
|
900
|
+
"notice.group.increase": GroupIncreaseNoticeEvent;
|
|
895
901
|
/** 通知事件 - 群成员减少 */
|
|
896
|
-
|
|
902
|
+
"notice.group.decrease": GroupDecreaseNoticeEvent;
|
|
897
903
|
/** 通知事件 - 群管理员变更 */
|
|
898
|
-
|
|
904
|
+
"notice.group.admin": GroupAdminNoticeEvent;
|
|
899
905
|
/** 通知事件 - 群成员被禁言 */
|
|
900
|
-
|
|
906
|
+
"notice.group.ban": GroupBanNoticeEvent;
|
|
901
907
|
/** 通知事件 - 群戳一戳 */
|
|
902
|
-
|
|
908
|
+
"notice.group.poke": GroupPokeNoticeEvent;
|
|
903
909
|
/** 通知事件 - 群头衔变更 */
|
|
904
|
-
|
|
910
|
+
"notice.group.title": GroupTitleNoticeEvent;
|
|
905
911
|
/** 通知事件 - 群名片变更 */
|
|
906
|
-
|
|
912
|
+
"notice.group.card": GroupCardNoticeEvent;
|
|
907
913
|
/** 通知事件 - 群公告变更 */
|
|
908
|
-
|
|
914
|
+
"notice.group.recall": GroupRecallNoticeEvent;
|
|
909
915
|
/** 通知事件 - 群上传文件 */
|
|
910
|
-
|
|
916
|
+
"notice.group.upload": GroupUploadNoticeEvent;
|
|
911
917
|
/** 通知事件 - 给群消息添加反应 Reaction */
|
|
912
|
-
|
|
918
|
+
"notice.group.reaction": GroupReactionNoticeEvent;
|
|
913
919
|
/** 通知事件 - 群精华消息变更 */
|
|
914
|
-
|
|
920
|
+
"notice.group.essence": GroupEssenceNoticeEvent;
|
|
915
921
|
}
|
|
916
922
|
/**
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
type OneBotAPI =
|
|
923
|
+
* OneBot 11 标准 API
|
|
924
|
+
* @description OneBot 11 规范定义的标准 API 接口
|
|
925
|
+
*/
|
|
926
|
+
type OneBotAPI = "delete_friend" | "delete_msg" | "get_forward_msg" | "get_friend_list" | "get_group_info" | "get_group_list" | "get_group_member_info" | "get_group_member_list" | "get_group_msg_history" | "get_login_info" | "get_msg" | "get_status" | "get_stranger_info" | "send_group_msg" | "send_private_msg" | "set_friend_add_request" | "set_group_add_request" | "set_group_admin" | "set_group_ban" | "set_group_card" | "set_group_kick" | "set_group_leave" | "set_group_name" | "set_group_portrait" | "set_group_special_title" | "set_qq_profile";
|
|
921
927
|
/**
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
type NapCatExtendAPI =
|
|
928
|
+
* NapCat 扩展 API
|
|
929
|
+
* @description NapCat 实现的额外扩展 API 接口
|
|
930
|
+
*/
|
|
931
|
+
type NapCatExtendAPI = "_del_group_notice" | "_get_group_notice" | "_get_model_show" | "_mark_all_as_read" | "_send_group_notice" | "_set_model_show" | ".handle_quick_operation" | ".ocr_image" | "ArkShareGroup" | "ArkSharePeer" | "bot_exit" | "can_send_image" | "can_send_record" | "clean_cache" | "click_inline_keyboard_button" | "create_collection" | "create_group_file_folder" | "delete_essence_msg" | "delete_group_file" | "delete_group_folder" | "download_file" | "fetch_custom_face" | "fetch_emoji_like" | "forward_friend_single_msg" | "forward_group_single_msg" | "friend_poke" | "get_ai_characters" | "get_ai_record" | "get_clientkey" | "get_collection_list" | "get_cookies" | "get_credentials" | "get_csrf_token" | "get_doubt_friends_add_request" | "get_essence_msg_list" | "get_file" | "get_friend_msg_history" | "get_friends_with_category" | "get_group_at_all_remain" | "get_group_detail_info" | "get_group_file_system_info" | "get_group_file_url" | "get_group_files_by_folder" | "get_group_honor_info" | "get_group_ignored_notifies" | "get_group_info_ex" | "get_group_root_files" | "get_group_shut_list" | "get_group_system_msg" | "get_image" | "get_mini_app_ark" | "get_online_clients" | "get_private_file_url" | "get_profile_like" | "get_recent_contact" | "get_record" | "get_rkey_server" | "get_rkey" | "get_robot_uin_range" | "get_unidirectional_friend_list" | "get_version_info" | "group_poke" | "mark_group_msg_as_read" | "mark_msg_as_read" | "mark_private_msg_as_read" | "move_group_file" | "nc_get_packet_status" | "nc_get_rkey" | "nc_get_user_status" | "ocr_image" | "rename_group_file" | "send_forward_msg" | "send_group_ai_record" | "send_group_sign" | "send_like" | "send_packet" | "send_poke" | "set_diy_online_status" | "set_essence_msg" | "set_friend_remark" | "set_group_add_option" | "set_group_kick_members" | "set_group_remark" | "set_group_robot_add_option" | "set_group_search" | "set_group_sign" | "set_group_whole_ban" | "set_input_status" | "set_msg_emoji_like" | "set_online_status" | "set_qq_avatar" | "set_self_longnick" | "trans_group_file" | "translate_en2zh" | "upload_group_file" | "upload_private_file";
|
|
926
932
|
/** 所有可用的 API 接口联合类型 */
|
|
927
933
|
type API = OneBotAPI | NapCatExtendAPI;
|
|
928
934
|
//#endregion
|
|
929
|
-
//#region src/types.d.ts
|
|
930
|
-
interface MiokiOptions {
|
|
931
|
-
/** NapCat 访问令牌 */
|
|
932
|
-
token: string;
|
|
933
|
-
/** NapCat 服务器协议,默认为 ws */
|
|
934
|
-
protocol?: 'ws' | 'wss';
|
|
935
|
-
/** NapCat 服务器主机,默认为 localhost */
|
|
936
|
-
host?: string;
|
|
937
|
-
/** NapCat 服务器端口,默认为 3333 */
|
|
938
|
-
port?: number;
|
|
939
|
-
/** 日志记录器,默认为控制台日志记录器 */
|
|
940
|
-
logger?: Logger;
|
|
941
|
-
}
|
|
942
|
-
type OptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T];
|
|
943
|
-
type OptionalProps<T> = Pick<T, OptionalKeys<T>>;
|
|
944
|
-
type ExtractByType<T, K$1> = T extends {
|
|
945
|
-
type: K$1;
|
|
946
|
-
} ? T : never;
|
|
947
|
-
interface EventMap extends OneBotEventMap {
|
|
948
|
-
/** WebSocket 连接已打开 */
|
|
949
|
-
'ws.open': void;
|
|
950
|
-
/** WebSocket 连接已关闭 */
|
|
951
|
-
'ws.close': void;
|
|
952
|
-
/** WebSocket 连接发生错误 */
|
|
953
|
-
'ws.error': Event;
|
|
954
|
-
/** 收到 WebSocket 消息 */
|
|
955
|
-
'ws.message': any;
|
|
956
|
-
}
|
|
957
|
-
//#endregion
|
|
958
935
|
//#region src/segment.d.ts
|
|
959
936
|
/**
|
|
960
|
-
|
|
961
|
-
|
|
937
|
+
* 消息片段构造器
|
|
938
|
+
*/
|
|
962
939
|
declare const segment: {
|
|
963
940
|
/** 创建一个文本消息片段 */
|
|
964
941
|
text: (text: string) => SendElement;
|
|
@@ -1001,12 +978,6 @@ declare const segment: {
|
|
|
1001
978
|
//#region src/napcat.d.ts
|
|
1002
979
|
declare const name: string;
|
|
1003
980
|
declare const version: string;
|
|
1004
|
-
declare const DEFAULT_NAPCAT_OPTIONS: {
|
|
1005
|
-
protocol: "ws";
|
|
1006
|
-
host: string;
|
|
1007
|
-
port: number;
|
|
1008
|
-
logger: Logger;
|
|
1009
|
-
};
|
|
1010
981
|
declare class NapCat {
|
|
1011
982
|
#private;
|
|
1012
983
|
private readonly options;
|
|
@@ -1022,39 +993,39 @@ declare class NapCat {
|
|
|
1022
993
|
/** 获取一个好友的信息,可以用于发送私聊消息等操作 */
|
|
1023
994
|
pickFriend(user_id: number): Promise<FriendWithInfo>;
|
|
1024
995
|
/**
|
|
1025
|
-
|
|
1026
|
-
|
|
996
|
+
* 注册一次性事件监听器
|
|
997
|
+
*/
|
|
1027
998
|
once<T extends keyof EventMap>(type: T, handler: (event: EventMap[NoInfer<T>]) => void): void;
|
|
1028
999
|
/**
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1000
|
+
* 注册事件监听器,支持主类型或者点分子类型
|
|
1001
|
+
*
|
|
1002
|
+
* 如: `notice`、`message.private`、`request.group.invite` 等
|
|
1003
|
+
*
|
|
1004
|
+
* 如果需要移除监听器,请调用 `off` 方法
|
|
1005
|
+
*/
|
|
1035
1006
|
on<T extends keyof EventMap>(type: T, handler: (event: EventMap[NoInfer<T>]) => void): void;
|
|
1036
1007
|
/**
|
|
1037
|
-
|
|
1038
|
-
|
|
1008
|
+
* 移除事件监听器
|
|
1009
|
+
*/
|
|
1039
1010
|
off<T extends keyof EventMap>(type: T, handler: (event: EventMap[NoInfer<T>]) => void): void;
|
|
1040
1011
|
api<T extends any>(action: API | (string & {}), params?: Record<string, any>): Promise<T>;
|
|
1041
1012
|
/**
|
|
1042
|
-
|
|
1043
|
-
|
|
1013
|
+
* 发送私聊消息
|
|
1014
|
+
*/
|
|
1044
1015
|
sendPrivateMsg(user_id: number, sendable: Sendable | Sendable[]): Promise<{
|
|
1045
1016
|
message_id: number;
|
|
1046
1017
|
}>;
|
|
1047
1018
|
/**
|
|
1048
|
-
|
|
1049
|
-
|
|
1019
|
+
* 发送群消息
|
|
1020
|
+
*/
|
|
1050
1021
|
sendGroupMsg(group_id: number, sendable: Sendable | Sendable[]): Promise<{
|
|
1051
1022
|
message_id: number;
|
|
1052
1023
|
}>;
|
|
1053
1024
|
/** 启动 NapCat SDK 实例,建立 WebSocket 连接 */
|
|
1054
|
-
|
|
1025
|
+
run(): Promise<void>;
|
|
1055
1026
|
/** 销毁 NapCat SDK 实例,关闭 WebSocket 连接 */
|
|
1056
|
-
|
|
1027
|
+
close(): void;
|
|
1057
1028
|
}
|
|
1058
1029
|
//#endregion
|
|
1059
|
-
export { ABSTRACT_LOGGER, CONSOLE_LOGGER,
|
|
1030
|
+
export { ABSTRACT_LOGGER, API, CONSOLE_LOGGER, EventBase, EventMap, ExtractByType, FlattenData, Friend, FriendDecreaseNoticeEvent, FriendIncreaseNoticeEvent, FriendInputNoticeEvent, FriendLikeNoticeEvent, FriendNoticeEvent, FriendNoticeEventBase, FriendPokeNoticeEvent, FriendRecallNoticeEvent, FriendRequestEvent, FriendWithInfo, Group, GroupAddRequestEvent, GroupAdminNoticeEvent, GroupBanNoticeEvent, GroupCardNoticeEvent, GroupDecreaseNoticeEvent, GroupEssenceNoticeEvent, GroupIncreaseNoticeEvent, GroupInviteRequestEvent, GroupMessageEvent, GroupNoticeEvent, GroupNoticeEventBase, GroupPokeNoticeEvent, GroupReactionNoticeEvent, GroupRecallNoticeEvent, GroupRequestEvent, GroupTitleNoticeEvent, GroupUploadNoticeEvent, GroupWithInfo, HeartbeatMetaEvent, LifecycleMetaEvent, LogLevel, Logger, MediaProps, MessageEvent, MessageEventBase, MessageType, MetaEvent, MetaEventBase, MetaEventType, MiokiOptions, NapCat, NapCatExtendAPI, NormalizedElementToSend, NoticeEvent, NoticeEventBase, NoticeSubType, NoticeType, OneBotAPI, OneBotEventMap, OptionalKeys, OptionalProps, PostType, PrivateMessageEvent, RecvAtElement, RecvDiceElement, RecvElement, RecvFaceElement, RecvFileElement, RecvForwardElement, RecvImageElement, RecvJsonElement, RecvLightAppElement, RecvLocationElement, RecvMarkdownElement, RecvPokeElement, RecvRecordElement, RecvReplyElement, RecvRpsElement, RecvShakeElement, RecvShareElement, RecvTextElement, RecvVideoElement, RequestEvent, RequestEventBase, SendAtElement, SendBfaceElement, SendContactElement, SendCustomMusicElement, SendElement, SendFaceElement, SendFileElement, SendForwardElement, SendImageElement, SendJsonElement, SendLightAppElement, SendMarkdownElement, SendMfaceElement, SendMusicElement, SendNodeContentElement, SendNodeElement, SendNodeRefElement, SendPlatformMusicElement, SendPokeElement, SendRecordElement, SendReplyElement, SendTextElement, SendVideoElement, Sendable, WrapData, name, noop, segment, version };
|
|
1060
1031
|
//# sourceMappingURL=index.d.mts.map
|