mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
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:
@@ -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}"
|
||||
)
|
||||
|
||||
@@ -131,8 +131,33 @@ class ReportDispatcher:
|
||||
|
||||
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('/')}"
|
||||
|
||||
sent = await self.message_sender.send_text(
|
||||
group_id,
|
||||
|
||||
Reference in New Issue
Block a user