MCPcopy Create free account
hub / github.com/Loping151/RoverSign / should_resume

Method should_resume

RoverSign/utils/sign_state.py:75–104  ·  view source on GitHub ↗

检查是否应该恢复签到任务 Returns: bool: True 表示需要恢复签到

()

Source from the content-addressed store, hash-verified

73
74 @staticmethod
75 def should_resume() -> bool:
76 """
77 检查是否应该恢复签到任务
78
79 Returns:
80 bool: True 表示需要恢复签到
81 """
82 if not STATE_FILE.exists():
83 return False
84
85 state = SigningState.get_state()
86 if not state:
87 return False
88
89 # 检查状态文件是否过期(超过24小时视为无效)
90 try:
91 start_time = datetime.strptime(state["start_time"], "%Y-%m-%d %H:%M:%S")
92 now = datetime.now()
93 elapsed = (now - start_time).total_seconds()
94
95 if elapsed > 86400: # 24小时
96 logger.warning(f"[库洛签到·签到状态] 状态文件已过期({elapsed/3600:.1f}小时),清除")
97 SigningState.clear_state()
98 return False
99
100 logger.info(f"[库洛签到·签到状态] 发现未完成的签到任务: type={state['type']}, elapsed={elapsed/60:.1f}分钟")
101 return True
102 except Exception as e:
103 logger.error(f"[库洛签到·签到状态] 检查状态文件时出错: {e}")
104 return False
105
106
107# 创建全局实例

Callers 1

check_and_resume_signingFunction · 0.80

Calls 2

get_stateMethod · 0.80
clear_stateMethod · 0.80

Tested by

no test coverage detected