feat(onebot): support replies to Qzone comments

Add threaded text replies while preserving existing comments and image
uploads. Include parent references and update SDK and MCP contracts.
Reject incomplete targets and unsupported reply images before sending.

Fixes #573
This commit is contained in:
DrSmoothl committed 2026-10-24 21:54:38 +08:00
1 parent dc2d60e57f
commit d95d3bf761
14 files changed
+892 -16

No files matched your search

+23
View File
@@ -99,3 +99,26 @@ try {
Waits register synchronously and do not connect, replay history, consume events from other listeners, or persist across reconnects. They observe the same public event stream as `onEvent`, **after middleware**; events stopped by middleware are not visible. `waitForMessage` includes both `message` and `message_sent`, so filter direction, conversation, and sender when needed. Multiple waits can resolve from the same event.
The default timeout is the client's `requestTimeoutMs` (30 seconds by default); `0` disables it. Timeout rejects with `SnowLumaTimeoutError`, cancellation with `SnowLumaAbortError`, and disconnect or explicit `close()` with `SnowLumaConnectionError`. Predicate exceptions reject with their original error. Every completion path removes its listener, abort handler, and timer. Cancellation affects the wait only; it does not close the client or undo a sent message.
## Reply to a Qzone comment
Both clients expose this through the typed `raw('comment_qzone', params)` action. Omitting `comment_id` and `comment_uin` preserves ordinary comments, including image uploads. `target_uin` always identifies the **post owner**, not the person being replied to.
Read `get_qzone_msg_detail` to obtain a parent comment's `comment_id` and `uin`. Pass both to create a text reply under that comment; `"0"` is a valid comment ID. To address someone inside the thread, also pass their `uin` and `name` as `reply_uin` and `reply_name`:
```ts
const result = await bot.raw('comment_qzone', {
tid: post.tid,
target_uin: postOwnerUin,
comment_id: parentComment.comment_id,
comment_uin: parentComment.uin,
reply_uin: selectedReply.uin,
reply_name: selectedReply.name,
content: 'Thanks for the explanation!',
});
console.log(result.comment_id, result.parent_comment_id);
```
`post`, `postOwnerUin`, `parentComment` and `selectedReply` above are the post and comments chosen by the caller. For an ordinary reply to the parent, omit `reply_uin` and `reply_name`. For a nested reply, keep the **top-level parent** in `comment_id`/`comment_uin`; do not substitute the nested reply's own ID. New servers also include `parent_comment_id` and `parent_comment_uin` on each inline reply to preserve this association. Inline replies may be incomplete; absence from a page does not mean a comment was deleted.
On success, `comment_id` is the **new reply's** ID and the result includes its parent ID and author. Those parent fields are optional in SDK types for compatibility with older servers. Non-empty `images` with a parent comment are rejected before upload: threaded replies currently support text only. Incomplete recipient/parent parameters are errors, and a failed reply never falls back to an ordinary comment or retries automatically. If an acknowledgement is malformed after sending, check the thread before retrying; the reply may already exist.
+10
View File
@@ -606,7 +606,17 @@ export interface LikeQzoneParams extends QzoneMsgIdParams {
export interface CommentQzoneParams extends QzoneMsgIdParams {
content: ActionStringInput;
/** Post owner, not the author being replied to. Defaults to the current account. */
target_uin?: ActionNumberInput;
/** Top-level parent ID, including "0". Requires comment_uin; omit for an ordinary comment. */
comment_id?: ActionStringInput;
/** Parent comment author from get_qzone_msg_detail. Requires comment_id. */
comment_uin?: ActionNumberInput;
/** Author to address inside the parent thread. Requires reply_name and a parent comment. */
reply_uin?: ActionNumberInput;
/** Addressed author's name from comment details. Requires reply_uin. */
reply_name?: ActionStringInput;
/** Ordinary comments only; non-empty images with comment_id are rejected before upload. */
images?: ActionStringInput[];
}
+7 -1
View File
@@ -8,6 +8,9 @@ export interface QzoneCommentReply {
content: string;
/** Scoped to the post, or parent comment for replies. */
comment_id: string;
/** Present on nested replies from newer servers; identifies their top-level parent. */
parent_comment_id?: string;
parent_comment_uin?: number;
}
export interface QzoneComment extends QzoneCommentReply {
@@ -413,8 +416,11 @@ export interface QzonePublishResult extends JsonObject {
}
export interface QzoneCommentResult extends JsonObject {
/** Empty string when the upstream response omits the new comment ID. */
/** New comment/reply ID. Ordinary comments may return an empty string if upstream omits it. */
comment_id: string;
/** Present when creating a nested reply, distinct from its new comment_id. */
parent_comment_id?: string;
parent_comment_uin?: number;
}
export interface QzoneUpdateRightResult extends JsonObject {
+10 -1
View File
@@ -16,7 +16,16 @@ export const actionParams = {
add_custom_face: { file: 'file:///fixture.png' },
cancel_group_album_media_like: mediaLike,
clean_stream_temp_file: {},
comment_qzone: { tid: 'post', content: 'Comment', target_uin: '10002', images: [] },
comment_qzone: {
tid: 'post',
content: 'Comment',
target_uin: '10002',
images: [],
comment_id: '0',
comment_uin: '10003',
reply_uin: '10004',
reply_name: 'Reader',
},
create_flash_task: {
files: ['file:///one', { file: 'file:///two', name: 'two.txt' }],
name: 'Files',
+10
View File
@@ -69,6 +69,16 @@ ws.downloadFileStream({});
const feeds = await http.raw('get_qzone_feeds', { page_num: '2', count: 10 });
const more: boolean = feeds.has_more;
const author: number = feeds.feeds[0].uin;
const qzoneReply = await http.raw('comment_qzone', actionParams.comment_qzone);
export const qzoneReplyId: string = qzoneReply.comment_id;
export const qzoneParentId: string | undefined = qzoneReply.parent_comment_id;
export const qzoneParentUin: number | undefined = qzoneReply.parent_comment_uin;
export const legacyQzoneComment: ActionParams<'comment_qzone'> = {
tid: 'post',
content: 'Comment',
images: ['https://example.com/image.png'],
};
export const legacyQzoneResult: ActionResult<'comment_qzone'> = { comment_id: '' };
const speech = await ws.raw('get_record_text', { message_id: -42 });
const transcription: string = speech.text;
const flash = await http.raw('get_fileset_info', { fileset_id: 'files' });