hotcat-bot-qq 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/botApi.d.ts +1163 -0
- package/dist/botApi.js +794 -0
- package/dist/botClient.d.ts +35 -0
- package/dist/botClient.js +75 -0
- package/dist/botConsole.d.ts +72 -0
- package/dist/botConsole.js +297 -0
- package/dist/botEvent.d.ts +182 -0
- package/dist/botEvent.js +557 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/message.d.ts +96 -0
- package/dist/message.js +187 -0
- package/logo.png +0 -0
- package/package.json +73 -0
package/dist/botApi.js
ADDED
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
import { NCWebsocket } from 'node-napcat-ts';
|
|
2
|
+
import { BotConsole } from './botConsole';
|
|
3
|
+
export class BotApi {
|
|
4
|
+
get client() { return this._client; }
|
|
5
|
+
set client(c) { this._client = c; }
|
|
6
|
+
constructor(config, debug) {
|
|
7
|
+
Object.defineProperty(this, "napcat", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: void 0
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "_client", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
this.napcat = new NCWebsocket(config, debug ?? false);
|
|
20
|
+
}
|
|
21
|
+
/** 建立 WebSocket 连接 */
|
|
22
|
+
async connect() {
|
|
23
|
+
await this.napcat.connect();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 获取当前 bot 登录信息
|
|
27
|
+
* @returns `{ user_id: number, nickname: string }`
|
|
28
|
+
*/
|
|
29
|
+
async getLoginInfo() {
|
|
30
|
+
return await this.napcat.get_login_info();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 发送消息(群聊或私聊)
|
|
34
|
+
* @param target - `{ group_id: number }` 发群聊,`{ user_id: number }` 发私聊
|
|
35
|
+
* @param messages - 消息段
|
|
36
|
+
*/
|
|
37
|
+
async sendMessage(target, ...messages) {
|
|
38
|
+
const type = 'group_id' in target ? 'sendGroupMessage' : 'sendPrivateMessage';
|
|
39
|
+
new BotConsole(type, messages).log();
|
|
40
|
+
await this.napcat.send_msg({
|
|
41
|
+
...target,
|
|
42
|
+
message: messages.map(m => m.toJson()),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 发送群聊消息
|
|
47
|
+
* @param groupId - 群号
|
|
48
|
+
* @param messages - 消息段
|
|
49
|
+
*/
|
|
50
|
+
async sendGroupMessage(groupId, ...messages) {
|
|
51
|
+
new BotConsole('sendGroupMessage', messages).log();
|
|
52
|
+
await this.napcat.send_group_msg({
|
|
53
|
+
group_id: groupId,
|
|
54
|
+
message: messages.map(m => m.toJson()),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 发送私聊消息
|
|
59
|
+
* @param userId - QQ 号
|
|
60
|
+
* @param messages - 消息段
|
|
61
|
+
*/
|
|
62
|
+
async sendPrivateMessage(userId, ...messages) {
|
|
63
|
+
new BotConsole('sendPrivateMessage', messages).log();
|
|
64
|
+
await this.napcat.send_private_msg({
|
|
65
|
+
user_id: userId,
|
|
66
|
+
message: messages.map(m => m.toJson()),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 发送合并转发(通用,自动判断群/私聊)
|
|
71
|
+
* @param target - `{ group_id }` 或 `{ user_id }`
|
|
72
|
+
* @param nodes - 转发节点,由 `Message.node()` / `Message.customNode()` 构建
|
|
73
|
+
*/
|
|
74
|
+
async sendForwardMsg(target, nodes) {
|
|
75
|
+
await this.napcat.send_forward_msg({
|
|
76
|
+
...target,
|
|
77
|
+
message: nodes.map(n => n.toJson()),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 发送群合并转发
|
|
82
|
+
* @param groupId - 群号
|
|
83
|
+
* @param nodes - 转发节点
|
|
84
|
+
*/
|
|
85
|
+
async sendGroupForwardMsg(groupId, nodes) {
|
|
86
|
+
await this.napcat.send_group_forward_msg({
|
|
87
|
+
group_id: groupId,
|
|
88
|
+
message: nodes.map(n => n.toJson()),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 发送私聊合并转发
|
|
93
|
+
* @param userId - QQ 号
|
|
94
|
+
* @param nodes - 转发节点
|
|
95
|
+
*/
|
|
96
|
+
async sendPrivateForwardMsg(userId, nodes) {
|
|
97
|
+
await this.napcat.send_private_forward_msg({
|
|
98
|
+
user_id: userId,
|
|
99
|
+
message: nodes.map(n => n.toJson()),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 转发单条消息到私聊
|
|
104
|
+
* @param userId - 目标 QQ
|
|
105
|
+
* @param messageId - 消息 ID
|
|
106
|
+
*/
|
|
107
|
+
async forwardFriendSingleMsg(userId, messageId) {
|
|
108
|
+
await this.napcat.forward_friend_single_msg({ user_id: userId, message_id: messageId });
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 转发单条消息到群聊
|
|
112
|
+
* @param groupId - 群号
|
|
113
|
+
* @param messageId - 消息 ID
|
|
114
|
+
*/
|
|
115
|
+
async forwardGroupSingleMsg(groupId, messageId) {
|
|
116
|
+
await this.napcat.forward_group_single_msg({ group_id: groupId, message_id: messageId });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 撤回消息
|
|
120
|
+
* @param messageId - 消息 ID
|
|
121
|
+
*/
|
|
122
|
+
async deleteMessage(messageId) {
|
|
123
|
+
await this.napcat.delete_msg({
|
|
124
|
+
message_id: messageId,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 获取单条消息详情
|
|
129
|
+
* @param messageId - 消息 ID
|
|
130
|
+
*/
|
|
131
|
+
async getMessage(messageId) {
|
|
132
|
+
return await this.napcat.get_msg({
|
|
133
|
+
message_id: messageId,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 获取合并转发消息
|
|
138
|
+
* @param messageId - 消息 ID
|
|
139
|
+
*/
|
|
140
|
+
async getForwardMsg(messageId) {
|
|
141
|
+
return await this.napcat.get_forward_msg({ message_id: messageId.toString() });
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 获取群聊历史消息
|
|
145
|
+
* @param groupId - 群号
|
|
146
|
+
* @param messageSeq - 起始消息序号
|
|
147
|
+
* @param count - 获取数量
|
|
148
|
+
*/
|
|
149
|
+
async getGroupMsgHistory(groupId, messageSeq, count) {
|
|
150
|
+
return await this.napcat.get_group_msg_history({
|
|
151
|
+
group_id: groupId,
|
|
152
|
+
message_seq: messageSeq,
|
|
153
|
+
count,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* 获取私聊消息历史
|
|
158
|
+
* @param userId - QQ 号
|
|
159
|
+
* @param messageSeq - 起始消息序号
|
|
160
|
+
* @param count - 获取数量
|
|
161
|
+
*/
|
|
162
|
+
async getFriendMsgHistory(userId, messageSeq, count) {
|
|
163
|
+
return await this.napcat.get_friend_msg_history({
|
|
164
|
+
user_id: userId,
|
|
165
|
+
message_seq: messageSeq,
|
|
166
|
+
count,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 标记消息已读
|
|
171
|
+
* @param target - `{ group_id: number }` | `{ user_id: number }` | `{ message_id: number }`
|
|
172
|
+
*/
|
|
173
|
+
async markMsgAsRead(target) {
|
|
174
|
+
await this.napcat.mark_msg_as_read(target);
|
|
175
|
+
}
|
|
176
|
+
/** 标记私聊已读 */
|
|
177
|
+
async markPrivateMsgAsRead(userId) {
|
|
178
|
+
await this.napcat.mark_private_msg_as_read({ user_id: userId });
|
|
179
|
+
}
|
|
180
|
+
/** 标记群聊已读 */
|
|
181
|
+
async markGroupMsgAsRead(groupId) {
|
|
182
|
+
await this.napcat.mark_group_msg_as_read({ group_id: groupId });
|
|
183
|
+
}
|
|
184
|
+
/** 标记所有消息已读 */
|
|
185
|
+
async markAllAsRead() {
|
|
186
|
+
await this.napcat._mark_all_as_read();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 设置消息表情回应
|
|
190
|
+
* @param messageId - 消息 ID
|
|
191
|
+
* @param emojiId - 表情 ID
|
|
192
|
+
* @param set - true 添加 / false 移除
|
|
193
|
+
*/
|
|
194
|
+
async setMsgEmojiLike(messageId, emojiId, set) {
|
|
195
|
+
await this.napcat.set_msg_emoji_like({
|
|
196
|
+
message_id: messageId,
|
|
197
|
+
emoji_id: emojiId,
|
|
198
|
+
set,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 拉取表情回应列表
|
|
203
|
+
* @param messageId - 消息 ID
|
|
204
|
+
* @param emojiId - 表情 ID
|
|
205
|
+
*/
|
|
206
|
+
async fetchEmojiLike(messageId, emojiId) {
|
|
207
|
+
return await this.napcat.fetch_emoji_like({
|
|
208
|
+
message_id: messageId,
|
|
209
|
+
emoji_id: emojiId,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** 英译中翻译 */
|
|
213
|
+
async translateEn2zh(words) {
|
|
214
|
+
return await this.napcat.translate_en2zh({ words });
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 群内禁言
|
|
218
|
+
* @param groupId - 群号
|
|
219
|
+
* @param userId - 目标 QQ
|
|
220
|
+
* @param duration - 禁言时长(秒),0 解除
|
|
221
|
+
*/
|
|
222
|
+
async banMember(groupId, userId, duration) {
|
|
223
|
+
await this.napcat.set_group_ban({
|
|
224
|
+
group_id: groupId,
|
|
225
|
+
user_id: userId,
|
|
226
|
+
duration,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 踢出群成员
|
|
231
|
+
* @param groupId - 群号
|
|
232
|
+
* @param userId - 目标 QQ
|
|
233
|
+
* @param rejectAdd - 是否拒绝再次加群
|
|
234
|
+
*/
|
|
235
|
+
async kickMember(groupId, userId, rejectAdd) {
|
|
236
|
+
await this.napcat.set_group_kick({
|
|
237
|
+
group_id: groupId,
|
|
238
|
+
user_id: userId,
|
|
239
|
+
reject_add_request: rejectAdd,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 全员禁言
|
|
244
|
+
* @param groupId - 群号
|
|
245
|
+
* @param enable - true 开启 / false 关闭,默认 true
|
|
246
|
+
*/
|
|
247
|
+
async setGroupWholeBan(groupId, enable) {
|
|
248
|
+
await this.napcat.set_group_whole_ban({
|
|
249
|
+
group_id: groupId,
|
|
250
|
+
enable,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* 设置/取消管理员
|
|
255
|
+
* @param groupId - 群号
|
|
256
|
+
* @param userId - 目标 QQ
|
|
257
|
+
* @param enable - true 设为管理 / false 取消,默认 true
|
|
258
|
+
*/
|
|
259
|
+
async setGroupAdmin(groupId, userId, enable) {
|
|
260
|
+
await this.napcat.set_group_admin({
|
|
261
|
+
group_id: groupId,
|
|
262
|
+
user_id: userId,
|
|
263
|
+
enable,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 修改群名片
|
|
268
|
+
* @param groupId - 群号
|
|
269
|
+
* @param userId - 目标 QQ
|
|
270
|
+
* @param card - 新群名片
|
|
271
|
+
*/
|
|
272
|
+
async setGroupCard(groupId, userId, card) {
|
|
273
|
+
await this.napcat.set_group_card({
|
|
274
|
+
group_id: groupId,
|
|
275
|
+
user_id: userId,
|
|
276
|
+
card,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* 修改群名称
|
|
281
|
+
* @param groupId - 群号
|
|
282
|
+
* @param groupName - 新群名
|
|
283
|
+
*/
|
|
284
|
+
async setGroupName(groupId, groupName) {
|
|
285
|
+
await this.napcat.set_group_name({
|
|
286
|
+
group_id: groupId,
|
|
287
|
+
group_name: groupName,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* 设置群备注
|
|
292
|
+
* @param groupId - 群号
|
|
293
|
+
* @param remark - 备注名
|
|
294
|
+
*/
|
|
295
|
+
async setGroupRemark(groupId, remark) {
|
|
296
|
+
await this.napcat.set_group_remark({
|
|
297
|
+
group_id: String(groupId),
|
|
298
|
+
remark,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* 设置群头衔
|
|
303
|
+
* @param groupId - 群号
|
|
304
|
+
* @param userId - 目标 QQ
|
|
305
|
+
* @param title - 头衔内容
|
|
306
|
+
*/
|
|
307
|
+
async setGroupSpecialTitle(groupId, userId, title) {
|
|
308
|
+
await this.napcat.set_group_special_title({
|
|
309
|
+
group_id: groupId,
|
|
310
|
+
user_id: userId,
|
|
311
|
+
special_title: title,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 退出 / 解散群
|
|
316
|
+
* @param groupId - 群号
|
|
317
|
+
* @param isDismiss - true 解散(群主),默认 false 仅退出
|
|
318
|
+
*/
|
|
319
|
+
async leaveGroup(groupId, isDismiss) {
|
|
320
|
+
await this.napcat.set_group_leave({
|
|
321
|
+
group_id: groupId,
|
|
322
|
+
is_dismiss: isDismiss,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* 处理加群申请
|
|
327
|
+
* @param flag - 申请标识(从事件中获取)
|
|
328
|
+
* @param approve - true 同意 / false 拒绝
|
|
329
|
+
* @param reason - 拒绝理由
|
|
330
|
+
*/
|
|
331
|
+
async handleGroupAddRequest(flag, approve, reason) {
|
|
332
|
+
await this.napcat.set_group_add_request({ flag, approve, reason });
|
|
333
|
+
}
|
|
334
|
+
/** 设置群头像,file 支持本地路径/base64/URL */
|
|
335
|
+
async setGroupPortrait(groupId, file) {
|
|
336
|
+
await this.napcat.set_group_portrait({
|
|
337
|
+
group_id: groupId,
|
|
338
|
+
file,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/** 群打卡 */
|
|
342
|
+
async sendGroupSign(groupId) {
|
|
343
|
+
await this.napcat.set_group_sign({ group_id: groupId });
|
|
344
|
+
}
|
|
345
|
+
/** 发送群公告 */
|
|
346
|
+
async sendGroupNotice(groupId, title, content) {
|
|
347
|
+
await this.napcat._send_group_notice({
|
|
348
|
+
group_id: groupId,
|
|
349
|
+
title,
|
|
350
|
+
content,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/** 获取群公告 */
|
|
354
|
+
async getGroupNotice(groupId) {
|
|
355
|
+
return await this.napcat._get_group_notice({ group_id: groupId });
|
|
356
|
+
}
|
|
357
|
+
/** 删除群公告 */
|
|
358
|
+
async deleteGroupNotice(groupId, noticeId) {
|
|
359
|
+
await this.napcat._del_group_notice({
|
|
360
|
+
group_id: groupId,
|
|
361
|
+
notice_id: noticeId,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 获取群信息
|
|
366
|
+
* @param groupId - 群号
|
|
367
|
+
*/
|
|
368
|
+
async getGroupInfo(groupId) {
|
|
369
|
+
return await this.napcat.get_group_info({
|
|
370
|
+
group_id: groupId,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/** 获取群额外信息 */
|
|
374
|
+
async getGroupInfoEx(groupId) {
|
|
375
|
+
return await this.napcat.get_group_info_ex({ group_id: groupId });
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* 获取群列表
|
|
379
|
+
* @param noCache - true 跳过缓存
|
|
380
|
+
*/
|
|
381
|
+
async getGroupList(noCache) {
|
|
382
|
+
return await this.napcat.get_group_list(noCache != null ? {
|
|
383
|
+
no_cache: noCache,
|
|
384
|
+
} : undefined);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 获取群成员信息
|
|
388
|
+
* @param groupId - 群号
|
|
389
|
+
* @param userId - QQ 号
|
|
390
|
+
* @param noCache - true 跳过缓存
|
|
391
|
+
*/
|
|
392
|
+
async getGroupMemberInfo(groupId, userId, noCache) {
|
|
393
|
+
return await this.napcat.get_group_member_info({
|
|
394
|
+
group_id: groupId,
|
|
395
|
+
user_id: userId,
|
|
396
|
+
no_cache: noCache,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* 获取群成员列表
|
|
401
|
+
* @param groupId - 群号
|
|
402
|
+
* @param noCache - true 跳过缓存
|
|
403
|
+
*/
|
|
404
|
+
async getGroupMemberList(groupId, noCache) {
|
|
405
|
+
return await this.napcat.get_group_member_list({
|
|
406
|
+
group_id: groupId,
|
|
407
|
+
no_cache: noCache,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* 获取群荣誉信息
|
|
412
|
+
* @param groupId - 群号
|
|
413
|
+
* @param type - 荣誉类型: all/talkative/performer/legend/strong_newbie/emotion
|
|
414
|
+
*/
|
|
415
|
+
async getGroupHonorInfo(groupId, type) {
|
|
416
|
+
return await this.napcat.get_group_honor_info({
|
|
417
|
+
group_id: groupId,
|
|
418
|
+
type,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/** 获取群系统消息 */
|
|
422
|
+
async getGroupSystemMsg(count) {
|
|
423
|
+
return await this.napcat.get_group_system_msg(count != null ? {
|
|
424
|
+
count,
|
|
425
|
+
} : undefined);
|
|
426
|
+
}
|
|
427
|
+
/** 获取群 @全体成员 剩余次数 */
|
|
428
|
+
async getGroupAtAllRemain(groupId) {
|
|
429
|
+
return await this.napcat.get_group_at_all_remain({
|
|
430
|
+
group_id: groupId,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
/** 获取群被禁言用户列表 */
|
|
434
|
+
async getGroupShutList(groupId) {
|
|
435
|
+
return await this.napcat.get_group_shut_list({
|
|
436
|
+
group_id: groupId,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/** 获取群忽略的加群请求 */
|
|
440
|
+
async getGroupIgnoreAddRequest(groupId) {
|
|
441
|
+
return await this.napcat.get_group_ignore_add_request({
|
|
442
|
+
group_id: groupId,
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
/** 获取精华消息列表 */
|
|
446
|
+
async getEssenceMsgList(groupId) {
|
|
447
|
+
return await this.napcat.get_essence_msg_list({
|
|
448
|
+
group_id: groupId,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
/** 设置精华消息 */
|
|
452
|
+
async setEssenceMsg(messageId) {
|
|
453
|
+
await this.napcat.set_essence_msg({
|
|
454
|
+
message_id: messageId,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
/** 移出精华消息 */
|
|
458
|
+
async deleteEssenceMsg(messageId) {
|
|
459
|
+
await this.napcat.delete_essence_msg({
|
|
460
|
+
message_id: messageId,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* 获取陌生人信息
|
|
465
|
+
* @param userId - QQ 号
|
|
466
|
+
*/
|
|
467
|
+
async getStrangerInfo(userId) {
|
|
468
|
+
return await this.napcat.get_stranger_info({
|
|
469
|
+
user_id: userId,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
/** 获取好友列表 */
|
|
473
|
+
async getFriendList() {
|
|
474
|
+
return await this.napcat.get_friend_list();
|
|
475
|
+
}
|
|
476
|
+
/** 获取好友分类列表 */
|
|
477
|
+
async getFriendsWithCategory() {
|
|
478
|
+
return await this.napcat.get_friends_with_category();
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* 删除好友
|
|
482
|
+
* @param userId - QQ 号
|
|
483
|
+
* @param tempBlock - 是否拉黑
|
|
484
|
+
* @param tempBothDel - 是否双向删除
|
|
485
|
+
*/
|
|
486
|
+
async deleteFriend(userId, tempBlock, tempBothDel) {
|
|
487
|
+
await this.napcat.delete_friend({
|
|
488
|
+
user_id: userId,
|
|
489
|
+
temp_block: tempBlock,
|
|
490
|
+
temp_both_del: tempBothDel,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* 处理好友申请
|
|
495
|
+
* @param flag - 申请标识(从事件中获取)
|
|
496
|
+
* @param approve - true 同意 / false 拒绝
|
|
497
|
+
* @param remark - 好友备注
|
|
498
|
+
*/
|
|
499
|
+
async handleFriendAddRequest(flag, approve, remark) {
|
|
500
|
+
await this.napcat.set_friend_add_request({ flag, approve, remark });
|
|
501
|
+
}
|
|
502
|
+
/** 获取用户在线状态 */
|
|
503
|
+
async getUserStatus(userId) {
|
|
504
|
+
return await this.napcat.nc_get_user_status({ user_id: userId });
|
|
505
|
+
}
|
|
506
|
+
/** 设置个人签名 */
|
|
507
|
+
async setSelfLongnick(longnick) {
|
|
508
|
+
await this.napcat.set_self_longnick({ longNick: longnick });
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* 群内戳一戳
|
|
512
|
+
* @param groupId - 群号
|
|
513
|
+
* @param userId - 目标 QQ
|
|
514
|
+
*/
|
|
515
|
+
async groupPoke(groupId, userId) {
|
|
516
|
+
await this.napcat.group_poke({
|
|
517
|
+
group_id: groupId,
|
|
518
|
+
user_id: userId,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* 好友戳一戳
|
|
523
|
+
* @param userId - 目标 QQ
|
|
524
|
+
*/
|
|
525
|
+
async friendPoke(userId) {
|
|
526
|
+
await this.napcat.friend_poke({
|
|
527
|
+
user_id: userId,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
/** 发送戳一戳(通用,自动判断群/私聊) */
|
|
531
|
+
async sendPoke(userId, groupId) {
|
|
532
|
+
if (groupId != null) {
|
|
533
|
+
await this.napcat.send_poke({ user_id: userId, group_id: groupId });
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
await this.napcat.send_poke({ user_id: userId });
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* 点赞
|
|
541
|
+
* @param userId - 目标 QQ
|
|
542
|
+
* @param times - 次数,默认 1
|
|
543
|
+
*/
|
|
544
|
+
async sendLike(userId, times) {
|
|
545
|
+
await this.napcat.send_like({
|
|
546
|
+
user_id: userId,
|
|
547
|
+
times,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* 获取图片文件
|
|
552
|
+
* @param file - 图片 file_id 或 URL
|
|
553
|
+
*/
|
|
554
|
+
async getImage(file) {
|
|
555
|
+
return await this.napcat.get_image({ file });
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* 获取语音文件
|
|
559
|
+
* @param file - 语音 file_id 或 URL
|
|
560
|
+
* @param outFormat - 输出格式
|
|
561
|
+
*/
|
|
562
|
+
async getRecord(file, outFormat) {
|
|
563
|
+
return await this.napcat.get_record({ file, out_format: outFormat });
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* 上传群文件
|
|
567
|
+
* @param groupId - 群号
|
|
568
|
+
* @param file - 本地文件路径
|
|
569
|
+
* @param name - 显示名称
|
|
570
|
+
* @param folderId - 目标文件夹 ID
|
|
571
|
+
*/
|
|
572
|
+
async uploadGroupFile(groupId, file, name, folderId) {
|
|
573
|
+
await this.napcat.upload_group_file({
|
|
574
|
+
group_id: groupId,
|
|
575
|
+
file,
|
|
576
|
+
name,
|
|
577
|
+
folder_id: folderId,
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* 上传私聊文件
|
|
582
|
+
* @param userId - QQ 号
|
|
583
|
+
* @param file - 本地文件路径
|
|
584
|
+
* @param name - 显示名称
|
|
585
|
+
*/
|
|
586
|
+
async uploadPrivateFile(userId, file, name) {
|
|
587
|
+
await this.napcat.upload_private_file({
|
|
588
|
+
user_id: userId,
|
|
589
|
+
file,
|
|
590
|
+
name,
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* 获取群文件下载链接
|
|
595
|
+
* @param groupId - 群号
|
|
596
|
+
* @param fileId - 文件 ID
|
|
597
|
+
*/
|
|
598
|
+
async getGroupFileUrl(groupId, fileId) {
|
|
599
|
+
return await this.napcat.get_group_file_url({
|
|
600
|
+
group_id: groupId,
|
|
601
|
+
file_id: fileId,
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* 图片 OCR 识别
|
|
606
|
+
* @param image - 图片 file_id 或 base64
|
|
607
|
+
*/
|
|
608
|
+
async ocrImage(image) {
|
|
609
|
+
return await this.napcat.ocr_image({ image });
|
|
610
|
+
}
|
|
611
|
+
/** 获取文件信息 */
|
|
612
|
+
async getFile(file) {
|
|
613
|
+
return await this.napcat.get_file({ file });
|
|
614
|
+
}
|
|
615
|
+
/** 下载文件到缓存目录 */
|
|
616
|
+
async downloadFile(url, name, headers) {
|
|
617
|
+
return await this.napcat.download_file({
|
|
618
|
+
url,
|
|
619
|
+
headers,
|
|
620
|
+
name,
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
/** 获取收藏表情 */
|
|
624
|
+
async fetchCustomFace(count) {
|
|
625
|
+
return await this.napcat.fetch_custom_face(count != null ? { count } : undefined);
|
|
626
|
+
}
|
|
627
|
+
/** 删除群文件 */
|
|
628
|
+
async deleteGroupFile(groupId, fileId) {
|
|
629
|
+
await this.napcat.delete_group_file({
|
|
630
|
+
group_id: groupId,
|
|
631
|
+
file_id: fileId,
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
/** 创建群文件夹 */
|
|
635
|
+
async createGroupFileFolder(groupId, folderName) {
|
|
636
|
+
await this.napcat.create_group_file_folder({
|
|
637
|
+
group_id: groupId,
|
|
638
|
+
folder_name: folderName,
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
/** 删除群文件夹 */
|
|
642
|
+
async deleteGroupFolder(groupId, folderId) {
|
|
643
|
+
await this.napcat.delete_group_folder({
|
|
644
|
+
group_id: groupId,
|
|
645
|
+
folder_id: folderId,
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/** 获取群文件系统信息 */
|
|
649
|
+
async getGroupFileSystemInfo(groupId) {
|
|
650
|
+
return await this.napcat.get_group_file_system_info({
|
|
651
|
+
group_id: groupId,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
/** 获取群根目录文件列表 */
|
|
655
|
+
async getGroupRootFiles(groupId) {
|
|
656
|
+
return await this.napcat.get_group_root_files({
|
|
657
|
+
group_id: groupId,
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
/** 获取群子目录文件列表 */
|
|
661
|
+
async getGroupFilesByFolder(groupId, folderId) {
|
|
662
|
+
return await this.napcat.get_group_files_by_folder({
|
|
663
|
+
group_id: groupId,
|
|
664
|
+
folder_id: folderId,
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
/** 获取最近的聊天记录 */
|
|
668
|
+
async getRecentContact() {
|
|
669
|
+
return await this.napcat.get_recent_contact();
|
|
670
|
+
}
|
|
671
|
+
/** 获取自身点赞列表 */
|
|
672
|
+
async getProfileLike() {
|
|
673
|
+
return await this.napcat.get_profile_like();
|
|
674
|
+
}
|
|
675
|
+
/** 创建文本收藏 */
|
|
676
|
+
async createCollection(rawData, brief) {
|
|
677
|
+
await this.napcat.create_collection({ rawData, brief });
|
|
678
|
+
}
|
|
679
|
+
/** 获取收藏列表 */
|
|
680
|
+
async getCollectionList(category, count) {
|
|
681
|
+
return await this.napcat.get_collection_list({ category, count });
|
|
682
|
+
}
|
|
683
|
+
/** 推荐联系人/群聊 */
|
|
684
|
+
async recommendContact(userId, phoneNumber) {
|
|
685
|
+
await this.napcat.ArkSharePeer({ user_id: userId, phoneNumber });
|
|
686
|
+
}
|
|
687
|
+
/** 推荐群聊 */
|
|
688
|
+
async recommendGroup(groupId) {
|
|
689
|
+
await this.napcat.ArkShareGroup({ group_id: groupId });
|
|
690
|
+
}
|
|
691
|
+
/** 获取 AI 语音角色列表 */
|
|
692
|
+
async getAiCharacters() {
|
|
693
|
+
return await this.napcat.get_ai_characters({ group_id: 0, chat_type: undefined });
|
|
694
|
+
}
|
|
695
|
+
/** AI 文字转语音 */
|
|
696
|
+
async getAiRecord(characterId, text) {
|
|
697
|
+
return await this.napcat.get_ai_record({ character_id: characterId, text });
|
|
698
|
+
}
|
|
699
|
+
/** 群聊发送 AI 语音 */
|
|
700
|
+
async sendGroupAiRecord(groupId, characterId, text) {
|
|
701
|
+
await this.napcat.send_group_ai_record({
|
|
702
|
+
group_id: groupId,
|
|
703
|
+
character_id: characterId,
|
|
704
|
+
text,
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
/** 签名小程序卡片(如 B 站分享卡片) */
|
|
708
|
+
async getMiniAppArk(app, bizSrc, meta) {
|
|
709
|
+
return await this.napcat.get_mini_app_ark({
|
|
710
|
+
app,
|
|
711
|
+
biz_src: bizSrc,
|
|
712
|
+
meta,
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
/** 获取 bot 运行状态 */
|
|
716
|
+
async getStatus() {
|
|
717
|
+
return await this.napcat.get_status();
|
|
718
|
+
}
|
|
719
|
+
/** 获取 napcat 版本信息 */
|
|
720
|
+
async getVersionInfo() {
|
|
721
|
+
return await this.napcat.get_version_info();
|
|
722
|
+
}
|
|
723
|
+
/** 获取 Cookies */
|
|
724
|
+
async getCookies(domain) {
|
|
725
|
+
return await this.napcat.get_cookies({ domain });
|
|
726
|
+
}
|
|
727
|
+
/** 获取 CSRF Token */
|
|
728
|
+
async getCsrfToken() {
|
|
729
|
+
return await this.napcat.get_csrf_token();
|
|
730
|
+
}
|
|
731
|
+
/** 获取 QQ 相关接口凭证 (cookies + csrf_token) */
|
|
732
|
+
async getCredentials() {
|
|
733
|
+
return await this.napcat.get_credentials();
|
|
734
|
+
}
|
|
735
|
+
/** 检查是否可以发送图片 */
|
|
736
|
+
async canSendImage() {
|
|
737
|
+
return await this.napcat.can_send_image();
|
|
738
|
+
}
|
|
739
|
+
/** 检查是否可以发送语音 */
|
|
740
|
+
async canSendRecord() {
|
|
741
|
+
return await this.napcat.can_send_record();
|
|
742
|
+
}
|
|
743
|
+
/** 清理缓存 */
|
|
744
|
+
async cleanCache() {
|
|
745
|
+
await this.napcat.clean_cache();
|
|
746
|
+
}
|
|
747
|
+
/** 获取 Rkey */
|
|
748
|
+
async getRkey() {
|
|
749
|
+
return await this.napcat.nc_get_rkey();
|
|
750
|
+
}
|
|
751
|
+
/** 获取 PacketServer 状态 */
|
|
752
|
+
async getPacketStatus() {
|
|
753
|
+
return await this.napcat.nc_get_packet_status();
|
|
754
|
+
}
|
|
755
|
+
/** 获取机器人 QQ 号区间 */
|
|
756
|
+
async getRobotUinRange() {
|
|
757
|
+
return await this.napcat.get_robot_uin_range();
|
|
758
|
+
}
|
|
759
|
+
/** 设置在线状态 */
|
|
760
|
+
async setOnlineStatus(status, extStatus, batteryStatus) {
|
|
761
|
+
await this.napcat.set_online_status({
|
|
762
|
+
status,
|
|
763
|
+
ext_status: extStatus,
|
|
764
|
+
battery_status: batteryStatus,
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
/** 设置 QQ 资料 */
|
|
768
|
+
async setQQProfile(nickname, personalNote, sex) {
|
|
769
|
+
await this.napcat.set_qq_profile({
|
|
770
|
+
nickname,
|
|
771
|
+
personal_note: personalNote,
|
|
772
|
+
sex,
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
/** 设置 QQ 头像,file 支持本地路径/base64/URL */
|
|
776
|
+
async setQQAvatar(file) {
|
|
777
|
+
await this.napcat.set_qq_avatar({ file });
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* 设置输入状态("正在输入…")
|
|
781
|
+
* @param userId - QQ 号
|
|
782
|
+
* @param eventType - 状态类型(具体值参考 napcat 文档)
|
|
783
|
+
*/
|
|
784
|
+
async setInputStatus(userId, eventType) {
|
|
785
|
+
await this.napcat.set_input_status({
|
|
786
|
+
user_id: String(userId),
|
|
787
|
+
event_type: eventType,
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
/** 对事件执行快速操作(隐藏 API) */
|
|
791
|
+
async handleQuickOperation(context, operation) {
|
|
792
|
+
await this.napcat['.handle_quick_operation']({ context, operation });
|
|
793
|
+
}
|
|
794
|
+
}
|