refactor: split up modules

This commit is contained in:
2026-07-07 13:48:39 +08:00
parent 17c419dca0
commit a3c8426786
10 changed files with 10 additions and 11 deletions

View File

@@ -0,0 +1,42 @@
import hashlib
import json
from datetime import datetime
import httpx
import pytz
from sdgb.settings import KeychipID
def qr_api(qr_code: str):
if len(qr_code) > 64:
qr_code = qr_code[-64:]
time_stamp = datetime.now(pytz.timezone("Asia/Tokyo")).strftime("%y%m%d%H%M%S")
auth_key = (
hashlib.sha256(
(KeychipID + time_stamp + "XcW5FW4cPArBXEk4vzKz3CIrMuA5EVVW").encode(
"UTF-8"
)
)
.hexdigest()
.upper()
)
param = {
"chipID": KeychipID,
"openGameID": "MAID",
"key": auth_key,
"qrCode": qr_code,
"timestamp": time_stamp,
}
headers = {
"Contention": "Keep-Alive",
"Host": "ai.sys-all.cn",
"User-Agent": "WC_AIME_LIB",
}
res = httpx.post(
"http://ai.sys-allnet.cn/wc_aime/api/get_data",
data=json.dumps(param, separators=(",", ":")),
headers=headers,
)
assert res.status_code == 200, "网络错误"
return json.loads(res.content)