From fd46fbb1232de18a9e317a338448fd0f543b7e4d Mon Sep 17 00:00:00 2001 From: Kohaku Date: Fri, 14 Feb 2025 14:43:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=B0=8F=E9=BB=91=E5=B1=8B=20?= =?UTF-8?q?=E7=8E=B0=E5=AE=9E=E6=80=A7=E5=B9=B3=E8=A1=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ForceLogout.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ForceLogout.py b/ForceLogout.py index c949bf7..d203b7c 100644 --- a/ForceLogout.py +++ b/ForceLogout.py @@ -27,18 +27,15 @@ def getMaimaiUNIXTime(mmddhhmmss, year=2025): 解析用户输入的 MMDDHHMMSS 格式的时间,返回 Unix 时间戳 时间会被推后一个小时,因为舞萌貌似是 UTC+9 """ - try: - #date_time_str = f"{year}{mmddhhmmss}" - # 舞萌需要把小时按往后推一个小时来计算,加上一个小时 - date_time_str = f"{year}{mmddhhmmss[:4]}{int(mmddhhmmss[4:6])+1:02}{mmddhhmmss[6:]}" - date_time_obj = datetime.strptime(date_time_str, '%Y%m%d%H%M%S') - # 将 datetime 对象转换为 Unix 时间戳 - unix_timestamp = int(time.mktime(date_time_obj.timetuple())) - logger.info(f"转换出了时间戳: {unix_timestamp}") - return unix_timestamp - except ValueError as e: - print(f"时间格式错误: {e}") - return None + #date_time_str = f"{year}{mmddhhmmss}" + # 舞萌需要把小时按往后推一个小时来计算,加上一个小时 + date_time_str = f"{year}{mmddhhmmss[:4]}{int(mmddhhmmss[4:6])+1:02}{mmddhhmmss[6:]}" + date_time_obj = datetime.strptime(date_time_str, '%Y%m%d%H%M%S') + # 将 datetime 对象转换为 Unix 时间戳 + unix_timestamp = int(time.mktime(date_time_obj.timetuple())) + logger.info(f"转换出了时间戳: {unix_timestamp}") + return unix_timestamp + def logOut(userId, Timestamp): """极其简单的登出实现,成功返回 True,失败返回 False @@ -64,7 +61,7 @@ def isCorrectTimestamp(timestamp, userId): logger.debug(f"时间戳 {timestamp} 是否正确: {isLoggedOut}") return isLoggedOut -def findCorrectTimestamp(timestamp, userId, max_attempts=1200): +def findCorrectTimestamp(timestamp, userId, max_attempts=600): # 初始化偏移量 offset = 1 attempts = 0