From e4819c866da0b30c6d7a54238ed6420165537867 Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Sun, 22 Feb 2026 15:33:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(image):=20=E5=A4=84=E7=90=86=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=E5=92=8C=E7=9B=B8=E5=AF=B9=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=9A=84=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 5 ++++- src/infrastructure/platform/adapters/onebot_adapter.py | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 973c860..8bc59da 100644 --- a/main.py +++ b/main.py @@ -328,7 +328,10 @@ class GroupDailyAnalysis(Star): parts = image_url.split(",", 1) data = base64.b64decode(parts[1]) if len(parts) == 2 else None elif os.path.isfile(image_url): - image_file = os.path.abspath(image_url) + if os.path.isabs(image_url): + image_file = image_url + else: + image_file = os.path.abspath(image_url) data = None else: return diff --git a/src/infrastructure/platform/adapters/onebot_adapter.py b/src/infrastructure/platform/adapters/onebot_adapter.py index 984b774..94cd1ed 100644 --- a/src/infrastructure/platform/adapters/onebot_adapter.py +++ b/src/infrastructure/platform/adapters/onebot_adapter.py @@ -474,7 +474,12 @@ class OneBotAdapter(PlatformAdapter): # 1) 优先尝试物理路径;2) 路径失败则回退 Base64 file_str = image_path if not image_path.startswith(("http://", "https://", "base64://")): - file_str = f"file:///{os.path.abspath(image_path)}" + if os.path.isabs(image_path): + # 如果是绝对路径,保持原样(兼容 Docker 中的 /AstrBot/ 路径) + file_str = f"file:///{image_path}" + else: + # 如果是相对路径,转为绝对路径 + file_str = f"file:///{os.path.abspath(image_path)}" try: message = list(base_message)