feat(feishu): support embedding images in interactive cards and sending mixed image+file messages

- Enhance Feishu card builder to embed images using remote URLs or uploaded files
- Add logic to send image card first, then file attachment when both image and file are present
- Update card schema to 2.0 and use new button behaviors for callbacks and URLs
- Improve callback data extraction for both new and legacy card actions
- Extend tests to cover image embedding, mixed messages, and new card structure
This commit is contained in:
jxxghp
2026-05-13 11:14:11 +08:00
parent 6fb6996d81
commit 3852c0e43e
3 changed files with 370 additions and 36 deletions

View File

@@ -92,7 +92,24 @@ class FeishuModule(_ModuleBase, _MessageBase[Feishu]):
userid, chat_id, receive_id_type = self._resolve_message_target(message)
client: Feishu = self.get_instance(conf.name)
if client:
if message.file_path:
if message.image and message.file_path:
# 普通文件无法嵌入卡片,先发送图文卡片,再单独发送附件,避免图片被 file_path 分支吞掉。
client.send_notification(
message=message.model_copy(update={"file_path": None, "file_name": None}),
userid=userid,
chat_id=chat_id,
receive_id_type=receive_id_type,
original_message_id=str(message.original_message_id) if message.original_message_id else None,
)
client.send_file(
file_path=message.file_path,
userid=userid,
chat_id=chat_id,
file_name=message.file_name,
receive_id_type=receive_id_type,
original_message_id=str(message.original_message_id) if message.original_message_id else None,
)
elif message.file_path:
client.send_file(
file_path=message.file_path,
userid=userid,
@@ -186,7 +203,24 @@ class FeishuModule(_ModuleBase, _MessageBase[Feishu]):
client: Feishu = self.get_instance(conf.name)
if not client:
continue
if message.file_path:
if message.image and message.file_path:
result = client.send_notification(
message=message.model_copy(update={"file_path": None, "file_name": None}),
userid=userid,
chat_id=chat_id,
receive_id_type=receive_id_type,
original_message_id=str(message.original_message_id) if message.original_message_id else None,
)
if result and result.get("success"):
client.send_file(
file_path=message.file_path,
userid=userid,
chat_id=chat_id,
file_name=message.file_name,
receive_id_type=receive_id_type,
original_message_id=str(message.original_message_id) if message.original_message_id else None,
)
elif message.file_path:
result = client.send_file(
file_path=message.file_path,
userid=userid,