mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
fix(image): 处理绝对路径和相对路径的文件路径转换
This commit is contained in:
@@ -328,7 +328,10 @@ class GroupDailyAnalysis(Star):
|
|||||||
parts = image_url.split(",", 1)
|
parts = image_url.split(",", 1)
|
||||||
data = base64.b64decode(parts[1]) if len(parts) == 2 else None
|
data = base64.b64decode(parts[1]) if len(parts) == 2 else None
|
||||||
elif os.path.isfile(image_url):
|
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
|
data = None
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -474,7 +474,12 @@ class OneBotAdapter(PlatformAdapter):
|
|||||||
# 1) 优先尝试物理路径;2) 路径失败则回退 Base64
|
# 1) 优先尝试物理路径;2) 路径失败则回退 Base64
|
||||||
file_str = image_path
|
file_str = image_path
|
||||||
if not image_path.startswith(("http://", "https://", "base64://")):
|
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:
|
try:
|
||||||
message = list(base_message)
|
message = list(base_message)
|
||||||
|
|||||||
Reference in New Issue
Block a user