From f3de4d48d367bb91e1b337b75aa0c76db658f840 Mon Sep 17 00:00:00 2001 From: Makoto Date: Tue, 13 Jan 2026 16:32:03 +0800 Subject: [PATCH] feat: add settings field to group notice API response (#1505) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add settings field to group notice API response - Add settings field to GroupNotice interface - Include announcement configuration options (is_show_edit_card, remind_ts, tip_window_type, confirm_required) - Fixes #1503 * refactor: make settings field optional for backward compatibility - Mark settings as optional in GroupNotice interface - Mark settings as optional in WebApiGroupNoticeFeed type - Prevents runtime errors when processing older or malformed notices - Addresses code review feedback on PR #1505 * Update GetGroupNotice.ts --------- Co-authored-by: 手瓜一十雪 --- packages/napcat-core/types/webapi.ts | 2 +- .../action/group/GetGroupNotice.ts | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/napcat-core/types/webapi.ts b/packages/napcat-core/types/webapi.ts index b96aaac0..4424ce9e 100644 --- a/packages/napcat-core/types/webapi.ts +++ b/packages/napcat-core/types/webapi.ts @@ -73,7 +73,7 @@ export interface WebApiGroupNoticeFeed { fn: number; cn: number; vn: number; - settings: { + settings?: { is_show_edit_card: number remind_ts: number tip_window_type: number diff --git a/packages/napcat-onebot/action/group/GetGroupNotice.ts b/packages/napcat-onebot/action/group/GetGroupNotice.ts index bffb5b2d..eceab3c5 100644 --- a/packages/napcat-onebot/action/group/GetGroupNotice.ts +++ b/packages/napcat-onebot/action/group/GetGroupNotice.ts @@ -7,19 +7,26 @@ interface GroupNotice { publish_time: number; notice_id: string; message: { - text: string + text: string; // 保持一段时间兼容性 防止以往版本出现问题 后续版本可考虑移除 image: Array<{ - height: string - width: string - id: string + height: string; + width: string; + id: string; }>, images: Array<{ - height: string - width: string - id: string - }> + height: string; + width: string; + id: string; + }>; }; + settings?: { + is_show_edit_card: number, + remind_ts: number, + tip_window_type: number, + confirm_required: number; + }; + read_num?: number; } const SchemaData = Type.Object({ @@ -59,6 +66,8 @@ export class GetGroupNotice extends OneBotAction { image, images: image, }, + settings: retApiNotice.settings, + read_num: retApiNotice.read_num }; retNotices.push(retNotice); }