@alemonjs/qq-bot 2.1.33 → 2.1.35

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.
Files changed (132) hide show
  1. package/README.md +46 -8
  2. package/dist/assets/index.css +1 -1
  3. package/dist/assets/index.js +12 -5
  4. package/dist/index.html +1 -1
  5. package/lib/config.d.ts +44 -19
  6. package/lib/config.js +39 -35
  7. package/lib/desktop.d.ts +4 -1
  8. package/lib/desktop.js +53 -57
  9. package/lib/format.d.ts +26 -5
  10. package/lib/format.js +84 -101
  11. package/lib/hook.d.ts +82 -65
  12. package/lib/hook.js +35 -32
  13. package/lib/index.d.ts +6 -4
  14. package/lib/index.js +13 -16
  15. package/lib/index.webhook.d.ts +4 -1
  16. package/lib/index.webhook.js +12 -14
  17. package/lib/index.websoket.d.ts +6 -3
  18. package/lib/index.websoket.js +131 -41
  19. package/lib/message/AT_MESSAGE_CREATE.d.ts +36 -33
  20. package/lib/message/AT_MESSAGE_CREATE.js +1 -1
  21. package/lib/message/CHANNEL_CREATE.d.ts +17 -14
  22. package/lib/message/CHANNEL_CREATE.js +1 -1
  23. package/lib/message/CHANNEL_DELETE.d.ts +22 -14
  24. package/lib/message/CHANNEL_DELETE.js +1 -1
  25. package/lib/message/CHANNEL_UPDATE.d.ts +22 -14
  26. package/lib/message/CHANNEL_UPDATE.js +1 -1
  27. package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +35 -27
  28. package/lib/message/DIRECT_MESSAGE_CREATE.js +1 -1
  29. package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +23 -15
  30. package/lib/message/DIRECT_MESSAGE_DELETE.js +1 -1
  31. package/lib/message/ERROR.d.ts +4 -1
  32. package/lib/message/ERROR.js +1 -1
  33. package/lib/message/GUILD_CREATE.d.ts +22 -14
  34. package/lib/message/GUILD_CREATE.js +1 -1
  35. package/lib/message/GUILD_DELETE.d.ts +22 -14
  36. package/lib/message/GUILD_DELETE.js +1 -1
  37. package/lib/message/GUILD_MEMBER_ADD.d.ts +21 -13
  38. package/lib/message/GUILD_MEMBER_ADD.js +1 -1
  39. package/lib/message/GUILD_MEMBER_REMOVE.d.ts +21 -13
  40. package/lib/message/GUILD_MEMBER_REMOVE.js +1 -1
  41. package/lib/message/GUILD_MEMBER_UPDATE.d.ts +21 -13
  42. package/lib/message/GUILD_MEMBER_UPDATE.js +1 -1
  43. package/lib/message/GUILD_UPDATE.d.ts +22 -14
  44. package/lib/message/GUILD_UPDATE.js +1 -1
  45. package/lib/message/INTERACTION_CREATE.d.ts +52 -44
  46. package/lib/message/INTERACTION_CREATE.js +1 -1
  47. package/lib/message/MESSAGE_CREATE.d.ts +12 -1
  48. package/lib/message/MESSAGE_CREATE.js +1 -1
  49. package/lib/message/MESSAGE_DELETE.d.ts +12 -1
  50. package/lib/message/MESSAGE_DELETE.js +1 -1
  51. package/lib/message/MESSAGE_REACTION_ADD.d.ts +15 -12
  52. package/lib/message/MESSAGE_REACTION_ADD.js +1 -1
  53. package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +15 -12
  54. package/lib/message/MESSAGE_REACTION_REMOVE.js +1 -1
  55. package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +20 -13
  56. package/lib/message/PUBLIC_MESSAGE_DELETE.js +1 -1
  57. package/lib/message/READY.d.ts +11 -5
  58. package/lib/message/READY.js +1 -1
  59. package/lib/message/group/C2C_MESSAGE_CREATE.d.ts +18 -15
  60. package/lib/message/group/C2C_MESSAGE_CREATE.js +1 -1
  61. package/lib/message/group/C2C_MSG_RECEIVE.d.ts +13 -3
  62. package/lib/message/group/C2C_MSG_RECEIVE.js +1 -1
  63. package/lib/message/group/C2C_MSG_REJECT.d.ts +9 -3
  64. package/lib/message/group/C2C_MSG_REJECT.js +1 -1
  65. package/lib/message/group/FRIEND_ADD.d.ts +13 -3
  66. package/lib/message/group/FRIEND_ADD.js +1 -1
  67. package/lib/message/group/FRIEND_DEL.d.ts +9 -3
  68. package/lib/message/group/FRIEND_DEL.js +1 -1
  69. package/lib/message/group/GROUP_ADD_ROBOT.d.ts +23 -4
  70. package/lib/message/group/GROUP_ADD_ROBOT.js +1 -1
  71. package/lib/message/group/GROUP_AT_MESSAGE_CREATE.d.ts +38 -32
  72. package/lib/message/group/GROUP_AT_MESSAGE_CREATE.js +1 -1
  73. package/lib/message/group/GROUP_DEL_ROBOT.d.ts +19 -4
  74. package/lib/message/group/GROUP_DEL_ROBOT.js +1 -1
  75. package/lib/message/group/GROUP_JOIN_REQUEST.d.ts +83 -22
  76. package/lib/message/group/GROUP_JOIN_REQUEST.js +1 -1
  77. package/lib/message/group/GROUP_MEMBER_ADD.d.ts +8 -5
  78. package/lib/message/group/GROUP_MEMBER_ADD.js +1 -1
  79. package/lib/message/group/GROUP_MEMBER_REMOVE.d.ts +8 -5
  80. package/lib/message/group/GROUP_MEMBER_REMOVE.js +1 -1
  81. package/lib/message/group/GROUP_MESSAGE_CREATE.d.ts +38 -32
  82. package/lib/message/group/GROUP_MESSAGE_CREATE.js +1 -1
  83. package/lib/message/group/GROUP_MSG_RECEIVE.d.ts +14 -4
  84. package/lib/message/group/GROUP_MSG_RECEIVE.js +1 -1
  85. package/lib/message/group/GROUP_MSG_REJECT.d.ts +10 -4
  86. package/lib/message/group/GROUP_MSG_REJECT.js +1 -1
  87. package/lib/message/group/MESSAGE_AUDIT_PASS.d.ts +12 -6
  88. package/lib/message/group/MESSAGE_AUDIT_PASS.js +1 -1
  89. package/lib/message/group/MESSAGE_AUDIT_REJECT.d.ts +12 -6
  90. package/lib/message/group/MESSAGE_AUDIT_REJECT.js +1 -1
  91. package/lib/register.d.ts +12 -9
  92. package/lib/register.js +1246 -1404
  93. package/lib/sdk/api.d.ts +937 -306
  94. package/lib/sdk/api.js +1481 -893
  95. package/lib/sdk/client.webhook.d.ts +25 -8
  96. package/lib/sdk/client.webhook.js +185 -189
  97. package/lib/sdk/client.websoket.d.ts +31 -9
  98. package/lib/sdk/client.websoket.js +369 -392
  99. package/lib/sdk/config.d.ts +6 -2
  100. package/lib/sdk/config.js +9 -6
  101. package/lib/sdk/instance.d.ts +11 -3
  102. package/lib/sdk/instance.js +72 -84
  103. package/lib/sdk/intents.d.ts +89 -3
  104. package/lib/sdk/intents.js +116 -33
  105. package/lib/sdk/message.d.ts +7 -4
  106. package/lib/sdk/message.group.d.ts +38 -35
  107. package/lib/sdk/message.group.js +1 -1
  108. package/lib/sdk/message.guild.d.ts +40 -37
  109. package/lib/sdk/message.guild.js +1 -1
  110. package/lib/sdk/message.js +1 -1
  111. package/lib/sdk/message.public.d.ts +8 -5
  112. package/lib/sdk/message.public.js +1 -1
  113. package/lib/sdk/qr-auth.d.ts +55 -0
  114. package/lib/sdk/qr-auth.js +166 -0
  115. package/lib/sdk/registry.d.ts +34 -24
  116. package/lib/sdk/registry.js +134 -114
  117. package/lib/sdk/session.d.ts +19 -15
  118. package/lib/sdk/session.js +51 -54
  119. package/lib/sdk/typing.d.ts +410 -184
  120. package/lib/sdk/typing.js +1 -1
  121. package/lib/sdk/webhook.secret.d.ts +33 -13
  122. package/lib/sdk/webhook.secret.js +50 -36
  123. package/lib/sends.d.ts +42 -25
  124. package/lib/sends.js +519 -541
  125. package/lib/types.d.ts +52 -41
  126. package/lib/types.js +1 -1
  127. package/lib/upload.d.ts +47 -18
  128. package/lib/upload.js +80 -51
  129. package/lib/utils.d.ts +9 -1
  130. package/lib/utils.js +10 -5
  131. package/package.json +10 -7
  132. package/LICENSE +0 -21
