napcat-sdk 0.9.2 → 0.10.0
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 +1 -1
- package/dist/index.d.cts +291 -291
- package/dist/index.d.mts +291 -291
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/logger.d.ts
|
|
2
|
-
type LogLevel =
|
|
2
|
+
type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
3
3
|
type Logger = Record<LogLevel, (...args: unknown[]) => void>;
|
|
4
4
|
declare const noop: () => void;
|
|
5
5
|
declare const ABSTRACT_LOGGER: Logger;
|
|
@@ -24,7 +24,7 @@ interface NapcatOptions {
|
|
|
24
24
|
/** NapCat 访问令牌 */
|
|
25
25
|
token?: string;
|
|
26
26
|
/** NapCat 服务器协议,默认为 ws */
|
|
27
|
-
protocol?:
|
|
27
|
+
protocol?: 'ws' | 'wss';
|
|
28
28
|
/** NapCat 服务器主机,默认为 localhost */
|
|
29
29
|
host?: string;
|
|
30
30
|
/** NapCat 服务器端口,默认为 3001 */
|
|
@@ -39,15 +39,15 @@ type ExtractByType<T, K$1> = T extends {
|
|
|
39
39
|
} ? T : never;
|
|
40
40
|
interface EventMap extends OneBotEventMap {
|
|
41
41
|
/** WebSocket 连接已打开 */
|
|
42
|
-
|
|
42
|
+
'ws.open': void;
|
|
43
43
|
/** WebSocket 连接已关闭 */
|
|
44
|
-
|
|
44
|
+
'ws.close': void;
|
|
45
45
|
/** WebSocket 连接发生错误 */
|
|
46
|
-
|
|
46
|
+
'ws.error': Event;
|
|
47
47
|
/** 收到 WebSocket 消息 */
|
|
48
|
-
|
|
48
|
+
'ws.message': any;
|
|
49
49
|
/** NapCat 连接已建立 */
|
|
50
|
-
|
|
50
|
+
'napcat.connected': {
|
|
51
51
|
user_id: number;
|
|
52
52
|
nickname: string;
|
|
53
53
|
app_name: string;
|
|
@@ -57,15 +57,15 @@ interface EventMap extends OneBotEventMap {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* 媒体消息的通用属性
|
|
61
|
-
*/
|
|
60
|
+
* 媒体消息的通用属性
|
|
61
|
+
*/
|
|
62
62
|
interface MediaProps {
|
|
63
63
|
/** 媒体文件的 URL 地址 */
|
|
64
64
|
url: string;
|
|
65
65
|
/** 媒体文件的本地路径 */
|
|
66
66
|
path: string;
|
|
67
67
|
/** 媒体文件名或特殊标识 */
|
|
68
|
-
file: (string & {}) |
|
|
68
|
+
file: (string & {}) | 'marketface';
|
|
69
69
|
/** 媒体文件 ID */
|
|
70
70
|
file_id: string;
|
|
71
71
|
/** 媒体文件大小(字节) */
|
|
@@ -75,31 +75,31 @@ interface MediaProps {
|
|
|
75
75
|
}
|
|
76
76
|
/** 接收的纯文本消息段 */
|
|
77
77
|
interface RecvTextElement {
|
|
78
|
-
type:
|
|
78
|
+
type: 'text';
|
|
79
79
|
/** 文本内容 */
|
|
80
80
|
text: string;
|
|
81
81
|
}
|
|
82
82
|
/** 接收的 @ 消息段 */
|
|
83
83
|
interface RecvAtElement {
|
|
84
|
-
type:
|
|
84
|
+
type: 'at';
|
|
85
85
|
/** 被 @ 的 QQ 号,'all' 表示 @全体成员 */
|
|
86
|
-
qq:
|
|
86
|
+
qq: 'all' | (string & {});
|
|
87
87
|
}
|
|
88
88
|
/** 接收的回复消息段 */
|
|
89
89
|
interface RecvReplyElement {
|
|
90
|
-
type:
|
|
90
|
+
type: 'reply';
|
|
91
91
|
/** 被回复的消息 ID */
|
|
92
92
|
id: string;
|
|
93
93
|
}
|
|
94
94
|
/** 接收的 QQ 表情消息段 */
|
|
95
95
|
interface RecvFaceElement {
|
|
96
|
-
type:
|
|
96
|
+
type: 'face';
|
|
97
97
|
/** QQ 表情 ID */
|
|
98
98
|
id: number;
|
|
99
99
|
}
|
|
100
100
|
/** 接收的图片消息段 */
|
|
101
101
|
interface RecvImageElement extends MediaProps {
|
|
102
|
-
type:
|
|
102
|
+
type: 'image';
|
|
103
103
|
/** 图片摘要/描述 */
|
|
104
104
|
summary?: string;
|
|
105
105
|
/** 图片子类型 */
|
|
@@ -107,43 +107,43 @@ interface RecvImageElement extends MediaProps {
|
|
|
107
107
|
}
|
|
108
108
|
/** 接收的语音消息段 */
|
|
109
109
|
interface RecvRecordElement extends MediaProps {
|
|
110
|
-
type:
|
|
110
|
+
type: 'record';
|
|
111
111
|
}
|
|
112
112
|
/** 接收的视频消息段 */
|
|
113
113
|
interface RecvVideoElement extends MediaProps {
|
|
114
|
-
type:
|
|
114
|
+
type: 'video';
|
|
115
115
|
}
|
|
116
116
|
/** 接收的猜拳消息段 */
|
|
117
117
|
interface RecvRpsElement {
|
|
118
|
-
type:
|
|
118
|
+
type: 'rps';
|
|
119
119
|
/** 猜拳结果:1-石头, 2-剪刀, 3-布 */
|
|
120
120
|
result: string;
|
|
121
121
|
}
|
|
122
122
|
/** 接收的掷骰子消息段 */
|
|
123
123
|
interface RecvDiceElement {
|
|
124
|
-
type:
|
|
124
|
+
type: 'dice';
|
|
125
125
|
/** 骰子点数:1-6 */
|
|
126
126
|
result: string;
|
|
127
127
|
}
|
|
128
128
|
/** 接收的窗口抖动消息段(戳一戳) */
|
|
129
129
|
interface RecvShakeElement {
|
|
130
|
-
type:
|
|
130
|
+
type: 'shake';
|
|
131
131
|
}
|
|
132
132
|
/** 接收的戳一戳消息段 */
|
|
133
133
|
interface RecvPokeElement {
|
|
134
|
-
type:
|
|
134
|
+
type: 'poke';
|
|
135
135
|
}
|
|
136
136
|
/** 接收的分享链接消息段 */
|
|
137
137
|
interface RecvShareElement {
|
|
138
|
-
type:
|
|
138
|
+
type: 'share';
|
|
139
139
|
}
|
|
140
140
|
/** 接收的位置消息段 */
|
|
141
141
|
interface RecvLocationElement {
|
|
142
|
-
type:
|
|
142
|
+
type: 'location';
|
|
143
143
|
}
|
|
144
144
|
/** 接收的合并转发消息段 */
|
|
145
145
|
interface RecvForwardElement {
|
|
146
|
-
type:
|
|
146
|
+
type: 'forward';
|
|
147
147
|
/** 合并转发消息 ID */
|
|
148
148
|
id: string;
|
|
149
149
|
/** 合并转发消息内容 */
|
|
@@ -151,48 +151,48 @@ interface RecvForwardElement {
|
|
|
151
151
|
}
|
|
152
152
|
/** 接收的 JSON 消息段 */
|
|
153
153
|
interface RecvJsonElement {
|
|
154
|
-
type:
|
|
154
|
+
type: 'json';
|
|
155
155
|
/** JSON 数据字符串 */
|
|
156
156
|
data: string;
|
|
157
157
|
}
|
|
158
158
|
/** 接收的文件消息段 */
|
|
159
159
|
interface RecvFileElement extends MediaProps {
|
|
160
|
-
type:
|
|
160
|
+
type: 'file';
|
|
161
161
|
}
|
|
162
162
|
/** 接收的 Markdown 消息段 */
|
|
163
163
|
interface RecvMarkdownElement {
|
|
164
|
-
type:
|
|
164
|
+
type: 'markdown';
|
|
165
165
|
}
|
|
166
166
|
/** 接收的小程序消息段 */
|
|
167
167
|
interface RecvLightAppElement {
|
|
168
|
-
type:
|
|
168
|
+
type: 'lightapp';
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
|
-
* 接收的消息段类型联合
|
|
172
|
-
* @description 表示从 QQ 接收到的所有可能的消息段类型
|
|
173
|
-
*/
|
|
171
|
+
* 接收的消息段类型联合
|
|
172
|
+
* @description 表示从 QQ 接收到的所有可能的消息段类型
|
|
173
|
+
*/
|
|
174
174
|
type RecvElement = RecvTextElement | RecvAtElement | RecvReplyElement | RecvFaceElement | RecvImageElement | RecvRecordElement | RecvVideoElement | RecvRpsElement | RecvDiceElement | RecvShakeElement | RecvPokeElement | RecvShareElement | RecvLocationElement | RecvForwardElement | RecvJsonElement | RecvFileElement | RecvMarkdownElement | RecvLightAppElement;
|
|
175
175
|
/** 发送的纯文本消息段 */
|
|
176
176
|
interface SendTextElement {
|
|
177
|
-
type:
|
|
177
|
+
type: 'text';
|
|
178
178
|
/** 文本内容 */
|
|
179
179
|
text: string;
|
|
180
180
|
}
|
|
181
181
|
/** 发送的 @ 消息段 */
|
|
182
182
|
interface SendAtElement {
|
|
183
|
-
type:
|
|
183
|
+
type: 'at';
|
|
184
184
|
/** 被 @ 的 QQ 号,'all' 表示 @全体成员 */
|
|
185
|
-
qq:
|
|
185
|
+
qq: 'all' | (string & {}) | number;
|
|
186
186
|
}
|
|
187
187
|
/** 发送的回复消息段 */
|
|
188
188
|
interface SendReplyElement {
|
|
189
|
-
type:
|
|
189
|
+
type: 'reply';
|
|
190
190
|
/** 被回复的消息 ID */
|
|
191
191
|
id: string;
|
|
192
192
|
}
|
|
193
193
|
/** 发送的商城表情消息段 */
|
|
194
194
|
interface SendMfaceElement {
|
|
195
|
-
type:
|
|
195
|
+
type: 'mface';
|
|
196
196
|
/** 表情 ID */
|
|
197
197
|
id: number;
|
|
198
198
|
/** 表情 key */
|
|
@@ -206,19 +206,19 @@ interface SendMfaceElement {
|
|
|
206
206
|
}
|
|
207
207
|
/** 发送的 QQ 表情消息段 */
|
|
208
208
|
interface SendFaceElement {
|
|
209
|
-
type:
|
|
209
|
+
type: 'face';
|
|
210
210
|
/** QQ 表情 ID */
|
|
211
211
|
id: number;
|
|
212
212
|
}
|
|
213
213
|
/** 发送的大表情消息段 */
|
|
214
214
|
interface SendBfaceElement {
|
|
215
|
-
type:
|
|
215
|
+
type: 'bface';
|
|
216
216
|
/** 大表情 ID */
|
|
217
217
|
id: number;
|
|
218
218
|
}
|
|
219
219
|
/** 发送的图片消息段 */
|
|
220
220
|
interface SendImageElement {
|
|
221
|
-
type:
|
|
221
|
+
type: 'image';
|
|
222
222
|
/** 图片文件,支持 file:// / http:// / base64:// 协议 */
|
|
223
223
|
file: string;
|
|
224
224
|
/** 图片文件名 */
|
|
@@ -230,7 +230,7 @@ interface SendImageElement {
|
|
|
230
230
|
}
|
|
231
231
|
/** 发送的视频消息段 */
|
|
232
232
|
interface SendVideoElement {
|
|
233
|
-
type:
|
|
233
|
+
type: 'video';
|
|
234
234
|
/** 视频文件,支持 file:// / http:// / base64:// 协议 */
|
|
235
235
|
file: string;
|
|
236
236
|
/** 视频文件名 */
|
|
@@ -240,7 +240,7 @@ interface SendVideoElement {
|
|
|
240
240
|
}
|
|
241
241
|
/** 发送的语音消息段 */
|
|
242
242
|
interface SendRecordElement {
|
|
243
|
-
type:
|
|
243
|
+
type: 'record';
|
|
244
244
|
/** 语音文件,支持 file:// / http:// / base64:// 协议 */
|
|
245
245
|
file: string;
|
|
246
246
|
/** 语音文件名 */
|
|
@@ -248,29 +248,29 @@ interface SendRecordElement {
|
|
|
248
248
|
}
|
|
249
249
|
/** 发送的推荐好友/群消息段 */
|
|
250
250
|
interface SendContactElement {
|
|
251
|
-
type:
|
|
251
|
+
type: 'contact';
|
|
252
252
|
/** 推荐类型:qq-好友, group-群 */
|
|
253
|
-
sub_type:
|
|
253
|
+
sub_type: 'qq' | 'group';
|
|
254
254
|
/** 被推荐的 QQ 号或群号 */
|
|
255
255
|
id: string;
|
|
256
256
|
}
|
|
257
257
|
/** 发送的戳一戳消息段 */
|
|
258
258
|
interface SendPokeElement {
|
|
259
|
-
type:
|
|
259
|
+
type: 'poke';
|
|
260
260
|
}
|
|
261
261
|
/** 发送的音乐分享消息段 - 平台音乐 */
|
|
262
262
|
interface SendPlatformMusicElement {
|
|
263
|
-
type:
|
|
263
|
+
type: 'music';
|
|
264
264
|
/** 音乐平台 */
|
|
265
|
-
platform:
|
|
265
|
+
platform: 'qq' | '163' | 'kugou' | 'migu' | 'kuwo';
|
|
266
266
|
/** 音乐 ID */
|
|
267
267
|
id: string;
|
|
268
268
|
}
|
|
269
269
|
/** 发送的音乐分享消息段 - 自定义音乐 */
|
|
270
270
|
interface SendCustomMusicElement {
|
|
271
|
-
type:
|
|
271
|
+
type: 'music';
|
|
272
272
|
/** 自定义音乐标识 */
|
|
273
|
-
platform:
|
|
273
|
+
platform: 'custom';
|
|
274
274
|
/** 跳转链接 URL */
|
|
275
275
|
url: string;
|
|
276
276
|
/** 音频链接 URL */
|
|
@@ -286,13 +286,13 @@ interface SendCustomMusicElement {
|
|
|
286
286
|
type SendMusicElement = SendPlatformMusicElement | SendCustomMusicElement;
|
|
287
287
|
/** 发送的合并转发消息段 */
|
|
288
288
|
interface SendForwardElement {
|
|
289
|
-
type:
|
|
289
|
+
type: 'forward';
|
|
290
290
|
/** 合并转发消息 ID */
|
|
291
291
|
id: string;
|
|
292
292
|
}
|
|
293
293
|
/** 发送的合并转发节点 - 引用已有消息 */
|
|
294
294
|
interface SendNodeRefElement {
|
|
295
|
-
type:
|
|
295
|
+
type: 'node';
|
|
296
296
|
/** 发送者 QQ 号(可选) */
|
|
297
297
|
user_id?: string;
|
|
298
298
|
/** 发送者昵称(可选) */
|
|
@@ -302,7 +302,7 @@ interface SendNodeRefElement {
|
|
|
302
302
|
}
|
|
303
303
|
/** 发送的合并转发节点 - 自定义内容 */
|
|
304
304
|
interface SendNodeContentElement {
|
|
305
|
-
type:
|
|
305
|
+
type: 'node';
|
|
306
306
|
/** 发送者 QQ 号(可选) */
|
|
307
307
|
user_id?: string;
|
|
308
308
|
/** 发送者昵称(可选) */
|
|
@@ -314,13 +314,13 @@ interface SendNodeContentElement {
|
|
|
314
314
|
type SendNodeElement = SendNodeRefElement | SendNodeContentElement;
|
|
315
315
|
/** 发送的 JSON 消息段 */
|
|
316
316
|
interface SendJsonElement {
|
|
317
|
-
type:
|
|
317
|
+
type: 'json';
|
|
318
318
|
/** JSON 数据字符串 */
|
|
319
319
|
data: string;
|
|
320
320
|
}
|
|
321
321
|
/** 发送的文件消息段 */
|
|
322
322
|
interface SendFileElement {
|
|
323
|
-
type:
|
|
323
|
+
type: 'file';
|
|
324
324
|
/** 文件,支持 file:// / http:// / base64:// 协议 */
|
|
325
325
|
file: string;
|
|
326
326
|
/** 文件名 */
|
|
@@ -328,56 +328,56 @@ interface SendFileElement {
|
|
|
328
328
|
}
|
|
329
329
|
/** 发送的 Markdown 消息段 */
|
|
330
330
|
interface SendMarkdownElement {
|
|
331
|
-
type:
|
|
331
|
+
type: 'markdown';
|
|
332
332
|
}
|
|
333
333
|
/** 发送的小程序消息段 */
|
|
334
334
|
interface SendLightAppElement {
|
|
335
|
-
type:
|
|
335
|
+
type: 'lightapp';
|
|
336
336
|
}
|
|
337
337
|
/**
|
|
338
|
-
* 发送的消息段类型联合
|
|
339
|
-
* @description 表示可以发送给 QQ 的所有可能的消息段类型
|
|
340
|
-
*/
|
|
338
|
+
* 发送的消息段类型联合
|
|
339
|
+
* @description 表示可以发送给 QQ 的所有可能的消息段类型
|
|
340
|
+
*/
|
|
341
341
|
type SendElement = SendTextElement | SendAtElement | SendReplyElement | SendMfaceElement | SendFaceElement | SendBfaceElement | SendImageElement | SendVideoElement | SendRecordElement | SendContactElement | SendPokeElement | SendMusicElement | SendForwardElement | SendNodeElement | SendJsonElement | SendFileElement | SendMarkdownElement | SendLightAppElement;
|
|
342
342
|
/**
|
|
343
|
-
* 将消息段类型包装为 OneBot 标准格式
|
|
344
|
-
* @description 将 { type, ...data } 转换为 { type, data: { ...data } } 格式
|
|
345
|
-
*/
|
|
343
|
+
* 将消息段类型包装为 OneBot 标准格式
|
|
344
|
+
* @description 将 { type, ...data } 转换为 { type, data: { ...data } } 格式
|
|
345
|
+
*/
|
|
346
346
|
type WrapData<T extends {
|
|
347
347
|
type: string;
|
|
348
348
|
}> = {
|
|
349
|
-
type: T[
|
|
350
|
-
data: Omit<T,
|
|
349
|
+
type: T['type'];
|
|
350
|
+
data: Omit<T, 'type'>;
|
|
351
351
|
};
|
|
352
352
|
/**
|
|
353
|
-
* 将 OneBot 标准格式展开为扁平格式
|
|
354
|
-
* @description 将 { type, data: { ...data } } 转换为 { type, ...data } 格式
|
|
355
|
-
*/
|
|
353
|
+
* 将 OneBot 标准格式展开为扁平格式
|
|
354
|
+
* @description 将 { type, data: { ...data } } 转换为 { type, ...data } 格式
|
|
355
|
+
*/
|
|
356
356
|
type FlattenData<T extends {
|
|
357
357
|
type: string;
|
|
358
358
|
}> = T extends {
|
|
359
359
|
data: infer U;
|
|
360
360
|
} ? U & {
|
|
361
|
-
type: T[
|
|
361
|
+
type: T['type'];
|
|
362
362
|
} : never;
|
|
363
363
|
/** 标准化后的发送消息段(OneBot 标准格式) */
|
|
364
364
|
type NormalizedElementToSend = WrapData<SendElement>;
|
|
365
365
|
/** 可发送的消息类型,可以是字符串或消息段 */
|
|
366
366
|
type Sendable = string | SendElement;
|
|
367
367
|
/** 上报事件类型 */
|
|
368
|
-
type PostType =
|
|
368
|
+
type PostType = 'meta_event' | 'message' | 'message_sent' | 'notice' | 'request';
|
|
369
369
|
/** 元事件类型 */
|
|
370
|
-
type MetaEventType =
|
|
370
|
+
type MetaEventType = 'heartbeat' | 'lifecycle';
|
|
371
371
|
/** 消息类型 */
|
|
372
|
-
type MessageType =
|
|
372
|
+
type MessageType = 'private' | 'group';
|
|
373
373
|
/** 通知类型 */
|
|
374
|
-
type NoticeType =
|
|
374
|
+
type NoticeType = 'friend' | 'group' | 'client';
|
|
375
375
|
/** 通知子类型 */
|
|
376
|
-
type NoticeSubType =
|
|
376
|
+
type NoticeSubType = 'increase' | 'decrease' | 'recall' | 'poke' | 'like' | 'input' | 'admin' | 'ban' | 'title' | 'card' | 'upload' | 'reaction' | 'essence';
|
|
377
377
|
/**
|
|
378
|
-
* 事件基础类型
|
|
379
|
-
* @description 所有事件的基础结构,包含时间戳、机器人 QQ 号和事件类型
|
|
380
|
-
*/
|
|
378
|
+
* 事件基础类型
|
|
379
|
+
* @description 所有事件的基础结构,包含时间戳、机器人 QQ 号和事件类型
|
|
380
|
+
*/
|
|
381
381
|
type EventBase<T extends PostType, U$1 extends object> = U$1 & {
|
|
382
382
|
/** 事件发生的 Unix 时间戳 */
|
|
383
383
|
time: number;
|
|
@@ -387,17 +387,17 @@ type EventBase<T extends PostType, U$1 extends object> = U$1 & {
|
|
|
387
387
|
post_type: T;
|
|
388
388
|
};
|
|
389
389
|
/**
|
|
390
|
-
* 元事件基础类型
|
|
391
|
-
* @description 元事件表示 OneBot 实现本身的状态变化
|
|
392
|
-
*/
|
|
393
|
-
type MetaEventBase<T extends MetaEventType, U$1 extends object> = EventBase<
|
|
390
|
+
* 元事件基础类型
|
|
391
|
+
* @description 元事件表示 OneBot 实现本身的状态变化
|
|
392
|
+
*/
|
|
393
|
+
type MetaEventBase<T extends MetaEventType, U$1 extends object> = EventBase<'meta_event', U$1 & {
|
|
394
394
|
meta_event_type: T;
|
|
395
395
|
}>;
|
|
396
396
|
/**
|
|
397
|
-
* 心跳元事件
|
|
398
|
-
* @description 定期发送的心跳事件,用于确认连接状态
|
|
399
|
-
*/
|
|
400
|
-
type HeartbeatMetaEvent = MetaEventBase<
|
|
397
|
+
* 心跳元事件
|
|
398
|
+
* @description 定期发送的心跳事件,用于确认连接状态
|
|
399
|
+
*/
|
|
400
|
+
type HeartbeatMetaEvent = MetaEventBase<'heartbeat', {
|
|
401
401
|
/** 状态信息 */
|
|
402
402
|
status: {
|
|
403
403
|
/** 是否在线 */
|
|
@@ -409,12 +409,12 @@ type HeartbeatMetaEvent = MetaEventBase<"heartbeat", {
|
|
|
409
409
|
interval: number;
|
|
410
410
|
}>;
|
|
411
411
|
/**
|
|
412
|
-
* 生命周期元事件
|
|
413
|
-
* @description OneBot 实现的生命周期事件
|
|
414
|
-
*/
|
|
415
|
-
type LifecycleMetaEvent = MetaEventBase<
|
|
412
|
+
* 生命周期元事件
|
|
413
|
+
* @description OneBot 实现的生命周期事件
|
|
414
|
+
*/
|
|
415
|
+
type LifecycleMetaEvent = MetaEventBase<'lifecycle', {
|
|
416
416
|
/** 生命周期子类型 */
|
|
417
|
-
sub_type:
|
|
417
|
+
sub_type: 'connect';
|
|
418
418
|
}>;
|
|
419
419
|
/** 元事件联合类型 */
|
|
420
420
|
type MetaEvent = HeartbeatMetaEvent | LifecycleMetaEvent;
|
|
@@ -431,9 +431,9 @@ type ReactionAction = (id: string) => Promise<void>;
|
|
|
431
431
|
/** 撤回消息的函数类型 */
|
|
432
432
|
type Recall = () => Promise<void>;
|
|
433
433
|
/**
|
|
434
|
-
* 群信息接口
|
|
435
|
-
* @description 包含群的基本信息和常用操作方法
|
|
436
|
-
*/
|
|
434
|
+
* 群信息接口
|
|
435
|
+
* @description 包含群的基本信息和常用操作方法
|
|
436
|
+
*/
|
|
437
437
|
interface Group {
|
|
438
438
|
/** 群号 */
|
|
439
439
|
group_id: number;
|
|
@@ -471,11 +471,11 @@ interface Group {
|
|
|
471
471
|
/** 发送群消息 */
|
|
472
472
|
sendMsg: SendMsg;
|
|
473
473
|
}
|
|
474
|
-
type GroupWithInfo = Group & Awaited<ReturnType<Group[
|
|
474
|
+
type GroupWithInfo = Group & Awaited<ReturnType<Group['getInfo']>>;
|
|
475
475
|
/**
|
|
476
|
-
* 好友信息接口
|
|
477
|
-
* @description 包含好友的基本信息和常用操作方法
|
|
478
|
-
*/
|
|
476
|
+
* 好友信息接口
|
|
477
|
+
* @description 包含好友的基本信息和常用操作方法
|
|
478
|
+
*/
|
|
479
479
|
interface Friend {
|
|
480
480
|
/** 好友 QQ 号 */
|
|
481
481
|
user_id: number;
|
|
@@ -573,12 +573,12 @@ interface Friend {
|
|
|
573
573
|
login_days: number;
|
|
574
574
|
}>;
|
|
575
575
|
}
|
|
576
|
-
type FriendWithInfo = Friend & Awaited<ReturnType<Friend[
|
|
576
|
+
type FriendWithInfo = Friend & Awaited<ReturnType<Friend['getInfo']>>;
|
|
577
577
|
/**
|
|
578
|
-
* 消息事件基础类型
|
|
579
|
-
* @description 所有消息事件的基础结构
|
|
580
|
-
*/
|
|
581
|
-
type MessageEventBase<T extends MessageType, U$1 extends object> = EventBase<
|
|
578
|
+
* 消息事件基础类型
|
|
579
|
+
* @description 所有消息事件的基础结构
|
|
580
|
+
*/
|
|
581
|
+
type MessageEventBase<T extends MessageType, U$1 extends object> = EventBase<'message', U$1 & {
|
|
582
582
|
/** 消息 ID */
|
|
583
583
|
message_id: number;
|
|
584
584
|
/** 引用的消息 ID */
|
|
@@ -599,14 +599,14 @@ type MessageEventBase<T extends MessageType, U$1 extends object> = EventBase<"me
|
|
|
599
599
|
reply: Reply;
|
|
600
600
|
}>;
|
|
601
601
|
/**
|
|
602
|
-
* 私聊消息事件
|
|
603
|
-
* @description 包含好友私聊、群临时会话等私聊消息
|
|
604
|
-
*/
|
|
605
|
-
type PrivateMessageEvent = MessageEventBase<
|
|
602
|
+
* 私聊消息事件
|
|
603
|
+
* @description 包含好友私聊、群临时会话等私聊消息
|
|
604
|
+
*/
|
|
605
|
+
type PrivateMessageEvent = MessageEventBase<'private', {
|
|
606
606
|
/** 发送者 QQ 号 */
|
|
607
607
|
user_id: number;
|
|
608
608
|
/** 私聊子类型:friend-好友, group-群临时会话, group_self-群中自己发送, other-其他 */
|
|
609
|
-
sub_type:
|
|
609
|
+
sub_type: 'friend' | 'group' | 'group_self' | 'other';
|
|
610
610
|
/** 接收者 QQ 号 */
|
|
611
611
|
target_id: number;
|
|
612
612
|
/** 好友信息对象 */
|
|
@@ -622,10 +622,10 @@ type PrivateMessageEvent = MessageEventBase<"private", {
|
|
|
622
622
|
};
|
|
623
623
|
}>;
|
|
624
624
|
/**
|
|
625
|
-
* 群消息事件
|
|
626
|
-
* @description 群聊中的消息事件
|
|
627
|
-
*/
|
|
628
|
-
type GroupMessageEvent = MessageEventBase<
|
|
625
|
+
* 群消息事件
|
|
626
|
+
* @description 群聊中的消息事件
|
|
627
|
+
*/
|
|
628
|
+
type GroupMessageEvent = MessageEventBase<'group', {
|
|
629
629
|
/** 群号 */
|
|
630
630
|
group_id: number;
|
|
631
631
|
/** 群名称 */
|
|
@@ -633,7 +633,7 @@ type GroupMessageEvent = MessageEventBase<"group", {
|
|
|
633
633
|
/** 发送者 QQ 号 */
|
|
634
634
|
user_id: number;
|
|
635
635
|
/** 群消息子类型:normal-普通消息, notice-通知消息 */
|
|
636
|
-
sub_type:
|
|
636
|
+
sub_type: 'normal' | 'notice';
|
|
637
637
|
/** 撤回该消息 */
|
|
638
638
|
recall: Recall;
|
|
639
639
|
/** 添加消息表态 */
|
|
@@ -659,33 +659,33 @@ type GroupMessageEvent = MessageEventBase<"group", {
|
|
|
659
659
|
/** 发送者群名片 */
|
|
660
660
|
card: string;
|
|
661
661
|
/** 发送者群角色:owner-群主, admin-管理员, member-普通成员 */
|
|
662
|
-
role:
|
|
662
|
+
role: 'owner' | 'admin' | 'member';
|
|
663
663
|
};
|
|
664
664
|
}>;
|
|
665
665
|
/** 消息事件联合类型 */
|
|
666
666
|
type MessageEvent = PrivateMessageEvent | GroupMessageEvent;
|
|
667
667
|
/**
|
|
668
|
-
* 将消息事件转换为发送消息事件类型
|
|
669
|
-
* @description 用于表示机器人自己发送的消息事件
|
|
670
|
-
*/
|
|
671
|
-
type ToMessageSent<T extends MessageEvent> = Omit<T,
|
|
672
|
-
post_type:
|
|
668
|
+
* 将消息事件转换为发送消息事件类型
|
|
669
|
+
* @description 用于表示机器人自己发送的消息事件
|
|
670
|
+
*/
|
|
671
|
+
type ToMessageSent<T extends MessageEvent> = Omit<T, 'post_type' | 'group' | 'friend' | 'reply'> & {
|
|
672
|
+
post_type: 'message_sent';
|
|
673
673
|
};
|
|
674
674
|
/**
|
|
675
|
-
* 通知事件基础类型
|
|
676
|
-
* @description 所有通知事件的基础结构
|
|
677
|
-
*/
|
|
678
|
-
type NoticeEventBase<T extends NoticeType, U$1 extends object> = EventBase<
|
|
675
|
+
* 通知事件基础类型
|
|
676
|
+
* @description 所有通知事件的基础结构
|
|
677
|
+
*/
|
|
678
|
+
type NoticeEventBase<T extends NoticeType, U$1 extends object> = EventBase<'notice', U$1 & {
|
|
679
679
|
/** 通知类型 */
|
|
680
680
|
notice_type: T;
|
|
681
681
|
/** 原始通知类型 */
|
|
682
682
|
original_notice_type: string;
|
|
683
683
|
}>;
|
|
684
684
|
/**
|
|
685
|
-
* 群通知事件基础类型
|
|
686
|
-
* @description 所有群相关通知事件的基础结构
|
|
687
|
-
*/
|
|
688
|
-
type GroupNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<
|
|
685
|
+
* 群通知事件基础类型
|
|
686
|
+
* @description 所有群相关通知事件的基础结构
|
|
687
|
+
*/
|
|
688
|
+
type GroupNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<'group', U$1 & {
|
|
689
689
|
/** 通知子类型 */
|
|
690
690
|
sub_type: T;
|
|
691
691
|
/** 群号 */
|
|
@@ -696,10 +696,10 @@ type GroupNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeE
|
|
|
696
696
|
group: Group;
|
|
697
697
|
}>;
|
|
698
698
|
/**
|
|
699
|
-
* 好友通知事件基础类型
|
|
700
|
-
* @description 所有好友相关通知事件的基础结构
|
|
701
|
-
*/
|
|
702
|
-
type FriendNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<
|
|
699
|
+
* 好友通知事件基础类型
|
|
700
|
+
* @description 所有好友相关通知事件的基础结构
|
|
701
|
+
*/
|
|
702
|
+
type FriendNoticeEventBase<T extends NoticeSubType, U$1 extends object> = NoticeEventBase<'friend', U$1 & {
|
|
703
703
|
/** 通知子类型 */
|
|
704
704
|
sub_type: T;
|
|
705
705
|
/** 相关用户 QQ 号 */
|
|
@@ -708,16 +708,16 @@ type FriendNoticeEventBase<T extends NoticeSubType, U$1 extends object> = Notice
|
|
|
708
708
|
friend: Friend;
|
|
709
709
|
}>;
|
|
710
710
|
/** 好友增加通知事件 */
|
|
711
|
-
type FriendIncreaseNoticeEvent = FriendNoticeEventBase<
|
|
711
|
+
type FriendIncreaseNoticeEvent = FriendNoticeEventBase<'increase', {}>;
|
|
712
712
|
/** 好友减少通知事件 */
|
|
713
|
-
type FriendDecreaseNoticeEvent = FriendNoticeEventBase<
|
|
713
|
+
type FriendDecreaseNoticeEvent = FriendNoticeEventBase<'decrease', {}>;
|
|
714
714
|
/** 好友消息撤回通知事件 */
|
|
715
|
-
type FriendRecallNoticeEvent = FriendNoticeEventBase<
|
|
715
|
+
type FriendRecallNoticeEvent = FriendNoticeEventBase<'recall', {
|
|
716
716
|
/** 被撤回的消息 ID */
|
|
717
717
|
message_id: number;
|
|
718
718
|
}>;
|
|
719
719
|
/** 好友戳一戳通知事件 */
|
|
720
|
-
type FriendPokeNoticeEvent = FriendNoticeEventBase<
|
|
720
|
+
type FriendPokeNoticeEvent = FriendNoticeEventBase<'poke', {
|
|
721
721
|
/** 被戳者 QQ 号 */
|
|
722
722
|
target_id: number;
|
|
723
723
|
/** 发送者 QQ 号 */
|
|
@@ -726,7 +726,7 @@ type FriendPokeNoticeEvent = FriendNoticeEventBase<"poke", {
|
|
|
726
726
|
raw_info: any[];
|
|
727
727
|
}>;
|
|
728
728
|
/** 好友点赞通知事件 */
|
|
729
|
-
type FriendLikeNoticeEvent = FriendNoticeEventBase<
|
|
729
|
+
type FriendLikeNoticeEvent = FriendNoticeEventBase<'like', {
|
|
730
730
|
/** 操作者 QQ 号 */
|
|
731
731
|
operator_id: number;
|
|
732
732
|
/** 操作者昵称 */
|
|
@@ -735,7 +735,7 @@ type FriendLikeNoticeEvent = FriendNoticeEventBase<"like", {
|
|
|
735
735
|
times: number;
|
|
736
736
|
}>;
|
|
737
737
|
/** 好友输入状态通知事件 */
|
|
738
|
-
type FriendInputNoticeEvent = FriendNoticeEventBase<
|
|
738
|
+
type FriendInputNoticeEvent = FriendNoticeEventBase<'input', {
|
|
739
739
|
/** 状态文本 */
|
|
740
740
|
status_text: string;
|
|
741
741
|
/** 事件类型 */
|
|
@@ -744,54 +744,54 @@ type FriendInputNoticeEvent = FriendNoticeEventBase<"input", {
|
|
|
744
744
|
/** 好友通知事件联合类型 */
|
|
745
745
|
type FriendNoticeEvent = FriendIncreaseNoticeEvent | FriendDecreaseNoticeEvent | FriendRecallNoticeEvent | FriendPokeNoticeEvent | FriendLikeNoticeEvent | FriendInputNoticeEvent;
|
|
746
746
|
/** 群成员增加通知事件 */
|
|
747
|
-
type GroupIncreaseNoticeEvent = GroupNoticeEventBase<
|
|
747
|
+
type GroupIncreaseNoticeEvent = GroupNoticeEventBase<'increase', {
|
|
748
748
|
/** 操作者 QQ 号(如邀请者) */
|
|
749
749
|
operator_id: number;
|
|
750
750
|
/** 加入类型:invite-邀请, add-主动加群, approve-管理员审批 */
|
|
751
|
-
actions_type:
|
|
751
|
+
actions_type: 'invite' | 'add' | 'approve';
|
|
752
752
|
}>;
|
|
753
753
|
/** 群成员减少通知事件 */
|
|
754
|
-
type GroupDecreaseNoticeEvent = GroupNoticeEventBase<
|
|
754
|
+
type GroupDecreaseNoticeEvent = GroupNoticeEventBase<'decrease', {
|
|
755
755
|
/** 操作者 QQ 号 */
|
|
756
756
|
operator_id: number;
|
|
757
757
|
/** 离开类型:kick-被踢, leave-主动退出 */
|
|
758
|
-
actions_type:
|
|
758
|
+
actions_type: 'kick' | 'leave';
|
|
759
759
|
}>;
|
|
760
760
|
/** 群管理员变动通知事件 */
|
|
761
|
-
type GroupAdminNoticeEvent = GroupNoticeEventBase<
|
|
761
|
+
type GroupAdminNoticeEvent = GroupNoticeEventBase<'admin', {
|
|
762
762
|
/** 操作类型:set-设置管理员, unset-取消管理员 */
|
|
763
|
-
action_type:
|
|
763
|
+
action_type: 'set' | 'unset';
|
|
764
764
|
}>;
|
|
765
765
|
/** 群禁言通知事件 */
|
|
766
|
-
type GroupBanNoticeEvent = GroupNoticeEventBase<
|
|
766
|
+
type GroupBanNoticeEvent = GroupNoticeEventBase<'ban', {
|
|
767
767
|
/** 禁言时长(秒),0 表示解除禁言 */
|
|
768
768
|
duration: number;
|
|
769
769
|
/** 操作类型:ban-禁言, lift_ban-解除禁言 */
|
|
770
|
-
action_type:
|
|
770
|
+
action_type: 'ban' | 'lift_ban';
|
|
771
771
|
/** 操作者 QQ 号 */
|
|
772
772
|
operator_id: number;
|
|
773
773
|
}>;
|
|
774
774
|
/** 群名片变动通知事件 */
|
|
775
|
-
type GroupCardNoticeEvent = GroupNoticeEventBase<
|
|
775
|
+
type GroupCardNoticeEvent = GroupNoticeEventBase<'card', {
|
|
776
776
|
/** 新名片 */
|
|
777
777
|
card_new: string;
|
|
778
778
|
/** 旧名片 */
|
|
779
779
|
card_old: string;
|
|
780
780
|
}>;
|
|
781
781
|
/** 群戳一戳通知事件 */
|
|
782
|
-
type GroupPokeNoticeEvent = GroupNoticeEventBase<
|
|
782
|
+
type GroupPokeNoticeEvent = GroupNoticeEventBase<'poke', {
|
|
783
783
|
/** 被戳者 QQ 号 */
|
|
784
784
|
target_id: number;
|
|
785
785
|
/** 原始信息 */
|
|
786
786
|
raw_info: any[];
|
|
787
787
|
}>;
|
|
788
788
|
/** 群头衔变动通知事件 */
|
|
789
|
-
type GroupTitleNoticeEvent = GroupNoticeEventBase<
|
|
789
|
+
type GroupTitleNoticeEvent = GroupNoticeEventBase<'title', {
|
|
790
790
|
/** 新头衔 */
|
|
791
791
|
title: string;
|
|
792
792
|
}>;
|
|
793
793
|
/** 群文件上传通知事件 */
|
|
794
|
-
type GroupUploadNoticeEvent = GroupNoticeEventBase<
|
|
794
|
+
type GroupUploadNoticeEvent = GroupNoticeEventBase<'upload', {
|
|
795
795
|
/** 上传的文件信息 */
|
|
796
796
|
file: {
|
|
797
797
|
/** 文件 ID */
|
|
@@ -805,7 +805,7 @@ type GroupUploadNoticeEvent = GroupNoticeEventBase<"upload", {
|
|
|
805
805
|
};
|
|
806
806
|
}>;
|
|
807
807
|
/** 群消息表态变动通知事件 */
|
|
808
|
-
type GroupReactionNoticeEvent = GroupNoticeEventBase<
|
|
808
|
+
type GroupReactionNoticeEvent = GroupNoticeEventBase<'reaction', {
|
|
809
809
|
/** 相关消息 ID */
|
|
810
810
|
message_id: number;
|
|
811
811
|
/** 表态列表 */
|
|
@@ -819,7 +819,7 @@ type GroupReactionNoticeEvent = GroupNoticeEventBase<"reaction", {
|
|
|
819
819
|
is_add: boolean;
|
|
820
820
|
}>;
|
|
821
821
|
/** 群精华消息变动通知事件 */
|
|
822
|
-
type GroupEssenceNoticeEvent = GroupNoticeEventBase<
|
|
822
|
+
type GroupEssenceNoticeEvent = GroupNoticeEventBase<'essence', {
|
|
823
823
|
/** 原消息发送者 QQ 号 */
|
|
824
824
|
sender_id: number;
|
|
825
825
|
/** 相关消息 ID */
|
|
@@ -827,10 +827,10 @@ type GroupEssenceNoticeEvent = GroupNoticeEventBase<"essence", {
|
|
|
827
827
|
/** 操作者 QQ 号 */
|
|
828
828
|
operator_id: number;
|
|
829
829
|
/** 操作类型:add-添加精华, remove-移除精华 */
|
|
830
|
-
action_type:
|
|
830
|
+
action_type: 'add' | 'remove';
|
|
831
831
|
}>;
|
|
832
832
|
/** 群消息撤回通知事件 */
|
|
833
|
-
type GroupRecallNoticeEvent = GroupNoticeEventBase<
|
|
833
|
+
type GroupRecallNoticeEvent = GroupNoticeEventBase<'recall', {
|
|
834
834
|
/** 被撤回的消息 ID */
|
|
835
835
|
message_id: number;
|
|
836
836
|
/** 操作者 QQ 号 */
|
|
@@ -841,10 +841,10 @@ type GroupNoticeEvent = GroupIncreaseNoticeEvent | GroupDecreaseNoticeEvent | Gr
|
|
|
841
841
|
/** 通知事件联合类型 */
|
|
842
842
|
type NoticeEvent = GroupNoticeEvent | FriendNoticeEvent;
|
|
843
843
|
/**
|
|
844
|
-
* 请求事件基础类型
|
|
845
|
-
* @description 所有请求事件的基础结构
|
|
846
|
-
*/
|
|
847
|
-
type RequestEventBase<T extends string, U$1 extends object> = EventBase<
|
|
844
|
+
* 请求事件基础类型
|
|
845
|
+
* @description 所有请求事件的基础结构
|
|
846
|
+
*/
|
|
847
|
+
type RequestEventBase<T extends string, U$1 extends object> = EventBase<'request', U$1 & {
|
|
848
848
|
/** 请求类型 */
|
|
849
849
|
request_type: T;
|
|
850
850
|
/** 请求者 QQ 号 */
|
|
@@ -859,117 +859,117 @@ type RequestEventBase<T extends string, U$1 extends object> = EventBase<"request
|
|
|
859
859
|
reject: (reason?: string) => Promise<void>;
|
|
860
860
|
}>;
|
|
861
861
|
/** 好友添加请求事件 */
|
|
862
|
-
type FriendRequestEvent = RequestEventBase<
|
|
862
|
+
type FriendRequestEvent = RequestEventBase<'friend', {}>;
|
|
863
863
|
/** 加群请求事件(他人申请加入群) */
|
|
864
|
-
type GroupAddRequestEvent = RequestEventBase<
|
|
864
|
+
type GroupAddRequestEvent = RequestEventBase<'group', {
|
|
865
865
|
/** 群号 */
|
|
866
866
|
group_id: number;
|
|
867
867
|
/** 请求子类型:add-主动加群 */
|
|
868
|
-
sub_type:
|
|
868
|
+
sub_type: 'add';
|
|
869
869
|
}>;
|
|
870
870
|
/** 邀请入群请求事件(他人邀请机器人入群) */
|
|
871
|
-
type GroupInviteRequestEvent = RequestEventBase<
|
|
871
|
+
type GroupInviteRequestEvent = RequestEventBase<'group', {
|
|
872
872
|
/** 群号 */
|
|
873
873
|
group_id: number;
|
|
874
874
|
/** 请求子类型:invite-被邀请 */
|
|
875
|
-
sub_type:
|
|
875
|
+
sub_type: 'invite';
|
|
876
876
|
}>;
|
|
877
877
|
/** 群请求事件联合类型 */
|
|
878
878
|
type GroupRequestEvent = GroupAddRequestEvent | GroupInviteRequestEvent;
|
|
879
879
|
/** 请求事件联合类型 */
|
|
880
880
|
type RequestEvent = FriendRequestEvent | GroupRequestEvent;
|
|
881
881
|
/**
|
|
882
|
-
* OneBot 事件映射表
|
|
883
|
-
* @description 定义了所有事件名称与对应事件类型的映射关系
|
|
884
|
-
*/
|
|
882
|
+
* OneBot 事件映射表
|
|
883
|
+
* @description 定义了所有事件名称与对应事件类型的映射关系
|
|
884
|
+
*/
|
|
885
885
|
interface OneBotEventMap {
|
|
886
886
|
/** 元事件,通常与 OneBot 服务端状态相关 */
|
|
887
887
|
meta_event: MetaEvent;
|
|
888
888
|
/** 元事件 - 心跳事件,确认服务端在线状态 */
|
|
889
|
-
|
|
889
|
+
'meta_event.heartbeat': HeartbeatMetaEvent;
|
|
890
890
|
/** 元事件 - 生命周期,服务端状态变化 */
|
|
891
|
-
|
|
891
|
+
'meta_event.lifecycle': LifecycleMetaEvent;
|
|
892
892
|
/** 元事件 - 生命周期 - 连接成功 */
|
|
893
|
-
|
|
893
|
+
'meta_event.lifecycle.connect': LifecycleMetaEvent;
|
|
894
894
|
/** 消息事件,包含私聊和群消息 */
|
|
895
895
|
message: MessageEvent;
|
|
896
896
|
/** 消息事件 - 私聊消息 */
|
|
897
|
-
|
|
897
|
+
'message.private': PrivateMessageEvent;
|
|
898
898
|
/** 消息事件 - 私聊消息 - 好友私聊 */
|
|
899
|
-
|
|
899
|
+
'message.private.friend': PrivateMessageEvent;
|
|
900
900
|
/** 消息事件 - 私聊消息 - 群临时会话 */
|
|
901
|
-
|
|
901
|
+
'message.private.group': PrivateMessageEvent;
|
|
902
902
|
/** 消息事件 - 群消息 */
|
|
903
|
-
|
|
903
|
+
'message.group': GroupMessageEvent;
|
|
904
904
|
/** 消息事件 - 群消息 - 普通消息 */
|
|
905
|
-
|
|
905
|
+
'message.group.normal': GroupMessageEvent;
|
|
906
906
|
message_sent: ToMessageSent<MessageEvent>;
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
907
|
+
'message_sent.private': ToMessageSent<PrivateMessageEvent>;
|
|
908
|
+
'message_sent.private.friend': ToMessageSent<PrivateMessageEvent>;
|
|
909
|
+
'message_sent.private.group': ToMessageSent<PrivateMessageEvent>;
|
|
910
|
+
'message_sent.group': ToMessageSent<GroupMessageEvent>;
|
|
911
|
+
'message_sent.group.normal': ToMessageSent<GroupMessageEvent>;
|
|
912
912
|
/** 请求事件 */
|
|
913
913
|
request: RequestEvent;
|
|
914
914
|
/** 请求事件 - 好友请求 */
|
|
915
|
-
|
|
915
|
+
'request.friend': FriendRequestEvent;
|
|
916
916
|
/** 请求事件 - 群请求 */
|
|
917
|
-
|
|
917
|
+
'request.group': GroupRequestEvent;
|
|
918
918
|
/** 请求事件 - 他人加群请求,当机器人是群主或管理员时收到 */
|
|
919
|
-
|
|
919
|
+
'request.group.add': GroupAddRequestEvent;
|
|
920
920
|
/** 请求事件 - 邀请加群请求,他人邀请机器人加入群时收到 */
|
|
921
|
-
|
|
921
|
+
'request.group.invite': GroupInviteRequestEvent;
|
|
922
922
|
/** 通知事件 */
|
|
923
923
|
notice: NoticeEvent;
|
|
924
924
|
/** 通知事件 - 好友相关通知 */
|
|
925
|
-
|
|
925
|
+
'notice.friend': FriendNoticeEvent;
|
|
926
926
|
/** 通知事件 - 好友增加 */
|
|
927
|
-
|
|
927
|
+
'notice.friend.increase': FriendIncreaseNoticeEvent;
|
|
928
928
|
/** 通知事件 - 好友减少 */
|
|
929
|
-
|
|
929
|
+
'notice.friend.decrease': FriendDecreaseNoticeEvent;
|
|
930
930
|
/** 通知事件 - 好友备注变更 */
|
|
931
|
-
|
|
931
|
+
'notice.friend.recall': FriendRecallNoticeEvent;
|
|
932
932
|
/** 通知事件 - 好友戳一戳 */
|
|
933
|
-
|
|
933
|
+
'notice.friend.poke': FriendPokeNoticeEvent;
|
|
934
934
|
/** 通知事件 - 好友点赞 */
|
|
935
|
-
|
|
935
|
+
'notice.friend.like': FriendLikeNoticeEvent;
|
|
936
936
|
/** 通知事件 - 好友输入状态 */
|
|
937
|
-
|
|
937
|
+
'notice.friend.input': FriendInputNoticeEvent;
|
|
938
938
|
/** 通知事件 - 群相关通知 */
|
|
939
|
-
|
|
939
|
+
'notice.group': GroupNoticeEvent;
|
|
940
940
|
/** 通知事件 - 群成员增加 */
|
|
941
|
-
|
|
941
|
+
'notice.group.increase': GroupIncreaseNoticeEvent;
|
|
942
942
|
/** 通知事件 - 群成员减少 */
|
|
943
|
-
|
|
943
|
+
'notice.group.decrease': GroupDecreaseNoticeEvent;
|
|
944
944
|
/** 通知事件 - 群管理员变更 */
|
|
945
|
-
|
|
945
|
+
'notice.group.admin': GroupAdminNoticeEvent;
|
|
946
946
|
/** 通知事件 - 群成员被禁言 */
|
|
947
|
-
|
|
947
|
+
'notice.group.ban': GroupBanNoticeEvent;
|
|
948
948
|
/** 通知事件 - 群戳一戳 */
|
|
949
|
-
|
|
949
|
+
'notice.group.poke': GroupPokeNoticeEvent;
|
|
950
950
|
/** 通知事件 - 群头衔变更 */
|
|
951
|
-
|
|
951
|
+
'notice.group.title': GroupTitleNoticeEvent;
|
|
952
952
|
/** 通知事件 - 群名片变更 */
|
|
953
|
-
|
|
953
|
+
'notice.group.card': GroupCardNoticeEvent;
|
|
954
954
|
/** 通知事件 - 群公告变更 */
|
|
955
|
-
|
|
955
|
+
'notice.group.recall': GroupRecallNoticeEvent;
|
|
956
956
|
/** 通知事件 - 群上传文件 */
|
|
957
|
-
|
|
957
|
+
'notice.group.upload': GroupUploadNoticeEvent;
|
|
958
958
|
/** 通知事件 - 给群消息添加反应 Reaction */
|
|
959
|
-
|
|
959
|
+
'notice.group.reaction': GroupReactionNoticeEvent;
|
|
960
960
|
/** 通知事件 - 群精华消息变更 */
|
|
961
|
-
|
|
961
|
+
'notice.group.essence': GroupEssenceNoticeEvent;
|
|
962
962
|
}
|
|
963
963
|
/**
|
|
964
|
-
* OneBot 11 标准 API
|
|
965
|
-
* @description OneBot 11 规范定义的标准 API 接口
|
|
966
|
-
*/
|
|
967
|
-
type OneBotAPI =
|
|
964
|
+
* OneBot 11 标准 API
|
|
965
|
+
* @description OneBot 11 规范定义的标准 API 接口
|
|
966
|
+
*/
|
|
967
|
+
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';
|
|
968
968
|
/**
|
|
969
|
-
* NapCat 扩展 API
|
|
970
|
-
* @description NapCat 实现的额外扩展 API 接口
|
|
971
|
-
*/
|
|
972
|
-
type NapCatExtendAPI =
|
|
969
|
+
* NapCat 扩展 API
|
|
970
|
+
* @description NapCat 实现的额外扩展 API 接口
|
|
971
|
+
*/
|
|
972
|
+
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';
|
|
973
973
|
/** 所有可用的 API 接口联合类型 */
|
|
974
974
|
type API = OneBotAPI | NapCatExtendAPI;
|
|
975
975
|
interface GroupMemberInfo {
|
|
@@ -989,14 +989,14 @@ interface GroupMemberInfo {
|
|
|
989
989
|
card_changeable: boolean;
|
|
990
990
|
is_robot: boolean;
|
|
991
991
|
shut_up_timestamp: number;
|
|
992
|
-
role:
|
|
992
|
+
role: 'owner' | 'admin' | 'member' | (string & {});
|
|
993
993
|
title: string;
|
|
994
994
|
}
|
|
995
995
|
//#endregion
|
|
996
996
|
//#region src/segment.d.ts
|
|
997
997
|
/**
|
|
998
|
-
* 消息片段构造器
|
|
999
|
-
*/
|
|
998
|
+
* 消息片段构造器
|
|
999
|
+
*/
|
|
1000
1000
|
declare const segment: {
|
|
1001
1001
|
/** 创建一个文本消息片段 */
|
|
1002
1002
|
text: (text: string) => SendElement;
|
|
@@ -1058,18 +1058,18 @@ declare class NapCat {
|
|
|
1058
1058
|
/** 消息段构建器 */
|
|
1059
1059
|
get segment(): typeof segment;
|
|
1060
1060
|
/**
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1061
|
+
* 机器人 QQ 号
|
|
1062
|
+
*
|
|
1063
|
+
* @deprecated 建议使用 `uin` 属性
|
|
1064
|
+
*/
|
|
1065
1065
|
get user_id(): number;
|
|
1066
1066
|
/**
|
|
1067
|
-
|
|
1068
|
-
|
|
1067
|
+
* 机器人 QQ 号
|
|
1068
|
+
*/
|
|
1069
1069
|
get uin(): number;
|
|
1070
1070
|
/**
|
|
1071
|
-
|
|
1072
|
-
|
|
1071
|
+
* 机器人昵称
|
|
1072
|
+
*/
|
|
1073
1073
|
get nickname(): string;
|
|
1074
1074
|
/** 标准化可发送消息元素 */
|
|
1075
1075
|
normalizeSendable(msg: Sendable | Sendable[]): NormalizedElementToSend[];
|
|
@@ -1079,147 +1079,147 @@ declare class NapCat {
|
|
|
1079
1079
|
/** 获取一个好友的信息,可以用于发送私聊消息等操作 */
|
|
1080
1080
|
pickFriend(user_id: number): Promise<FriendWithInfo | null>;
|
|
1081
1081
|
/**
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1082
|
+
* 注册「一次性」事件监听器,支持主类型或者点分子类型
|
|
1083
|
+
*
|
|
1084
|
+
* 如: `notice`、`message.private`、`request.group.invite` 等
|
|
1085
|
+
*
|
|
1086
|
+
* 如果需要移除监听器,请调用 `off` 方法或者使用返回的函数
|
|
1087
|
+
*
|
|
1088
|
+
*/
|
|
1089
1089
|
once<T extends keyof EventMap>(type: T, handler: (event: EventMap[NoInfer<T>]) => void): () => void;
|
|
1090
1090
|
/**
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1091
|
+
* 注册事件监听器,支持主类型或者点分子类型
|
|
1092
|
+
*
|
|
1093
|
+
* 如: `notice`、`message.private`、`request.group.invite` 等
|
|
1094
|
+
*
|
|
1095
|
+
* 如果需要移除监听器,请调用 `off` 方法或者使用返回的函数
|
|
1096
|
+
*/
|
|
1097
1097
|
on<T extends keyof EventMap>(type: T, handler: (event: EventMap[NoInfer<T>]) => void): () => void;
|
|
1098
1098
|
/**
|
|
1099
|
-
|
|
1100
|
-
|
|
1099
|
+
* 移除事件监听器
|
|
1100
|
+
*/
|
|
1101
1101
|
off<T extends keyof EventMap>(type: T, handler: (event: EventMap[NoInfer<T>]) => void): void;
|
|
1102
1102
|
/**
|
|
1103
|
-
|
|
1104
|
-
|
|
1103
|
+
* 调用 NapCat API
|
|
1104
|
+
*/
|
|
1105
1105
|
api<T extends any>(action: API | (string & {}), params?: Record<string, any>): Promise<T>;
|
|
1106
1106
|
/**
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
* 给好友名片点赞
|
|
1108
|
+
*/
|
|
1109
1109
|
sendLike(user_id: number, times?: number): Promise<any>;
|
|
1110
1110
|
/**
|
|
1111
|
-
|
|
1112
|
-
|
|
1111
|
+
* 获取好友列表
|
|
1112
|
+
*/
|
|
1113
1113
|
getFriendList(): Promise<(Friend & Record<string, any>)[]>;
|
|
1114
1114
|
/**
|
|
1115
|
-
|
|
1116
|
-
|
|
1115
|
+
* 获取群列表
|
|
1116
|
+
*/
|
|
1117
1117
|
getGroupList(): Promise<(Group & Record<string, any>)[]>;
|
|
1118
1118
|
/**
|
|
1119
|
-
|
|
1120
|
-
|
|
1119
|
+
* 添加消息回应
|
|
1120
|
+
*/
|
|
1121
1121
|
addReaction(message_id: number, id: string): Promise<void>;
|
|
1122
1122
|
/**
|
|
1123
|
-
|
|
1124
|
-
|
|
1123
|
+
* 删除消息回应
|
|
1124
|
+
*/
|
|
1125
1125
|
delReaction(message_id: number, id: string): Promise<void>;
|
|
1126
1126
|
/**
|
|
1127
|
-
|
|
1128
|
-
|
|
1127
|
+
* 获取消息
|
|
1128
|
+
*/
|
|
1129
1129
|
getMsg(message_id?: number | string | null): Promise<GroupMessageEvent | PrivateMessageEvent | null>;
|
|
1130
1130
|
/**
|
|
1131
|
-
|
|
1132
|
-
|
|
1131
|
+
* 删除好友
|
|
1132
|
+
*/
|
|
1133
1133
|
deleteFriend(user_id: number, block?: boolean, both?: boolean): Promise<void>;
|
|
1134
1134
|
/**
|
|
1135
|
-
|
|
1136
|
-
|
|
1135
|
+
* 设置群成员禁言
|
|
1136
|
+
*/
|
|
1137
1137
|
setGroupBan(group_id: number, user_id: number, duration: number): Promise<void>;
|
|
1138
1138
|
/**
|
|
1139
|
-
|
|
1140
|
-
|
|
1139
|
+
* 撤回消息
|
|
1140
|
+
*/
|
|
1141
1141
|
recallMsg(message_id: number): Promise<void>;
|
|
1142
1142
|
/**
|
|
1143
|
-
|
|
1144
|
-
|
|
1143
|
+
* 获取陌生人信息
|
|
1144
|
+
*/
|
|
1145
1145
|
getStrangerInfo(user_id: number): Promise<any>;
|
|
1146
1146
|
/**
|
|
1147
|
-
|
|
1148
|
-
|
|
1147
|
+
* 发送私聊消息
|
|
1148
|
+
*/
|
|
1149
1149
|
sendPrivateMsg(user_id: number, sendable: Sendable | Sendable[]): Promise<{
|
|
1150
1150
|
message_id: number;
|
|
1151
1151
|
}>;
|
|
1152
1152
|
/**
|
|
1153
|
-
|
|
1154
|
-
|
|
1153
|
+
* 发送群消息
|
|
1154
|
+
*/
|
|
1155
1155
|
sendGroupMsg(group_id: number, sendable: Sendable | Sendable[]): Promise<{
|
|
1156
1156
|
message_id: number;
|
|
1157
1157
|
}>;
|
|
1158
1158
|
/**
|
|
1159
|
-
|
|
1160
|
-
|
|
1159
|
+
* 获取群信息
|
|
1160
|
+
*/
|
|
1161
1161
|
getGroupInfo(group_id: number): Promise<any>;
|
|
1162
1162
|
/**
|
|
1163
|
-
|
|
1164
|
-
|
|
1163
|
+
* 群签到
|
|
1164
|
+
*/
|
|
1165
1165
|
setGroupSign(group_id: number): Promise<any>;
|
|
1166
1166
|
/**
|
|
1167
|
-
|
|
1168
|
-
|
|
1167
|
+
* 设置群精华消息
|
|
1168
|
+
*/
|
|
1169
1169
|
setEssenceMsg(message_id: number): Promise<void>;
|
|
1170
1170
|
/**
|
|
1171
|
-
|
|
1172
|
-
|
|
1171
|
+
* 删除群精华消息
|
|
1172
|
+
*/
|
|
1173
1173
|
deleteEssenceMsg(message_id: number): Promise<void>;
|
|
1174
1174
|
/**
|
|
1175
|
-
|
|
1176
|
-
|
|
1175
|
+
* 设置群成员名片
|
|
1176
|
+
*/
|
|
1177
1177
|
setGroupCard(group_id: number, user_id: number, card: string): Promise<void>;
|
|
1178
1178
|
/**
|
|
1179
|
-
|
|
1180
|
-
|
|
1179
|
+
* 设置群成员专属头衔
|
|
1180
|
+
*/
|
|
1181
1181
|
setGroupSpecialTitle(group_id: number, user_id: number, title: string): Promise<void>;
|
|
1182
1182
|
/**
|
|
1183
|
-
|
|
1184
|
-
|
|
1183
|
+
* 获取群成员列表
|
|
1184
|
+
*/
|
|
1185
1185
|
getGroupMemberList(group_id: number): Promise<GroupMemberInfo[]>;
|
|
1186
1186
|
/**
|
|
1187
|
-
|
|
1188
|
-
|
|
1187
|
+
* 获取群成员信息
|
|
1188
|
+
*/
|
|
1189
1189
|
getGroupMemberInfo(group_id: number, user_id: number): Promise<GroupMemberInfo>;
|
|
1190
1190
|
/**
|
|
1191
|
-
|
|
1192
|
-
|
|
1191
|
+
* 机器人是否在线
|
|
1192
|
+
*/
|
|
1193
1193
|
isOnline(): boolean;
|
|
1194
1194
|
/**
|
|
1195
|
-
|
|
1196
|
-
|
|
1195
|
+
* 计算 GTK 值
|
|
1196
|
+
*/
|
|
1197
1197
|
getGTk(pskey: string): number;
|
|
1198
1198
|
/**
|
|
1199
|
-
|
|
1200
|
-
|
|
1199
|
+
* 获取 NapCat 原始 Cookie 相关信息
|
|
1200
|
+
*/
|
|
1201
1201
|
getNapCatCookies(domain: string): Promise<{
|
|
1202
1202
|
cookies: string;
|
|
1203
1203
|
bkn: string;
|
|
1204
1204
|
}>;
|
|
1205
1205
|
/**
|
|
1206
|
-
|
|
1207
|
-
|
|
1206
|
+
* 获取版本信息
|
|
1207
|
+
*/
|
|
1208
1208
|
getVersionInfo(): Promise<{
|
|
1209
1209
|
app_name: string;
|
|
1210
1210
|
protocol_version: string;
|
|
1211
1211
|
app_version: string;
|
|
1212
1212
|
}>;
|
|
1213
1213
|
/**
|
|
1214
|
-
|
|
1215
|
-
|
|
1214
|
+
* 获取登录信息
|
|
1215
|
+
*/
|
|
1216
1216
|
getLoginInfo(): Promise<{
|
|
1217
1217
|
user_id: number;
|
|
1218
1218
|
nickname: string;
|
|
1219
1219
|
}>;
|
|
1220
1220
|
/**
|
|
1221
|
-
|
|
1222
|
-
|
|
1221
|
+
* 获取 Cookie 相关信息
|
|
1222
|
+
*/
|
|
1223
1223
|
getCookie(domain: string): Promise<{
|
|
1224
1224
|
uin: number;
|
|
1225
1225
|
pskey: string;
|
|
@@ -1230,12 +1230,12 @@ declare class NapCat {
|
|
|
1230
1230
|
legacyCookie: string;
|
|
1231
1231
|
}>;
|
|
1232
1232
|
/**
|
|
1233
|
-
|
|
1234
|
-
|
|
1233
|
+
* 通过域名获取 Pskey
|
|
1234
|
+
*/
|
|
1235
1235
|
getPskey(domain: string): Promise<string>;
|
|
1236
1236
|
/**
|
|
1237
|
-
|
|
1238
|
-
|
|
1237
|
+
* 获取 Bkn 值
|
|
1238
|
+
*/
|
|
1239
1239
|
getBkn(): Promise<string>;
|
|
1240
1240
|
/** 启动 NapCat SDK 实例,建立 WebSocket 连接 */
|
|
1241
1241
|
run(): Promise<void>;
|