事先声明,我不确定改完的逻辑正确

This commit is contained in:
shenjack 2024-11-04 00:24:31 +08:00
parent da31bcdc48
commit ba7b9a61d5
Signed by: shenjack
GPG Key ID: 7B1134A979775551

70
main.py
View File

@ -67,11 +67,23 @@ class TimeChecker:
end_time = datetime.datetime.strptime(times[1], "%H:%M") end_time = datetime.datetime.strptime(times[1], "%H:%M")
self.rest_lst.append((start_time, end_time)) self.rest_lst.append((start_time, end_time))
logger.info("时间检查器初始化完成") logger.info("时间检查器初始化完成")
def rest_time(self) -> int: ... def rest_last_time(self) -> int:
"""课间剩多久"""
if not self.during_rest():
return 0
now = datetime.datetime.now()
now_rest = [end_time for start_time, end_time in self.rest_lst if start_time <= now <= end_time]
if not now_rest:
return 0
return (now_rest[0] - now).seconds
def class_time(self) -> int: ...
def during_rest(self) -> bool:
now = datetime.datetime.now()
return any(start_time <= now <= end_time for start_time, end_time in self.rest_lst)
def is_during_class(self) -> int: ...
TIME_CHCKER = TimeChecker() TIME_CHCKER = TimeChecker()
@ -1531,16 +1543,10 @@ def choice(fromwhere):
try: try:
try: try:
if zz != fi[1]: if zz != fi[1]:
if rest(): on_button_click(
on_button_click( "人名单文件的sha256值\n与上次不一致。\n请确认人名单是否被篡改。\n按确定以继续。",
"人名单文件的sha256值\n与上次不一致。\n请确认人名单是否被篡改。\n按确定以继续。", "" if TIME_CHCKER.during_rest() else "pppp",
"", )
)
elif not rest():
on_button_click(
"人名单文件的sha256值\n与上次不一致。\n请确认人名单是否被篡改。\n按确定以继续。",
"pppp",
)
else: else:
password = True password = True
except: except:
@ -1548,7 +1554,7 @@ def choice(fromwhere):
password = True password = True
except: except:
pass pass
if rest() or (not rest() and password): if TIME_CHCKER.during_rest() or password:
logger.info("人名单sha256:" + file_sha256(NAME_LST_PATH)) logger.info("人名单sha256:" + file_sha256(NAME_LST_PATH))
logger.info(f"当前有{len(g_list)}") logger.info(f"当前有{len(g_list)}")
password = False password = False
@ -1565,20 +1571,14 @@ def choice(fromwhere):
sha = file_sha256(r"support/record.txt") + "\n" sha = file_sha256(r"support/record.txt") + "\n"
try: try:
if ooo != sha: if ooo != sha:
if rest(): on_button_click(
on_button_click( "抽中记录的sha256值\n与上次不一致。\n请确认记录是否被篡改。\n按确定以继续。",
"抽中记录的sha256值\n与上次不一致。\n请确认记录是否被篡改。\n按确定以继续。", "" if TIME_CHCKER.during_rest() else "pppp",
"", )
)
elif not rest():
on_button_click(
"抽中记录的sha256值\n与上次不一致。\n请确认记录是否被篡改。\n按确定以继续。",
"pppp",
)
else: else:
password = True password = True
if (rest()) or (not rest() and password): if TIME_CHCKER.during_rest() or password:
logger.info(f'操作后sha256:{file_sha256(r"support/record.txt")}') logger.info(f"操作后sha256:{file_sha256(r'support/record.txt')}")
password = False password = False
except: except:
pass pass
@ -1593,19 +1593,13 @@ def choice(fromwhere):
sha = file_sha256(r"support/journal.log") + "\n" sha = file_sha256(r"support/journal.log") + "\n"
try: try:
if jourlog != sha: if jourlog != sha:
if rest(): on_button_click(
on_button_click( "日志的sha256值\n与程序自动操作的不一致。\n请确认记录是否被篡改。\n按确定以继续。",
"日志的sha256值\n与程序自动操作的不一致。\n请确认记录是否被篡改。\n按确定以继续。", "" if TIME_CHCKER.during_rest() else "pppp",
"", )
)
elif not rest():
on_button_click(
"日志的sha256值\n与程序自动操作的不一致。\n请确认记录是否被篡改。\n按确定以继续。",
"pppp",
)
else: else:
password = True password = True
if (rest()) or (not rest() and password): if TIME_CHCKER.during_rest() or password:
password = False password = False
except: except:
pass pass
@ -2108,4 +2102,4 @@ t3 = threading.Thread(target=bsy, name="bsy")
t1.start() # 开始运行t1线程 t1.start() # 开始运行t1线程
time.sleep(5) time.sleep(5)
t2.start() # 开始运行t2线程 t2.start() # 开始运行t2线程
# t3.start() t3.start()