forked from Kohaku/maimaiDX-Api
Minor modifies
This commit is contained in:
parent
6e05b211ac
commit
a714fc5655
@ -55,14 +55,14 @@ def implLoginBonus(userId: int, currentLoginTimestamp:int, currentLoginResult, b
|
||||
try:
|
||||
currentUserAllResult = json.loads(apiSDGB(data, "UpsertUserAllApi", userId))
|
||||
except Request500Error:
|
||||
logger.warning("500 Error Triggered. Rebuilding data.")
|
||||
logger.warning("500エラーが発生しました。データを再構築します。")
|
||||
retries += 1
|
||||
continue
|
||||
except Exception:
|
||||
raise WahlapServerBoomedError("邪门错误")
|
||||
raise WahlapServerBoomedError("不明なエラー")
|
||||
break
|
||||
else: # 重试次数超过3次
|
||||
raise Request500Error("多次尝试后仍无法成功上传 UserAll")
|
||||
else:
|
||||
raise Request500Error("500エラーが発生しました。UserAllをアップロードできませんでした。")
|
||||
|
||||
|
||||
###### Debug 機能:ログインボーナスをもう一度取得(確認用)
|
||||
@ -83,21 +83,21 @@ def generateLoginBonusList(userId, generateMode=1):
|
||||
ログインボーナスリストを生成します。
|
||||
generateMode は、ログインボーナスを生成する方法を指定します。
|
||||
1: 全部 MAX にする
|
||||
2: いま選択したボーナスのみ MAX にする(選択したボーナスはないの場合は False を返す)
|
||||
2: 選択したボーナスのみ MAX にする(選択したボーナスはないの場合は False を返す)
|
||||
'''
|
||||
|
||||
# ログインボーナスの MAX POINT は5の場合があります
|
||||
# その全部のボーナスIDをこのリストに追加してください
|
||||
Bonus5Id = [12, 29, 30, 38, 43, 604]
|
||||
|
||||
# HDDから、ログインボーナスデータを読み込む
|
||||
# アップデートがある場合、このファイルを更新する必要があります
|
||||
# 必ず最新のデータを使用してください!
|
||||
# 必ず最新のデータを使用してください
|
||||
with open('loginBonus.json') as file:
|
||||
cache = json.load(file)
|
||||
loginBonusIdList = [item['id'] for item in cache]
|
||||
logger.debug(f"ログインボーナスIDリスト: {loginBonusIdList}")
|
||||
|
||||
# ログインボーナスの MAX POINT は5の場合があります
|
||||
# その全部のボーナスIDをこのリストに追加してください
|
||||
# 必ず最新のデータを使用してください
|
||||
Bonus5Id = [12, 29, 30, 38, 43, 604]
|
||||
|
||||
# サーバーからUserのログインボーナスデータを取得
|
||||
data = json.dumps({
|
||||
"userId": int(userId),
|
||||
|
@ -17,17 +17,18 @@ aesKeyPrism = "A;mv5YUpHBK3YxTy5KB^[;5]C2AL50Bq"
|
||||
aesIVPrism = "9FM:sd9xA91X14v]"
|
||||
|
||||
class AESPKCS7:
|
||||
# 实现了 maimai 通讯所用的 AES 加密的类
|
||||
def __init__(self, key: str, iv: str):
|
||||
self.key = key.encode('utf-8')
|
||||
self.iv = iv.encode('utf-8')
|
||||
self.mode = AES.MODE_CBC
|
||||
|
||||
# 加密
|
||||
def encrypt(self, content: bytes) -> bytes:
|
||||
cipher = AES.new(self.key, self.mode, self.iv)
|
||||
content_padded = pad(content, AES.block_size)
|
||||
encrypted_bytes = cipher.encrypt(content_padded)
|
||||
return encrypted_bytes
|
||||
|
||||
# 解密
|
||||
def decrypt(self, encrypted_content: bytes) -> str:
|
||||
cipher = AES.new(self.key, self.mode, self.iv)
|
||||
decrypted_padded = cipher.decrypt(encrypted_content)
|
||||
|
@ -39,15 +39,12 @@ def implUnlockThing(newUserItemList, userId: int, currentLoginTimestamp:int, cur
|
||||
"extNum1": 0
|
||||
})
|
||||
|
||||
# UserData を取得
|
||||
currentUserData = implGetUser_("Data", userId)
|
||||
currentUserData2 = currentUserData['userData']
|
||||
|
||||
# UserPlayLog を構築してアップロード
|
||||
currentUploadUserPlaylogApiResult = apiUploadUserPlaylog(userId, musicDataToBeUploaded, currentUserData2, currentLoginResult['loginId'])
|
||||
logger.debug(f"上传 UserPlayLog 结果: {currentUploadUserPlaylogApiResult}")
|
||||
|
||||
# UserAllを構築してアップロード
|
||||
retries = 0
|
||||
while retries < 3:
|
||||
currentSpecialNumber = calcSpecialNumber()
|
||||
@ -68,7 +65,7 @@ def implUnlockThing(newUserItemList, userId: int, currentLoginTimestamp:int, cur
|
||||
except Exception:
|
||||
raise WahlapServerBoomedError("邪门错误")
|
||||
break
|
||||
else: # 重试次数超过3次
|
||||
else:
|
||||
raise Request500Error("多次尝试后仍无法成功上传 UserAll")
|
||||
|
||||
logger.info("解锁东西:结果:"+ str(currentUserAllResult))
|
||||
|
@ -13,17 +13,6 @@ from Static_Settings import *
|
||||
def apiUploadUserPlaylog(userId:int, musicDataToBeUploaded, currentUserData2, loginId:int) -> str:
|
||||
'''返回 Json String。'''
|
||||
|
||||
# 暂存,优化可读性(迫真)
|
||||
musicId = musicDataToBeUploaded['musicId']
|
||||
level = musicDataToBeUploaded['level']
|
||||
#playCount = musicDataToBeUploaded['playCount']
|
||||
achievement = musicDataToBeUploaded['achievement']
|
||||
#comboStatus = musicDataToBeUploaded['comboStatus']
|
||||
#syncStatus = musicDataToBeUploaded['syncStatus']
|
||||
deluxscoreMax = musicDataToBeUploaded['deluxscoreMax']
|
||||
scoreRank = musicDataToBeUploaded['scoreRank']
|
||||
#extNum1 = musicDataToBeUploaded['extNum1']
|
||||
|
||||
# 构建一个 PlayLog
|
||||
data = json.dumps({
|
||||
"userId": int(userId),
|
||||
@ -34,12 +23,12 @@ def apiUploadUserPlaylog(userId:int, musicDataToBeUploaded, currentUserData2, lo
|
||||
"version": 1041000,
|
||||
"placeId": placeId,
|
||||
"placeName": placeName,
|
||||
"loginDate": int(time.time()), #似乎和登录timestamp不同,暂时不作更改
|
||||
"loginDate": int(time.time()), #似乎和登录timestamp不同
|
||||
"playDate": datetime.now(pytz.timezone('Asia/Shanghai')).strftime('%Y-%m-%d'),
|
||||
"userPlayDate": datetime.now(pytz.timezone('Asia/Shanghai')).strftime('%Y-%m-%d %H:%M:%S') + '.0',
|
||||
"type": 0,
|
||||
"musicId": int(musicId),
|
||||
"level": int(level),
|
||||
"musicId": int(musicDataToBeUploaded['musicId']),
|
||||
"level": int(musicDataToBeUploaded['level']),
|
||||
"trackNo": 1,
|
||||
"vsMode": 0,
|
||||
"vsUserName": "",
|
||||
@ -73,9 +62,9 @@ def apiUploadUserPlaylog(userId:int, musicDataToBeUploaded, currentUserData2, lo
|
||||
"characterId5": currentUserData2['charaSlot'][4],
|
||||
"characterLevel5": random.randint(1000,6500),
|
||||
"characterAwakening5": 5,
|
||||
"achievement": int(achievement),
|
||||
"deluxscore": int(deluxscoreMax),
|
||||
"scoreRank": int(scoreRank),
|
||||
"achievement": int(musicDataToBeUploaded['achievement']),
|
||||
"deluxscore": int(musicDataToBeUploaded['deluxscoreMax']),
|
||||
"scoreRank": int(musicDataToBeUploaded['scoreRank']),
|
||||
"maxCombo": 0,
|
||||
"totalCombo": random.randint(700,900),
|
||||
"maxSync": 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user