From 9a09e56f1326dd5a3a90a234d7edee047ca2a159 Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Tue, 6 Jan 2026 23:15:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8CCPU=20=E5=AF=86=E9=9B=86=E5=9E=8B=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=EF=BC=88=E7=BB=9F=E8=AE=A1=E5=92=8C=E5=88=86=E6=9E=90=EF=BC=89?= =?UTF-8?q?=E5=B7=B2=E5=8D=B8=E8=BD=BD=E5=88=B0=E5=90=84=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=B1=A0=EF=BC=8C=E9=81=BF=E5=85=8D=E9=98=BB=E5=A1=9E=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: 存储路径规范化:PDF 报告现在存储在 data/plugin_data/astrbot_plugin_qq_group_daily_analysis/reports --- src/core/config.py | 15 ++++++++++++--- src/utils/helpers.py | 9 +++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/core/config.py b/src/core/config.py index 32955cb..e1398f2 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -6,6 +6,7 @@ import sys from astrbot.api import AstrBotConfig, logger +from astrbot.core.utils.astrbot_path import get_astrbot_data_path class ConfigManager: @@ -139,9 +140,17 @@ class ConfigManager: def get_pdf_output_dir(self) -> str: """获取PDF输出目录""" - return self.config.get( - "pdf_output_dir", "data/plugins/astrbot-qq-group-daily-analysis/reports" - ) + try: + plugin_name = "astrbot_plugin_qq_group_daily_analysis" + data_path = get_astrbot_data_path() + default_path = data_path / "plugin_data" / plugin_name / "reports" + return self.config.get("pdf_output_dir", str(default_path)) + except Exception: + # Fallback for older versions or import errors + return self.config.get( + "pdf_output_dir", + "data/plugins/astrbot_plugin_qq_group_daily_analysis/reports", + ) def get_bot_qq_ids(self) -> list: """获取bot QQ号列表""" diff --git a/src/utils/helpers.py b/src/utils/helpers.py index e0fb3f0..1c175b4 100644 --- a/src/utils/helpers.py +++ b/src/utils/helpers.py @@ -3,6 +3,7 @@ 包含消息分析和其他通用功能 """ +import asyncio from astrbot.api import logger from ...src.analysis.llm_analyzer import LLMAnalyzer @@ -49,10 +50,14 @@ class MessageAnalyzer: """完整的消息分析流程""" try: # 基础统计 - statistics = self.message_handler.calculate_statistics(messages) + statistics = await asyncio.to_thread( + self.message_handler.calculate_statistics, messages + ) # 用户分析 - user_analysis = self.user_analyzer.analyze_users(messages) + user_analysis = await asyncio.to_thread( + self.user_analyzer.analyze_users, messages + ) # 获取活跃用户列表 - 使用get_top_users方法,limit从配置中读取 max_user_titles = self.config_manager.get_max_user_titles()