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