解决bug
This commit is contained in:
@@ -142,13 +142,20 @@ class MessagePushTask(MessagePluginInterface):
|
||||
recurring_time = task.get('recurring_time')
|
||||
if recurring_time:
|
||||
try:
|
||||
# 处理带秒数的时间格式
|
||||
time_parts = recurring_time.split(':')
|
||||
if len(time_parts) == 3:
|
||||
hour, minute, second = map(int, time_parts)
|
||||
# 处理 timedelta 对象
|
||||
if isinstance(recurring_time, timedelta):
|
||||
total_seconds = int(recurring_time.total_seconds())
|
||||
hour = total_seconds // 3600
|
||||
minute = (total_seconds % 3600) // 60
|
||||
second = total_seconds % 60
|
||||
else:
|
||||
hour, minute = map(int, time_parts)
|
||||
second = 0
|
||||
# 处理字符串格式
|
||||
time_parts = str(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秒内
|
||||
target_time = now.replace(hour=hour, minute=minute, second=second, microsecond=0)
|
||||
|
||||
Reference in New Issue
Block a user