@alemonjs/qq-bot 0.0.22 → 0.0.23
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/lib/index.d.ts +2 -1
- package/lib/register.js +5 -27
- package/lib/sends.js +43 -15
- package/package.json +1 -1
- package/dist/assets/index.css +0 -1255
- package/dist/assets/index.js +0 -11257
- package/dist/index.html +0 -15
- package/lib/send/index.js +0 -453
package/lib/index.d.ts
CHANGED
package/lib/register.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getConfigValue, useUserHashKey, onProcessor } from 'alemonjs';
|
|
2
|
-
import {
|
|
2
|
+
import { GROUP_AT_MESSAGE_CREATE, C2C_MESSAGE_CREATE, DIRECT_MESSAGE_CREATE, AT_MESSAGE_CREATE, MESSAGE_CREATE } from './sends.js';
|
|
3
3
|
import { isGuild } from './utils.js';
|
|
4
4
|
|
|
5
5
|
const platform = 'qq-bot';
|
|
@@ -15,7 +15,7 @@ const register = (client) => {
|
|
|
15
15
|
* C2C_MESSAGE_CREATE
|
|
16
16
|
*/
|
|
17
17
|
const createUserAvatarURL = (author_id) => {
|
|
18
|
-
return `https://q.qlogo.cn/qqapp/${config.app_id}/${author_id}/
|
|
18
|
+
return `https://q.qlogo.cn/qqapp/${config.app_id}/${author_id}/640`;
|
|
19
19
|
};
|
|
20
20
|
// 监听消息
|
|
21
21
|
client.on('GROUP_AT_MESSAGE_CREATE', async (event) => {
|
|
@@ -363,34 +363,12 @@ const createClientAPI = (client) => {
|
|
|
363
363
|
return Promise.all([]);
|
|
364
364
|
},
|
|
365
365
|
mention: async (e) => {
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
e.value;
|
|
367
|
+
e.tag;
|
|
368
368
|
// const event = e.value
|
|
369
369
|
const Metions = [];
|
|
370
370
|
// group
|
|
371
|
-
|
|
372
|
-
return Metions;
|
|
373
|
-
// guild
|
|
374
|
-
if (event.mentions) {
|
|
375
|
-
const mentions = e.value['mentions'];
|
|
376
|
-
// 艾特消息处理
|
|
377
|
-
const MessageMention = mentions.map(item => {
|
|
378
|
-
return {
|
|
379
|
-
UserId: item.id,
|
|
380
|
-
IsMaster: false,
|
|
381
|
-
UserName: item.username,
|
|
382
|
-
IsBot: item.bot,
|
|
383
|
-
UserKey: useUserHashKey({
|
|
384
|
-
Platform: 'qq-guild-bot',
|
|
385
|
-
UserId: item.id
|
|
386
|
-
})
|
|
387
|
-
};
|
|
388
|
-
}) ?? [];
|
|
389
|
-
return MessageMention;
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
return Metions;
|
|
393
|
-
}
|
|
371
|
+
return Metions;
|
|
394
372
|
}
|
|
395
373
|
}
|
|
396
374
|
}
|
package/lib/sends.js
CHANGED
|
@@ -190,7 +190,9 @@ const GROUP_AT_MESSAGE_CREATE = async (client, event, val) => {
|
|
|
190
190
|
return createResult(ResultCode.Ok, 'client.groupOpenMessages', {
|
|
191
191
|
id: res.id
|
|
192
192
|
});
|
|
193
|
-
})).catch(err => [
|
|
193
|
+
})).catch(err => [
|
|
194
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
195
|
+
]);
|
|
194
196
|
return res;
|
|
195
197
|
}
|
|
196
198
|
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
@@ -237,9 +239,11 @@ const GROUP_AT_MESSAGE_CREATE = async (client, event, val) => {
|
|
|
237
239
|
});
|
|
238
240
|
}
|
|
239
241
|
catch (error) {
|
|
240
|
-
return createResult(ResultCode.Fail, error ?
|
|
242
|
+
return createResult(ResultCode.Fail, error ? error?.message ?? error : 'client.groupOpenMessages', null);
|
|
241
243
|
}
|
|
242
|
-
})).catch(err => [
|
|
244
|
+
})).catch(err => [
|
|
245
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
246
|
+
]);
|
|
243
247
|
}
|
|
244
248
|
// buttons
|
|
245
249
|
const buttons = val.filter(item => item.type == 'BT.group');
|
|
@@ -275,7 +279,9 @@ const GROUP_AT_MESSAGE_CREATE = async (client, event, val) => {
|
|
|
275
279
|
return createResult(ResultCode.Ok, 'client.groupOpenMessages', {
|
|
276
280
|
id: res.id
|
|
277
281
|
});
|
|
278
|
-
})).catch(err => [
|
|
282
|
+
})).catch(err => [
|
|
283
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
284
|
+
]);
|
|
279
285
|
}
|
|
280
286
|
// ark
|
|
281
287
|
const ark = val.filter(item => item.type == 'Ark.BigCard' || item.type == 'Ark.Card' || item.type == 'Ark.list');
|
|
@@ -311,7 +317,9 @@ const GROUP_AT_MESSAGE_CREATE = async (client, event, val) => {
|
|
|
311
317
|
msg_seq: client.getMessageSeq(event.MessageId)
|
|
312
318
|
});
|
|
313
319
|
return createResult(ResultCode.Ok, 'client.groupOpenMessages', { id: res.id });
|
|
314
|
-
})).catch(err => [
|
|
320
|
+
})).catch(err => [
|
|
321
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
322
|
+
]);
|
|
315
323
|
}
|
|
316
324
|
return Promise.all([]);
|
|
317
325
|
};
|
|
@@ -346,7 +354,9 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
|
346
354
|
return createResult(ResultCode.Ok, 'client.usersOpenMessages', {
|
|
347
355
|
id: res.id
|
|
348
356
|
});
|
|
349
|
-
})).catch(err => [
|
|
357
|
+
})).catch(err => [
|
|
358
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
359
|
+
]);
|
|
350
360
|
}
|
|
351
361
|
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
352
362
|
if (images && images.length > 0) {
|
|
@@ -385,7 +395,9 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
|
385
395
|
msg_type: 7,
|
|
386
396
|
msg_seq: client.getMessageSeq(event.MessageId)
|
|
387
397
|
});
|
|
388
|
-
})).catch(err => [
|
|
398
|
+
})).catch(err => [
|
|
399
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
400
|
+
]);
|
|
389
401
|
}
|
|
390
402
|
// buttons
|
|
391
403
|
const buttons = val.filter(item => item.type == 'BT.group');
|
|
@@ -421,7 +433,9 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
|
421
433
|
return createResult(ResultCode.Ok, 'client.usersOpenMessages', {
|
|
422
434
|
id: res.id
|
|
423
435
|
});
|
|
424
|
-
})).catch(err => [
|
|
436
|
+
})).catch(err => [
|
|
437
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
438
|
+
]);
|
|
425
439
|
}
|
|
426
440
|
// ark
|
|
427
441
|
const ark = val.filter(item => item.type == 'Ark.BigCard' || item.type == 'Ark.Card' || item.type == 'Ark.list');
|
|
@@ -455,7 +469,9 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
|
455
469
|
msg_seq: client.getMessageSeq(event.MessageId)
|
|
456
470
|
});
|
|
457
471
|
return createResult(ResultCode.Ok, 'client.usersOpenMessages', { id: res.id });
|
|
458
|
-
})).catch(err => [
|
|
472
|
+
})).catch(err => [
|
|
473
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
474
|
+
]);
|
|
459
475
|
}
|
|
460
476
|
return Promise.all([]);
|
|
461
477
|
};
|
|
@@ -486,7 +502,9 @@ const DIRECT_MESSAGE_CREATE = (client, event, val) => {
|
|
|
486
502
|
msg_id: event.MessageId
|
|
487
503
|
});
|
|
488
504
|
return createResult(ResultCode.Ok, 'client.dmsMessage', { id: res?.id });
|
|
489
|
-
})).catch(err => [
|
|
505
|
+
})).catch(err => [
|
|
506
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
507
|
+
]);
|
|
490
508
|
}
|
|
491
509
|
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
492
510
|
if (images && images.length > 0) {
|
|
@@ -510,7 +528,9 @@ const DIRECT_MESSAGE_CREATE = (client, event, val) => {
|
|
|
510
528
|
image: Buffer.isBuffer(file_data) ? file_data : Buffer.from(file_data)
|
|
511
529
|
});
|
|
512
530
|
return createResult(ResultCode.Ok, 'client.postDirectImage', { id: res?.id });
|
|
513
|
-
})).catch(err => [
|
|
531
|
+
})).catch(err => [
|
|
532
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
533
|
+
]);
|
|
514
534
|
}
|
|
515
535
|
return Promise.all([]);
|
|
516
536
|
};
|
|
@@ -548,7 +568,9 @@ const AT_MESSAGE_CREATE = (client, event, val) => {
|
|
|
548
568
|
msg_id: event.MessageId
|
|
549
569
|
});
|
|
550
570
|
return createResult(ResultCode.Ok, 'client.channelsMessagesPost', { id: res?.id });
|
|
551
|
-
})).catch(err => [
|
|
571
|
+
})).catch(err => [
|
|
572
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
573
|
+
]);
|
|
552
574
|
}
|
|
553
575
|
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
554
576
|
if (images && images.length > 0) {
|
|
@@ -572,7 +594,9 @@ const AT_MESSAGE_CREATE = (client, event, val) => {
|
|
|
572
594
|
image: Buffer.isBuffer(file_data) ? file_data : Buffer.from(file_data)
|
|
573
595
|
});
|
|
574
596
|
return createResult(ResultCode.Ok, 'client.postImage', { id: res?.id });
|
|
575
|
-
})).catch(err => [
|
|
597
|
+
})).catch(err => [
|
|
598
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
599
|
+
]);
|
|
576
600
|
}
|
|
577
601
|
return Promise.all([]);
|
|
578
602
|
};
|
|
@@ -616,7 +640,9 @@ const MESSAGE_CREATE = (client, event, val) => {
|
|
|
616
640
|
msg_id: event.MessageId
|
|
617
641
|
});
|
|
618
642
|
return createResult(ResultCode.Ok, 'client.channelsMessagesPost', { id: res?.id });
|
|
619
|
-
})).catch(err => [
|
|
643
|
+
})).catch(err => [
|
|
644
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
645
|
+
]);
|
|
620
646
|
}
|
|
621
647
|
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
622
648
|
if (images && images.length > 0) {
|
|
@@ -640,7 +666,9 @@ const MESSAGE_CREATE = (client, event, val) => {
|
|
|
640
666
|
image: Buffer.isBuffer(file_data) ? file_data : Buffer.from(file_data)
|
|
641
667
|
});
|
|
642
668
|
return createResult(ResultCode.Ok, 'client.postImage', { id: res?.id });
|
|
643
|
-
})).catch(err => [
|
|
669
|
+
})).catch(err => [
|
|
670
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null)
|
|
671
|
+
]);
|
|
644
672
|
}
|
|
645
673
|
return Promise.all([]);
|
|
646
674
|
};
|