From 02dee2d664bee083da1be7b0e28e8d8fa8b9bb39 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 21 Mar 2025 16:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20add=20error=20handling?= =?UTF-8?q?=20for=20missing=20pyffmpeg=20library=20in=20video=20sending=20?= =?UTF-8?q?functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/platform/sources/gewechat/gewechat_event.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/astrbot/core/platform/sources/gewechat/gewechat_event.py b/astrbot/core/platform/sources/gewechat/gewechat_event.py index 160b7c8a3..5b74a63eb 100644 --- a/astrbot/core/platform/sources/gewechat/gewechat_event.py +++ b/astrbot/core/platform/sources/gewechat/gewechat_event.py @@ -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): - from pyffmpeg import FFmpeg + 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 下载视频