fix eula确认存在问题
This commit is contained in:
39
bot.py
39
bot.py
@@ -167,7 +167,7 @@ async def uvicorn_main():
|
||||
await server.serve()
|
||||
|
||||
def check_eula():
|
||||
eula_confirm_file = Path("elua.confirmed")
|
||||
eula_confirm_file = Path("eula.confirmed")
|
||||
privacy_confirm_file = Path("privacy.confirmed")
|
||||
eula_file = Path("EULA.md")
|
||||
privacy_file = Path("PRIVACY.md")
|
||||
@@ -180,33 +180,40 @@ def check_eula():
|
||||
eula_confirmed = False
|
||||
privacy_confirmed = False
|
||||
|
||||
# 检查EULA确认文件是否存在
|
||||
if eula_confirm_file.exists():
|
||||
# 检查EULA文件版本是否更新(对比哈希)
|
||||
# 首先计算当前EULA文件的哈希值
|
||||
if eula_file.exists():
|
||||
with open(eula_file, "r", encoding="utf-8") as f:
|
||||
eula_content = f.read()
|
||||
eula_new_hash = hashlib.md5(eula_content.encode("utf-8")).hexdigest()
|
||||
else:
|
||||
logger.error("EULA.md 文件不存在")
|
||||
raise FileNotFoundError("EULA.md 文件不存在")
|
||||
|
||||
# 首先计算当前隐私条款文件的哈希值
|
||||
if privacy_file.exists():
|
||||
with open(privacy_file, "r", encoding="utf-8") as f:
|
||||
privacy_content = f.read()
|
||||
privacy_new_hash = hashlib.md5(privacy_content.encode("utf-8")).hexdigest()
|
||||
else:
|
||||
logger.error("PRIVACY.md 文件不存在")
|
||||
raise FileNotFoundError("PRIVACY.md 文件不存在")
|
||||
|
||||
# 检查EULA确认文件是否存在
|
||||
if eula_confirm_file.exists():
|
||||
with open(eula_confirm_file, "r", encoding="utf-8") as f:
|
||||
confirmed_content = f.read()
|
||||
# 计算EULA文件的md5值
|
||||
eula_new_hash = hashlib.md5(eula_content.encode("utf-8")).hexdigest()
|
||||
if eula_new_hash == confirmed_content:
|
||||
eula_confirmed = True
|
||||
eula_updated = False
|
||||
|
||||
|
||||
# 检查隐私条款确认文件是否存在
|
||||
if privacy_confirm_file.exists():
|
||||
# 检查隐私条款文件版本是否更新(对比哈希)
|
||||
with open(privacy_file, "r", encoding="utf-8") as f:
|
||||
privacy_content = f.read()
|
||||
with open(privacy_confirm_file, "r", encoding="utf-8") as f:
|
||||
confirmed_content = f.read()
|
||||
# 计算隐私条款文件的md5值
|
||||
privacy_new_hash = hashlib.md5(privacy_content.encode("utf-8")).hexdigest()
|
||||
if privacy_new_hash == confirmed_content:
|
||||
privacy_confirmed = True
|
||||
privacy_updated = False
|
||||
|
||||
|
||||
# 如果EULA或隐私条款有更新,提示用户重新确认
|
||||
if eula_updated or privacy_updated:
|
||||
print("EULA或隐私条款内容已更新,请在阅读后重新确认,继续运行视为同意更新后的以上两款协议")
|
||||
@@ -214,9 +221,13 @@ def check_eula():
|
||||
while True:
|
||||
user_input = input().strip().lower()
|
||||
if user_input in ['同意', 'confirmed']:
|
||||
# print("确认成功,继续运行")
|
||||
# print(f"确认成功,继续运行{eula_updated} {privacy_updated}")
|
||||
if eula_updated:
|
||||
print(f"更新EULA确认文件{eula_new_hash}")
|
||||
eula_confirm_file.write_text(eula_new_hash,encoding="utf-8")
|
||||
if privacy_updated:
|
||||
print(f"更新隐私条款确认文件{privacy_new_hash}")
|
||||
privacy_confirm_file.write_text(privacy_new_hash,encoding="utf-8")
|
||||
break
|
||||
else:
|
||||
@@ -232,7 +243,7 @@ def raw_main():
|
||||
time.tzset()
|
||||
|
||||
check_eula()
|
||||
|
||||
print("检查EULA和隐私条款完成")
|
||||
easter_egg()
|
||||
init_config()
|
||||
init_env()
|
||||
|
||||
Reference in New Issue
Block a user