@@ -1,38 +1,52 @@
1
- import { ed25519 } from '@noble/curves/ed25519';
1
+ import { ed25519 } from "@noble/curves/ed25519";
2
2
 
3
- class WebhookAPI {
4
- config;
5
- constructor(config) {
6
- this.config = config;
7
- }
8
- validSign(ts, body, sign) {
9
- const { publicKey } = this.getKey();
10
- const sig = Buffer.isBuffer(sign) ? sign : Buffer.from(sign, 'hex');
11
- const httpBody = Buffer.from(body);
12
- const msg = Buffer.from(ts + httpBody);
13
- return ed25519.verify(sig, msg, publicKey);
14
- }
15
- getSign(eventTs, plainToken) {
16
- const { privateKey } = this.getKey();
17
- const msg = Buffer.from(eventTs + plainToken);
18
- const signature = Buffer.from(ed25519.sign(msg, privateKey)).toString('hex');
19
- return signature;
20
- }
21
- getKey() {
22
- let seed = this.config.secret;
23
- if (!seed) {
24
- throw new Error("secret not set, can't calc ed25519 key");
25
- }
26
- while (seed.length < 32) {
27
- seed = seed.repeat(2);
28
- }
29
- seed = seed.slice(0, 32);
30
- const privateKey = Buffer.from(seed);
31
- return {
32
- privateKey,
33
- publicKey: ed25519.getPublicKey(privateKey)
34
- };
35
- }
36
- }
3
+ //#region src/sdk/webhook.secret.ts
4
+ var WebhookAPI = class {
5
+ config;
6
+ constructor(config) {
7
+ this.config = config;
8
+ }
9
+ /**
10
+ * 验证签名
11
+ * @param ts
12
+ * @param body
13
+ * @param sign
14
+ * @returns
15
+ */
16
+ validSign(ts, body, sign) {
17
+ const { publicKey } = this.getKey();
18
+ const sig = Buffer.isBuffer(sign) ? sign : Buffer.from(sign, "hex");
19
+ const httpBody = Buffer.from(body);
20
+ const msg = Buffer.from(ts + httpBody);
21
+ return ed25519.verify(sig, msg, publicKey);
22
+ }
23
+ /**
24
+ * 生成签名
25
+ * @param eventTs
26
+ * @param plainToken
27
+ * @returns
28
+ */
29
+ getSign(eventTs, plainToken) {
30
+ const { privateKey } = this.getKey();
31
+ const msg = Buffer.from(eventTs + plainToken);
32
+ return Buffer.from(ed25519.sign(msg, privateKey)).toString("hex");
33
+ }
34
+ /**
35
+ * 获取 key
36
+ * @returns
37
+ */
38
+ getKey() {
39
+ let seed = this.config.secret;
40
+ if (!seed) throw new Error("secret not set, can't calc ed25519 key");
41
+ while (seed.length < 32) seed = seed.repeat(2);
42
+ seed = seed.slice(0, 32);
43
+ const privateKey = Buffer.from(seed);
44
+ return {
45
+ privateKey,
46
+ publicKey: ed25519.getPublicKey(privateKey)
47
+ };
48
+ }
49
+ };
37
50
 
