解决bug
This commit is contained in:
@@ -184,7 +184,7 @@ class MessagePushTask(MessagePluginInterface):
|
||||
self.db.log_task_action({
|
||||
'log_id': f"log_{datetime.now().strftime('%Y%m%d%H%M%S')}",
|
||||
'task_id': task['task_id'],
|
||||
'action': 'update', # 使用现有的action类型
|
||||
'action': 'update',
|
||||
'user_id': task['creator_id'],
|
||||
'changes': {'status': 'running'}
|
||||
})
|
||||
@@ -217,16 +217,6 @@ class MessagePushTask(MessagePluginInterface):
|
||||
)
|
||||
await self.bot.send_link_xml_message(xml_content, group_id)
|
||||
|
||||
# # 发送小程序消息
|
||||
# if content_miniprogram:
|
||||
# await self.bot.send_miniprogram_message(
|
||||
# group_id,
|
||||
# content_miniprogram.get('title'),
|
||||
# content_miniprogram.get('appid'),
|
||||
# content_miniprogram.get('pagepath'),
|
||||
# content_miniprogram.get('thumb_url')
|
||||
# )
|
||||
|
||||
success_count += 1
|
||||
|
||||
except Exception as e:
|
||||
@@ -234,12 +224,24 @@ class MessagePushTask(MessagePluginInterface):
|
||||
fail_count += 1
|
||||
|
||||
# 更新任务状态
|
||||
if fail_count == 0:
|
||||
status = 'completed'
|
||||
elif success_count == 0:
|
||||
status = 'failed'
|
||||
if task['schedule_type'] == 'recurring':
|
||||
# 检查是否超过重复结束时间
|
||||
recurring_end = task.get('recurring_end')
|
||||
if recurring_end and now > recurring_end:
|
||||
# 如果超过结束时间,标记为已完成
|
||||
status = 'completed'
|
||||
else:
|
||||
# 如果未超过结束时间,根据发送结果设置状态
|
||||
if fail_count == 0:
|
||||
status = 'scheduled' # 保持为已调度状态
|
||||
else:
|
||||
status = 'failed' # 任何失败都标记为失败
|
||||
else:
|
||||
status = 'partially_completed'
|
||||
# 非重复任务的状态处理
|
||||
if fail_count == 0:
|
||||
status = 'completed'
|
||||
else:
|
||||
status = 'failed'
|
||||
|
||||
self.db.update_task(task['task_id'], {'status': status})
|
||||
|
||||
@@ -247,13 +249,13 @@ class MessagePushTask(MessagePluginInterface):
|
||||
self.db.log_task_action({
|
||||
'log_id': f"log_{datetime.now().strftime('%Y%m%d%H%M%S')}",
|
||||
'task_id': task['task_id'],
|
||||
'action': 'update', # 使用现有的action类型
|
||||
'action': 'update',
|
||||
'user_id': task['creator_id'],
|
||||
'changes': {'status': status}
|
||||
})
|
||||
|
||||
# 如果是重复任务,更新下次执行时间
|
||||
if task['schedule_type'] == 'recurring':
|
||||
# 如果是重复任务且未超过结束时间,更新下次执行时间
|
||||
if task['schedule_type'] == 'recurring' and status != 'completed':
|
||||
next_time = self._calculate_next_schedule_time(
|
||||
task['schedule_time'],
|
||||
task['recurring_interval'],
|
||||
@@ -278,7 +280,7 @@ class MessagePushTask(MessagePluginInterface):
|
||||
self.db.log_task_action({
|
||||
'log_id': f"log_{datetime.now().strftime('%Y%m%d%H%M%S')}",
|
||||
'task_id': task['task_id'],
|
||||
'action': 'update', # 使用现有的action类型
|
||||
'action': 'update',
|
||||
'user_id': task['creator_id'],
|
||||
'changes': {'status': 'failed', 'error': str(e)}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user