[fix] 将 AutoScheduler 中残留的 self.bot_instance 全部改为通过 BotManager 获取实例

报错 “‘AutoScheduler’ object has no attribute ‘bot_instance’” 的原因是:我们在解耦后移除了 AutoScheduler 上的 bot_instance 成员,但 AutoScheduler 中发送消息的方法仍然使用了 self.bot_instance。
This commit is contained in:
SXP-Simon
2025-09-15 22:17:16 +08:00
parent 53a21f7642
commit 9443953c94
+10 -7
View File
@@ -216,12 +216,13 @@ class AutoScheduler:
async def _send_image_message(self, group_id: str, image_url: str):
"""发送图片消息到群"""
try:
if not self.bot_instance:
bot_instance = self.bot_manager.get_bot_instance()
if not bot_instance:
logger.error(f"{group_id} 发送图片失败:缺少bot实例")
return
# 发送图片消息到群
await self.bot_instance.api.call_action(
await bot_instance.api.call_action(
"send_group_msg",
group_id=group_id,
message=[{
@@ -240,12 +241,13 @@ class AutoScheduler:
async def _send_text_message(self, group_id: str, text_content: str):
"""发送文本消息到群"""
try:
if not self.bot_instance:
bot_instance = self.bot_manager.get_bot_instance()
if not bot_instance:
logger.error(f"{group_id} 发送文本失败:缺少bot实例")
return
# 发送文本消息到群
await self.bot_instance.api.call_action(
await bot_instance.api.call_action(
"send_group_msg",
group_id=group_id,
message=text_content
@@ -258,12 +260,13 @@ class AutoScheduler:
async def _send_pdf_file(self, group_id: str, pdf_path: str):
"""发送PDF文件到群"""
try:
if not self.bot_instance:
bot_instance = self.bot_manager.get_bot_instance()
if not bot_instance:
logger.error(f"{group_id} 发送PDF失败:缺少bot实例")
return
# 发送PDF文件到群
await self.bot_instance.api.call_action(
await bot_instance.api.call_action(
"send_group_msg",
group_id=group_id,
message=[{
@@ -280,7 +283,7 @@ class AutoScheduler:
logger.error(f"发送PDF文件到群 {group_id} 失败: {e}")
# 发送失败提示
try:
await self.bot_instance.api.call_action(
await bot_instance.api.call_action(
"send_group_msg",
group_id=group_id,
message=f"📊 每日群聊分析报告已生成,但发送PDF文件失败。PDF文件路径:{pdf_path}"