@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,9 +1,26 @@
1
- import { QQBotAPI } from './api.js';
2
- import { QQBotEventMap } from './message.js';
3
- import { Options } from '../config.js';
4
- export declare class QQBotClient extends QQBotAPI {
5
- #private;
6
- constructor(opstion: Options);
7
- on<T extends keyof QQBotEventMap>(key: T, val: (event: QQBotEventMap[T]) => any): this;
8
- connect(): void;
1
+ import { Options } from "../config.js";
2
+ import { QQBotAPI } from "./api.js";
3
+ import { QQBotEventMap } from "./message.js";
4
+ //#region src/sdk/client.webhook.d.ts
5
+ declare class QQBotClient extends QQBotAPI {
6
+ #private;
7
+ /**
8
+ * 设置配置
9
+ * @param opstion
10
+ */
11
+ constructor(opstion: Options);
12
+ /**
13
+ * 注册事件处理程序
14
+ * @param key 事件名称
15
+ * @param val 事件处理函数
16
+ */
17
+ on<T extends keyof QQBotEventMap>(key: T, val: (event: QQBotEventMap[T]) => any): this;
18
+ /**
19
+ *
20
+ * @param cfg
21
+ * @param conversation
22
+ */
23
+ connect(): void;
9
24
  }
25
+ //#endregion
26
+ export { QQBotClient };
@@ -1,193 +1,189 @@
1
- import { QQBotAPI } from './api.js';
2
- import bodyParser from 'koa-bodyparser';
3
- import Router from 'koa-router';
4
- import { WebhookAPI } from './webhook.secret.js';
5
- import Koa from 'koa';
6
- import { v4 } from 'uuid';
7
- import { WebSocketServer, WebSocket } from 'ws';
1
+ import { QQBotAPI } from "./api.js";
2
+ import { WebhookAPI } from "./webhook.secret.js";
3
+ import { WebSocket, WebSocketServer } from "ws";
4
+ import bodyParser from "koa-bodyparser";
5
+ import Router from "koa-router";
6
+ import Koa from "koa";
7
+ import { v4 } from "uuid";
8
8
 
9
+ //#region src/sdk/client.webhook.ts
9
10
  const normalizeGatewayMessage = (message) => {
10
- if (!message?.id || !message?.d || typeof message.d !== 'object' || Array.isArray(message.d)) {
11
- return message;
12
- }
13
- if (message.d.id === undefined || message.d.id === null || message.d.id === '') {
14
- message.d.id = message.id;
15
- }
16
- return message;
11
+ if (!message?.id || !message?.d || typeof message.d !== "object" || Array.isArray(message.d)) return message;
12
+ if (message.d.id === void 0 || message.d.id === null || message.d.id === "") message.d.id = message.id;
13
+ return message;
14
+ };
15
+ var QQBotClient = class extends QQBotAPI {
16
+ #events = {};
17
+ #app = null;
18
+ #count = 0;
19
+ #client = [];
20
+ #ws = null;
21
+ /**
22
+ * 设置配置
23
+ * @param opstion
24
+ */
25
+ constructor(opstion) {
26
+ super(opstion);
27
+ }
28
+ /**
29
+ * 注册事件处理程序
30
+ * @param key 事件名称
31
+ * @param val 事件处理函数
32
+ */
33
+ on(key, val) {
34
+ if (!this.#events[key]) this.#events[key] = [];
35
+ this.#events[key].push(val);
36
+ return this;
37
+ }
38
+ /**
39
+ * 定时鉴权
40
+ * @param cfg
41
+ * @returns
42
+ */
43
+ async #setTimeoutBotConfig() {
44
+ const callBack = async () => {
45
+ const app_id = this.config.get("app_id");
46
+ const secret = this.config.get("secret");
47
+ if (!app_id || !secret) return;
48
+ const data = await this.getAuthentication();
49
+ this.config.set("access_token", data.access_token);
50
+ console.info("refresh", data.expires_in, "s");
51
+ setTimeout(() => void callBack(), data.expires_in * 1e3);
52
+ };
53
+ await callBack();
54
+ }
55
+ /**
56
+ *
57
+ * @param cfg
58
+ * @param conversation
59
+ */
60
+ connect() {
61
+ try {
62
+ const ws = this.config.get("ws");
63
+ this.updateConnectionStatus({
64
+ state: "connecting",
65
+ transport: ws ? "proxy" : "webhook"
66
+ });
67
+ if (!ws) {
68
+ this.#setTimeoutBotConfig();
69
+ this.#app = new Koa();
70
+ this.#app.use(bodyParser());
71
+ const router = new Router();
72
+ const port = this.config.get("port");
73
+ const secret = this.config.get("secret");
74
+ const route = this.config.get("route") ?? "/webhook";
75
+ const cfg = {
76
+ secret: secret ?? "",
77
+ port: port ? Number(port) : 17157
78
+ };
79
+ const ntqqWebhook = new WebhookAPI({ secret: cfg.secret });
80
+ this.#app.use(async (ctx, next) => {
81
+ let rawData = "";
82
+ ctx.req.on("data", (chunk) => rawData += chunk);
83
+ ctx.req.on("end", () => ctx.request.rawBody = rawData);
84
+ await next();
85
+ });
86
+ router.post(route, (ctx) => {
87
+ const sign = ctx.req.headers["x-signature-ed25519"];
88
+ const timestamp = ctx.req.headers["x-signature-timestamp"];
89
+ const rawBody = ctx.request.rawBody;
90
+ if (!ntqqWebhook.validSign(timestamp, rawBody, String(sign))) {
91
+ ctx.status = 400;
92
+ ctx.body = { msg: "invalid signature" };
93
+ return;
94
+ }
95
+ const body = normalizeGatewayMessage(ctx.request.body);
96
+ if (+body.op === 13) {
97
+ ctx.status = 200;
98
+ ctx.body = {
99
+ plain_token: body.d.plain_token,
100
+ signature: ntqqWebhook.getSign(body.d.event_ts, body.d.plain_token)
101
+ };
102
+ } else if (+body.op === 0) {
103
+ ctx.status = 204;
104
+ for (const event of this.#events[body.t] || []) event(body.d);
105
+ const accessToken = this.config.get("access_token");
106
+ for (const client of this.#client) try {
107
+ if (accessToken) body["access_token"] = accessToken;
108
+ client.ws.send(JSON.stringify(body));
109
+ } catch (e) {
110
+ this.#error(e);
111
+ }
112
+ }
113
+ });
114
+ this.#app.use(router.routes());
115
+ this.#app.use(router.allowedMethods());
116
+ const server = this.#app.listen(cfg.port, () => {
117
+ console.log("Server running at http://localhost:" + cfg.port + route);
118
+ this.updateConnectionStatus({ state: "ready" });
119
+ });
120
+ const wss = new WebSocketServer({ server });
121
+ console.log("Server running at ws://localhost:" + cfg.port + "/");
122
+ wss.on("connection", (ws) => {
123
+ const clientId = v4();
124
+ ws["clientId"] = clientId;
125
+ console.log(clientId, "connection");
126
+ this.#client.push({
127
+ id: clientId,
128
+ ws
129
+ });
130
+ ws.on("message", (message) => {
131
+ try {
132
+ const body = normalizeGatewayMessage(JSON.parse(message.toString()));
133
+ for (const event of this.#events[body.t] || []) event(body.d);
134
+ } catch (e) {
135
+ this.#error(e);
136
+ }
137
+ });
138
+ ws.on("close", () => {
139
+ console.log(`${clientId} disconnected`);
140
+ this.#client = this.#client.filter((client) => client.id !== clientId);
141
+ });
142
+ });
143
+ } else {
144
+ const reConnect = () => {
145
+ this.#ws = new WebSocket(ws);
146
+ this.#ws.on("open", () => {
147
+ this.#count = 0;
148
+ this.updateConnectionStatus({ state: "ready" });
149
+ console.log("ws connected");
150
+ });
151
+ this.#ws.on("message", (data) => {
152
+ try {
153
+ const body = normalizeGatewayMessage(JSON.parse(data.toString()));
154
+ const accessToken = body["access_token"];
155
+ if (accessToken) this.config.set("access_token", accessToken);
156
+ for (const event of this.#events[body.t] || []) event(body.d);
157
+ } catch (e) {
158
+ this.#error(e);
159
+ }
160
+ });
161
+ this.#ws.on("close", () => {
162
+ this.updateConnectionStatus({ state: "offline" });
163
+ console.log("ws closed");
164
+ if (this.#count > 5) return;
165
+ setTimeout(() => {
166
+ reConnect();
167
+ }, 1300);
168
+ });
169
+ this.#ws.on("error", (e) => {
170
+ this.#error(e);
171
+ });
172
+ };
173
+ reConnect();
174
+ }
175
+ } catch (e) {
176
+ this.#error(e);
177
+ }
178
+ }
179
+ /**
180
+ *
181
+ * @param error
182
+ */
183
+ #error(error) {
184
+ if (this.#events["ERROR"]) for (const event of this.#events["ERROR"] || []) event(error);
185
+ }
17
186
  };
