1
1
mirror of https://github.com/KenanZhu/AutoLibrary.git synced 2026-06-17 23:13:03 +08:00

refactor(LibChecker, AutoLib): 重构 LibChecker 类中 canRenew 方法的返回值类型:

将 canRenew 方法的返回值类型指定为 tuple(bool, dict),并随之修改返回值以及调用
模块的调用逻辑。
This commit is contained in:
2026-02-19 17:05:42 +08:00
parent 3963b3f2e6
commit 99d454a566
2 changed files with 7 additions and 5 deletions
+2 -1
View File
@@ -252,7 +252,8 @@ class AutoLib(MsgBase):
result = 2
# renewal
if run_mode["auto_renewal"] and result == 2:
if record := self.__lib_checker.canRenew():
can_renew, record = self.__lib_checker.canRenew()
if can_renew:
if self.__lib_renew.renew(username, record, reserve_info):
if self.__lib_checker.postRenewCheck(record):
result = 0
+5 -4
View File
@@ -309,7 +309,7 @@ class LibChecker(LibOperator):
def canRenew(
self
):
) -> tuple[bool, dict]:
# only check the current date
date = time.strftime("%Y-%m-%d", time.localtime())
@@ -326,12 +326,13 @@ class LibChecker(LibOperator):
)
if abs(time_diff_seconds) < 120*60:
self._showTrace(f"{trace_msg}, 可以续约")
return record
return True, record
else:
self._showTrace(f"{trace_msg}, 无法续约")
return None
return False, None # we do not need to return the record, because if current
# time is not available for renewal, the record is not required
self._showTrace(f"用户在 {date} 没有有效预约记录, 无法续约")
return None
return False, None
def postRenewCheck(