mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
fix(typo): bot_qq_id 更新配置说明
This commit is contained in:
+3
-3
@@ -32,11 +32,11 @@
|
||||
"default": false,
|
||||
"hint": "是否在指定时间自动进行群聊分析,启用需要填写下面的机器人QQ号,并且确保群聊号在 enabled_groups 配置中,否则获取不到实例,不会自动分析"
|
||||
},
|
||||
"bot_qq_id": {
|
||||
"bot_qq_ids": {
|
||||
"type": "list",
|
||||
"description": "机器人QQ号列表",
|
||||
"description": "群分析时屏蔽的QQ号列表",
|
||||
"default": [],
|
||||
"hint": "用于自动分析的机器人QQ号,填写后可启用自动分析功能。支持配置多个QQ号,用于多机器人场景",
|
||||
"hint": "填写后可启用自动分析功能。可以填写用于自动分析的机器人QQ号、多消息平台QQ号、不希望出现于群分析中的其他人的机器人QQ号等,这种群聊中出现但是不希望分析的QQ号。",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class TopicAnalyzer(BaseAnalyzer):
|
||||
|
||||
# 获取发送者ID并过滤机器人消息
|
||||
user_id = str(sender.get("user_id", ""))
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_id()
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_ids()
|
||||
|
||||
# 跳过机器人自己的消息
|
||||
if bot_qq_ids and user_id in [str(qq) for qq in bot_qq_ids]:
|
||||
@@ -325,7 +325,7 @@ class TopicAnalyzer(BaseAnalyzer):
|
||||
|
||||
# 获取发送者ID并过滤机器人消息
|
||||
user_id = str(sender.get("user_id", ""))
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_id()
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_ids()
|
||||
|
||||
# 跳过机器人自己的消息
|
||||
if bot_qq_ids and user_id in [str(qq) for qq in bot_qq_ids]:
|
||||
|
||||
@@ -152,7 +152,7 @@ class UserTitleAnalyzer(BaseAnalyzer):
|
||||
"""
|
||||
try:
|
||||
# 获取机器人QQ号列表用于过滤
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_id()
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_ids()
|
||||
|
||||
user_summaries = []
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class UserAnalyzer:
|
||||
def analyze_users(self, messages: List[Dict]) -> Dict[str, Dict]:
|
||||
"""分析用户活跃度"""
|
||||
# 获取机器人QQ号列表用于过滤
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_id()
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_ids()
|
||||
|
||||
user_stats = defaultdict(
|
||||
lambda: {
|
||||
@@ -82,7 +82,7 @@ class UserAnalyzer:
|
||||
) -> List[Dict]:
|
||||
"""获取最活跃的用户"""
|
||||
# 获取机器人QQ号列表用于过滤
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_id()
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_ids()
|
||||
|
||||
users = []
|
||||
for user_id, stats in user_analysis.items():
|
||||
|
||||
+15
-14
@@ -31,15 +31,15 @@ class BotManager:
|
||||
if bot_qq_id:
|
||||
self._bot_qq_id = str(bot_qq_id)
|
||||
|
||||
def set_bot_qq_id(self, bot_qq_id):
|
||||
"""设置bot QQ号(支持单个或列表)"""
|
||||
if isinstance(bot_qq_id, list):
|
||||
self._bot_qq_ids = [str(qq) for qq in bot_qq_id if qq]
|
||||
def set_bot_qq_ids(self, bot_qq_ids):
|
||||
"""设置bot QQ号(支持单个QQ号或QQ号列表)"""
|
||||
if isinstance(bot_qq_ids, list):
|
||||
self._bot_qq_ids = [str(qq) for qq in bot_qq_ids if qq]
|
||||
if self._bot_qq_ids:
|
||||
self._bot_qq_id = self._bot_qq_ids[0] # 保持向后兼容
|
||||
elif bot_qq_id:
|
||||
self._bot_qq_id = str(bot_qq_id)
|
||||
self._bot_qq_ids = [str(bot_qq_id)]
|
||||
elif bot_qq_ids:
|
||||
self._bot_qq_id = str(bot_qq_ids)
|
||||
self._bot_qq_ids = [str(bot_qq_ids)]
|
||||
|
||||
def get_bot_instance(self):
|
||||
"""获取当前bot实例"""
|
||||
@@ -79,9 +79,9 @@ class BotManager:
|
||||
async def initialize_from_config(self):
|
||||
"""从配置初始化bot管理器"""
|
||||
# 设置配置的bot QQ号列表
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_id()
|
||||
bot_qq_ids = self.config_manager.get_bot_qq_ids()
|
||||
if bot_qq_ids:
|
||||
self.set_bot_qq_id(bot_qq_ids)
|
||||
self.set_bot_qq_ids(bot_qq_ids)
|
||||
|
||||
# 自动发现bot实例
|
||||
await self.auto_discover_bot_instance()
|
||||
@@ -106,12 +106,13 @@ class BotManager:
|
||||
# 每次都尝试从bot实例提取QQ号
|
||||
bot_qq_id = self._extract_bot_qq_id(event.bot)
|
||||
if bot_qq_id:
|
||||
self.set_bot_qq_id(bot_qq_id)
|
||||
# 将单个QQ号转换为列表,保持统一处理
|
||||
self.set_bot_qq_ids([bot_qq_id])
|
||||
else:
|
||||
# 如果bot实例没有QQ号,尝试使用配置的QQ号
|
||||
config_qq_id = self.config_manager.get_bot_qq_id()
|
||||
if config_qq_id:
|
||||
self.set_bot_qq_id(config_qq_id)
|
||||
# 如果bot实例没有QQ号,尝试使用配置的QQ号列表
|
||||
config_qq_ids = self.config_manager.get_bot_qq_ids()
|
||||
if config_qq_ids:
|
||||
self.set_bot_qq_ids(config_qq_ids)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
+2
-2
@@ -115,9 +115,9 @@ class ConfigManager:
|
||||
"pdf_output_dir", "data/plugins/astrbot-qq-group-daily-analysis/reports"
|
||||
)
|
||||
|
||||
def get_bot_qq_id(self) -> list:
|
||||
def get_bot_qq_ids(self) -> list:
|
||||
"""获取bot QQ号列表"""
|
||||
return self.config.get("bot_qq_id", [])
|
||||
return self.config.get("bot_qq_ids", [])
|
||||
|
||||
def get_pdf_filename_format(self) -> str:
|
||||
"""获取PDF文件名格式"""
|
||||
|
||||
@@ -19,16 +19,16 @@ class MessageHandler:
|
||||
self.activity_visualizer = ActivityVisualizer()
|
||||
self.bot_manager = bot_manager
|
||||
|
||||
async def set_bot_qq_id(self, bot_qq_id):
|
||||
async def set_bot_qq_ids(self, bot_qq_ids):
|
||||
"""设置机器人QQ号(支持单个QQ号或QQ号列表)"""
|
||||
try:
|
||||
if self.bot_manager:
|
||||
# 确保传入的是列表,保持统一处理
|
||||
if isinstance(bot_qq_id, list):
|
||||
self.bot_manager.set_bot_qq_id(bot_qq_id)
|
||||
elif bot_qq_id:
|
||||
self.bot_manager.set_bot_qq_id([bot_qq_id])
|
||||
logger.info(f"设置机器人QQ号: {bot_qq_id}")
|
||||
if isinstance(bot_qq_ids, list):
|
||||
self.bot_manager.set_bot_qq_ids(bot_qq_ids)
|
||||
elif bot_qq_ids:
|
||||
self.bot_manager.set_bot_qq_ids([bot_qq_ids])
|
||||
logger.info(f"设置机器人QQ号: {bot_qq_ids}")
|
||||
except Exception as e:
|
||||
logger.error(f"设置机器人QQ号失败: {e}")
|
||||
|
||||
@@ -62,7 +62,7 @@ class MessageHandler:
|
||||
bot_qq_id = self._extract_bot_qq_id_from_instance(bot_instance)
|
||||
if bot_qq_id:
|
||||
# 将单个QQ号转换为列表,保持统一处理
|
||||
self.bot_manager.set_bot_qq_id([bot_qq_id])
|
||||
self.bot_manager.set_bot_qq_ids([bot_qq_id])
|
||||
|
||||
# 计算时间范围
|
||||
end_time = datetime.now()
|
||||
|
||||
@@ -33,13 +33,13 @@ class AutoScheduler:
|
||||
"""设置bot实例(保持向后兼容)"""
|
||||
self.bot_manager.set_bot_instance(bot_instance)
|
||||
|
||||
def set_bot_qq_id(self, bot_qq_id):
|
||||
def set_bot_qq_ids(self, bot_qq_ids):
|
||||
"""设置bot QQ号(支持单个QQ号或QQ号列表)"""
|
||||
# 确保传入的是列表,保持统一处理
|
||||
if isinstance(bot_qq_id, list):
|
||||
self.bot_manager.set_bot_qq_id(bot_qq_id)
|
||||
elif bot_qq_id:
|
||||
self.bot_manager.set_bot_qq_id([bot_qq_id])
|
||||
if isinstance(bot_qq_ids, list):
|
||||
self.bot_manager.set_bot_qq_ids(bot_qq_ids)
|
||||
elif bot_qq_ids:
|
||||
self.bot_manager.set_bot_qq_ids([bot_qq_ids])
|
||||
|
||||
def _get_platform_id(self):
|
||||
"""获取平台ID"""
|
||||
|
||||
+11
-1
@@ -22,6 +22,16 @@ class MessageAnalyzer:
|
||||
self.llm_analyzer = LLMAnalyzer(context, config_manager)
|
||||
self.user_analyzer = UserAnalyzer(config_manager)
|
||||
|
||||
def _extract_bot_qq_id_from_instance(self, bot_instance):
|
||||
"""从bot实例中提取QQ号(单个)"""
|
||||
if hasattr(bot_instance, "self_id") and bot_instance.self_id:
|
||||
return str(bot_instance.self_id)
|
||||
elif hasattr(bot_instance, "qq") and bot_instance.qq:
|
||||
return str(bot_instance.qq)
|
||||
elif hasattr(bot_instance, "user_id") and bot_instance.user_id:
|
||||
return str(bot_instance.user_id)
|
||||
return None
|
||||
|
||||
async def set_bot_instance(self, bot_instance):
|
||||
"""设置bot实例(保持向后兼容)"""
|
||||
if self.bot_manager:
|
||||
@@ -31,7 +41,7 @@ class MessageAnalyzer:
|
||||
bot_qq_id = self._extract_bot_qq_id_from_instance(bot_instance)
|
||||
if bot_qq_id:
|
||||
# 将单个QQ号转换为列表,保持统一处理
|
||||
await self.message_handler.set_bot_qq_id([bot_qq_id])
|
||||
await self.message_handler.set_bot_qq_ids([bot_qq_id])
|
||||
|
||||
async def analyze_messages(
|
||||
self, messages: List[Dict], group_id: str, unified_msg_origin: str = None
|
||||
|
||||
Reference in New Issue
Block a user