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:
19 files changed
+1287
-120
No files matched your search
@@ -122,3 +122,45 @@ 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.
|
||||
|
||||
## Read structured Qzone friend feeds
|
||||
|
||||
`get_qzone_feeds` retains `page_num`, `count`, `feeds`, `has_more`, and each feed's
|
||||
original `html`. Newer servers also return `tid`, `content`, `content_complete`,
|
||||
`images`, `like_count`, and `comment_count`. A `null` value means the source did
|
||||
not establish that field; it does not mean zero or an empty post. A collapsed
|
||||
excerpt has `content_complete: false`. Images cover only pictures available in
|
||||
the post body, excluding avatars, comment pictures and video covers; they are
|
||||
not a complete album listing. Non-post feed types may have no `tid`.
|
||||
|
||||
Use the returned `next_cursor` unchanged to continue on the same account:
|
||||
|
||||
```ts
|
||||
let cursor: string | undefined;
|
||||
while (true) {
|
||||
const page = await bot.raw('get_qzone_feeds', { count: 10, cursor });
|
||||
for (const feed of page.feeds) {
|
||||
console.log(feed.content, feed.images);
|
||||
}
|
||||
if (!page.has_more) {
|
||||
break;
|
||||
}
|
||||
if (!page.next_cursor) {
|
||||
throw new Error('This server did not provide a continuation cursor');
|
||||
}
|
||||
cursor = page.next_cursor;
|
||||
}
|
||||
```
|
||||
|
||||
Omit `page_num` when using a cursor, or supply its corresponding page number.
|
||||
Without a cursor, requesting a later `page_num` walks earlier pages from the
|
||||
beginning and can take longer; requesting beyond the end returns an empty page.
|
||||
The service may return fewer entries than `count`, including empty intermediate
|
||||
pages with a continuation. Follow `has_more` and `next_cursor`, not array length.
|
||||
Invalid, foreign-account or stalled cursors fail visibly. Results reflect a live
|
||||
feed, not a frozen snapshot; posts may change between requests.
|
||||
|
||||
The added result fields are optional in SDK types so older servers and existing
|
||||
consumer-created result objects remain supported. MCP discovers the same fields
|
||||
and cursor examples through `get_action` and calls this read-only action through
|
||||
`query_action`; its existing mode restrictions are unchanged.
|
||||
@@ -570,9 +570,11 @@ export interface GetQzoneMsgListParams extends JsonObject {
|
||||
}
|
||||
|
||||
export interface GetQzoneFeedsParams extends JsonObject {
|
||||
/** Page number starts at 1; only the first page is reliable upstream. */
|
||||
/** Starts at 1. Without a cursor, earlier pages are traversed to reach this page. */
|
||||
page_num?: ActionNumberInput;
|
||||
count?: ActionNumberInput;
|
||||
/** Pass next_cursor unchanged for the same account; omit page_num when continuing. */
|
||||
cursor?: string;
|
||||
}
|
||||
|
||||
export interface QzoneMsgIdParams extends JsonObject {
|
||||
|
||||
@@ -403,11 +403,22 @@ export interface QzoneFeed extends JsonObject {
|
||||
appid: number;
|
||||
key: string;
|
||||
html: string;
|
||||
/** Newer servers return these fields; null means the source could not establish the value. */
|
||||
tid?: string | null;
|
||||
content?: string | null;
|
||||
/** False for a collapsed excerpt; null when content is unavailable. */
|
||||
content_complete?: boolean | null;
|
||||
/** Images visible in the post body, excluding avatars, comment images and video covers. */
|
||||
images?: string[] | null;
|
||||
like_count?: number | null;
|
||||
comment_count?: number | null;
|
||||
}
|
||||
|
||||
export interface QzoneFeedsResult extends JsonObject {
|
||||
feeds: QzoneFeed[];
|
||||
has_more: boolean;
|
||||
/** Opaque account-bound continuation; null at the end, absent on older servers. */
|
||||
next_cursor?: string | null;
|
||||
}
|
||||
|
||||
export interface QzonePublishResult extends JsonObject {
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ export const actionParams = {
|
||||
get_group_signed_list: { group_id: '10001' },
|
||||
get_msg_emoji_likes: { message_id: '-42' },
|
||||
get_qun_album_list: { group_id: '10001', attach_info: '' },
|
||||
get_qzone_feeds: { page_num: '1', count: '10' },
|
||||
get_qzone_feeds: { page_num: '1', count: '10', cursor: 'cursor-from-previous-response' },
|
||||
get_qzone_msg_list: { target_uin: '10002', pos: '0', num: '20' },
|
||||
get_rkey_server: {},
|
||||
get_share_link: fileset,
|
||||
|
||||
+14
@@ -69,6 +69,20 @@ 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;
|
||||
export const legacyFeedHtml: string = feeds.feeds[0].html;
|
||||
export const feedContent: string | null | undefined = feeds.feeds[0].content;
|
||||
export const feedPhotos: string[] | null | undefined = feeds.feeds[0].images;
|
||||
export const feedLikeCount: number | null | undefined = feeds.feeds[0].like_count;
|
||||
export const feedCursor: string | null | undefined = feeds.next_cursor;
|
||||
if (feedCursor) {
|
||||
await http.raw('get_qzone_feeds', { cursor: feedCursor, count: 10 });
|
||||
}
|
||||
export const legacyFeedsResult: ActionResult<'get_qzone_feeds'> = {
|
||||
feeds: [{ uin: 10002, nickname: 'User', time: 1, appid: 311, key: 'post', html: '' }],
|
||||
has_more: false,
|
||||
};
|
||||
// @ts-expect-error continuation tokens must be strings
|
||||
http.raw('get_qzone_feeds', { cursor: 123 });
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user