解决bug
This commit is contained in:
@@ -142,14 +142,21 @@ class MessagePushTask(MessagePluginInterface):
|
|||||||
recurring_time = task.get('recurring_time')
|
recurring_time = task.get('recurring_time')
|
||||||
if recurring_time:
|
if recurring_time:
|
||||||
try:
|
try:
|
||||||
hour, minute = map(int, recurring_time.split(':'))
|
# 处理带秒数的时间格式
|
||||||
|
time_parts = recurring_time.split(':')
|
||||||
|
if len(time_parts) == 3:
|
||||||
|
hour, minute, second = map(int, time_parts)
|
||||||
|
else:
|
||||||
|
hour, minute = map(int, time_parts)
|
||||||
|
second = 0
|
||||||
|
|
||||||
# 检查当前时间是否在目标时间的前后5秒内
|
# 检查当前时间是否在目标时间的前后5秒内
|
||||||
target_time = now.replace(hour=hour, minute=minute, second=0, microsecond=0)
|
target_time = now.replace(hour=hour, minute=minute, second=second, microsecond=0)
|
||||||
time_diff = abs((now - target_time).total_seconds())
|
time_diff = abs((now - target_time).total_seconds())
|
||||||
if time_diff > 5: # 允许5秒的误差
|
if time_diff > 5: # 允许5秒的误差
|
||||||
continue
|
continue
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError) as e:
|
||||||
self.LOG.error(f"无效的执行时间格式: {recurring_time}")
|
self.LOG.error(f"无效的执行时间格式: {recurring_time}, 错误: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 更新任务状态为执行中
|
# 更新任务状态为执行中
|
||||||
|
|||||||
Reference in New Issue
Block a user