mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
[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:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user