@alemonjs/qq-bot 2.1.0-alpha.17 → 2.1.0-alpha.18
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/README.md +0 -30
- package/lib/desktop.js +3 -2
- package/lib/hook.js +6 -6
- package/lib/index.d.ts +2 -2
- package/lib/index.js +33 -4
- package/lib/index.webhook.js +1 -1
- package/lib/index.websoket.js +3 -3
- package/lib/register.js +68 -36
- package/lib/sdk/api.d.ts +14 -14
- package/lib/sdk/api.js +142 -140
- package/lib/sdk/client.webhook.js +19 -14
- package/lib/sdk/client.websoket.js +38 -38
- package/lib/sdk/instance.js +109 -0
- package/lib/sdk/webhook.secret.js +5 -3
- package/lib/sends.js +66 -71
- package/package.json +1 -1
package/lib/sdk/api.js
CHANGED
|
@@ -2,6 +2,7 @@ import axios from 'axios';
|
|
|
2
2
|
import { config } from './config.js';
|
|
3
3
|
import FormData from 'form-data';
|
|
4
4
|
import { createPicFrom } from 'alemonjs/utils';
|
|
5
|
+
import { createAxiosInstance } from './instance.js';
|
|
5
6
|
|
|
6
7
|
const BOTS_API_RUL = 'https://bots.qq.com';
|
|
7
8
|
const API_URL_SANDBOX = 'https://sandbox.api.sgroup.qq.com';
|
|
@@ -35,10 +36,10 @@ class QQBotAPI {
|
|
|
35
36
|
timeout: 20000,
|
|
36
37
|
headers: {
|
|
37
38
|
'X-Union-Appid': app_id,
|
|
38
|
-
|
|
39
|
+
Authorization: `QQBot ${token}`
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
|
-
return service
|
|
42
|
+
return createAxiosInstance(service, options);
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* guild
|
|
@@ -56,29 +57,29 @@ class QQBotAPI {
|
|
|
56
57
|
Authorization: `Bot ${app_id}.${token}`
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
|
-
return service
|
|
60
|
+
return createAxiosInstance(service, opstion);
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
63
|
* 得到鉴权
|
|
63
64
|
* @returns
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
|
+
gateway() {
|
|
66
67
|
const mode = config.get('mode');
|
|
67
68
|
if (mode === 'group') {
|
|
68
69
|
return this.groupService({
|
|
69
70
|
url: '/gateway'
|
|
70
|
-
})
|
|
71
|
+
});
|
|
71
72
|
}
|
|
72
73
|
else if (mode === 'guild') {
|
|
73
74
|
return this.guildServer({
|
|
74
75
|
url: '/gateway'
|
|
75
|
-
})
|
|
76
|
+
});
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
79
|
// 默认group
|
|
79
80
|
return this.groupService({
|
|
80
81
|
url: '/gateway'
|
|
81
|
-
})
|
|
82
|
+
});
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
@@ -89,7 +90,7 @@ class QQBotAPI {
|
|
|
89
90
|
* @returns
|
|
90
91
|
* 0 文本 1 图文 2 md 3 ark 4 embed
|
|
91
92
|
*/
|
|
92
|
-
|
|
93
|
+
usersOpenMessages(openid, data) {
|
|
93
94
|
const db = {
|
|
94
95
|
...(data.event_id
|
|
95
96
|
? { event_id: data.event_id }
|
|
@@ -102,7 +103,7 @@ class QQBotAPI {
|
|
|
102
103
|
url: `/v2/users/${openid}/messages`,
|
|
103
104
|
method: 'post',
|
|
104
105
|
data: db
|
|
105
|
-
})
|
|
106
|
+
});
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
109
|
* 得到消息序列
|
|
@@ -116,8 +117,9 @@ class QQBotAPI {
|
|
|
116
117
|
// 如果映射表大小超过 100,则删除最早添加的 MessageId
|
|
117
118
|
if (msgMap.size > 100) {
|
|
118
119
|
const firstKey = msgMap.keys().next().value;
|
|
119
|
-
if (firstKey)
|
|
120
|
+
if (firstKey) {
|
|
120
121
|
msgMap.delete(firstKey);
|
|
122
|
+
}
|
|
121
123
|
}
|
|
122
124
|
return seq;
|
|
123
125
|
}
|
|
@@ -127,7 +129,7 @@ class QQBotAPI {
|
|
|
127
129
|
* @param data
|
|
128
130
|
* @returns
|
|
129
131
|
*/
|
|
130
|
-
|
|
132
|
+
groupOpenMessages(group_openid, data) {
|
|
131
133
|
const db = {
|
|
132
134
|
...(data.event_id
|
|
133
135
|
? { event_id: data.event_id }
|
|
@@ -140,7 +142,7 @@ class QQBotAPI {
|
|
|
140
142
|
url: `/v2/groups/${group_openid}/messages`,
|
|
141
143
|
method: 'post',
|
|
142
144
|
data: db
|
|
143
|
-
})
|
|
145
|
+
});
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
146
148
|
* 发送私聊富媒体文件
|
|
@@ -150,12 +152,12 @@ class QQBotAPI {
|
|
|
150
152
|
* 1 图文 2 视频 3 语言 4 文件
|
|
151
153
|
* 图片:png/jpg,视频:mp4,语音:silk
|
|
152
154
|
*/
|
|
153
|
-
|
|
155
|
+
postRichMediaByUser(openid, data) {
|
|
154
156
|
return this.groupService({
|
|
155
157
|
url: `/v2/users/${openid}/files`,
|
|
156
158
|
method: 'post',
|
|
157
159
|
data: data
|
|
158
|
-
})
|
|
160
|
+
});
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
161
163
|
* 发送群里文件
|
|
@@ -165,7 +167,7 @@ class QQBotAPI {
|
|
|
165
167
|
* 1 图文 2 视频 3 语言 4 文件
|
|
166
168
|
* 图片:png/jpg,视频:mp4,语音:silk
|
|
167
169
|
*/
|
|
168
|
-
|
|
170
|
+
postRichMediaByGroup(openid, data) {
|
|
169
171
|
return this.groupService({
|
|
170
172
|
url: `/v2/groups/${openid}/files`,
|
|
171
173
|
method: 'post',
|
|
@@ -173,7 +175,7 @@ class QQBotAPI {
|
|
|
173
175
|
srv_send_msg: false,
|
|
174
176
|
...data
|
|
175
177
|
}
|
|
176
|
-
})
|
|
178
|
+
});
|
|
177
179
|
}
|
|
178
180
|
/**
|
|
179
181
|
*
|
|
@@ -181,11 +183,11 @@ class QQBotAPI {
|
|
|
181
183
|
* @param message_id
|
|
182
184
|
* @returns
|
|
183
185
|
*/
|
|
184
|
-
|
|
186
|
+
userMessageDelete(openid, message_id) {
|
|
185
187
|
return this.groupService({
|
|
186
188
|
url: `/v2/users/${openid}/messages/${message_id}`,
|
|
187
189
|
method: 'delete'
|
|
188
|
-
})
|
|
190
|
+
});
|
|
189
191
|
}
|
|
190
192
|
/**
|
|
191
193
|
*
|
|
@@ -193,11 +195,11 @@ class QQBotAPI {
|
|
|
193
195
|
* @param message_id
|
|
194
196
|
* @returns
|
|
195
197
|
*/
|
|
196
|
-
|
|
198
|
+
grouMessageDelte(group_openid, message_id) {
|
|
197
199
|
return this.groupService({
|
|
198
200
|
url: `/v2/groups/${group_openid}/messages/${message_id}`,
|
|
199
201
|
method: 'delete'
|
|
200
|
-
})
|
|
202
|
+
});
|
|
201
203
|
}
|
|
202
204
|
/**
|
|
203
205
|
* ************
|
|
@@ -233,7 +235,7 @@ class QQBotAPI {
|
|
|
233
235
|
'Content-Type': `multipart/form-data; boundary=${dary}`
|
|
234
236
|
},
|
|
235
237
|
data: formdata
|
|
236
|
-
})
|
|
238
|
+
});
|
|
237
239
|
}
|
|
238
240
|
/**
|
|
239
241
|
* 私聊发送
|
|
@@ -263,7 +265,7 @@ class QQBotAPI {
|
|
|
263
265
|
'Content-Type': `multipart/form-data; boundary=${dary}`
|
|
264
266
|
},
|
|
265
267
|
data: formdata
|
|
266
|
-
})
|
|
268
|
+
});
|
|
267
269
|
}
|
|
268
270
|
/**
|
|
269
271
|
* ********
|
|
@@ -275,23 +277,23 @@ class QQBotAPI {
|
|
|
275
277
|
* @param message
|
|
276
278
|
* @returns
|
|
277
279
|
*/
|
|
278
|
-
|
|
280
|
+
usersMe() {
|
|
279
281
|
return this.guildServer({
|
|
280
282
|
method: 'get',
|
|
281
|
-
url:
|
|
282
|
-
})
|
|
283
|
+
url: '/users/@me'
|
|
284
|
+
});
|
|
283
285
|
}
|
|
284
286
|
/**
|
|
285
287
|
* 获取用户频道列表
|
|
286
288
|
* @param message
|
|
287
289
|
* @returns
|
|
288
290
|
*/
|
|
289
|
-
|
|
291
|
+
usersMeGuilds(params) {
|
|
290
292
|
return this.guildServer({
|
|
291
293
|
method: 'get',
|
|
292
|
-
url:
|
|
294
|
+
url: '/users/@me/guilds',
|
|
293
295
|
params
|
|
294
|
-
})
|
|
296
|
+
});
|
|
295
297
|
}
|
|
296
298
|
/**
|
|
297
299
|
* **********
|
|
@@ -303,11 +305,11 @@ class QQBotAPI {
|
|
|
303
305
|
* @param guild_id
|
|
304
306
|
* @returns
|
|
305
307
|
*/
|
|
306
|
-
|
|
308
|
+
guilds(guild_id) {
|
|
307
309
|
return this.guildServer({
|
|
308
310
|
method: 'get',
|
|
309
311
|
url: `/guilds/${guild_id}`
|
|
310
|
-
})
|
|
312
|
+
});
|
|
311
313
|
}
|
|
312
314
|
/**
|
|
313
315
|
* ************
|
|
@@ -319,46 +321,46 @@ class QQBotAPI {
|
|
|
319
321
|
* @param guild_id
|
|
320
322
|
* @returns
|
|
321
323
|
*/
|
|
322
|
-
|
|
324
|
+
guildsChannels(guild_id) {
|
|
323
325
|
return this.guildServer({
|
|
324
326
|
method: 'get',
|
|
325
327
|
url: `/guilds/${guild_id}/channels`
|
|
326
|
-
})
|
|
328
|
+
});
|
|
327
329
|
}
|
|
328
330
|
/**
|
|
329
331
|
* 获取子频道详情
|
|
330
332
|
* @param channel_id
|
|
331
333
|
* @returns
|
|
332
334
|
*/
|
|
333
|
-
|
|
335
|
+
channels(channel_id) {
|
|
334
336
|
return this.guildServer({
|
|
335
337
|
method: 'get',
|
|
336
338
|
url: `/channels/${channel_id}`
|
|
337
|
-
})
|
|
339
|
+
});
|
|
338
340
|
}
|
|
339
341
|
/**
|
|
340
342
|
* 创建子频道
|
|
341
343
|
* @param guild_id
|
|
342
344
|
* @returns
|
|
343
345
|
*/
|
|
344
|
-
|
|
346
|
+
guildsChannelsCreate(guild_id, data) {
|
|
345
347
|
return this.guildServer({
|
|
346
348
|
method: 'post',
|
|
347
349
|
url: `/guilds/${guild_id}/channels`,
|
|
348
350
|
data
|
|
349
|
-
})
|
|
351
|
+
});
|
|
350
352
|
}
|
|
351
353
|
/**
|
|
352
354
|
* 创建子频道
|
|
353
355
|
* @param channel_id
|
|
354
356
|
* @returns
|
|
355
357
|
*/
|
|
356
|
-
|
|
358
|
+
guildsChannelsUpdate(channel_id, data) {
|
|
357
359
|
return this.guildServer({
|
|
358
360
|
method: 'PATCH',
|
|
359
361
|
url: `/channels/${channel_id}`,
|
|
360
362
|
data
|
|
361
|
-
})
|
|
363
|
+
});
|
|
362
364
|
}
|
|
363
365
|
/**
|
|
364
366
|
* 删除子频道
|
|
@@ -366,23 +368,23 @@ class QQBotAPI {
|
|
|
366
368
|
* @param data
|
|
367
369
|
* @returns
|
|
368
370
|
*/
|
|
369
|
-
|
|
371
|
+
guildsChannelsdelete(channel_id, data) {
|
|
370
372
|
return this.guildServer({
|
|
371
373
|
method: 'DELETE',
|
|
372
374
|
url: `/channels/${channel_id}`,
|
|
373
375
|
data
|
|
374
|
-
})
|
|
376
|
+
});
|
|
375
377
|
}
|
|
376
378
|
/**
|
|
377
379
|
* 获取在线成员数
|
|
378
380
|
* @param channel_id
|
|
379
381
|
* @returns
|
|
380
382
|
*/
|
|
381
|
-
|
|
383
|
+
channelsChannelOnlineNums(channel_id) {
|
|
382
384
|
return this.guildServer({
|
|
383
385
|
method: 'GET',
|
|
384
386
|
url: `/channels/${channel_id}/online_nums`
|
|
385
|
-
})
|
|
387
|
+
});
|
|
386
388
|
}
|
|
387
389
|
/**
|
|
388
390
|
* *********
|
|
@@ -394,12 +396,12 @@ class QQBotAPI {
|
|
|
394
396
|
* @param guild_id
|
|
395
397
|
* @returns
|
|
396
398
|
*/
|
|
397
|
-
|
|
399
|
+
guildsMembers(guild_id, params) {
|
|
398
400
|
return this.guildServer({
|
|
399
401
|
method: 'GET',
|
|
400
402
|
url: `/guilds/${guild_id}/members`,
|
|
401
403
|
params
|
|
402
|
-
})
|
|
404
|
+
});
|
|
403
405
|
}
|
|
404
406
|
/**
|
|
405
407
|
* 获取频道身份组成员列表
|
|
@@ -408,12 +410,12 @@ class QQBotAPI {
|
|
|
408
410
|
* @param params
|
|
409
411
|
* @returns
|
|
410
412
|
*/
|
|
411
|
-
|
|
413
|
+
guildsRolesMembers(guild_id, role_id, params) {
|
|
412
414
|
return this.guildServer({
|
|
413
415
|
method: 'GET',
|
|
414
416
|
url: `/guilds/${guild_id}/roles/${role_id}/members`,
|
|
415
417
|
params
|
|
416
|
-
})
|
|
418
|
+
});
|
|
417
419
|
}
|
|
418
420
|
/**
|
|
419
421
|
* 获取成员详情
|
|
@@ -421,11 +423,11 @@ class QQBotAPI {
|
|
|
421
423
|
* @param user_id
|
|
422
424
|
* @returns
|
|
423
425
|
*/
|
|
424
|
-
|
|
426
|
+
guildsMembersMessage(guild_id, user_id) {
|
|
425
427
|
return this.guildServer({
|
|
426
428
|
method: 'GET',
|
|
427
429
|
url: `/guilds/${guild_id}/members/${user_id}`
|
|
428
|
-
})
|
|
430
|
+
});
|
|
429
431
|
}
|
|
430
432
|
/**
|
|
431
433
|
* 删除频道成员
|
|
@@ -433,11 +435,11 @@ class QQBotAPI {
|
|
|
433
435
|
* @param user_id
|
|
434
436
|
* @returns
|
|
435
437
|
*/
|
|
436
|
-
|
|
438
|
+
guildsMembersDelete(guild_id, user_id) {
|
|
437
439
|
return this.guildServer({
|
|
438
440
|
method: 'DELETE',
|
|
439
441
|
url: `/guilds/${guild_id}/members/${user_id}`
|
|
440
|
-
})
|
|
442
|
+
});
|
|
441
443
|
}
|
|
442
444
|
/**
|
|
443
445
|
* 获取指定消息
|
|
@@ -445,11 +447,11 @@ class QQBotAPI {
|
|
|
445
447
|
* @param message_id
|
|
446
448
|
* @returns
|
|
447
449
|
*/
|
|
448
|
-
|
|
450
|
+
channelsMessagesById(channel_id, message_id) {
|
|
449
451
|
return this.guildServer({
|
|
450
452
|
method: 'GET',
|
|
451
453
|
url: `/channels/${channel_id}/messages/${message_id}`
|
|
452
|
-
})
|
|
454
|
+
});
|
|
453
455
|
}
|
|
454
456
|
/**
|
|
455
457
|
* 撤回消息
|
|
@@ -458,11 +460,11 @@ class QQBotAPI {
|
|
|
458
460
|
* @param hidetip
|
|
459
461
|
* @returns
|
|
460
462
|
*/
|
|
461
|
-
|
|
463
|
+
channelsMessagesDelete(channel_id, message_id, hidetip = true) {
|
|
462
464
|
return this.guildServer({
|
|
463
465
|
method: 'DELETE',
|
|
464
466
|
url: `/channels/${channel_id}/messages/${message_id}?hidetip=${hidetip}`
|
|
465
|
-
})
|
|
467
|
+
});
|
|
466
468
|
}
|
|
467
469
|
/**
|
|
468
470
|
* ***********
|
|
@@ -474,11 +476,11 @@ class QQBotAPI {
|
|
|
474
476
|
* @param guild_id 频道id
|
|
475
477
|
* @returns
|
|
476
478
|
*/
|
|
477
|
-
|
|
479
|
+
guildsRoles(guild_id) {
|
|
478
480
|
return this.guildServer({
|
|
479
481
|
method: 'GET',
|
|
480
482
|
url: `/guilds/${guild_id}/roles`
|
|
481
|
-
})
|
|
483
|
+
});
|
|
482
484
|
}
|
|
483
485
|
/**
|
|
484
486
|
* 创建频道身份组
|
|
@@ -489,12 +491,12 @@ class QQBotAPI {
|
|
|
489
491
|
* @param {object?} data.hoist 在成员列表中单独展示: 0-否, 1-是
|
|
490
492
|
* @returns
|
|
491
493
|
*/
|
|
492
|
-
|
|
494
|
+
guildsRolesPost(guild_id, data) {
|
|
493
495
|
return this.guildServer({
|
|
494
496
|
method: 'POST',
|
|
495
497
|
url: `/guilds/${guild_id}/roles`,
|
|
496
498
|
data
|
|
497
|
-
})
|
|
499
|
+
});
|
|
498
500
|
}
|
|
499
501
|
/**
|
|
500
502
|
* 修改频道身份组
|
|
@@ -505,23 +507,23 @@ class QQBotAPI {
|
|
|
505
507
|
* @param {object?} data.hoist 在成员列表中单独展示: 0-否, 1-是
|
|
506
508
|
* @returns
|
|
507
509
|
*/
|
|
508
|
-
|
|
510
|
+
guildsRolesPatch(guild_id, role_id, data) {
|
|
509
511
|
return this.guildServer({
|
|
510
512
|
method: 'PATCH',
|
|
511
513
|
url: `/guilds/${guild_id}/roles/${role_id}`,
|
|
512
514
|
data
|
|
513
|
-
})
|
|
515
|
+
});
|
|
514
516
|
}
|
|
515
517
|
/**
|
|
516
518
|
* 删除频道身份组
|
|
517
519
|
* @param guild_id 频道id
|
|
518
520
|
* @param role_id 身份组id
|
|
519
521
|
*/
|
|
520
|
-
|
|
522
|
+
guildsRolesDelete(guild_id, role_id) {
|
|
521
523
|
return this.guildServer({
|
|
522
524
|
method: 'DELETE',
|
|
523
525
|
url: `/guilds/${guild_id}/roles/${role_id}`
|
|
524
|
-
})
|
|
526
|
+
});
|
|
525
527
|
}
|
|
526
528
|
/**
|
|
527
529
|
* 将成员添加到频道身份组
|
|
@@ -531,7 +533,7 @@ class QQBotAPI {
|
|
|
531
533
|
* @param role_id 身份组id
|
|
532
534
|
* @returns
|
|
533
535
|
*/
|
|
534
|
-
|
|
536
|
+
guildsRolesMembersPut(guild_id, channel_id, user_id, role_id) {
|
|
535
537
|
return this.guildServer({
|
|
536
538
|
method: 'PUT',
|
|
537
539
|
url: `/guilds/${guild_id}/members/${user_id}/roles/${role_id}`,
|
|
@@ -540,7 +542,7 @@ class QQBotAPI {
|
|
|
540
542
|
id: channel_id
|
|
541
543
|
}
|
|
542
544
|
}
|
|
543
|
-
})
|
|
545
|
+
});
|
|
544
546
|
}
|
|
545
547
|
/**
|
|
546
548
|
* 将成员从频道身份组移除
|
|
@@ -550,7 +552,7 @@ class QQBotAPI {
|
|
|
550
552
|
* @param role_id 身份组id
|
|
551
553
|
* @returns
|
|
552
554
|
*/
|
|
553
|
-
|
|
555
|
+
guildsRolesMembersDelete(guild_id, channel_id, user_id, role_id) {
|
|
554
556
|
return this.guildServer({
|
|
555
557
|
method: 'DELETE',
|
|
556
558
|
url: `/guilds/${guild_id}/members/${user_id}/roles/${role_id}`,
|
|
@@ -559,7 +561,7 @@ class QQBotAPI {
|
|
|
559
561
|
id: channel_id
|
|
560
562
|
}
|
|
561
563
|
}
|
|
562
|
-
})
|
|
564
|
+
});
|
|
563
565
|
}
|
|
564
566
|
/**
|
|
565
567
|
* **********
|
|
@@ -571,11 +573,11 @@ class QQBotAPI {
|
|
|
571
573
|
* @param channel_id 子频道id
|
|
572
574
|
* @param user_id 用户id
|
|
573
575
|
*/
|
|
574
|
-
|
|
576
|
+
channelsPermissions(channel_id, user_id) {
|
|
575
577
|
return this.guildServer({
|
|
576
578
|
method: 'GET',
|
|
577
579
|
url: `/channels/${channel_id}/members/${user_id}/permissions`
|
|
578
|
-
})
|
|
580
|
+
});
|
|
579
581
|
}
|
|
580
582
|
/**
|
|
581
583
|
* 修改子频道用户权限
|
|
@@ -583,7 +585,7 @@ class QQBotAPI {
|
|
|
583
585
|
* @param user_id 用户id
|
|
584
586
|
* @param 参数包括add和remove两个字段分别表示授予的权限以及删除的权限。要授予用户权限即把add对应位置 1,删除用户权限即把remove对应位置 1。当两个字段同一位都为 1,表现为删除权限。
|
|
585
587
|
*/
|
|
586
|
-
|
|
588
|
+
channelsPermissionsPut(channel_id, user_id, add, remove) {
|
|
587
589
|
return this.guildServer({
|
|
588
590
|
method: 'PUT',
|
|
589
591
|
url: `/channels/${channel_id}/members/${user_id}/permissions`,
|
|
@@ -591,7 +593,7 @@ class QQBotAPI {
|
|
|
591
593
|
add,
|
|
592
594
|
remove
|
|
593
595
|
}
|
|
594
|
-
})
|
|
596
|
+
});
|
|
595
597
|
}
|
|
596
598
|
/**
|
|
597
599
|
* *******
|
|
@@ -608,11 +610,11 @@ class QQBotAPI {
|
|
|
608
610
|
* @param guild_id 频道id
|
|
609
611
|
* @returns
|
|
610
612
|
*/
|
|
611
|
-
|
|
613
|
+
guildsMessageSetting(guild_id) {
|
|
612
614
|
return this.guildServer({
|
|
613
615
|
method: 'GET',
|
|
614
616
|
url: `/guilds/${guild_id}/message/setting`
|
|
615
|
-
})
|
|
617
|
+
});
|
|
616
618
|
}
|
|
617
619
|
/**
|
|
618
620
|
* ***********
|
|
@@ -625,11 +627,11 @@ class QQBotAPI {
|
|
|
625
627
|
* @param source_guild_id 源频道 id
|
|
626
628
|
* @returns
|
|
627
629
|
*/
|
|
628
|
-
|
|
630
|
+
usersMeDms() {
|
|
629
631
|
return this.guildServer({
|
|
630
632
|
method: 'POST',
|
|
631
|
-
url:
|
|
632
|
-
})
|
|
633
|
+
url: '/users/@me/dms'
|
|
634
|
+
});
|
|
633
635
|
}
|
|
634
636
|
/**
|
|
635
637
|
* 撤回私信
|
|
@@ -637,11 +639,11 @@ class QQBotAPI {
|
|
|
637
639
|
* @param data
|
|
638
640
|
* @returns
|
|
639
641
|
*/
|
|
640
|
-
|
|
642
|
+
dmsMessageDelete(guild_id, message_id, hidetip = true) {
|
|
641
643
|
return this.guildServer({
|
|
642
644
|
method: 'DELETE',
|
|
643
645
|
url: `/dms/${guild_id}/messages/${message_id}?hidetip=${hidetip}`
|
|
644
|
-
})
|
|
646
|
+
});
|
|
645
647
|
}
|
|
646
648
|
/**
|
|
647
649
|
* *********
|
|
@@ -654,12 +656,12 @@ class QQBotAPI {
|
|
|
654
656
|
* @param data { mute_end_timestamp:禁言结束时间戳, mute_seconds:禁言时长 } 两个参数必须传一个 优先级 mute_end_timestamp > mute_seconds
|
|
655
657
|
* 将mute_end_timestamp或mute_seconds传值为字符串'0',则表示解除全体禁言
|
|
656
658
|
*/
|
|
657
|
-
|
|
659
|
+
guildsMuteAll(guild_id, data) {
|
|
658
660
|
return this.guildServer({
|
|
659
661
|
method: 'PATCH',
|
|
660
662
|
url: `/guilds/${guild_id}/mute`,
|
|
661
663
|
data
|
|
662
|
-
})
|
|
664
|
+
});
|
|
663
665
|
}
|
|
664
666
|
/**
|
|
665
667
|
* 频道指定成员禁言
|
|
@@ -669,12 +671,12 @@ class QQBotAPI {
|
|
|
669
671
|
* 将mute_end_timestamp或mute_seconds传值为字符串'0',则表示解除禁言
|
|
670
672
|
* @returns
|
|
671
673
|
*/
|
|
672
|
-
|
|
674
|
+
guildsMemberMute(guild_id, user_id, data) {
|
|
673
675
|
return this.guildServer({
|
|
674
676
|
method: 'PATCH',
|
|
675
677
|
url: `/guilds/${guild_id}/members/${user_id}/mute`,
|
|
676
678
|
data
|
|
677
|
-
})
|
|
679
|
+
});
|
|
678
680
|
}
|
|
679
681
|
/**
|
|
680
682
|
* 频道批量禁言
|
|
@@ -682,12 +684,12 @@ class QQBotAPI {
|
|
|
682
684
|
* @param data { mute_end_timestamp:禁言结束时间戳, mute_seconds:禁言时长, user_ids:用户id数组 } 两个参数必须传一个 优先级 mute_end_timestamp > mute_seconds
|
|
683
685
|
* 将mute_end_timestamp或mute_seconds传值为字符串'0',则表示解除禁言
|
|
684
686
|
*/
|
|
685
|
-
|
|
687
|
+
guildsMute(guild_id, data) {
|
|
686
688
|
return this.guildServer({
|
|
687
689
|
method: 'PATCH',
|
|
688
690
|
url: `/guilds/${guild_id}/mute`,
|
|
689
691
|
data
|
|
690
|
-
})
|
|
692
|
+
});
|
|
691
693
|
}
|
|
692
694
|
/**
|
|
693
695
|
* *******
|
|
@@ -705,12 +707,12 @@ class QQBotAPI {
|
|
|
705
707
|
* @param recommend_channels 推荐频道id数组 "recommend_channels": [{ "channel_id": "xxxx","introduce": "推荐语" }]
|
|
706
708
|
* @returns 返回Announces 对象 (https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/announces/model.html#Announces)
|
|
707
709
|
*/
|
|
708
|
-
|
|
710
|
+
guildsAnnounces(guild_id, data) {
|
|
709
711
|
return this.guildServer({
|
|
710
712
|
method: 'POST',
|
|
711
713
|
url: `/guilds/${guild_id}/announces`,
|
|
712
714
|
data
|
|
713
|
-
})
|
|
715
|
+
});
|
|
714
716
|
}
|
|
715
717
|
/**
|
|
716
718
|
* 删除频道公告
|
|
@@ -718,11 +720,11 @@ class QQBotAPI {
|
|
|
718
720
|
* @param message_id 消息id message_id 有值时,会校验 message_id 合法性,若不校验校验 message_id,请将 message_id 设置为 all
|
|
719
721
|
* @returns
|
|
720
722
|
*/
|
|
721
|
-
|
|
723
|
+
guildsAnnouncesDelete(guild_id, message_id) {
|
|
722
724
|
return this.guildServer({
|
|
723
725
|
method: 'DELETE',
|
|
724
726
|
url: `/guilds/${guild_id}/announces/${message_id}`
|
|
725
|
-
})
|
|
727
|
+
});
|
|
726
728
|
}
|
|
727
729
|
/**
|
|
728
730
|
* **********
|
|
@@ -736,11 +738,11 @@ class QQBotAPI {
|
|
|
736
738
|
* @returns 返回 PinsMessage对象 { "guild_id": "xxxxxx", "channel_id": "xxxxxx", "message_ids": ["xxxxx"]}
|
|
737
739
|
* @returns message_ids 为当前请求后子频道内所有精华消息 message_id 数组
|
|
738
740
|
*/
|
|
739
|
-
|
|
741
|
+
channelsPinsPut(channel_id, message_id) {
|
|
740
742
|
return this.guildServer({
|
|
741
743
|
method: 'PUT',
|
|
742
744
|
url: `/channels/${channel_id}/pins/${message_id}`
|
|
743
|
-
})
|
|
745
|
+
});
|
|
744
746
|
}
|
|
745
747
|
/**
|
|
746
748
|
* 删除精华消息
|
|
@@ -749,11 +751,11 @@ class QQBotAPI {
|
|
|
749
751
|
* 删除子频道内全部精华消息,请将 message_id 设置为 all
|
|
750
752
|
* @returns
|
|
751
753
|
*/
|
|
752
|
-
|
|
754
|
+
channelsPinsDelete(channel_id, message_id) {
|
|
753
755
|
return this.guildServer({
|
|
754
756
|
method: 'DELETE',
|
|
755
757
|
url: `/channels/${channel_id}/pins/${message_id}`
|
|
756
|
-
})
|
|
758
|
+
});
|
|
757
759
|
}
|
|
758
760
|
/**
|
|
759
761
|
* 获取精华消息
|
|
@@ -761,11 +763,11 @@ class QQBotAPI {
|
|
|
761
763
|
* @returns 返回 PinsMessage对象 { "guild_id": "xxxxxx", "channel_id": "xxxxxx", "message_ids": ["xxxxx"]}
|
|
762
764
|
* @returns message_ids 为当前请求后子频道内所有精华消息 message_id 数组
|
|
763
765
|
*/
|
|
764
|
-
|
|
766
|
+
channelsPins(channel_id) {
|
|
765
767
|
return this.guildServer({
|
|
766
768
|
method: 'GET',
|
|
767
769
|
url: `/channels/${channel_id}/pins`
|
|
768
|
-
})
|
|
770
|
+
});
|
|
769
771
|
}
|
|
770
772
|
/**
|
|
771
773
|
* ********
|
|
@@ -777,11 +779,11 @@ class QQBotAPI {
|
|
|
777
779
|
* @param channel_id 子频道id
|
|
778
780
|
* @returns 返回 Schedule 对象数组(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
|
|
779
781
|
*/
|
|
780
|
-
|
|
782
|
+
channelsSchedules(channel_id) {
|
|
781
783
|
return this.guildServer({
|
|
782
784
|
method: 'GET',
|
|
783
785
|
url: `/channels/${channel_id}/schedules`
|
|
784
|
-
})
|
|
786
|
+
});
|
|
785
787
|
}
|
|
786
788
|
/**
|
|
787
789
|
* 获取频道日程详情
|
|
@@ -789,11 +791,11 @@ class QQBotAPI {
|
|
|
789
791
|
* @param schedule_id 日程id
|
|
790
792
|
* @returns 返回 Schedule 对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
|
|
791
793
|
*/
|
|
792
|
-
|
|
794
|
+
channelsSchedulesSchedule(channel_id, schedule_id) {
|
|
793
795
|
return this.guildServer({
|
|
794
796
|
method: 'GET',
|
|
795
797
|
url: `/channels/${channel_id}/schedules/${schedule_id}`
|
|
796
|
-
})
|
|
798
|
+
});
|
|
797
799
|
}
|
|
798
800
|
/**
|
|
799
801
|
* 创建频道日程
|
|
@@ -804,20 +806,20 @@ class QQBotAPI {
|
|
|
804
806
|
* @param end_timestamp 日程结束时间戳
|
|
805
807
|
* @param jump_channel_id 日程开始时跳转的子频道id
|
|
806
808
|
* @param remind_type 日程提醒类型
|
|
807
|
-
* 0
|
|
808
|
-
* 1
|
|
809
|
-
* 2
|
|
810
|
-
* 3
|
|
811
|
-
* 4
|
|
812
|
-
* 5
|
|
809
|
+
* 0不提醒
|
|
810
|
+
* 1开始时提醒
|
|
811
|
+
* 2开始前 5 分钟提醒
|
|
812
|
+
* 3开始前 15 分钟提醒
|
|
813
|
+
* 4开始前 30 分钟提醒
|
|
814
|
+
* 5开始前 60 分钟提醒
|
|
813
815
|
* @returns 返回 Schedule 对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
|
|
814
816
|
*/
|
|
815
|
-
|
|
817
|
+
channelsSchedulesPost(channel_id, data) {
|
|
816
818
|
return this.guildServer({
|
|
817
819
|
method: 'POST',
|
|
818
820
|
url: `/channels/${channel_id}/schedules`,
|
|
819
821
|
data
|
|
820
|
-
})
|
|
822
|
+
});
|
|
821
823
|
}
|
|
822
824
|
/**
|
|
823
825
|
* 修改频道日程
|
|
@@ -829,20 +831,20 @@ class QQBotAPI {
|
|
|
829
831
|
* @param end_timestamp 日程结束时间戳
|
|
830
832
|
* @param jump_channel_id 日程开始时跳转的子频道id
|
|
831
833
|
* @param remind_type 日程提醒类型
|
|
832
|
-
* 0
|
|
833
|
-
* 1
|
|
834
|
-
* 2
|
|
835
|
-
* 3
|
|
836
|
-
* 4
|
|
837
|
-
* 5
|
|
834
|
+
* 0不提醒
|
|
835
|
+
* 1开始时提醒
|
|
836
|
+
* 2开始前 5 分钟提醒
|
|
837
|
+
* 3开始前 15 分钟提醒
|
|
838
|
+
* 4开始前 30 分钟提醒
|
|
839
|
+
* 5开始前 60 分钟提醒
|
|
838
840
|
* @returns 返回 Schedule 对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
|
|
839
841
|
*/
|
|
840
|
-
|
|
842
|
+
channelsSchedulesSchedulePatch(channel_id, schedule_id, data) {
|
|
841
843
|
return this.guildServer({
|
|
842
844
|
method: 'PATCH',
|
|
843
845
|
url: `/channels/${channel_id}/schedules/${schedule_id}`,
|
|
844
846
|
data
|
|
845
|
-
})
|
|
847
|
+
});
|
|
846
848
|
}
|
|
847
849
|
/**
|
|
848
850
|
* 删除频道日程
|
|
@@ -850,11 +852,11 @@ class QQBotAPI {
|
|
|
850
852
|
* @param schedule_id 日程id
|
|
851
853
|
* @returns
|
|
852
854
|
*/
|
|
853
|
-
|
|
855
|
+
channelsSchedulesScheduleDelete(channel_id, schedule_id) {
|
|
854
856
|
return this.guildServer({
|
|
855
857
|
method: 'DELETE',
|
|
856
858
|
url: `/channels/${channel_id}/schedules/${schedule_id}`
|
|
857
|
-
})
|
|
859
|
+
});
|
|
858
860
|
}
|
|
859
861
|
/**
|
|
860
862
|
* ***********
|
|
@@ -869,11 +871,11 @@ class QQBotAPI {
|
|
|
869
871
|
* @param id 表情id 参考https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#Emoji%20%E5%88%97%E8%A1%A8
|
|
870
872
|
* @returns
|
|
871
873
|
*/
|
|
872
|
-
|
|
874
|
+
channelsMessagesReactionsPut(channel_id, message_id, type, id) {
|
|
873
875
|
return this.guildServer({
|
|
874
876
|
method: 'PUT',
|
|
875
877
|
url: `/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`
|
|
876
|
-
})
|
|
878
|
+
});
|
|
877
879
|
}
|
|
878
880
|
/**
|
|
879
881
|
* 删除机器人发表的表情表态
|
|
@@ -883,11 +885,11 @@ class QQBotAPI {
|
|
|
883
885
|
* @param id 表情id 参考https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#Emoji%20%E5%88%97%E8%A1%A8
|
|
884
886
|
* @returns
|
|
885
887
|
*/
|
|
886
|
-
|
|
888
|
+
channelsMessagesReactionsDelete(channel_id, message_id, type, id) {
|
|
887
889
|
return this.guildServer({
|
|
888
890
|
method: 'DELETE',
|
|
889
891
|
url: `/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`
|
|
890
|
-
})
|
|
892
|
+
});
|
|
891
893
|
}
|
|
892
894
|
/**
|
|
893
895
|
* 获取消息表情表态的用户列表
|
|
@@ -900,12 +902,12 @@ class QQBotAPI {
|
|
|
900
902
|
* @param {object} data.limit 返回的用户数量 默认20 最大50
|
|
901
903
|
* @returns data:{ users:User[], cookie:string,is_end:true|false }
|
|
902
904
|
*/
|
|
903
|
-
|
|
905
|
+
channelsMessagesReactionsUsers(channel_id, message_id, type, id, data) {
|
|
904
906
|
return this.guildServer({
|
|
905
907
|
method: 'GET',
|
|
906
908
|
url: `/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`,
|
|
907
909
|
data
|
|
908
|
-
})
|
|
910
|
+
});
|
|
909
911
|
}
|
|
910
912
|
/**
|
|
911
913
|
* ***********
|
|
@@ -921,34 +923,34 @@ class QQBotAPI {
|
|
|
921
923
|
* @param text 状态文本(比如:简单爱-周杰伦),可选,status为0时传,其他操作不传
|
|
922
924
|
* @returns
|
|
923
925
|
*/
|
|
924
|
-
|
|
926
|
+
channelsAudioPost(channel_id, data) {
|
|
925
927
|
return this.guildServer({
|
|
926
928
|
method: 'POST',
|
|
927
929
|
url: `/channels/${channel_id}/audio`,
|
|
928
930
|
data
|
|
929
|
-
})
|
|
931
|
+
});
|
|
930
932
|
}
|
|
931
933
|
/**
|
|
932
934
|
* 机器人上麦
|
|
933
935
|
* @param channel_id 语音子频道id
|
|
934
936
|
* @returns {}
|
|
935
937
|
*/
|
|
936
|
-
|
|
938
|
+
channelsMicPut(channel_id) {
|
|
937
939
|
return this.guildServer({
|
|
938
940
|
method: 'PUT',
|
|
939
941
|
url: `/channels/${channel_id}/mic`
|
|
940
|
-
})
|
|
942
|
+
});
|
|
941
943
|
}
|
|
942
944
|
/**
|
|
943
945
|
* 机器人下麦
|
|
944
946
|
* @param channel_id 语音子频道id
|
|
945
947
|
* @returns {}
|
|
946
948
|
*/
|
|
947
|
-
|
|
949
|
+
channelsMicDelete(channel_id) {
|
|
948
950
|
return this.guildServer({
|
|
949
951
|
method: 'DELETE',
|
|
950
952
|
url: `/channels/${channel_id}/mic`
|
|
951
|
-
})
|
|
953
|
+
});
|
|
952
954
|
}
|
|
953
955
|
/**
|
|
954
956
|
* **********
|
|
@@ -965,11 +967,11 @@ class QQBotAPI {
|
|
|
965
967
|
* @returns 返回 Thread 对象数组(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/forum/model.html#Thread)
|
|
966
968
|
* @returns is_finish 为 1 时,表示已拉取完 为 0 时,表示未拉取完
|
|
967
969
|
*/
|
|
968
|
-
|
|
970
|
+
channelsThreads(channel_id) {
|
|
969
971
|
return this.guildServer({
|
|
970
972
|
method: 'GET',
|
|
971
973
|
url: `/channels/${channel_id}/threads`
|
|
972
|
-
})
|
|
974
|
+
});
|
|
973
975
|
}
|
|
974
976
|
/**
|
|
975
977
|
* 获取帖子详情
|
|
@@ -978,11 +980,11 @@ class QQBotAPI {
|
|
|
978
980
|
* @returns 返回 帖子详情对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/forum/model.html#ThreadInfo)
|
|
979
981
|
* 其中content字段可参考 https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/forum/model.html#RichText
|
|
980
982
|
*/
|
|
981
|
-
|
|
983
|
+
channelsThreadsThread(channel_id, thread_id) {
|
|
982
984
|
return this.guildServer({
|
|
983
985
|
method: 'GET',
|
|
984
986
|
url: `/channels/${channel_id}/threads/${thread_id}`
|
|
985
|
-
})
|
|
987
|
+
});
|
|
986
988
|
}
|
|
987
989
|
/**
|
|
988
990
|
* 发表帖子
|
|
@@ -992,12 +994,12 @@ class QQBotAPI {
|
|
|
992
994
|
* @param format 帖子内容格式 1:纯文本 2:HTML 3:Markdown 4:JSON
|
|
993
995
|
* @returns 返回 {task_id:string,create_time:string} 其中 task_id 为帖子id,create_time 发帖时间戳
|
|
994
996
|
*/
|
|
995
|
-
|
|
997
|
+
channelsThreadsPut(channel_id, data) {
|
|
996
998
|
return this.guildServer({
|
|
997
999
|
method: 'PUT',
|
|
998
1000
|
url: `/channels/${channel_id}/threads`,
|
|
999
1001
|
data
|
|
1000
|
-
})
|
|
1002
|
+
});
|
|
1001
1003
|
}
|
|
1002
1004
|
/**
|
|
1003
1005
|
* 删除帖子
|
|
@@ -1005,11 +1007,11 @@ class QQBotAPI {
|
|
|
1005
1007
|
* @param thread_id 帖子id
|
|
1006
1008
|
* @returns
|
|
1007
1009
|
*/
|
|
1008
|
-
|
|
1010
|
+
channelsThreadsDelete(channel_id, thread_id) {
|
|
1009
1011
|
return this.guildServer({
|
|
1010
1012
|
method: 'DELETE',
|
|
1011
1013
|
url: `/channels/${channel_id}/threads/${thread_id}`
|
|
1012
|
-
})
|
|
1014
|
+
});
|
|
1013
1015
|
}
|
|
1014
1016
|
/**
|
|
1015
1017
|
* ********
|
|
@@ -1021,10 +1023,10 @@ class QQBotAPI {
|
|
|
1021
1023
|
* @param guild_id
|
|
1022
1024
|
* @returns
|
|
1023
1025
|
*/
|
|
1024
|
-
|
|
1026
|
+
guildApiPermission(guild_id) {
|
|
1025
1027
|
return this.guildServer({
|
|
1026
1028
|
url: `/guilds/${guild_id}/api_permission`
|
|
1027
|
-
})
|
|
1029
|
+
});
|
|
1028
1030
|
}
|
|
1029
1031
|
/**
|
|
1030
1032
|
* 交互事件回应
|
|
@@ -1032,7 +1034,7 @@ class QQBotAPI {
|
|
|
1032
1034
|
* @param code
|
|
1033
1035
|
* @returns
|
|
1034
1036
|
*/
|
|
1035
|
-
|
|
1037
|
+
interactionResponse(mode, interaction_id, code) {
|
|
1036
1038
|
if (mode === 'group') {
|
|
1037
1039
|
return this.groupService({
|
|
1038
1040
|
method: 'PUT',
|
|
@@ -1040,7 +1042,7 @@ class QQBotAPI {
|
|
|
1040
1042
|
data: {
|
|
1041
1043
|
code: code || 0
|
|
1042
1044
|
}
|
|
1043
|
-
})
|
|
1045
|
+
});
|
|
1044
1046
|
}
|
|
1045
1047
|
else {
|
|
1046
1048
|
return this.guildServer({
|
|
@@ -1049,7 +1051,7 @@ class QQBotAPI {
|
|
|
1049
1051
|
data: {
|
|
1050
1052
|
code: code || 0
|
|
1051
1053
|
}
|
|
1052
|
-
})
|
|
1054
|
+
});
|
|
1053
1055
|
}
|
|
1054
1056
|
}
|
|
1055
1057
|
}
|