fix eula确认存在问题
This commit is contained in:
37
bot.py
37
bot.py
@@ -167,7 +167,7 @@ async def uvicorn_main():
|
|||||||
await server.serve()
|
await server.serve()
|
||||||
|
|
||||||
def check_eula():
|
def check_eula():
|
||||||
eula_confirm_file = Path("elua.confirmed")
|
eula_confirm_file = Path("eula.confirmed")
|
||||||
privacy_confirm_file = Path("privacy.confirmed")
|
privacy_confirm_file = Path("privacy.confirmed")
|
||||||
eula_file = Path("EULA.md")
|
eula_file = Path("EULA.md")
|
||||||
privacy_file = Path("PRIVACY.md")
|
privacy_file = Path("PRIVACY.md")
|
||||||
@@ -180,29 +180,36 @@ def check_eula():
|
|||||||
eula_confirmed = False
|
eula_confirmed = False
|
||||||
privacy_confirmed = False
|
privacy_confirmed = False
|
||||||
|
|
||||||
# 检查EULA确认文件是否存在
|
# 首先计算当前EULA文件的哈希值
|
||||||
if eula_confirm_file.exists():
|
if eula_file.exists():
|
||||||
# 检查EULA文件版本是否更新(对比哈希)
|
|
||||||
with open(eula_file, "r", encoding="utf-8") as f:
|
with open(eula_file, "r", encoding="utf-8") as f:
|
||||||
eula_content = f.read()
|
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:
|
with open(eula_confirm_file, "r", encoding="utf-8") as f:
|
||||||
confirmed_content = f.read()
|
confirmed_content = f.read()
|
||||||
# 计算EULA文件的md5值
|
|
||||||
eula_new_hash = hashlib.md5(eula_content.encode("utf-8")).hexdigest()
|
|
||||||
if eula_new_hash == confirmed_content:
|
if eula_new_hash == confirmed_content:
|
||||||
eula_confirmed = True
|
eula_confirmed = True
|
||||||
eula_updated = False
|
eula_updated = False
|
||||||
|
|
||||||
|
|
||||||
# 检查隐私条款确认文件是否存在
|
# 检查隐私条款确认文件是否存在
|
||||||
if privacy_confirm_file.exists():
|
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:
|
with open(privacy_confirm_file, "r", encoding="utf-8") as f:
|
||||||
confirmed_content = f.read()
|
confirmed_content = f.read()
|
||||||
# 计算隐私条款文件的md5值
|
|
||||||
privacy_new_hash = hashlib.md5(privacy_content.encode("utf-8")).hexdigest()
|
|
||||||
if privacy_new_hash == confirmed_content:
|
if privacy_new_hash == confirmed_content:
|
||||||
privacy_confirmed = True
|
privacy_confirmed = True
|
||||||
privacy_updated = False
|
privacy_updated = False
|
||||||
@@ -214,9 +221,13 @@ def check_eula():
|
|||||||
while True:
|
while True:
|
||||||
user_input = input().strip().lower()
|
user_input = input().strip().lower()
|
||||||
if user_input in ['同意', 'confirmed']:
|
if user_input in ['同意', 'confirmed']:
|
||||||
|
# print("确认成功,继续运行")
|
||||||
|
# print(f"确认成功,继续运行{eula_updated} {privacy_updated}")
|
||||||
if eula_updated:
|
if eula_updated:
|
||||||
|
print(f"更新EULA确认文件{eula_new_hash}")
|
||||||
eula_confirm_file.write_text(eula_new_hash,encoding="utf-8")
|
eula_confirm_file.write_text(eula_new_hash,encoding="utf-8")
|
||||||
if privacy_updated:
|
if privacy_updated:
|
||||||
|
print(f"更新隐私条款确认文件{privacy_new_hash}")
|
||||||
privacy_confirm_file.write_text(privacy_new_hash,encoding="utf-8")
|
privacy_confirm_file.write_text(privacy_new_hash,encoding="utf-8")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@@ -232,7 +243,7 @@ def raw_main():
|
|||||||
time.tzset()
|
time.tzset()
|
||||||
|
|
||||||
check_eula()
|
check_eula()
|
||||||
|
print("检查EULA和隐私条款完成")
|
||||||
easter_egg()
|
easter_egg()
|
||||||
init_config()
|
init_config()
|
||||||
init_env()
|
init_env()
|
||||||
|
|||||||
Reference in New Issue
Block a user