@alemonjs/qq-bot 2.1.32 → 2.1.34
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 +1984 -35
- package/dist/assets/index.css +1 -1
- package/dist/assets/index.js +12 -5
- package/dist/index.html +1 -1
- package/lib/config.d.ts +44 -19
- package/lib/config.js +39 -35
- package/lib/desktop.d.ts +4 -1
- package/lib/desktop.js +53 -57
- package/lib/format.d.ts +26 -5
- package/lib/format.js +84 -101
- package/lib/hook.d.ts +82 -64
- package/lib/hook.js +35 -32
- package/lib/index.d.ts +6 -4
- package/lib/index.js +13 -16
- package/lib/index.webhook.d.ts +4 -1
- package/lib/index.webhook.js +12 -14
- package/lib/index.websoket.d.ts +6 -3
- package/lib/index.websoket.js +131 -41
- package/lib/message/AT_MESSAGE_CREATE.d.ts +36 -33
- package/lib/message/AT_MESSAGE_CREATE.js +1 -1
- package/lib/message/CHANNEL_CREATE.d.ts +17 -14
- package/lib/message/CHANNEL_CREATE.js +1 -1
- package/lib/message/CHANNEL_DELETE.d.ts +22 -14
- package/lib/message/CHANNEL_DELETE.js +1 -1
- package/lib/message/CHANNEL_UPDATE.d.ts +22 -14
- package/lib/message/CHANNEL_UPDATE.js +1 -1
- package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +35 -27
- package/lib/message/DIRECT_MESSAGE_CREATE.js +1 -1
- package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +23 -15
- package/lib/message/DIRECT_MESSAGE_DELETE.js +1 -1
- package/lib/message/ERROR.d.ts +4 -1
- package/lib/message/ERROR.js +1 -1
- package/lib/message/GUILD_CREATE.d.ts +22 -14
- package/lib/message/GUILD_CREATE.js +1 -1
- package/lib/message/GUILD_DELETE.d.ts +22 -14
- package/lib/message/GUILD_DELETE.js +1 -1
- package/lib/message/GUILD_MEMBER_ADD.d.ts +21 -13
- package/lib/message/GUILD_MEMBER_ADD.js +1 -1
- package/lib/message/GUILD_MEMBER_REMOVE.d.ts +21 -13
- package/lib/message/GUILD_MEMBER_REMOVE.js +1 -1
- package/lib/message/GUILD_MEMBER_UPDATE.d.ts +21 -13
- package/lib/message/GUILD_MEMBER_UPDATE.js +1 -1
- package/lib/message/GUILD_UPDATE.d.ts +22 -14
- package/lib/message/GUILD_UPDATE.js +1 -1
- package/lib/message/INTERACTION_CREATE.d.ts +52 -44
- package/lib/message/INTERACTION_CREATE.js +1 -1
- package/lib/message/MESSAGE_CREATE.d.ts +12 -1
- package/lib/message/MESSAGE_CREATE.js +1 -1
- package/lib/message/MESSAGE_DELETE.d.ts +12 -1
- package/lib/message/MESSAGE_DELETE.js +1 -1
- package/lib/message/MESSAGE_REACTION_ADD.d.ts +15 -12
- package/lib/message/MESSAGE_REACTION_ADD.js +1 -1
- package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +15 -12
- package/lib/message/MESSAGE_REACTION_REMOVE.js +1 -1
- package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +20 -13
- package/lib/message/PUBLIC_MESSAGE_DELETE.js +1 -1
- package/lib/message/READY.d.ts +11 -5
- package/lib/message/READY.js +1 -1
- package/lib/message/group/C2C_MESSAGE_CREATE.d.ts +18 -15
- package/lib/message/group/C2C_MESSAGE_CREATE.js +1 -1
- package/lib/message/group/C2C_MSG_RECEIVE.d.ts +13 -3
- package/lib/message/group/C2C_MSG_RECEIVE.js +1 -1
- package/lib/message/group/C2C_MSG_REJECT.d.ts +9 -3
- package/lib/message/group/C2C_MSG_REJECT.js +1 -1
- package/lib/message/group/FRIEND_ADD.d.ts +13 -3
- package/lib/message/group/FRIEND_ADD.js +1 -1
- package/lib/message/group/FRIEND_DEL.d.ts +9 -3
- package/lib/message/group/FRIEND_DEL.js +1 -1
- package/lib/message/group/GROUP_ADD_ROBOT.d.ts +23 -4
- package/lib/message/group/GROUP_ADD_ROBOT.js +1 -1
- package/lib/message/group/GROUP_AT_MESSAGE_CREATE.d.ts +38 -32
- package/lib/message/group/GROUP_AT_MESSAGE_CREATE.js +1 -1
- package/lib/message/group/GROUP_DEL_ROBOT.d.ts +19 -4
- package/lib/message/group/GROUP_DEL_ROBOT.js +1 -1
- package/lib/message/group/GROUP_JOIN_REQUEST.d.ts +84 -0
- package/lib/message/group/GROUP_JOIN_REQUEST.js +1 -0
- package/lib/message/group/GROUP_MEMBER_ADD.d.ts +8 -5
- package/lib/message/group/GROUP_MEMBER_ADD.js +1 -1
- package/lib/message/group/GROUP_MEMBER_REMOVE.d.ts +8 -5
- package/lib/message/group/GROUP_MEMBER_REMOVE.js +1 -1
- package/lib/message/group/GROUP_MESSAGE_CREATE.d.ts +38 -32
- package/lib/message/group/GROUP_MESSAGE_CREATE.js +1 -1
- package/lib/message/group/GROUP_MSG_RECEIVE.d.ts +14 -4
- package/lib/message/group/GROUP_MSG_RECEIVE.js +1 -1
- package/lib/message/group/GROUP_MSG_REJECT.d.ts +10 -4
- package/lib/message/group/GROUP_MSG_REJECT.js +1 -1
- package/lib/message/group/MESSAGE_AUDIT_PASS.d.ts +12 -6
- package/lib/message/group/MESSAGE_AUDIT_PASS.js +1 -1
- package/lib/message/group/MESSAGE_AUDIT_REJECT.d.ts +12 -6
- package/lib/message/group/MESSAGE_AUDIT_REJECT.js +1 -1
- package/lib/register.d.ts +12 -9
- package/lib/register.js +1246 -1200
- package/lib/sdk/api.d.ts +937 -251
- package/lib/sdk/api.js +1481 -758
- package/lib/sdk/client.webhook.d.ts +25 -8
- package/lib/sdk/client.webhook.js +185 -189
- package/lib/sdk/client.websoket.d.ts +31 -9
- package/lib/sdk/client.websoket.js +369 -392
- package/lib/sdk/config.d.ts +6 -2
- package/lib/sdk/config.js +9 -6
- package/lib/sdk/instance.d.ts +11 -3
- package/lib/sdk/instance.js +73 -83
- package/lib/sdk/intents.d.ts +89 -3
- package/lib/sdk/intents.js +116 -31
- package/lib/sdk/message.d.ts +7 -4
- package/lib/sdk/message.group.d.ts +38 -33
- package/lib/sdk/message.group.js +1 -1
- package/lib/sdk/message.guild.d.ts +40 -37
- package/lib/sdk/message.guild.js +1 -1
- package/lib/sdk/message.js +1 -1
- package/lib/sdk/message.public.d.ts +8 -5
- package/lib/sdk/message.public.js +1 -1
- package/lib/sdk/qr-auth.d.ts +55 -0
- package/lib/sdk/qr-auth.js +169 -0
- package/lib/sdk/registry.d.ts +34 -24
- package/lib/sdk/registry.js +134 -114
- package/lib/sdk/session.d.ts +19 -15
- package/lib/sdk/session.js +51 -54
- package/lib/sdk/typing.d.ts +416 -68
- package/lib/sdk/typing.js +1 -1
- package/lib/sdk/webhook.secret.d.ts +33 -13
- package/lib/sdk/webhook.secret.js +50 -36
- package/lib/sends.d.ts +46 -25
- package/lib/sends.js +533 -497
- package/lib/types.d.ts +52 -41
- package/lib/types.js +1 -1
- package/lib/upload.d.ts +50 -0
- package/lib/upload.js +89 -0
- package/lib/utils.d.ts +9 -1
- package/lib/utils.js +10 -5
- package/package.json +11 -8
|
@@ -1,38 +1,52 @@
|
|
|
1
|
-
import { ed25519 } from
|
|
1
|
+
import { ed25519 } from "@noble/curves/ed25519";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
export { WebhookAPI };
|
package/lib/sends.d.ts
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
import { QQBotAPI } from
|
|
2
|
-
import { ClientAPIMessageResult,
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 群组消息
|
|
7
|
+
*/
|
|
8
|
+
declare const GROUP_AT_MESSAGE_CREATE: (client: Client, event: {
|
|
9
|
+
ChannelId: string;
|
|
10
|
+
MessageId?: string;
|
|
11
|
+
_tag?: string;
|
|
12
|
+
}, val: DataEnums[], options?: {
|
|
13
|
+
forceVerifyImageResource?: boolean;
|
|
14
|
+
}) => Promise<ClientAPIMessageResult[]>;
|
|
15
|
+
/**
|
|
16
|
+
* 私聊消息
|
|
17
|
+
*/
|
|
18
|
+
declare const C2C_MESSAGE_CREATE: (client: Client, event: {
|
|
19
|
+
UserId: string;
|
|
20
|
+
MessageId?: string;
|
|
21
|
+
_tag?: string;
|
|
22
|
+
}, val: DataEnums[], options?: {
|
|
23
|
+
forceVerifyImageResource?: boolean;
|
|
24
|
+
}) => Promise<ClientAPIMessageResult[]>;
|
|
25
|
+
/**
|
|
26
|
+
* 频道私聊
|
|
27
|
+
*/
|
|
28
|
+
declare const DIRECT_MESSAGE_CREATE: (client: Client, event: {
|
|
29
|
+
UserId: string;
|
|
30
|
+
MessageId?: string;
|
|
31
|
+
_tag?: string;
|
|
8
32
|
}, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
/**
|
|
34
|
+
* 频道公聊
|
|
35
|
+
*/
|
|
36
|
+
declare const MESSAGE_CREATE: (client: Client, event: {
|
|
37
|
+
ChannelId: string;
|
|
38
|
+
MessageId?: string;
|
|
39
|
+
_tag?: string;
|
|
13
40
|
}, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
41
|
+
/**
|
|
42
|
+
* 频道公聊 @
|
|
43
|
+
*/
|
|
44
|
+
declare const AT_MESSAGE_CREATE: (client: Client, event: {
|
|
45
|
+
ChannelId: string;
|
|
46
|
+
MessageId?: string;
|
|
47
|
+
_tag?: string;
|
|
18
48
|
}, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
MessageId?: string;
|
|
22
|
-
_tag?: string;
|
|
23
|
-
}, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
24
|
-
export declare const AT_MESSAGE_CREATE: (client: Client, event: {
|
|
25
|
-
ChannelId: string;
|
|
26
|
-
MessageId?: string;
|
|
27
|
-
_tag?: string;
|
|
28
|
-
}, val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
29
|
-
export {};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { AT_MESSAGE_CREATE, C2C_MESSAGE_CREATE, DIRECT_MESSAGE_CREATE, GROUP_AT_MESSAGE_CREATE, MESSAGE_CREATE };
|