From 1b852dee9a0d2790b8e686d656f1caf9d7c486d7 Mon Sep 17 00:00:00 2001 From: Remik1r3n Date: Fri, 24 Jan 2025 11:35:54 +0800 Subject: [PATCH] minus improvements --- API_TitleServer.py | 6 +++--- ActionLoginBonus.py | 15 ++++++++++++--- HelperUnlockThing.py | 14 +------------- Static_Settings.py | 2 +- __init__.py | 0 5 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 __init__.py diff --git a/API_TitleServer.py b/API_TitleServer.py index d7eea97..db17d24 100644 --- a/API_TitleServer.py +++ b/API_TitleServer.py @@ -59,13 +59,13 @@ class aes_pkcs7(object): def SDGBApiHash(api): return hashlib.md5((api+"MaimaiChn"+ObfuscateParam).encode()).hexdigest() -def apiSDGB(data:str, useApi, agentExtraData, maxRetries=5): +def apiSDGB(data:str, useApi, agentExtraData, maxRetries=3): ''' 舞萌DX 2024 API 通讯用函数 :param data: 请求数据 :param useApi: 使用的 API :param agentExtraData: UA 附加信息,机台相关则为狗号(如A63E01E9564),用户相关则为 UID - :param maxRetry: 最大重试次数, 默认为 3 + :param maxRetry: 最大重试次数, ''' # 历史遗留代码有时候会传入 int,故先全部转 str @@ -123,7 +123,7 @@ def apiSDGB(data:str, useApi, agentExtraData, maxRetries=5): continue # 解压成功,解密请求并返回 resultResponse = unpad(aes.decrypt(responseDecompressed), 16).decode() - logger.info("TitleServer Response OK!") + logger.info("TitleServer:" + useApi + " Response: " + str(responseRaw.status_code)) logger.debug("TitleServer Response: " + str(resultResponse)) return resultResponse diff --git a/ActionLoginBonus.py b/ActionLoginBonus.py index 2bd8889..c31ab25 100644 --- a/ActionLoginBonus.py +++ b/ActionLoginBonus.py @@ -11,6 +11,15 @@ from HelperGetUserThing import implGetUser_ from HelperUploadUserPlayLog import apiUploadUserPlaylog from HelperUserAll import generateFullUserAll +def apiQueryLoginBonus(userId:int) -> str: + '''ログインボーナスを取得する API リクエスター''' + data = json.dumps({ + "userId": int(userId), + "nextIndex": 0, + "maxCount": 2000 + }) + return apiSDGB(data, "GetUserLoginBonusApi", userId) + def implLoginBonus(userId: int, currentLoginTimestamp:int, currentLoginResult, bonusGenerateMode=2): ''' ログインボーナスデータをアップロードする @@ -73,10 +82,10 @@ def implLoginBonus(userId: int, currentLoginTimestamp:int, currentLoginResult, b "nextIndex": 0, "maxCount": 2000 }) - logger.debug(json.loads(apiSDGB(data, "GetUserLoginBonusApi", userId))) + finalLoginBonusData = json.loads(apiSDGB(data, "GetUserLoginBonusApi", userId)) ###### PRODUCTION 用には、上記のコードを削除してください - return currentUserAllResult + return finalLoginBonusData def generateLoginBonusList(userId, generateMode=1): ''' @@ -88,7 +97,7 @@ def generateLoginBonusList(userId, generateMode=1): # HDDから、ログインボーナスデータを読み込む # アップデートがある場合、このファイルを更新する必要があります # 必ず最新のデータを使用してください - with open('loginBonus.json') as file: + with open('loginBonus.json', encoding='utf-8') as file: cache = json.load(file) loginBonusIdList = [item['id'] for item in cache] logger.debug(f"ログインボーナスIDリスト: {loginBonusIdList}") diff --git a/HelperUnlockThing.py b/HelperUnlockThing.py index 4ef4945..1675899 100644 --- a/HelperUnlockThing.py +++ b/HelperUnlockThing.py @@ -12,19 +12,6 @@ from HelperUserAll import generateFullUserAll def implUnlockThing(newUserItemList, userId: int, currentLoginTimestamp:int, currentLoginResult) -> str: ''' 解锁东西的实现 - Note: itemKind 如下 - PLATE = 1 # 姓名框 - TITLE = 2 # 称号 - ICON = 3 # 头像 - PRESENT = 4 - MUSIC = 5 # 乐曲 - MUSIC_MASTER = 6 - MUSIC_RE_MASTER = 7 - MUSIC_STRONG = 8 - CHARACTER = 9 # 旅行伙伴 - PARTNER = 10 # 搭档 - FRAME = 11 # 背景板 - TICKET = 12 # 功能票 ''' # 上传上去的歌曲记录 musicDataToBeUploaded = ({ @@ -70,3 +57,4 @@ def implUnlockThing(newUserItemList, userId: int, currentLoginTimestamp:int, cur logger.info("解锁东西:结果:"+ str(currentUserAllResult)) return currentUserAllResult + diff --git a/Static_Settings.py b/Static_Settings.py index 2011eff..f2c09e1 100644 --- a/Static_Settings.py +++ b/Static_Settings.py @@ -5,4 +5,4 @@ placeName = "赛博时空枣庄市中店" clientId = "A63E01E9564" # 日本精工,安全防漏 -from Private_Static_Settings import * +#from Private_Static_Settings import * diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29