检查日期和时间, 会设置是麒麟还是阴界之门 :return: 符合19:00-21:00的时间返回True, 否则返回False
(self)
| 45 | raise TaskEnd('Hunt') |
| 46 | |
| 47 | def check_datetime(self) -> bool: |
| 48 | """ |
| 49 | 检查日期和时间, 会设置是麒麟还是阴界之门 |
| 50 | :return: 符合19:00-21:00的时间返回True, 否则返回False |
| 51 | """ |
| 52 | now = datetime.now() |
| 53 | day_of_week = now.weekday() |
| 54 | if 0 <= day_of_week <= 3: |
| 55 | self.kirin_day = True |
| 56 | elif 4 <= day_of_week <= 6: |
| 57 | self.kirin_day = False |
| 58 | |
| 59 | |
| 60 | now = datetime.now() |
| 61 | # 如果时间在00:00-19:00 之间则设定时间为当天的19:00,返回False |
| 62 | if now.time() < time(19, 0): |
| 63 | next_run = datetime.combine(now.date(), time(19, 0)) |
| 64 | self.set_next_run(task='Hunt', success=False, finish=True, target=next_run) |
| 65 | raise TaskEnd('Hunt') |
| 66 | # 如果是在21:00-23:59之间则设定时间为明天的19:00,返回False |
| 67 | elif now.time() > time(21, 0): |
| 68 | next_run = datetime.combine(now.date() + timedelta(days=1), time(19, 0)) |
| 69 | self.set_next_run(task='Hunt', success=False, finish=True, target=next_run) |
| 70 | raise TaskEnd('Hunt') |
| 71 | # 如果是在19:00-21:00之间则返回True |
| 72 | else: |
| 73 | return True |
| 74 | |
| 75 | |
| 76 | def kirin(self): |
no test coverage detected