mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
fix: 性能优化,CPU 密集型计算(统计和分析)已卸载到各线程池,避免阻塞事件循环
feat: 存储路径规范化:PDF 报告现在存储在 data/plugin_data/astrbot_plugin_qq_group_daily_analysis/reports
This commit is contained in:
+12
-3
@@ -6,6 +6,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from astrbot.api import AstrBotConfig, logger
|
from astrbot.api import AstrBotConfig, logger
|
||||||
|
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
|
||||||
|
|
||||||
|
|
||||||
class ConfigManager:
|
class ConfigManager:
|
||||||
@@ -139,9 +140,17 @@ class ConfigManager:
|
|||||||
|
|
||||||
def get_pdf_output_dir(self) -> str:
|
def get_pdf_output_dir(self) -> str:
|
||||||
"""获取PDF输出目录"""
|
"""获取PDF输出目录"""
|
||||||
return self.config.get(
|
try:
|
||||||
"pdf_output_dir", "data/plugins/astrbot-qq-group-daily-analysis/reports"
|
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:
|
def get_bot_qq_ids(self) -> list:
|
||||||
"""获取bot QQ号列表"""
|
"""获取bot QQ号列表"""
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
包含消息分析和其他通用功能
|
包含消息分析和其他通用功能
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from astrbot.api import logger
|
from astrbot.api import logger
|
||||||
|
|
||||||
from ...src.analysis.llm_analyzer import LLMAnalyzer
|
from ...src.analysis.llm_analyzer import LLMAnalyzer
|
||||||
@@ -49,10 +50,14 @@ class MessageAnalyzer:
|
|||||||
"""完整的消息分析流程"""
|
"""完整的消息分析流程"""
|
||||||
try:
|
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从配置中读取
|
# 获取活跃用户列表 - 使用get_top_users方法,limit从配置中读取
|
||||||
max_user_titles = self.config_manager.get_max_user_titles()
|
max_user_titles = self.config_manager.get_max_user_titles()
|
||||||
|
|||||||
Reference in New Issue
Block a user