From b2b7ed87c60f6d7a1a7f69dcca4d9e6747cfa531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 30 Oct 2026 14:02:44 +0800 Subject: [PATCH] fix: #2118 --- packages/napcat-core/apis/webapi.ts | 41 ++++++++++++++++++- packages/napcat-core/data/album.ts | 1 + .../services/NodeIKernelAlbumService.ts | 29 ++++++++++++- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/packages/napcat-core/apis/webapi.ts b/packages/napcat-core/apis/webapi.ts index 38bcf289d..72d43fab6 100644 --- a/packages/napcat-core/apis/webapi.ts +++ b/packages/napcat-core/apis/webapi.ts @@ -681,11 +681,41 @@ export class NTQQWebApi { lloc: string | undefined, content: string, batchId: string = '') { + if (!lloc && !batchId) { + throw new Error('lloc 或 batch_id 至少需要提供一个'); + } const random_seq = Math.floor(Math.random() * 9000) + 1000; const uin = this.core.selfInfo.uin || '10001'; + const albumService = this.context.session.getAlbumService(); + let feed; + if (lloc) { + feed = createAlbumMediaFeed(uin, albumId, lloc, batchId); + } else { + // Batch comments need the server's feed identity and uploader, not an + // empty media cell with the commenter substituted for the feed owner. + const { response } = await albumService.getQunFeedDetail({ + seq: random_seq, + request_time_line: { request_invoke_time: '0' }, + ext_info: { map_info: [], map_bytes_info: [], map_user_account: [] }, + qun_id: qunId, + feed_id: '', + comment_count: 20, + attach_info: '', + album_id: albumId, + batch_id: batchId, + lloc: '', + }); + if (response?.result !== 0) { + throw new Error(`获取群相册批次动态失败, ${response?.result ?? 'unknown'}:${response?.errMs || '未知错误'}`); + } + feed = response.feed?.feed; + if (!feed?.cell_common?.feed_id || !feed.cell_user_info?.user || !feed.cell_media) { + throw new Error('获取群相册批次动态失败: 未返回有效动态'); + } + } // 16位number数字 const client_key = Date.now() * 1000; - return await this.context.session.getAlbumService().doQunComment( + const result = await albumService.doQunComment( random_seq, { map_info: [], map_bytes_info: [], @@ -693,9 +723,16 @@ export class NTQQWebApi { }, qunId, 2, - createAlbumMediaFeed(uin, albumId, lloc, batchId), + feed, createAlbumCommentRequest(uin, content, client_key) ); + if (result?.result !== 0) { + throw new Error(`群相册评论失败, ${result?.result ?? 'unknown'}:${result?.errMs || '未知错误'}`); + } + if (!result.comment?.id) { + throw new Error('群相册评论失败: 未返回有效评论'); + } + return result; } async deleteAlbumMediaByNTQQ ( diff --git a/packages/napcat-core/data/album.ts b/packages/napcat-core/data/album.ts index d52a2b9c5..9989aeb45 100644 --- a/packages/napcat-core/data/album.ts +++ b/packages/napcat-core/data/album.ts @@ -44,6 +44,7 @@ export function createAlbumListRequest ( export interface AlbumMediaFeed { cell_common: { time: string; + feed_id?: string; }; cell_user_info: { user: { diff --git a/packages/napcat-core/services/NodeIKernelAlbumService.ts b/packages/napcat-core/services/NodeIKernelAlbumService.ts index e5058e732..80a185ba1 100644 --- a/packages/napcat-core/services/NodeIKernelAlbumService.ts +++ b/packages/napcat-core/services/NodeIKernelAlbumService.ts @@ -56,7 +56,28 @@ export interface NodeIKernelAlbumService { getQunFeeds (arg: unknown): unknown;// needs 1 arguments - getQunFeedDetail (arg: unknown): unknown;// needs 1 arguments + getQunFeedDetail (params: { + seq: number; + request_time_line: { request_invoke_time: string; }; + ext_info: { + map_info: unknown[]; + map_bytes_info: unknown[]; + map_user_account: unknown[]; + }; + qun_id: string; + feed_id: string; + comment_count: number; + attach_info: string; + album_id: string; + batch_id: string; + lloc: string; + }): Promise<{ + response: { + result: number; + errMs?: string; + feed?: { feed?: AlbumMediaFeed; }; + }; + }>; getQunNoticeList (arg1: number, arg2: unknown, arg3: string, arg4: string): unknown;// needs 4 arguments @@ -77,7 +98,11 @@ export interface NodeIKernelAlbumService { commentType: number, feed: AlbumMediaFeed, content: AlbumCommentReplyContent, - ): Promise;// needs 6 arguments + ): Promise<{ + result: number; + errMs?: string; + comment?: { id: string; }; + }>;// needs 6 arguments doQunReply (arg1: number, arg2: unknown, arg3: string, arg4: number, arg5: unknown, arg6: unknown, arg7: unknown): unknown;// needs 7 arguments