MCPcopy Create free account
hub / github.com/runhey/OnmyojiAutoScript / check_time

Method check_time

tasks/DemonEncounter/script_task.py:348–369  ·  view source on GitHub ↗

检查时间是否正确, 如果正确就继续 如果不在17:00到22:00之间,就推迟到下一个 17:30 :return:

(self)

Source from the content-addressed store, hash-verified

346 pass
347
348 def check_time(self):
349 """
350 检查时间是否正确,
351 如果正确就继续
352 如果不在17:00到22:00之间,就推迟到下一个 17:30
353 :return:
354 """
355 now = datetime.now()
356 if now.hour < 17:
357 # 17点之前,推迟到当天的17点半
358 logger.info('Before 17:00, wait to 17:30')
359 target_time = datetime(now.year, now.month, now.day, 17, 30, 0)
360 self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
361 return False
362 elif now.hour >= 22:
363 # 22点之后,推迟到第二天的17:30
364 logger.info('After 22:00, wait to 17:30')
365 target_time = datetime(now.year, now.month, now.day, 17, 30, 0) + timedelta(days=1)
366 self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
367 return False
368 else:
369 return True
370
371 def battle_wait(self, random_click_swipt_enable: bool) -> bool:
372 # 重写

Callers 1

runMethod · 0.95

Calls 1

set_next_runMethod · 0.80

Tested by

no test coverage detected