mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-04 06:59:42 +08:00
fix: 支持飞书语音消息识别
This commit is contained in:
@@ -301,11 +301,32 @@ class FeishuModule(_ModuleBase, _MessageBase[Feishu]):
|
||||
client = self.get_instance(client_config.name)
|
||||
if not client:
|
||||
return None
|
||||
parts = file_ref.replace("feishu://file/", "", 1).split("/", 1)
|
||||
file_key = parts[0].strip() if parts else ""
|
||||
parts = [
|
||||
part.strip()
|
||||
for part in file_ref.replace("feishu://file/", "", 1).split("/")
|
||||
if part.strip()
|
||||
]
|
||||
file_key = ""
|
||||
downloaded = None
|
||||
if len(parts) >= 2 and parts[0].startswith("om_"):
|
||||
message_id, file_key = parts[0], parts[1]
|
||||
downloaded = client.download_message_resource_bytes(
|
||||
message_id=message_id,
|
||||
file_key=file_key,
|
||||
resource_type="audio",
|
||||
)
|
||||
if not downloaded:
|
||||
downloaded = client.download_message_resource_bytes(
|
||||
message_id=message_id,
|
||||
file_key=file_key,
|
||||
resource_type="file",
|
||||
)
|
||||
else:
|
||||
file_key = parts[0] if parts else ""
|
||||
if not file_key:
|
||||
return None
|
||||
downloaded = client.download_file_bytes(file_key)
|
||||
if not downloaded:
|
||||
downloaded = client.download_file_bytes(file_key)
|
||||
if not downloaded:
|
||||
return None
|
||||
content, _, _ = downloaded
|
||||
|
||||
@@ -235,13 +235,16 @@ class Feishu:
|
||||
elif message_type in {"audio", "media", "file"}:
|
||||
file_key = str(content.get("file_key") or "").strip()
|
||||
file_name = str(content.get("file_name") or "").strip() or None
|
||||
message_id = str(getattr(message, "message_id", None) or "").strip()
|
||||
if file_key:
|
||||
if message_type == "audio":
|
||||
audio_refs = [f"feishu://file/{file_key}/{file_name or 'audio.opus'}"]
|
||||
resource_path = f"{message_id}/{file_key}" if message_id else file_key
|
||||
audio_refs = [f"feishu://file/{resource_path}/{file_name or 'audio.opus'}"]
|
||||
else:
|
||||
resource_path = f"{message_id}/{file_key}" if message_id else file_key
|
||||
files = [
|
||||
CommingMessage.MessageAttachment(
|
||||
ref=f"feishu://file/{file_key}/{file_name or 'attachment'}",
|
||||
ref=f"feishu://file/{resource_path}/{file_name or 'attachment'}",
|
||||
name=file_name,
|
||||
)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user