@tencent-connect/qqbot-nodejs 1.0.4 → 1.0.5
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/CHANGELOG.md +96 -0
- package/LICENSE +21 -0
- package/README.md +167 -86
- package/README.zh-CN.md +280 -0
- package/USAGE.md +80 -27
- package/dist/QQBot.d.ts +33 -3
- package/dist/QQBot.d.ts.map +1 -1
- package/dist/QQBot.js +84 -34
- package/dist/QQBot.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol/api/token.d.ts.map +1 -1
- package/dist/protocol/api/token.js +6 -2
- package/dist/protocol/api/token.js.map +1 -1
- package/dist/protocol/gateway/constants.d.ts +6 -1
- package/dist/protocol/gateway/constants.d.ts.map +1 -1
- package/dist/protocol/gateway/constants.js +6 -1
- package/dist/protocol/gateway/constants.js.map +1 -1
- package/dist/protocol/gateway/errors.d.ts +22 -0
- package/dist/protocol/gateway/errors.d.ts.map +1 -0
- package/dist/protocol/gateway/errors.js +24 -0
- package/dist/protocol/gateway/errors.js.map +1 -0
- package/dist/protocol/gateway/gateway-connection.d.ts +45 -4
- package/dist/protocol/gateway/gateway-connection.d.ts.map +1 -1
- package/dist/protocol/gateway/gateway-connection.js +252 -143
- package/dist/protocol/gateway/gateway-connection.js.map +1 -1
- package/dist/protocol/gateway/reconnect.d.ts +24 -1
- package/dist/protocol/gateway/reconnect.d.ts.map +1 -1
- package/dist/protocol/gateway/reconnect.js +42 -6
- package/dist/protocol/gateway/reconnect.js.map +1 -1
- package/dist/protocol/index.d.ts +4 -3
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +3 -2
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/utils/file-utils.d.ts +2 -2
- package/dist/protocol/utils/file-utils.js +2 -2
- package/dist/protocol/utils/image-size.d.ts +3 -3
- package/dist/protocol/utils/image-size.js +3 -3
- package/dist/protocol/utils/ref-index-store.d.ts +1 -1
- package/dist/protocol/utils/ref-index-store.js +1 -1
- package/package.json +23 -7
- package/src/QQBot.ts +93 -37
- package/src/index.ts +5 -0
- package/src/protocol/api/token.ts +6 -2
- package/src/protocol/gateway/constants.ts +6 -1
- package/src/protocol/gateway/errors.ts +32 -0
- package/src/protocol/gateway/gateway-connection.ts +288 -157
- package/src/protocol/gateway/reconnect.ts +61 -7
- package/src/protocol/index.ts +10 -1
- package/src/protocol/utils/file-utils.ts +2 -2
- package/src/protocol/utils/image-size.ts +3 -3
- package/src/protocol/utils/ref-index-store.ts +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# 1.0.5 (2026-10-12)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **gateway:** startup now fails fast with a clear reason when the connection can't be established, instead of waiting forever
|
|
6
|
+
* **gateway:** new `disconnected` event reports why the connection dropped and whether the SDK will recover on its own
|
|
7
|
+
* **gateway:** reconnects are now configurable — cap the attempts and tune the backoff; unrecoverable cases (banned bot, sandbox-only account) are reported once and explicitly
|
|
8
|
+
* **sdk:** `bot.getCredentials()` exposes the configured credentials for calling the lower-level APIs directly
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **gateway:** retries are no longer reset by a connection that is accepted then immediately rejected, so a misconfigured bot can't spin in a tight reconnect loop
|
|
13
|
+
* **gateway:** fixed several issues that could stall or misjudge the connection: an exception in your own handler, a silently dropped handshake, and a platform-requested reconnect treated as permanent
|
|
14
|
+
* **token:** restarting the bot no longer cancels the token refresh belonging to the new session
|
|
15
|
+
|
|
16
|
+
### Behavior changes
|
|
17
|
+
|
|
18
|
+
* The SDK now keeps retrying until the failure is clearly unrecoverable (previously it gave up after 100 attempts). Set `reconnect.maxAttempts` for a hard cap.
|
|
19
|
+
|
|
20
|
+
## 1.0.4 (2026-07-14)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **token:** fetching an access token now times out, and failures report the HTTP status and server response instead of a generic error
|
|
25
|
+
* **token:** fixed edge cases that could leave token refresh stuck or log a crash that never happened
|
|
26
|
+
|
|
27
|
+
## 1.0.3 (2026-07-13)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* **sdk:** add universal send(), API gateway, rawEvent, and P1 messaging capabilities
|
|
33
|
+
* **media:** auto-fill fileName from localPath/URL in uploadMedia
|
|
34
|
+
* **media:** pre-check fileData size before upload
|
|
35
|
+
* **middleware:** concurrency-guard merge support
|
|
36
|
+
* **middleware:** enhance types & buffered reply
|
|
37
|
+
* **concurrency:** add maxProcessingMs timeout with abort
|
|
38
|
+
* **concurrency:** add urgentPredicate for priority flush
|
|
39
|
+
* **quote-ref:** prefer msg_elements over stored entry
|
|
40
|
+
* **quote-ref:** add enrichEntry & extend entry
|
|
41
|
+
* **api:** support data in acknowledge interaction
|
|
42
|
+
* **sanitizer:** support new face tag format
|
|
43
|
+
* **slash:** add per-command authorized check
|
|
44
|
+
* export webhook transport types
|
|
45
|
+
* update mention-gate
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Bug Fixes
|
|
49
|
+
|
|
50
|
+
* **slash:** check rawEventType for group @bot detection
|
|
51
|
+
* **media:** use raw https for COS chunked upload
|
|
52
|
+
* **media:** pass Uint8Array directly to fetch body
|
|
53
|
+
* **middleware:** refine mention-gate logic
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## 1.0.2 (2026-06-10)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
* **qqbot:** support tokenPrefetch option for sync/async token initialization
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## 1.0.1 (2026-05-20)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Features
|
|
68
|
+
|
|
69
|
+
* **middleware:** add concurrencyGuard for per-target serial processing
|
|
70
|
+
* **middleware:** add ctx.abort() and ctx.signal for async cancellation
|
|
71
|
+
* **middleware:** add typing keepalive to typingIndicator
|
|
72
|
+
* **middleware:** add receivedAt to MiddlewareContext for latency measurement
|
|
73
|
+
* **concurrency:** add merge strategy with dependency-inverted dispatch
|
|
74
|
+
* **slash:** add allowFrom option for command access control
|
|
75
|
+
* **event:** expose messageScene on C2C inbound messages
|
|
76
|
+
* **transport:** add webhook example and update readme
|
|
77
|
+
* dataflow middleware pipeline
|
|
78
|
+
* check slash scope
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Bug Fixes
|
|
82
|
+
|
|
83
|
+
* **webhook:** async dispatch to prevent ACK timeout on long-running handlers
|
|
84
|
+
* **webhook:** log full event payload in dispatch debug output
|
|
85
|
+
* **stream:** ensure DONE frame is sent even when flush is in progress
|
|
86
|
+
* **streaming:** catch throttle flush error to prevent unhandledRejection
|
|
87
|
+
* **streaming:** fix rate-limit retry storm in flush
|
|
88
|
+
* **concurrency-guard:** evict queued waiters on abort to prevent stale replies
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# 1.0.0 (2026-04-30)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### Features
|
|
95
|
+
|
|
96
|
+
* initialize QQ Open Platform Node.js SDK
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tencent
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
# @tencent-connect/qqbot-nodejs
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
协议层能力:HTTP REST、WebSocket / Webhook 双传输、Koa-style 中间件管线、
|
|
5
|
-
消息收发、媒体上传(含大文件分块)、C2C 流式消息(stream_messages)。
|
|
3
|
+
> **English** (this file) · [简体中文](./README.zh-CN.md)
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@tencent-connect/qqbot-nodejs)
|
|
6
|
+
[](https://github.com/tencent-connect/qqbot-nodejs/actions/workflows/ci.yml)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
|
|
10
|
+
Tencent QQ Open Platform Node.js SDK. Provides every protocol-layer capability
|
|
11
|
+
needed to integrate with the QQ Bot Open Platform: HTTP REST, dual WebSocket /
|
|
12
|
+
Webhook transport, a Koa-style middleware pipeline, messaging, media upload
|
|
13
|
+
(including chunked upload for large files), and C2C streaming messages
|
|
14
|
+
(`stream_messages`).
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Node.js **>= 20** (uses global `fetch` / `AbortController`)
|
|
19
|
+
- Pure ESM (`"type": "module"`); CJS consumers should use dynamic `import()`
|
|
20
|
+
|
|
21
|
+
## Install
|
|
8
22
|
|
|
9
23
|
```bash
|
|
10
24
|
pnpm add @tencent-connect/qqbot-nodejs
|
|
11
|
-
#
|
|
25
|
+
# or
|
|
12
26
|
npm install @tencent-connect/qqbot-nodejs
|
|
13
27
|
```
|
|
14
28
|
|
|
15
|
-
##
|
|
29
|
+
## Quick Start
|
|
16
30
|
|
|
17
31
|
```ts
|
|
18
32
|
import { QQBot } from "@tencent-connect/qqbot-nodejs";
|
|
@@ -24,32 +38,36 @@ const bot = new QQBot({
|
|
|
24
38
|
});
|
|
25
39
|
|
|
26
40
|
bot.on("message", async (ctx, msg) => {
|
|
27
|
-
// ctx — Koa-style MiddlewareContext
|
|
41
|
+
// ctx — Koa-style MiddlewareContext carrying data injected by middleware
|
|
28
42
|
await bot.sendText(msg.replyTarget, `Echo: ${msg.content}`);
|
|
29
43
|
});
|
|
30
44
|
|
|
31
45
|
await bot.start();
|
|
32
46
|
```
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
See the complete examples under [examples/](./examples/):
|
|
35
49
|
|
|
36
|
-
|
|
|
50
|
+
| Example | Description |
|
|
37
51
|
|------|------|
|
|
38
|
-
| [playground](./examples/playground/) |
|
|
39
|
-
| [middleware](./examples/middleware/) |
|
|
40
|
-
| [webhook](./examples/webhook/) | Webhook
|
|
41
|
-
| [send-plain-100](./examples/send-plain-100/) |
|
|
42
|
-
| [send-streaming-100](./examples/send-streaming-100/) |
|
|
52
|
+
| [playground](./examples/playground/) | Core capabilities demo (text, streaming, media, commands) |
|
|
53
|
+
| [middleware](./examples/middleware/) | Full 13-layer Koa-style middleware pipeline |
|
|
54
|
+
| [webhook](./examples/webhook/) | Webhook (HTTP callback) transport |
|
|
55
|
+
| [send-plain-100](./examples/send-plain-100/) | Plain-text send baseline |
|
|
56
|
+
| [send-streaming-100](./examples/send-streaming-100/) | Streaming-message send baseline |
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
> Examples read `QQBOT_APP_ID` / `QQBOT_APP_SECRET` from `process.env` **only
|
|
59
|
+
> for demo convenience**. The SDK itself never reads environment variables —
|
|
60
|
+
> credentials are always injected via `new QQBot({ appId, appSecret })`.
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
## Features
|
|
63
|
+
|
|
64
|
+
### 1. Dual transport (WebSocket / Webhook)
|
|
47
65
|
|
|
48
66
|
```ts
|
|
49
|
-
// WebSocket
|
|
67
|
+
// WebSocket (default) — long-lived connection + heartbeat + RESUME
|
|
50
68
|
const bot = new QQBot({ appId, appSecret });
|
|
51
69
|
|
|
52
|
-
// Webhook — HTTP
|
|
70
|
+
// Webhook — HTTP callback, suited to Serverless / horizontal scaling
|
|
53
71
|
const bot = new QQBot({
|
|
54
72
|
appId, appSecret,
|
|
55
73
|
transport: "webhook",
|
|
@@ -57,11 +75,12 @@ const bot = new QQBot({
|
|
|
57
75
|
});
|
|
58
76
|
```
|
|
59
77
|
|
|
60
|
-
|
|
78
|
+
Middleware, event listeners and send APIs are identical in both modes.
|
|
61
79
|
|
|
62
|
-
### 2. Koa-style
|
|
80
|
+
### 2. Koa-style middleware
|
|
63
81
|
|
|
64
|
-
SDK
|
|
82
|
+
The SDK uses an onion-model middleware chain; `bot.on("message")` is the
|
|
83
|
+
innermost downstream:
|
|
65
84
|
|
|
66
85
|
```ts
|
|
67
86
|
import { errorHandler, messageFilter, contentSanitizer, mentionGate } from "@tencent-connect/qqbot-nodejs";
|
|
@@ -71,7 +90,7 @@ bot.use(messageFilter({ skipSelfEcho: true, dedup: { windowMs: 5000 } }));
|
|
|
71
90
|
bot.use(contentSanitizer({ stripBotMention: true }));
|
|
72
91
|
bot.use(mentionGate({ requireMentionInGroup: true }));
|
|
73
92
|
|
|
74
|
-
//
|
|
93
|
+
// Custom middleware
|
|
75
94
|
bot.use(async (ctx, next) => {
|
|
76
95
|
const start = Date.now();
|
|
77
96
|
await next();
|
|
@@ -79,33 +98,33 @@ bot.use(async (ctx, next) => {
|
|
|
79
98
|
});
|
|
80
99
|
```
|
|
81
100
|
|
|
82
|
-
|
|
101
|
+
Built-in middleware:
|
|
83
102
|
|
|
84
|
-
|
|
|
103
|
+
| Middleware | Purpose |
|
|
85
104
|
|--------|------|
|
|
86
|
-
| `errorHandler` |
|
|
87
|
-
| `messageFilter` |
|
|
88
|
-
| `rateLimiter` |
|
|
89
|
-
| `concurrencyGuard` |
|
|
90
|
-
| `accessPolicy` |
|
|
91
|
-
| `contentSanitizer` |
|
|
92
|
-
| `mentionGate` |
|
|
93
|
-
| `quoteRef` |
|
|
94
|
-
| `historyBuffer` |
|
|
95
|
-
| `envelopeFormatter` |
|
|
96
|
-
| `typingIndicator` | C2C
|
|
97
|
-
| `slashCommand` | /cmd
|
|
98
|
-
|
|
99
|
-
### 3.
|
|
105
|
+
| `errorHandler` | Unified error capture + friendly reply |
|
|
106
|
+
| `messageFilter` | Bot echo filtering + message dedup |
|
|
107
|
+
| `rateLimiter` | Three-tier rate limiting (sender / group / global) |
|
|
108
|
+
| `concurrencyGuard` | Serial processing per user / group (avoids stream races) |
|
|
109
|
+
| `accessPolicy` | Allow / block lists |
|
|
110
|
+
| `contentSanitizer` | Strip @markers / face tags / whitespace |
|
|
111
|
+
| `mentionGate` | Group @bot gating |
|
|
112
|
+
| `quoteRef` | Message index recording + quoted-message resolution |
|
|
113
|
+
| `historyBuffer` | Group history buffer |
|
|
114
|
+
| `envelopeFormatter` | Assemble LLM prompt context (XML tags) |
|
|
115
|
+
| `typingIndicator` | Automatic C2C typing |
|
|
116
|
+
| `slashCommand` | /cmd command framework |
|
|
117
|
+
|
|
118
|
+
### 3. Text messages
|
|
100
119
|
|
|
101
120
|
```ts
|
|
102
121
|
await bot.sendText(target, "hello");
|
|
103
122
|
```
|
|
104
123
|
|
|
105
|
-
### 4.
|
|
124
|
+
### 4. Files / images / voice
|
|
106
125
|
|
|
107
|
-
`sendImage` / `sendVoice` / `sendVideo` / `sendFile`
|
|
108
|
-
|
|
126
|
+
`sendImage` / `sendVoice` / `sendVideo` / `sendFile` are convenience wrappers
|
|
127
|
+
over `sendMedia`. Sources ≥ 5 MB switch to chunked upload automatically.
|
|
109
128
|
|
|
110
129
|
```ts
|
|
111
130
|
await bot.sendImage(target, { localPath: "/tmp/cat.jpg" });
|
|
@@ -120,7 +139,7 @@ await bot.sendFile(
|
|
|
120
139
|
);
|
|
121
140
|
```
|
|
122
141
|
|
|
123
|
-
### 5. C2C
|
|
142
|
+
### 5. C2C streaming messages
|
|
124
143
|
|
|
125
144
|
```ts
|
|
126
145
|
const stream = bot.openStream({ target });
|
|
@@ -130,19 +149,48 @@ for (const partial of generator) {
|
|
|
130
149
|
await stream.complete();
|
|
131
150
|
```
|
|
132
151
|
|
|
133
|
-
QQ
|
|
152
|
+
QQ Open Platform constraint: `stream_messages` is available for C2C (private chat) only.
|
|
134
153
|
|
|
135
|
-
### 6.
|
|
154
|
+
### 6. Events
|
|
136
155
|
|
|
137
156
|
```ts
|
|
138
157
|
bot.on("ready", () => console.log("connected"));
|
|
139
158
|
bot.on("resumed", () => console.log("reconnected"));
|
|
140
|
-
bot.on("
|
|
159
|
+
bot.on("disconnected", ({ code, willReconnect }) => console.log("closed", code, willReconnect));
|
|
160
|
+
bot.on("error", (err) => console.error(err)); // recoverable failures; never ends start()
|
|
141
161
|
bot.on("message", (ctx, msg) => { /* C2C / Group / Guild / DM */ });
|
|
142
162
|
bot.on("interaction", (ctx, event) => { /* button click etc. */ });
|
|
143
163
|
```
|
|
144
164
|
|
|
145
|
-
### 7.
|
|
165
|
+
### 7. Lifecycle
|
|
166
|
+
|
|
167
|
+
WebSocket mode reconnects forever by default. `start()` resolves on `stop()` /
|
|
168
|
+
abort, and rejects — after releasing the connection and token refresher — only
|
|
169
|
+
when it cannot recover:
|
|
170
|
+
|
|
171
|
+
| Rejection | Cause | Handling |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `GatewayError` `GATEWAY_FATAL_CLOSE` | 4914 offline / sandbox-only, 4915 banned | Needs operator action; don't restart |
|
|
174
|
+
| `GatewayError` `GATEWAY_RETRY_EXHAUSTED` | Only with a finite `reconnect.maxAttempts` | Restart with backoff |
|
|
175
|
+
| `Error` | Startup token fetch failed (default `tokenPrefetch: "sync"`) | Check credentials / network |
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { GatewayErrorCode, QQBot } from "@tencent-connect/qqbot-nodejs";
|
|
179
|
+
|
|
180
|
+
// Set a limit only when an outer supervisor owns process-level restarts
|
|
181
|
+
const bot = new QQBot({ appId, appSecret, reconnect: { maxAttempts: 10 } });
|
|
182
|
+
try {
|
|
183
|
+
await bot.start(signal);
|
|
184
|
+
} catch (err) {
|
|
185
|
+
if ((err as { code?: string }).code === GatewayErrorCode.FATAL_CLOSE) markBlocked(err);
|
|
186
|
+
else scheduleRestart(err);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`bot.stop(); bot.start();` restarts in place. See [USAGE.md §7](./USAGE.md#7-生命周期管理)
|
|
191
|
+
for close-code handling.
|
|
192
|
+
|
|
193
|
+
### 8. Protocol-level access
|
|
146
194
|
|
|
147
195
|
```ts
|
|
148
196
|
import {
|
|
@@ -153,55 +201,88 @@ import {
|
|
|
153
201
|
} from "@tencent-connect/qqbot-nodejs/protocol";
|
|
154
202
|
```
|
|
155
203
|
|
|
156
|
-
##
|
|
204
|
+
## Documentation
|
|
205
|
+
|
|
206
|
+
- **[USAGE.md](./USAGE.md)** — complete usage guide (currently in Chinese;
|
|
207
|
+
contributions to translate are very welcome).
|
|
208
|
+
|
|
209
|
+
## Optional dependencies
|
|
210
|
+
|
|
211
|
+
These `peerDependencies` are declared as optional. Install them only if you
|
|
212
|
+
need the feature:
|
|
213
|
+
|
|
214
|
+
| Package | Enables |
|
|
215
|
+
| ----------------- | ------------------------------------------ |
|
|
216
|
+
| `silk-wasm` | Sending voice messages (SILK encoding) |
|
|
217
|
+
| `mpg123-decoder` | Decoding MP3 audio to PCM before encoding |
|
|
218
|
+
|
|
219
|
+
## Contributing
|
|
220
|
+
|
|
221
|
+
Bug reports, feature proposals and pull requests are welcome. Please read:
|
|
222
|
+
|
|
223
|
+
- [CONTRIBUTING.md](./CONTRIBUTING.md) — dev workflow & commit convention
|
|
224
|
+
- [SECURITY.md](./SECURITY.md) — how to report vulnerabilities privately
|
|
225
|
+
|
|
226
|
+
## Module structure
|
|
157
227
|
|
|
158
228
|
```
|
|
159
229
|
src/
|
|
160
|
-
├── QQBot.ts ←
|
|
161
|
-
├── streaming.ts ← C2C
|
|
162
|
-
├── index.ts ←
|
|
163
|
-
├── middleware/ ← Koa-style
|
|
164
|
-
│ ├── types.ts
|
|
165
|
-
│ ├── error-handler.ts
|
|
166
|
-
│ ├── message-filter.ts
|
|
167
|
-
│ ├── rate-limiter.ts
|
|
168
|
-
│ ├── concurrency-guard.ts
|
|
169
|
-
│ ├── access-policy.ts
|
|
170
|
-
│ ├── content-sanitizer.ts
|
|
171
|
-
│ ├── mention-gate.ts @bot
|
|
172
|
-
│ ├── quote-ref.ts
|
|
173
|
-
│ ├── history-buffer.ts
|
|
174
|
-
│ ├── envelope-formatter.ts LLM prompt
|
|
175
|
-
│ ├── typing-indicator.ts
|
|
176
|
-
│ └── slash-command.ts
|
|
177
|
-
└── protocol/ ←
|
|
230
|
+
├── QQBot.ts ← High-level facade
|
|
231
|
+
├── streaming.ts ← C2C streaming-message controller
|
|
232
|
+
├── index.ts ← Public API
|
|
233
|
+
├── middleware/ ← Koa-style middleware
|
|
234
|
+
│ ├── types.ts Middleware types + onion runner
|
|
235
|
+
│ ├── error-handler.ts Unified error capture
|
|
236
|
+
│ ├── message-filter.ts Echo filtering + dedup
|
|
237
|
+
│ ├── rate-limiter.ts Three-tier rate limiting
|
|
238
|
+
│ ├── concurrency-guard.ts Serial processing per user / group
|
|
239
|
+
│ ├── access-policy.ts Allow / block lists
|
|
240
|
+
│ ├── content-sanitizer.ts Content sanitizing
|
|
241
|
+
│ ├── mention-gate.ts @bot gating
|
|
242
|
+
│ ├── quote-ref.ts Quote resolution + message index
|
|
243
|
+
│ ├── history-buffer.ts Group history buffer
|
|
244
|
+
│ ├── envelope-formatter.ts LLM prompt assembly
|
|
245
|
+
│ ├── typing-indicator.ts Typing state
|
|
246
|
+
│ └── slash-command.ts Command framework
|
|
247
|
+
└── protocol/ ← Protocol layer
|
|
178
248
|
├── api/
|
|
179
|
-
│ ├── api-client.ts HTTP
|
|
180
|
-
│ ├── token.ts access_token
|
|
181
|
-
│ ├── messages.ts
|
|
182
|
-
│ ├── media.ts
|
|
183
|
-
│ ├── media-chunked.ts
|
|
184
|
-
│ ├── retry.ts
|
|
185
|
-
│ └── routes.ts
|
|
249
|
+
│ ├── api-client.ts HTTP client
|
|
250
|
+
│ ├── token.ts access_token management
|
|
251
|
+
│ ├── messages.ts Message sending
|
|
252
|
+
│ ├── media.ts Small-file upload
|
|
253
|
+
│ ├── media-chunked.ts Chunked large-file upload
|
|
254
|
+
│ ├── retry.ts Retry engine
|
|
255
|
+
│ └── routes.ts Route templates
|
|
186
256
|
├── gateway/
|
|
187
257
|
│ ├── constants.ts opcode / intent / close code
|
|
188
|
-
│ ├── codec.ts
|
|
189
|
-
│ ├── reconnect.ts
|
|
190
|
-
│ ├──
|
|
191
|
-
│
|
|
258
|
+
│ ├── codec.ts Message decoding
|
|
259
|
+
│ ├── reconnect.ts Reconnect state machine + reconnect policy
|
|
260
|
+
│ ├── errors.ts GatewayError (terminal start() errors)
|
|
261
|
+
│ ├── event-dispatcher.ts Event → InboundMessage
|
|
262
|
+
│ └── gateway-connection.ts WebSocket lifecycle
|
|
192
263
|
├── transport/
|
|
193
|
-
│ ├── types.ts EventTransport
|
|
194
|
-
│ ├── webhook.ts Webhook
|
|
195
|
-
│ ├── webhook-verify.ts Ed25519
|
|
196
|
-
│ └── webhook-server-node.ts
|
|
264
|
+
│ ├── types.ts EventTransport interface
|
|
265
|
+
│ ├── webhook.ts Webhook transport
|
|
266
|
+
│ ├── webhook-verify.ts Ed25519 signature verification
|
|
267
|
+
│ └── webhook-server-node.ts Built-in node:http adapter
|
|
197
268
|
├── utils/
|
|
198
|
-
│ ├── format.ts
|
|
199
|
-
│ ├── file-utils.ts
|
|
200
|
-
│ └── upload-cache.ts file_info TTL
|
|
201
|
-
├── types.ts
|
|
202
|
-
└── index.ts protocol
|
|
269
|
+
│ ├── format.ts Formatting helpers
|
|
270
|
+
│ ├── file-utils.ts File helpers
|
|
271
|
+
│ └── upload-cache.ts file_info TTL cache
|
|
272
|
+
├── types.ts All public types + errors
|
|
273
|
+
└── index.ts protocol sub-entry
|
|
203
274
|
```
|
|
204
275
|
|
|
276
|
+
## Contributors
|
|
277
|
+
|
|
278
|
+
Thanks to everyone who has contributed to this project!
|
|
279
|
+
|
|
280
|
+
<a href="https://github.com/tencent-connect/qqbot-nodejs/graphs/contributors">
|
|
281
|
+
<img src="https://contrib.rocks/image?repo=tencent-connect/qqbot-nodejs" alt="Contributors" />
|
|
282
|
+
</a>
|
|
283
|
+
|
|
284
|
+
<sub>Contributor avatars are rendered by [contrib.rocks](https://contrib.rocks).</sub>
|
|
285
|
+
|
|
205
286
|
## License
|
|
206
287
|
|
|
207
|
-
MIT
|
|
288
|
+
[MIT](./LICENSE) © Tencent
|