前往
大廳
主題

2025 英雄聯盟卸除個人資料成就代幣

勝利巧虎 | 2025-11-26 08:51:45 | 巴幣 0 | 人氣 53

使用python3執行下列程式碼 第四行根據自己的遊戲資料夾進行修改 (如果不在C槽的話自行修改一下)

import base64
import requests

LOCKFILE_PATH = r"C:\Riot Games\League of Legends\lockfile"

def parse_lockfile(path):
    """
    - LeagueClient:PID:PORT:PASSWORD:PROTOCOL
    - RiotClientUx:PORT:PASSWORD:PROTOCOL:PID
    回傳 dict: {name, pid, port, password, protocol}
    """
    with open(path, "r", encoding="utf-8") as f:
        raw = f.read().strip()

    parts = raw.split(":")
    if len(parts) < 5:
        raise ValueError(f"Lockfile 欄位不足,內容: {raw}")

    name = parts[0]

    # LeagueClient 格式
    if name.startswith("LeagueClient") or name.startswith("LeagueClientUx"):
        pid = parts[1]
        port = parts[2]
        password = parts[3]
        protocol = parts[4]
    # RiotClient 格式
    elif name.startswith("RiotClient") or name.startswith("RiotClientUx"):
        port = parts[1]
        password = parts[2]
        protocol = parts[3]
        pid = parts[4]
    else:
        # 嘗試推斷
        nums = [p for p in parts if p.isdigit()]
        if not nums:
            raise ValueError(f"Lockfile 無數字欄位可判斷 port,內容: {raw}")
        port = nums[1] if len(nums) >= 2 else nums[0]
        password_candidates = [p for p in parts if not p.isdigit() and p.lower() not in ("http", "https") and not p.startswith(name)]
        password = password_candidates[0] if password_candidates else parts[2]
        protocol_candidates = [p for p in parts if p.lower() in ("http", "https")]
        protocol = protocol_candidates[0] if protocol_candidates else "https"
        pid = nums[0]
        name = parts[0]

    if not port.isdigit():
        raise ValueError(f"Port 欄位不是數字:{port},lockfile: {raw}")

    return {
        "name": name,
        "pid": pid,
        "port": int(port),
        "password": password,
        "protocol": protocol.lower()
    }

def build_auth_header(password: str):
    token = base64.b64encode(f"riot:{password}".encode()).decode()
    return {"Authorization": f"Basic {token}"}

def main():
    info = parse_lockfile(LOCKFILE_PATH)
    print(f"[DEBUG] lockfile 解析: {info}")

    scheme = "https" if info["protocol"] == "https" else "http"
    base = f"{scheme}://127.0.0.1:{info['port']}"
    url = f"{base}/lol-challenges/v1/update-player-preferences"

    headers = {
        **build_auth_header(info["password"]),
        "Content-Type": "application/json",
        "Accept": "application/json"
    }

    # 卸除成就代幣的 body
    payload = {
        "challengeIds": [-1, -1, -1],   # 全部設為 -1 表示不顯示任何挑戰代幣
    }

    print(f"[DEBUG] POST {url}")
    print(f"[DEBUG] Headers: {{'Authorization': <hidden>, 'Content-Type': 'application/json'}}")
    print(f"[DEBUG] Payload: {payload}")

    try:
        resp = requests.post(url, json=payload, headers=headers, verify=False, timeout=5)
        print(f"[RESULT] Status: {resp.status_code}")
        print(f"[RESULT] Body: {resp.text}")
    except requests.exceptions.RequestException as e:
        print(f"[ERROR] 連線失敗: {e}")

if __name__ == "__main__":
    main()

相關創作

更多創作