38
- export { WebhookAPI };
51
+ //#endregion
52
+ export { WebhookAPI };
package/lib/sends.d.ts CHANGED
@@ -1,33 +1,50 @@
1
- import { QQBotAPI } from './sdk/api';
2
- import { ClientAPIMessageResult, type DataEnums } from 'alemonjs';
1
+ import { QQBotAPI } from "./sdk/api.js";
2
+ import { ClientAPIMessageResult, DataEnums } from "alemonjs";
3
+ //#region src/sends.d.ts
3
4
  type Client = typeof QQBotAPI.prototype;
4
- export declare const GROUP_AT_MESSAGE_CREATE: (client: Client, event: {
5
- ChannelId: string;
6
- MessageId?: string;
7
- _tag?: string;
5
+ /**
6
+ * 群组消息
7
+ */
8
+ declare const GROUP_AT_MESSAGE_CREATE: (client: Client, event: {
9
+ ChannelId: string;
10
+ MessageId?: string;
11
+ _tag?: string;
8
12
  }, val: DataEnums[], options?: {
9
- forceVerifyImageResource?: boolean;
13
+ forceVerifyImageResource?: boolean;
10
14
  }) => Promise<ClientAPIMessageResult[]>;
11
- export declare const C2C_MESSAGE_CREATE: (client: Client, event: {
12
- UserId: string;
13
- MessageId?: string;
14
- _tag?: string;
15
+ /**
16
+ * 私聊消息
17
+ */
18
+ declare const C2C_MESSAGE_CREATE: (client: Client, event: {
19
+ UserId: string;
20
+ MessageId?: string;
21
+ _tag?: string;
15
22
  }, val: DataEnums[], options?: {
16
- forceVerifyImageResource?: boolean;
23
+ forceVerifyImageResource?: boolean;
17
24
  }) => Promise<ClientAPIMessageResult[]>;
18
- export declare const DIRECT_MESSAGE_CREATE: (client: Client, event: {
19
- UserId: string;
20
- MessageId?: string;
21
- _tag?: string;
25
+ /**
26
+ * 频道私聊
27
+ */
28
+ declare const DIRECT_MESSAGE_CREATE: (client: Client, event: {
29
+ UserId: string;
30
+ MessageId?: string;
31
+ _tag?: string;
22
32
  }, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
23
- export declare const MESSAGE_CREATE: (client: Client, event: {
24
- ChannelId: string;
25
- MessageId?: string;
26
- _tag?: string;
33
+ /**
34
+ * 频道公聊
35
+ */
36
+ declare const MESSAGE_CREATE: (client: Client, event: {
37
+ ChannelId: string;
38
+ MessageId?: string;
39
+ _tag?: string;
27
40
  }, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
28
- export declare const AT_MESSAGE_CREATE: (client: Client, event: {
29
- ChannelId: string;
30
- MessageId?: string;
31
- _tag?: string;
41
+ /**
42
+ * 频道公聊 @
43
+ */
44
+ declare const AT_MESSAGE_CREATE: (client: Client, event: {
45
+ ChannelId: string;
46
+ MessageId?: string;
47
+ _tag?: string;
32
48
  }, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
33
- export {};
49
+ //#endregion
50
+ export { AT_MESSAGE_CREATE, C2C_MESSAGE_CREATE, DIRECT_MESSAGE_CREATE, GROUP_AT_MESSAGE_CREATE, MESSAGE_CREATE };