Skip to content

Commit 064fe58

Browse files
committed
fix(bot): polish interactive card per review feedback
Follow-up to volcengine#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
1 parent ca9a6cc commit 064fe58

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

bot/vikingbot/channels/feishu.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,13 @@ async def _process_content_with_images(
499499

500500
# Add image elements
501501
for img in images:
502-
elements.append({"tag": "img", "img_key": img["img_key"]})
502+
elements.append(
503+
{
504+
"tag": "img",
505+
"img_key": img["img_key"],
506+
"alt": {"tag": "plain_text", "content": ""},
507+
}
508+
)
503509

504510
if not elements:
505511
elements = [{"tag": "markdown", "content": content_no_images}]
@@ -552,7 +558,7 @@ async def send(self, msg: OutboundMessage) -> None:
552558
# @mention prefix only when replying in group chats
553559
mention_prefix = ""
554560
if reply_to_message_id and original_sender_id and chat_type == "group":
555-
mention_prefix = f"<at id={original_sender_id}></at>"
561+
mention_prefix = f'<at id="{original_sender_id}"></at>'
556562

557563
if content_with_mentions.strip():
558564
md_content = (
@@ -566,13 +572,23 @@ async def send(self, msg: OutboundMessage) -> None:
566572

567573
# Add images
568574
for img in images:
569-
card_elements.append({"tag": "img", "img_key": img["image_key"]})
575+
card_elements.append(
576+
{
577+
"tag": "img",
578+
"img_key": img["image_key"],
579+
"alt": {"tag": "plain_text", "content": ""},
580+
}
581+
)
570582

571583
if not card_elements:
572584
card_elements.append({"tag": "markdown", "content": " "})
573585

574-
# Build interactive card message (no extra {"card": ...} wrapper)
575-
card_content = json.dumps({"elements": card_elements}, ensure_ascii=False)
586+
# Build interactive card message
587+
card_payload = {
588+
"config": {"wide_screen_mode": True},
589+
"elements": card_elements,
590+
}
591+
card_content = json.dumps(card_payload, ensure_ascii=False)
576592

577593
if reply_to_message_id:
578594
# Reply to existing message (quotes the original)

0 commit comments

Comments
 (0)