fix: 修复了当html_only_url打开时,URL拼接错误问题 (#169)

Fixes #169

* fix:修复了当html_only_url打开时,手动触发部分URL拼接错误问题

* fix:修复了当html_only_url打开时,自动触发部分URL拼接错误问题

* fix: ruff

---------

Co-authored-by: SXP-Simon <sxp20061207@163.com>
This commit is contained in:
Shiitin
2026-04-13 15:37:18 +08:00
committed by GitHub
co-authored by SXP-Simon
parent 45c9ca9bea
commit d47a9411b2
2 changed files with 55 additions and 4 deletions
+28 -2
View File
@@ -633,8 +633,34 @@ class GroupDailyAnalysis(Star):
if is_only_url:
if base_url and base_url.strip():
filename = os.path.basename(html_path)
report_url = f"{base_url.rstrip('/')}/{filename}"
# 获取配置中的输出目录
html_output_dir = self.config_manager.get_html_output_dir()
# 若用户配置为空,使用默认目录
if not html_output_dir:
try:
from astrbot.api.star import StarTools
html_output_dir = os.path.join(
StarTools.get_data_dir(), "self_hosted_html_reports"
)
except Exception:
from astrbot.core.utils.astrbot_path import (
get_astrbot_data_path,
)
html_output_dir = os.path.join(
get_astrbot_data_path(),
"plugin_data",
"astrbot_plugin_qq_group_daily_analysis",
"self_hosted_html_reports",
)
# 计算相对路径并转换为URL
rel_path = os.path.relpath(html_path, html_output_dir)
url_path = rel_path.replace(os.sep, "/")
report_url = f"{base_url.rstrip('/')}/{url_path.lstrip('/')}"
yield event.plain_result(
f"📊 今日群聊分析报告已生成:\n{report_url}"
)