mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 23:43:02 +08:00
refactor(LibChecker, AutoLib): 重构 LibChecker 类中 canRenew 方法的返回值类型:
将 canRenew 方法的返回值类型指定为 tuple(bool, dict),并随之修改返回值以及调用 模块的调用逻辑。
This commit is contained in:
@@ -252,7 +252,8 @@ class AutoLib(MsgBase):
|
|||||||
result = 2
|
result = 2
|
||||||
# renewal
|
# renewal
|
||||||
if run_mode["auto_renewal"] and result == 2:
|
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_renew.renew(username, record, reserve_info):
|
||||||
if self.__lib_checker.postRenewCheck(record):
|
if self.__lib_checker.postRenewCheck(record):
|
||||||
result = 0
|
result = 0
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ class LibChecker(LibOperator):
|
|||||||
|
|
||||||
def canRenew(
|
def canRenew(
|
||||||
self
|
self
|
||||||
):
|
) -> tuple[bool, dict]:
|
||||||
|
|
||||||
# only check the current date
|
# only check the current date
|
||||||
date = time.strftime("%Y-%m-%d", time.localtime())
|
date = time.strftime("%Y-%m-%d", time.localtime())
|
||||||
@@ -326,12 +326,13 @@ class LibChecker(LibOperator):
|
|||||||
)
|
)
|
||||||
if abs(time_diff_seconds) < 120*60:
|
if abs(time_diff_seconds) < 120*60:
|
||||||
self._showTrace(f"{trace_msg}, 可以续约")
|
self._showTrace(f"{trace_msg}, 可以续约")
|
||||||
return record
|
return True, record
|
||||||
else:
|
else:
|
||||||
self._showTrace(f"{trace_msg}, 无法续约")
|
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} 没有有效预约记录, 无法续约")
|
self._showTrace(f"用户在 {date} 没有有效预约记录, 无法续约")
|
||||||
return None
|
return False, None
|
||||||
|
|
||||||
|
|
||||||
def postRenewCheck(
|
def postRenewCheck(
|
||||||
|
|||||||
Reference in New Issue
Block a user