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