feat(onebot): add structured Qzone feeds and cursor pagination

Expose readable feed content, media and available statistics while preserving existing result fields and callers. Carry continuation state across pages and report invalid or stalled pagination explicitly.
This commit is contained in:
DrSmoothl committed 2026-10-24 22:16:06 +08:00
1 parent d95d3bf761
commit 9bf4b9107b
19 files changed
+1287 -120

No files matched your search

+4 -4
View File
@@ -11,7 +11,7 @@ import {
updateQzoneMsgRight,
uploadQzoneImageFromSource,
type QzoneCommentResult,
type QzoneFeedsResult,
type QzoneFeedsPage,
type QzoneMsgDetailResult,
type QzoneMsgListResult,
type QzonePublishResult,
@@ -53,12 +53,12 @@ export class QzoneApi {
}
/**
* 获取好友动态(feed)。`pageNum` 为 1 起的页码,`count` 为本页数量。
* 获取好友动态。页码调用从首页顺序定位;续页优先传上一页的 cursor。
* 始终以机器人自己的身份拉取好友动态。
*/
async getFeeds(pageNum = 1, count = 10): Promise<QzoneFeedsResult> {
async getFeeds(pageNum = 1, count = 10, cursor?: string): Promise<QzoneFeedsPage> {
const cookieObject = await this.ctx.apis.web.getCookies('qzone.qq.com');
return getQzoneFeeds(cookieObject, this.ctx.identity.uin, pageNum, count);
return getQzoneFeeds(cookieObject, this.ctx.identity.uin, pageNum, count, cursor);
}
/**
+10 -2
View File
@@ -77,10 +77,18 @@ describe('apis/qzone', () => {
const bridge = mockBridge({ apis: { ...mockApiHub(), web: { getCookies } } as never });
const feedsSpy = vi
.spyOn(qzoneWeb, 'getQzoneFeeds')
.mockResolvedValue({ feeds: [], has_more: false });
.mockResolvedValue({ feeds: [], has_more: false, next_cursor: null });
await new QzoneApi(bridge as never).getFeeds(3, 20);
expect(getCookies).toHaveBeenCalledWith('qzone.qq.com');
expect(feedsSpy).toHaveBeenCalledWith({ p_skey: 'PSK' }, '10001', 3, 20);
expect(feedsSpy).toHaveBeenCalledWith({ p_skey: 'PSK' }, '10001', 3, 20, undefined);
await new QzoneApi(bridge as never).getFeeds(1, 20, 'opaque-cursor');
expect(feedsSpy).toHaveBeenLastCalledWith(
{ p_skey: 'PSK' },
'10001',
1,
20,
'opaque-cursor',
);
});
it('uploadImageFromSource uploads from file:// http:// base64:// and returns richval + url', async () => {