From 064fe58e178edff5daef4332ab5b2d09e73f1d68 Mon Sep 17 00:00:00 2001
From: wzr <2668940489@qq.com>
Date: Sat, 28 Mar 2026 04:33:43 +0800
Subject: [PATCH] fix(bot): polish interactive card per review feedback
Follow-up to #1015. Addresses review comments from yeshion23333:
1. Add config.wide_screen_mode to card payload to prevent text/table
truncation and align with official card schema
2. Add alt field to img elements for card schema completeness
3. Quote id attribute in @mention tag for parser compatibility
---
bot/vikingbot/channels/feishu.py | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/bot/vikingbot/channels/feishu.py b/bot/vikingbot/channels/feishu.py
index ad3be7a76..bfe75501d 100644
--- a/bot/vikingbot/channels/feishu.py
+++ b/bot/vikingbot/channels/feishu.py
@@ -499,7 +499,13 @@ async def _process_content_with_images(
# Add image elements
for img in images:
- elements.append({"tag": "img", "img_key": img["img_key"]})
+ elements.append(
+ {
+ "tag": "img",
+ "img_key": img["img_key"],
+ "alt": {"tag": "plain_text", "content": ""},
+ }
+ )
if not elements:
elements = [{"tag": "markdown", "content": content_no_images}]
@@ -552,7 +558,7 @@ async def send(self, msg: OutboundMessage) -> None:
# @mention prefix only when replying in group chats
mention_prefix = ""
if reply_to_message_id and original_sender_id and chat_type == "group":
- mention_prefix = f""
+ mention_prefix = f''
if content_with_mentions.strip():
md_content = (
@@ -566,13 +572,23 @@ async def send(self, msg: OutboundMessage) -> None:
# Add images
for img in images:
- card_elements.append({"tag": "img", "img_key": img["image_key"]})
+ card_elements.append(
+ {
+ "tag": "img",
+ "img_key": img["image_key"],
+ "alt": {"tag": "plain_text", "content": ""},
+ }
+ )
if not card_elements:
card_elements.append({"tag": "markdown", "content": " "})
- # Build interactive card message (no extra {"card": ...} wrapper)
- card_content = json.dumps({"elements": card_elements}, ensure_ascii=False)
+ # Build interactive card message
+ card_payload = {
+ "config": {"wide_screen_mode": True},
+ "elements": card_elements,
+ }
+ card_content = json.dumps(card_payload, ensure_ascii=False)
if reply_to_message_id:
# Reply to existing message (quotes the original)