feat(qzone): add homepage feeds and share cards

Read accessible Qzone homepage posts and generate their original share cards. Return sharing notices so callers can confirm visibility before sending through the existing message actions.

Include SDK contracts, action discovery, documentation, and regression coverage.

Fixes #609
This commit is contained in:
DrSmoothl committed 2026-10-31 18:28:05 +08:00
1 parent 304f3e772f
commit eb119ecb92
15 files changed
+944 -4

No files matched your search

+15
View File
@@ -183,6 +183,21 @@ for (const comment of detail.comments) {
### 空友爱看与公共空间
`get_qzone_home_feeds` 读取自己的空间主页,可传 `target_uin` 访问有权限的其他主页;`cursor` 使用同一账号、同一主页上次返回的 `next_cursor`。它返回完整动态,旧版 `get_qzone_feeds` 和 `get_qzone_msg_list` 保持原有格式。
把主页或推荐列表的完整动态传给 `get_qzone_share_ark`,可获得 `{ ark, requires_confirmation, notice }`。此动作会生成分享卡片但不发送消息;将 `ark` 原文交给普通 JSON 消息发送接口即可获得消息编号,继续使用已有撤回及发送事件能力。
分享链接可能让未登录者也能访问动态,并包含作者 QQ 号。若 `requires_confirmation` 为 `true`,发送前应展示 `notice` 并取得确认;上游禁止分享或生成失败会返回错误。
```ts
const page = await bot.raw('get_qzone_home_feeds', {});
if (page.feeds[0]) {
const card = await bot.raw('get_qzone_share_ark', { feed: page.feeds[0] });
// 先按 requires_confirmation / notice 确认分享范围,再由调用方决定是否发送。
// 发送时使用 [{ type: 'json', data: { data: card.ark } }],保持卡片原文。
}
```
公共空间动作使用推荐域 `3` 的 JSON 接口,与上面的旧空间 CGI 动作分开。先读取 `get_qzone_public_feeds`,再把返回的完整 `feed` 对象传给详情和互动动作,保留其中的身份、传递数据及未知字段;不要用旧说说 `tid` 拼造。
| 动作 | 主要参数 |
+2
View File
@@ -184,6 +184,7 @@ export const SNOWLUMA_ACTIONS = [
'get_msg_emoji_likes',
'get_qun_album_list',
'get_qzone_feeds',
'get_qzone_home_feeds',
'get_qzone_msg_detail',
'get_qzone_msg_list',
'get_qzone_profile',
@@ -192,6 +193,7 @@ export const SNOWLUMA_ACTIONS = [
'get_qzone_public_feed_detail',
'get_qzone_public_feeds',
'get_qzone_public_replies',
'get_qzone_share_ark',
'get_rkey_server',
'get_share_link',
'like_qzone',
+5
View File
@@ -103,6 +103,8 @@ import type {
GetQzoneMsgListParams,
GetQzoneProfileParams,
GetQzonePublicFeedsParams,
GetQzoneHomeFeedsParams,
GetQzoneShareArkParams,
GetQzonePublicCommentsParams,
GetQzonePublicRepliesParams,
GroupAlbumCommentParams,
@@ -203,6 +205,7 @@ import type {
QzonePublishResult,
QzoneProfileResult,
QzonePublicFeedsPage,
QzoneShareArkResult,
QzoneUpdateRightResult,
RkeyServerResult,
SendFlashMsgResult,
@@ -424,6 +427,8 @@ export interface SnowLumaActionMap {
get_qzone_profile: { params: GetQzoneProfileParams; data: QzoneProfileResult };
get_qzone_public_capabilities: { params: JsonObject; data: JsonObject };
get_qzone_public_feeds: { params: GetQzonePublicFeedsParams; data: QzonePublicFeedsPage };
get_qzone_home_feeds: { params: GetQzoneHomeFeedsParams; data: QzonePublicFeedsPage };
get_qzone_share_ark: { params: GetQzoneShareArkParams; data: QzoneShareArkResult };
get_qzone_public_feed_detail: { params: QzonePublicFeedParams; data: JsonObject };
get_qzone_public_comments: { params: GetQzonePublicCommentsParams; data: JsonObject };
get_qzone_public_replies: { params: GetQzonePublicRepliesParams; data: JsonObject };
+11
View File
@@ -627,6 +627,17 @@ export interface GetQzonePublicFeedsParams extends JsonObject {
cursor?: string;
}
export interface GetQzoneHomeFeedsParams extends JsonObject {
target_uin?: ActionNumberInput;
/** Continuation for the same account and target homepage. */
cursor?: string;
}
export interface GetQzoneShareArkParams extends JsonObject {
/** Original feed from get_qzone_home_feeds or get_qzone_public_feeds. */
feed: JsonObject;
}
export interface QzonePublicFeedParams extends JsonObject {
/** The original feed cells returned in get_qzone_public_feeds.feeds. */
feed: JsonObject;
+8
View File
@@ -422,6 +422,14 @@ export interface QzonePublicFeedsPage extends JsonObject {
next_cursor: string | null;
}
export interface QzoneShareArkResult extends JsonObject {
/** Preserve this string when sending a JSON message. */
ark: string;
/** Display notice and obtain confirmation before sending when true. */
requires_confirmation: boolean;
notice: string | null;
}
export interface QzoneFeed extends JsonObject {
uin: number;
nickname: string;
+6
View File
@@ -96,6 +96,8 @@ export const actionParams = {
get_qzone_msg_list: { target_uin: '10002', pos: '0', num: '20' },
get_qzone_profile: { target_uin: '10002' },
get_qzone_public_capabilities: {},
get_qzone_home_feeds: { target_uin: '10001', cursor: 'home-feed-cursor' },
get_qzone_share_ark: { feed: qzonePublicFeed },
get_qzone_public_comments: { feed: qzonePublicFeed, cursor: 'comments-from-detail' },
get_qzone_public_feed_detail: { feed: qzonePublicFeed },
get_qzone_public_feeds: { cursor: 'public-feed-cursor' },
@@ -229,6 +231,8 @@ export type CoveredAction =
| 'get_qzone_msg_list'
| 'get_qzone_profile'
| 'get_qzone_public_capabilities'
| 'get_qzone_home_feeds'
| 'get_qzone_share_ark'
| 'get_qzone_public_comments'
| 'get_qzone_public_feed_detail'
| 'get_qzone_public_feeds'
@@ -464,6 +468,8 @@ export const actionResults = {
},
get_qzone_profile: { name: 'Space', description: 'Description' },
get_qzone_public_capabilities: { public_qzone_entrance_switch: true, can_upvote: true },
get_qzone_home_feeds: { feeds: [qzonePublicFeed], has_more: false, next_cursor: null },
get_qzone_share_ark: { ark: '{"app":"com.tencent.tuwen.lua"}', requires_confirmation: false, notice: null },
get_qzone_public_comments: {
cell_comment: { comments: [qzonePublicComment] },
attach_info: 'next-comments',
+33 -1
View File
@@ -1,5 +1,10 @@
import { describe, expect, expectTypeOf, it, vi } from 'vitest';
import { SnowLumaHttpClient, type JsonObject, type QzonePublicFeedsPage } from '../src';
import {
SnowLumaHttpClient,
type JsonObject,
type QzonePublicFeedsPage,
type QzoneShareArkResult,
} from '../src';
const feed: JsonObject = {
cell_common: {
@@ -11,6 +16,33 @@ const feed: JsonObject = {
};
describe('public Qzone raw actions', () => {
it('exposes homepage and card types without automatically sending the card', async () => {
const page: QzonePublicFeedsPage = { feeds: [feed], has_more: false, next_cursor: null };
const card: QzoneShareArkResult = {
ark: '{ "app": "com.tencent.tuwen.lua" }',
requires_confirmation: true,
notice: '所有人可见',
};
const fetchImpl = vi
.fn()
.mockResolvedValueOnce(
new Response(JSON.stringify({ status: 'ok', retcode: 0, data: page })),
)
.mockResolvedValueOnce(
new Response(JSON.stringify({ status: 'ok', retcode: 0, data: card })),
);
const client = new SnowLumaHttpClient({ fetch: fetchImpl });
const homepage = await client.raw('get_qzone_home_feeds', {});
expectTypeOf(homepage).toEqualTypeOf<QzonePublicFeedsPage>();
const result = await client.raw('get_qzone_share_ark', { feed: homepage.feeds[0]! });
expectTypeOf(result).toEqualTypeOf<QzoneShareArkResult>();
expect(result).toEqual(card);
expect(fetchImpl).toHaveBeenCalledTimes(2);
expect(JSON.parse(fetchImpl.mock.calls[1]![1].body)).toEqual({
action: 'get_qzone_share_ark',
params: { feed },
});
});
it('preserves original feed cells and follows an explicit cursor after a short page', async () => {
const first: QzonePublicFeedsPage = {
feeds: [feed],