🎈 perf: add error handling for missing pyffmpeg library in video sending functionality

This commit is contained in:
Soulter
2025-03-21 16:51:23 +08:00
parent a3dd2c3069
commit 02dee2d664

View File

@@ -84,7 +84,15 @@ class GewechatPlatformEvent(AstrMessageEvent):
logger.debug(f"gewe callback img url: {img_url}")
await client.post_image(to_wxid, img_url)
elif isinstance(comp, Video):
try:
from pyffmpeg import FFmpeg
except (ImportError, ModuleNotFoundError):
logger.error(
"需要安装 pyffmpeg 库才能发送视频: pip install pyffmpeg"
)
raise ModuleNotFoundError(
"需要安装 pyffmpeg 库才能发送视频: pip install pyffmpeg"
)
video_url = comp.file
# 根据 url 下载视频