18
- class QQBotClient extends QQBotAPI {
19
- #events = {};
20
- #app = null;
21
- #count = 0;
22
- #client = [];
23
- #ws = null;
24
- constructor(opstion) {
25
- super(opstion);
26
- }
27
- on(key, val) {
28
- if (!this.#events[key]) {
29
- this.#events[key] = [];
30
- }
31
- this.#events[key].push(val);
32
- return this;
33
- }
34
- async #setTimeoutBotConfig() {
35
- const callBack = async () => {
36
- const app_id = this.config.get('app_id');
37
- const secret = this.config.get('secret');
38
- if (!app_id || !secret) {
39
- return;
40
- }
41
- const data = await this.getAuthentication();
42
- this.config.set('access_token', data.access_token);
43
- console.info('refresh', data.expires_in, 's');
44
- setTimeout(() => void callBack(), data.expires_in * 1000);
45
- };
46
- await callBack();
47
- }
48
- connect() {
49
- try {
50
- const ws = this.config.get('ws');
51
- this.updateConnectionStatus({ state: 'connecting', transport: ws ? 'proxy' : 'webhook' });
52
- if (!ws) {
53
- void this.#setTimeoutBotConfig();
54
- this.#app = new Koa();
55
- this.#app.use(bodyParser());
56
- const router = new Router();
57
- const port = this.config.get('port');
58
- const secret = this.config.get('secret');
59
- const route = this.config.get('route') ?? '/webhook';
60
- const cfg = {
61
- secret: secret ?? '',
62
- port: port ? Number(port) : 17157
63
- };
64
- const ntqqWebhook = new WebhookAPI({
65
- secret: cfg.secret
66
- });
67
- this.#app.use(async (ctx, next) => {
68
- let rawData = '';
69
- ctx.req.on('data', chunk => (rawData += chunk));
70
- ctx.req.on('end', () => (ctx.request.rawBody = rawData));
71
- await next();
72
- });
73
- router.post(route, ctx => {
74
- const sign = ctx.req.headers['x-signature-ed25519'];
75
- const timestamp = ctx.req.headers['x-signature-timestamp'];
76
- const rawBody = ctx.request.rawBody;
77
- const isValid = ntqqWebhook.validSign(timestamp, rawBody, String(sign));
78
- if (!isValid) {
79
- ctx.status = 400;
80
- ctx.body = { msg: 'invalid signature' };
81
- return;
82
- }
83
- const body = normalizeGatewayMessage(ctx.request.body);
84
- if (+body.op === 13) {
85
- ctx.status = 200;
86
- ctx.body = {
87
- plain_token: body.d.plain_token,
88
- signature: ntqqWebhook.getSign(body.d.event_ts, body.d.plain_token)
89
- };
90
- }
91
- else if (+body.op === 0) {
92
- ctx.status = 204;
93
- for (const event of this.#events[body.t] || []) {
94
- event(body.d);
95
- }
96
- const accessToken = this.config.get('access_token');
97
- for (const client of this.#client) {
98
- try {
99
- if (accessToken) {
100
- body['access_token'] = accessToken;
101
- }
102
- client.ws.send(JSON.stringify(body));
103
- }
104
- catch (e) {
105
- this.#error(e);
106
- }
107
- }
108
- }
109
- });
110
- this.#app.use(router.routes());
111
- this.#app.use(router.allowedMethods());
112
- const server = this.#app.listen(cfg.port, () => {
113
- console.log('Server running at http://localhost:' + cfg.port + route);
114
- this.updateConnectionStatus({ state: 'ready' });
115
- });
116
- const wss = new WebSocketServer({ server: server });
117
- console.log('Server running at ws://localhost:' + cfg.port + '/');
118
- wss.on('connection', ws => {
119
- const clientId = v4();
120
- ws['clientId'] = clientId;
121
- console.log(clientId, 'connection');
122
- this.#client.push({ id: clientId, ws });
123
- ws.on('message', (message) => {
124
- try {
125
- const body = normalizeGatewayMessage(JSON.parse(message.toString()));
126
- for (const event of this.#events[body.t] || []) {
127
- event(body.d);
128
- }
129
- }
130
- catch (e) {
131
- this.#error(e);
132
- }
133
- });
134
- ws.on('close', () => {
135
- console.log(`${clientId} disconnected`);
136
- this.#client = this.#client.filter(client => client.id !== clientId);
137
- });
138
- });
139
- }
140
- else {
141
- const reConnect = () => {
142
- this.#ws = new WebSocket(ws);
143
- this.#ws.on('open', () => {
144
- this.#count = 0;
145
- this.updateConnectionStatus({ state: 'ready' });
146
- console.log('ws connected');
147
- });
148
- this.#ws.on('message', data => {
149
- try {
150
- const body = normalizeGatewayMessage(JSON.parse(data.toString()));
151
- const accessToken = body['access_token'];
152
- if (accessToken) {
153
- this.config.set('access_token', accessToken);
154
- }
155
- for (const event of this.#events[body.t] || []) {
156
- event(body.d);
157
- }
158
- }
159
- catch (e) {
160
- this.#error(e);
161
- }
162
- });
163
- this.#ws.on('close', () => {
164
- this.updateConnectionStatus({ state: 'offline' });
165
- console.log('ws closed');
166
- if (this.#count > 5) {
167
- return;
168
- }
169
- setTimeout(() => {
170
- reConnect();
171
- }, 1300);
172
- });
173
- this.#ws.on('error', e => {
174
- this.#error(e);
175
- });
176
- };
177
- reConnect();
178
- }
179
- }
180
- catch (e) {
181
- this.#error(e);
182
- }
183
- }
184
- #error(error) {
185
- if (this.#events['ERROR']) {
186
- for (const event of this.#events['ERROR'] || []) {
187
- event(error);
188
- }
189
- }
190
- }
191
- }
192
187
 
