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

+49
View File
@@ -290,4 +290,53 @@ describe('apis/qzone', () => {
richval,
);
});
it.each([undefined, 20002])(
'routes replies with the account cookies and post owner (%s)',
async (targetUin) => {
const getCookies = vi.fn(async () => ({ p_skey: 'PSK' }));
const bridge = mockBridge({ apis: { ...mockApiHub(), web: { getCookies } } as never });
const target = {
commentId: '0',
commentUin: '30003',
replyTo: { uin: '40004', name: 'Reader' },
};
const result = { comment_id: '8', parent_comment_id: '0', parent_comment_uin: 30003 };
const replySpy = vi.spyOn(qzoneWeb, 'replyQzoneComment').mockResolvedValue(result);
const commentSpy = vi.spyOn(qzoneWeb, 'commentQzoneMsg');
const out = await new QzoneApi(bridge as never).comment(
'TIDX',
'Reply',
targetUin,
undefined,
undefined,
target,
);
expect(out).toEqual(result);
expect(getCookies).toHaveBeenCalledWith('qzone.qq.com');
expect(replySpy).toHaveBeenCalledWith(
{ p_skey: 'PSK' },
'10001',
String(targetUin ?? 10001),
'TIDX',
'Reply',
target,
);
expect(commentSpy).not.toHaveBeenCalled();
},
);
it('rejects reply images before acquiring cookies or sending', async () => {
const getCookies = vi.fn();
const bridge = mockBridge({ apis: { ...mockApiHub(), web: { getCookies } } as never });
await expect(
new QzoneApi(bridge as never).comment('TIDX', 'Reply', undefined, 1, 'URL', {
commentId: '0',
commentUin: '30003',
}),
).rejects.toThrow('images are not supported');
expect(getCookies).not.toHaveBeenCalled();
});
});