fastqq 0.1.0__tar.gz

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.

Potentially problematic release.


This version of fastqq might be problematic. Click here for more details.

Files changed (47) hide show
  1. fastqq-0.1.0/LICENSE +21 -0
  2. fastqq-0.1.0/MANIFEST.in +6 -0
  3. fastqq-0.1.0/PKG-INFO +515 -0
  4. fastqq-0.1.0/README.md +476 -0
  5. fastqq-0.1.0/examples/ncatbot_test/README.md +164 -0
  6. fastqq-0.1.0/examples/ncatbot_test/config.yaml +28 -0
  7. fastqq-0.1.0/examples/ncatbot_test/plugins/fastqq_test/main.py +89 -0
  8. fastqq-0.1.0/examples/ncatbot_test/plugins/fastqq_test/manifest.toml +12 -0
  9. fastqq-0.1.0/pyproject.toml +83 -0
  10. fastqq-0.1.0/setup.cfg +4 -0
  11. fastqq-0.1.0/src/fastqq/__init__.py +3 -0
  12. fastqq-0.1.0/src/fastqq/__main__.py +4 -0
  13. fastqq-0.1.0/src/fastqq/bot.py +106 -0
  14. fastqq-0.1.0/src/fastqq/cli.py +138 -0
  15. fastqq-0.1.0/src/fastqq/config.py +280 -0
  16. fastqq-0.1.0/src/fastqq/contacts.py +198 -0
  17. fastqq-0.1.0/src/fastqq/engine.py +394 -0
  18. fastqq-0.1.0/src/fastqq/errors.py +10 -0
  19. fastqq-0.1.0/src/fastqq/gateway.py +298 -0
  20. fastqq-0.1.0/src/fastqq/log.py +69 -0
  21. fastqq-0.1.0/src/fastqq/onebot/__init__.py +1 -0
  22. fastqq-0.1.0/src/fastqq/onebot/api.py +206 -0
  23. fastqq-0.1.0/src/fastqq/onebot/events.py +83 -0
  24. fastqq-0.1.0/src/fastqq/onebot/message.py +211 -0
  25. fastqq-0.1.0/src/fastqq/py.typed +0 -0
  26. fastqq-0.1.0/src/fastqq/tools/__init__.py +1 -0
  27. fastqq-0.1.0/src/fastqq/tools/inspect_ntqq.py +297 -0
  28. fastqq-0.1.0/src/fastqq/uia/__init__.py +1 -0
  29. fastqq-0.1.0/src/fastqq/uia/client.py +973 -0
  30. fastqq-0.1.0/src/fastqq/uia/clipboard.py +55 -0
  31. fastqq-0.1.0/src/fastqq/uia/selectors.py +120 -0
  32. fastqq-0.1.0/src/fastqq/uia/win32.py +106 -0
  33. fastqq-0.1.0/src/fastqq.egg-info/PKG-INFO +515 -0
  34. fastqq-0.1.0/src/fastqq.egg-info/SOURCES.txt +45 -0
  35. fastqq-0.1.0/src/fastqq.egg-info/dependency_links.txt +1 -0
  36. fastqq-0.1.0/src/fastqq.egg-info/entry_points.txt +2 -0
  37. fastqq-0.1.0/src/fastqq.egg-info/requires.txt +11 -0
  38. fastqq-0.1.0/src/fastqq.egg-info/top_level.txt +1 -0
  39. fastqq-0.1.0/tests/conftest.py +88 -0
  40. fastqq-0.1.0/tests/test_api.py +182 -0
  41. fastqq-0.1.0/tests/test_cli.py +56 -0
  42. fastqq-0.1.0/tests/test_contacts.py +52 -0
  43. fastqq-0.1.0/tests/test_engine.py +141 -0
  44. fastqq-0.1.0/tests/test_gateway.py +199 -0
  45. fastqq-0.1.0/tests/test_message.py +104 -0
  46. fastqq-0.1.0/tests/test_token_config.py +123 -0
  47. fastqq-0.1.0/tests/test_uia_parser.py +163 -0