193
- export { QQBotClient };
188
+ //#endregion
189
+ export { QQBotClient };
@@ -1,10 +1,32 @@
1
- import { QQBotAPI } from './api.js';
2
- import { QQBotEventMap } from './message.js';
3
- import { Options } from './typing.js';
4
- export declare class QQBotClients extends QQBotAPI {
5
- #private;
6
- constructor(option: Options);
7
- disconnect(): void;
8
- on<T extends keyof QQBotEventMap>(key: T, val: (event: QQBotEventMap[T]) => any): this;
9
- connect(gatewayURL?: string): Promise<void>;
1
+ import { Options } from "./typing.js";
2
+ import { QQBotAPI } from "./api.js";
3
+ import { QQBotEventMap } from "./message.js";
4
+ //#region src/sdk/client.websoket.d.ts
5
+ /**
6
+ * QQ 机器人网关连接。
7
+ *
8
+ * 网关会主动发送 op=7 要求客户端重新连接,也可能因网络或重复连接被关闭。
9
+ * 因此重连必须由客户端统一调度,避免旧 socket 的 close 事件重复创建连接。
10
+ */
11
+ declare class QQBotClients extends QQBotAPI {
12
+ #private;
13
+ /**
14
+ * 设置配置
15
+ * @param option
16
+ */
17
+ constructor(option: Options);
18
+ /** Stops reconnecting and releases the active gateway socket. */
19
+ disconnect(): void;
20
+ /**
21
+ * 注册事件处理程序
22
+ * @param key 事件名称
23
+ * @param val 事件处理函数
24
+ */
25
+ on<T extends keyof QQBotEventMap>(key: T, val: (event: QQBotEventMap[T]) => any): this;
26
+ /**
27
+ * 建立或恢复网关连接。
28
+ */
29
+ connect(gatewayURL?: string): Promise<void>;
10
30
  }
31
+ //#endregion
32
+ export { QQBotClients };