From 09dd3588cbae430b6a2f6929f1ca2505badd11df Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 12 Jun 2025 13:45:47 +0800 Subject: [PATCH] =?UTF-8?q?voice=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/message_push_task/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/message_push_task/main.py b/plugins/message_push_task/main.py index d915f69..e582c1c 100644 --- a/plugins/message_push_task/main.py +++ b/plugins/message_push_task/main.py @@ -258,7 +258,10 @@ class MessagePushTask(MessagePluginInterface): # 发送语音消息 if content_voice: - await self.bot.send_voice_message(group_id, Path(content_voice)) + voice_path = Path(task['content_voice']) + # 根据文件扩展名确定类型 + voice_type = 'wav' if voice_path.suffix.lower() == '.wav' else 'mp3' + await self.bot.send_voice_message(group_id, Path(content_voice), voice_type) # 发送视频消息 if content_video: @@ -312,7 +315,7 @@ class MessagePushTask(MessagePluginInterface): update_data = {'status': status} if next_time: update_data['schedule_time'] = next_time - + self.db.update_task(task['task_id'], update_data) # 记录任务完成 @@ -415,13 +418,15 @@ class MessagePushTask(MessagePluginInterface): days_ahead = next_weekday - current_weekday # 计算下次执行时间 - next_time = now.replace(hour=hour, minute=minute, second=second, microsecond=0) + timedelta(days=days_ahead) + next_time = now.replace(hour=hour, minute=minute, second=second, microsecond=0) + timedelta( + days=days_ahead) # 如果计算出的时间小于等于当前时间,说明计算有误,需要再加一周 if next_time <= now: next_time = next_time + timedelta(days=7) - self.LOG.info(f"每周任务计算:当前周几={current_weekday}, 下次执行周几={next_weekday}, 天数差={days_ahead}, 下次执行时间={next_time}") + self.LOG.info( + f"每周任务计算:当前周几={current_weekday}, 下次执行周几={next_weekday}, 天数差={days_ahead}, 下次执行时间={next_time}") except (json.JSONDecodeError, ValueError, IndexError) as e: self.LOG.error(f"处理每周执行日失败: {e}")