fastqq-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zetsr
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.
@@ -0,0 +1,6 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include examples *
5
+ recursive-include tests *.py
6
+ global-exclude __pycache__ *.py[cod]
fastqq-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,515 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastqq
3
+ Version: 0.1.0
4
+ Summary: Zero-injection QQNT desktop gateway exposing a strict OneBot v11 WebSocket API through Windows UI Automation.
5
+ Author: zetsr
6
+ Maintainer: zetsr
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://gitlab.com/zetsr/fastqq
9
+ Project-URL: Repository, https://gitlab.com/zetsr/fastqq
10
+ Project-URL: Issues, https://gitlab.com/zetsr/fastqq/-/issues
11
+ Project-URL: Source, https://gitlab.com/zetsr/fastqq
12
+ Keywords: qq,qqnt,onebot,onebot11,uiautomation,windows,ncatbot
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Win32 (MS Windows)
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Communications :: Chat
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: uiautomation>=2.0.20
29
+ Requires-Dist: websockets<18,>=14
30
+ Requires-Dist: pywin32>=306
31
+ Requires-Dist: PyYAML>=6.0
32
+ Requires-Dist: pydantic>=2.6
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=8; extra == "dev"
35
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
36
+ Requires-Dist: build>=1.2; extra == "dev"
37
+ Requires-Dist: twine>=5; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # FastQQ
41
+
42
+ **FastQQ** is a zero-injection, black-box QQNT desktop gateway for Windows. It
43
+ drives a normal, already-logged-in **Windows QQNT** client through
44
+ **Windows UI Automation (UIA)** and exposes a strict **OneBot v11** WebSocket
45
+ interface for downstream frameworks such as [`ncatbot`](https://github.com/ncatbot/NcatBot).
46
+
47
+ - Repository: <https://gitlab.com/zetsr/fastqq>
48
+ - PyPI package: `fastqq`
49
+ - Author / maintainer: **zetsr**
50
+ - Tested QQNT: **9.9.37-54395** on Windows, zh-CN, Chromium/Electron UI
51
+ - License: MIT
52
+
53
+ FastQQ does **not** inject a DLL into QQ, patch QQ, read its databases, or
54
+ speak QQ's private protocol. It reads the accessibility tree and performs
55
+ ordinary keyboard/clipboard operations on the foreground QQNT window.
56
+
57
+ > FastQQ is an independent project, not affiliated with Tencent. Use it only
58
+ > with accounts and machines you are authorized to automate.
59
+
60
+ ---
61
+
62
+ ## 1. Scope (core MVP)
63
+
64
+ Supported:
65
+
66
+ - Receive private text messages (`private` message events).
67
+ - Receive group text messages (`group` message events; @ mentions are mapped to
68
+ OneBot `at` segments when the member's numeric id is known).
69
+ - Send private text messages.
70
+ - Send group text messages.
71
+ - Send real QQ **@ capsules** by typing `@`, filtering the member picker by the
72
+ target's numeric QQ number, and pressing Enter. `qq="all"` uses the
73
+ `全体成员` picker row.
74
+ - OneBot v11 forward WebSocket server and reverse WebSocket client, separately
75
+ or simultaneously.
76
+ - Bearer token / `access_token` authentication, lifecycle events, heartbeats,
77
+ echo-preserving API responses, and the `SUSPENDED` offline state machine.
78
+
79
+ Deliberately **not** implemented:
80
+
81
+ - Images, files, voice, video, stickers, poke, recall.
82
+ - Group administration (kick, mute, approve).
83
+ - HTTP API, webhook, SSE.
84
+ - Auto-dismissing QQ update dialogs or auto-hanging-up voice calls.
85
+ - Linux/macOS or old (non-NT) QQ.
86
+
87
+ The project intentionally stays small: one UIA engine, one WebSocket transport,
88
+ one protocol adapter.
89
+
90
+ ---
91
+
92
+ ## 2. How it works
93
+
94
+ ```
95
+ QQNT (normal Windows client, logged in)
96
+ │ UIA tree + keyboard/clipboard
97
+ ▼
98
+ ┌─────────────── FastQQ ───────────────┐
99
+ │ QQClient (blocking UIA worker) │
100
+ │ ├─ enumerate QQ Chromium windows │
101
+ │ ├─ session list / unread badges │
102
+ │ ├─ chat header, message list │
103
+ │ └─ editor, @ member picker │
104
+ │ │
105
+ │ UIAEngine (80–150 ms tick + diff) │
106
+ │ ├─ retained snapshots │
107
+ │ ├─ ONLINE / SUSPENDED │
108
+ │ └─ asyncio.Lock (all UI actions) │
109
+ │ │
110
+ │ OneBot v11 gateway │
111
+ │ ├─ forward WS server │
112
+ │ ├─ reverse WS client │
113
+ │ ├─ lifecycle + heartbeat │
114
+ │ └─ action router + echo fallback │
115
+ └──────────────────────────────────────┘
116
+ │ forward WS / reverse WS
117
+ ▼
118
+ ncatbot / another OneBot v11 client
119
+ ```
120
+
121
+ The poller is deliberately **retained and stateless internally**: each tick
122
+ re-reads the current UIA tree as the single source of truth, compares it with
123
+ the previous frame, and emits the difference. It does not rely on UIA event
124
+ callbacks, which are easily missed during QQNT list re-rendering.
125
+
126
+ All UI work runs on one dedicated COM/UIA thread. A single `asyncio.Lock`
127
+ serializes session switching, reading, clipboard use, search and sending, so
128
+ incoming scans cannot steal the editor from an outgoing action.
129
+
130
+ ---
131
+
132
+ ## 3. Requirements
133
+
134
+ - Windows 10/11 x64 with an **interactive, logged-in desktop session**.
135
+ - Standard Windows QQNT, logged in. FastQQ must run in the **same user
136
+ session** as QQNT.
137
+ - Python **3.10+** (tested with 3.14).
138
+ - QQNT must expose its Chromium accessibility tree. FastQQ restores a minimized
139
+ main window when needed. A locked screen, disconnected RDP session, or
140
+ Windows service/session-0 context will prevent UIA and keyboard input from
141
+ working; this is a platform limitation, not a protocol feature.
142
+
143
+ Install:
144
+
145
+ ```powershell
146
+ pip install fastqq
147
+ ```
148
+
149
+ For development from this repository:
150
+
151
+ ```powershell
152
+ python -m venv .venv
153
+ .\.venv\Scripts\pip install -e ".[dev]"
154
+ ```
155
+
156
+ ---
157
+
158
+ ## 4. Quick start
159
+
160
+ ### 4.1 Create a config
161
+
162
+ ```powershell
163
+ cd C:\path\to\empty\bot-dir
164
+ fastqq init
165
+ ```
166
+
167
+ `fastqq init` writes:
168
+
169
+ - `config.yaml`
170
+ - `contacts_cache.json`
171
+ - a fresh **16-character** `ws_token` containing uppercase, lowercase, digits
172
+ and URL/YAML-safe symbols (`!@$^*_-~.`).
173
+
174
+ ### 4.2 Edit `config.yaml`
175
+
176
+ Set at least:
177
+
178
+ ```yaml
179
+ bot_uin: 1573213 # your bot QQ number
180
+ nickname: "Kiana" # optional
181
+ ws_token: "already-generated"
182
+ forward_ws:
183
+ enabled: true
184
+ host: 0.0.0.0
185
+ port: 3001
186
+ path: /onebot/v11/ws
187
+ ```
188
+
189
+ Then:
190
+
191
+ ```powershell
192
+ fastqq run
193
+ ```
194
+
195
+ `fastqq run` refuses to start if `bot_uin` is still `0` or `ws_token` is empty.
196
+ Use `fastqq run --log-level DEBUG` while diagnosing selectors.
197
+
198
+ ### 4.3 Inspect the live UI tree
199
+
200
+ If QQNT changes and selectors stop matching:
201
+
202
+ ```powershell
203
+ fastqq inspect
204
+ ```
205
+
206
+ This writes `uia_dump.txt` in the current directory with the real
207
+ `ControlTypeName`, `Name`, `ClassName`, `AutomationId`, value/text and bounding
208
+ rectangle of every QQNT UIA node. It is read-only. Add any new selector to
209
+ `src/fastqq/uia/selectors.py` together with the QQNT version comment; do not
210
+ guess.
211
+
212
+ ---
213
+
214
+ ## 5. Configuration reference
215
+
216
+ ```yaml
217
+ bot_uin: 1573213
218
+ nickname: "Kiana"
219
+ ws_token: "Abc123!@$^*_-~."
220
+ heartbeat_interval: 5.0
221
+
222
+ forward_ws: # FastQQ is the WebSocket server
223
+ enabled: true
224
+ host: 0.0.0.0
225
+ port: 3001
226
+ path: /onebot/v11/ws
227
+
228
+ reverse_ws: # FastQQ is the WebSocket client
229
+ enabled: false
230
+ url: "ws://203.0.113.10:3001/onebot/v11/ws"
231
+ reconnect_interval: 5.0
232
+
233
+ offline:
234
+ notify_downstream: false # default: stay silent
235
+ keep_ws_alive: true # default: never drop the socket
236
+ poll_interval: 2.0 # suspended-state retry interval
237
+
238
+ engine:
239
+ tick_interval: 0.12 # 80–150 ms recommended
240
+ send_timeout: 10.0
241
+ switch_timeout: 3.0
242
+ max_messages_per_scan: 50
243
+
244
+ contacts_cache: contacts_cache.json
245
+
246
+ # UIA exposes display names, not numeric ids, for most surfaces.
247
+ # Bind names to numbers here for reliable receive-side ids.
248
+ session_map:
249
+ groups:
250
+ "123456789": "My test group"
251
+ users:
252
+ "1573213": "Kiana"
253
+ "1620737": "Neth3"
254
+ ```
255
+
256
+ Forward WebSocket paths accepted: `/`, `/onebot/v11/ws`, and the configured
257
+ `forward_ws.path`. Authentication accepts either:
258
+
259
+ ```http
260
+ Authorization: Bearer <ws_token>
261
+ ```
262
+
263
+ or:
264
+
265
+ ```text
266
+ ws://host:3001/onebot/v11/ws?access_token=<ws_token>
267
+ ```
268
+
269
+ A bad token or path closes the socket with code `1008`.
270
+
271
+ ---
272
+
273
+ ## 6. Identity mapping (important)
274
+
275
+ OneBot requires integer `group_id` / `user_id`; QQNT's UIA tree usually exposes
276
+ only display names. FastQQ handles this as follows:
277
+
278
+ 1. `session_map` in `config.yaml` supplies manual numeric bindings.
279
+ 2. Sending to a numeric id uses QQ's global search box. The exact result row is
280
+ verified as containing `(<id>)`; after opening it, FastQQ learns the
281
+ `display name <-> id` pair and persists it to `contacts_cache.json`.
282
+ 3. On receive, FastQQ looks up the active chat title (`group`) or sender
283
+ nickname (`private`) in the cache.
284
+
285
+ If an id is unknown, FastQQ **drops that event and logs a warning** rather than
286
+ inventing a hash or using `0`. An incorrect `user_id` would be worse than a
287
+ dropped event. To receive from a session before sending to it, add it to
288
+ `session_map`.
289
+
290
+ Group members are harder: QQNT does not expose every member's QQ number. A
291
+ group message from a member whose nickname is not mapped is therefore dropped
292
+ with a warning until you add that nickname/id under `session_map.users`. The
293
+ @ picker uses the numeric QQ number directly and is not affected by this
294
+ limitation.
295
+
296
+ The cache file is ignored by Git and must not be committed; it contains real
297
+ contact names.
298
+
299
+ ---
300
+
301
+ ## 7. OneBot v11 behavior
302
+
303
+ ### 7.1 Events
304
+
305
+ On each connection FastQQ sends:
306
+
307
+ ```json
308
+ {"time":1700000000,"self_id":123456789,"post_type":"meta_event","meta_event_type":"lifecycle","sub_type":"connect"}
309
+ ```
310
+
311
+ Heartbeats are sent every `heartbeat_interval` seconds:
312
+
313
+ ```json
314
+ {"time":1700000000,"self_id":123456789,"post_type":"meta_event","meta_event_type":"heartbeat","status":{"online":true,"good":true},"interval":5000}
315
+ ```
316
+
317
+ Message events use `message_format: "array"` and include `raw_message`. Example:
318
+
319
+ ```json
320
+ {
321
+ "time": 1700000000,
322
+ "self_id": 123456789,
323
+ "post_type": "message",
324
+ "message_type": "group",
325
+ "sub_type": "normal",
326
+ "message_id": 7713925890446905169,
327
+ "group_id": 123456789,
328
+ "user_id": 987654321,
329
+ "message": [{"type": "at", "data": {"qq": "987654321"}}, {"type": "text", "data": {"text": " hello"}}],
330
+ "raw_message": "[CQ:at,qq=987654321] hello",
331
+ "font": 0,
332
+ "message_format": "array",
333
+ "sender": {"user_id": 987654321, "nickname": "Alice", "card": "Alice"}
334
+ }
335
+ ```
336
+
337
+ Outgoing text and at segments are supported. Strings may contain CQ codes:
338
+
339
+ ```json
340
+ {"action":"send_group_msg","params":{"group_id":123456789,"message":"[CQ:at,qq=987654321] hi"},"echo":"1"}
341
+ ```
342
+
343
+ `auto_escape: true` disables CQ parsing for a string message.
344
+
345
+ ncatbot's default `event.reply()` prepends a OneBot `reply` segment. FastQQ's
346
+ MVP does not implement quoted replies, so it **ignores `reply` segments** and
347
+ still delivers the text/@ portion. This keeps ncatbot replies working instead
348
+ of failing the whole action. Images, files, voice and other unsupported segment
349
+ types are still rejected explicitly.
350
+
351
+ ### 7.2 Actions
352
+
353
+ | Action | Behavior |
354
+ |---|---|
355
+ | `send_msg` | infer `group_id` / `user_id`, then send |
356
+ | `send_group_msg` | send group text / @ |
357
+ | `send_private_msg` | send private text (at rejected) |
358
+ | `get_login_info` | configured `bot_uin` and nickname |
359
+ | `get_version_info` | `app_name: fastqq`, `protocol_version: v11` |
360
+ | `get_status` | `{"online": true, "good": true}` (silent suspended mode stays true) |
361
+ | `get_group_list` | known cache entries or `[]` |
362
+ | `get_friend_list` | known cache entries or `[]` |
363
+ | `can_send_image` | `{"yes": false}` |
364
+ | `can_send_record` | `{"yes": false}` |
365
+
366
+ Any unsupported action returns:
367
+
368
+ ```json
369
+ {"status":"failed","retcode":1404,"data":null,"message":"Unsupported action in FastQQ UIA MVP","echo":"..."}
370
+ ```
371
+
372
+ If a request contains `echo` — including `0`, `null`, an object, or an array —
373
+ the response returns the **same** `echo` value. This is what keeps ncatbot
374
+ futures from hanging. Malformed JSON has no echo to preserve and returns
375
+ `retcode: 1400`.
376
+
377
+ Successful sends return:
378
+
379
+ ```json
380
+ {"status":"ok","retcode":0,"data":{"message_id":1234567890123},"message":"","echo":"..."}
381
+ ```
382
+
383
+ `message_id` is the observed QQNT message-list automation id; if QQNT has not
384
+ rendered the row before the timeout, FastQQ falls back to a millisecond
385
+ timestamp (still an integer). The message itself was already sent at that
386
+ point.
387
+
388
+ ### 7.3 Suspended / offline behavior
389
+
390
+ If the QQNT main window, session list or chat surface disappears (QQ closed,
391
+ logged out, kicked offline, or a modal offline dialog blocks the UI), FastQQ
392
+ **does not exit**. It enters `SUSPENDED` and retries every
393
+ `offline.poll_interval` seconds.
394
+
395
+ With the default `notify_downstream: false`:
396
+
397
+ - no `lifecycle:disable` event is emitted;
398
+ - the WebSocket is **not** disconnected;
399
+ - heartbeats continue with `{"online": true, "good": true}`;
400
+ - send actions return exactly:
401
+
402
+ ```json
403
+ {"status":"failed","retcode":-1,"data":null,"message":"QQNT is temporarily offline (suspended)","echo":"..."}
404
+ ```
405
+
406
+ This prevents ncatbot from committing suicide just because QQNT is
407
+ reconnecting. Set `notify_downstream: true` only if your downstream explicitly
408
+ wants lifecycle disable/enable events; `keep_ws_alive: false` additionally
409
+ closes sockets during a notified offline period.
410
+
411
+ ---
412
+
413
+ ## 8. ncatbot manual interoperability test
414
+
415
+ Ready-to-copy files are in
416
+ [`examples/ncatbot_test/`](https://gitlab.com/zetsr/fastqq/-/tree/main/examples/ncatbot_test).
417
+ The example targets **ncatbot 5**, whose normal NapCat adapter is a WebSocket
418
+ **client**. Therefore use FastQQ's **forward** server; "Connect mode" in
419
+ ncatbot means `skip_setup: true`, not a server mode.
420
+
421
+ On the ncatbot machine:
422
+
423
+ ```text
424
+ examples/ncatbot_test/
425
+ ├── config.yaml
426
+ ├── README.md
427
+ └── plugins/
428
+ └── fastqq_test/
429
+ ├── manifest.toml
430
+ └── main.py
431
+ ```
432
+
433
+ Set the public IPv4 of the FastQQ Windows machine, the FastQQ port and the same
434
+ `ws_token`, then run `ncatbot run`. The plugin implements:
435
+
436
+ - private `/ping` -> `pong (private)`
437
+ - group `/ping` -> `pong (group)`
438
+ - group `/at` -> reply while @-mentioning the sender
439
+ - group `/send <qq> <content>` -> proactive private message API call
440
+ - group `/fastqq help` -> command summary
441
+
442
+ See
443
+ [`examples/ncatbot_test/README.md`](https://gitlab.com/zetsr/fastqq/-/blob/main/examples/ncatbot_test/README.md)
444
+ for the full procedure and networking notes.
445
+
446
+ FastQQ's reverse WebSocket mode is for a downstream that itself listens as a
447
+ OneBot v11 server. ncatbot 5 does not expose that server mode, so do not point
448
+ FastQQ's reverse URL at ncatbot.
449
+
450
+ ---
451
+
452
+ ## 9. Security and operations
453
+
454
+ - Set a non-empty `ws_token`; `fastqq init` generates one.
455
+ - Prefer a private network / VPN / firewall allowlist. Exposing port 3001 to
456
+ `0.0.0.0` on the public Internet grants message-sending authority to anyone
457
+ with the token.
458
+ - `config.yaml`, `contacts_cache.json`, `uia_dump.txt` and `.pypirc` are in
459
+ `.gitignore`.
460
+ - FastQQ uses the clipboard and foreground keyboard. Run it on a dedicated,
461
+ unattended desktop; do not fight a human user for focus.
462
+ - FastQQ does not restore the previous clipboard (intentionally, to keep the
463
+ MVP small). Avoid copying secrets while a send is in progress.
464
+ - Do not send test messages to random contacts or real work groups. Use your
465
+ own account / a dedicated test friend or group.
466
+
467
+ ---
468
+
469
+ ## 10. Development and tests
470
+
471
+ ```powershell
472
+ python -m pip install -e ".[dev]"
473
+ python -m pytest -q
474
+ python -m compileall -q src
475
+ python -m build
476
+ twine check dist/*
477
+ ```
478
+
479
+ The test suite covers:
480
+
481
+ - 16-character strong-token rules and config generation;
482
+ - CQ / message-array / @ parsing and unsupported-segment rejection;
483
+ - echo preservation (including `0`, `null`, objects) and the 1404 fallback;
484
+ - forward and reverse WebSocket handshakes, auth, `X-Self-ID`,
485
+ `X-Client-Role`, lifecycle and heartbeat;
486
+ - `ONLINE <-> SUSPENDED` transitions and silent offline behavior;
487
+ - contact cache persistence;
488
+ - live-QQNT selector parsing helpers.
489
+
490
+ Live UIA tests are deliberately read-only unless a safe target is configured.
491
+ The author's live verification used only the bot's own account and a controlled
492
+ second account; no messages were sent to unrelated contacts or groups.
493
+
494
+ ---
495
+
496
+ ## 11. Troubleshooting
497
+
498
+ | Symptom | Check |
499
+ |---|---|
500
+ | `QQNT main window / session list is not accessible` | QQNT is running, logged in, not locked; run `fastqq inspect` |
501
+ | `the QQNT session list is not visible` | QQNT is on the message page, not a modal dialog |
502
+ | `QQNT global search box is not available` | main window restored / accessible |
503
+ | `no numeric id is known for ...` | add the name to `session_map` or send to that id once |
504
+ | `the @ picker did not return a member` | QQ group member list is available; try the numeric QQ |
505
+ | ncatbot hangs forever | confirm FastQQ returns the same `echo`; run with `--log-level DEBUG` |
506
+ | ncatbot exits on QQNT reconnect | `offline.notify_downstream` must be `false` (default) |
507
+ | QQNT updated and selectors break | `fastqq inspect`, update `selectors.py` with the new real values |
508
+
509
+ ---
510
+
511
+ ## 12. Repository
512
+
513
+ GitLab: <https://gitlab.com/zetsr/fastqq>
514
+
515
+ All development happens on GitLab. No GitHub mirror is maintained.