本站所有源码来源于网络。源码只是供大家研究学习之用。请大家不要商用,如因商用或其他原因引起一切纠纷和本人与论坛无关,后果自负,请下载后24小时内删除!!!

获取召唤师信息
     自动寻找接受对局
     一键配置符文
     下载符文到本地(https://www.op.gg/_next/data/4PrRvjK6-FMwqJEfhArSq/champions/’ + name + ‘/’ + position + ‘/runes.json)
     4PrRvjK6-FMwqJEfhArSq这一段是opgg定时会随机成其他字符串,请问各位有解决方法么
【main.py】

import json
import runes_path
import os
import re
import sys
import threading
from time import sleep
import requests
import urllib3
 
# 屏蔽安全警告
urllib3.disable_warnings()
# 设置Falg线程参数
event = threading.Event()
 
 
class AuthToken(object):
    """获取LOL端口及密钥信息"""
 
    def __init__(self):
        self.url = None
        self.host = '127.0.0.1'
        self.agreement = 'https://'
        self.port = None
        self.token = None
 
    def get_info(self):
        f = os.popen('WMIC PROCESS WHERE name="LeagueClientUx.exe" GET commandline', 'r')
        d = f.read()
        self.port = re.findall(r'--app-port=(\d*)', d)[0]
        self.token = re.findall(r'--remoting-auth-token=(.*?)"', d)[0]
        # port_token = app_port + app_token
        self.url = self.agreement + 'riot:' + str(self.token) + '@' + self.host + ':' + str(self.port)
        return self.url
 
 
class LcuApi(AuthToken):
    @staticmethod
    def tips():
        print('-' * 15 + '功能选择' + '-' * 15)
        print('第一次打开应用需要手动选择更新符文信息,否则会导致符文配置功能无法使用')
        print('请勿频繁更新符文,会导致IP被限制访问opgg,第一次打开程序更新一次,后面可以每天选择更新一次!')
        print("1、获取召唤师信息")
        print("2、开启自动寻找与接受对局")
        print("3、关闭自动寻找与接受对局")
        print("4、一键配置符文")
        print("5、更新符文信息")
        print("0、退出系统")
 
    def client_info(self):
        """取客户端状态信息"""
        while True:
            rest = "/lol-gameflow/v1/gameflow-phase"
            text = requests.get(self.url + rest, verify=False)
            info_list = text.json()
            event.wait()
            if info_list == 'ReadyCheck':
                lcu.accept_match()
            elif info_list == 'Lobby':
                lcu.auto_match()
            sleep(1)
 
    def friend(self):
        """获取好友信息"""
        rest = "/lol-summoner/v1/current-summoner"
        request = requests.get(self.url + rest, verify=False).json()
        print(f'用户名:{request["displayName"]}')
        print(f'等  级:{request["summonerLevel"]}')
        print(f'经  验:{request["xpSinceLastLevel"]} / {request["xpUntilNextLevel"]}')
        print(f'用户id:{request["accountId"]}')
        money = requests.get(self.url + '/lol-store/v1/wallet', verify=False).json()
        print(f'蓝色精粹:{money["rp"]}')
        print(f'橙色精粹:{money["ip"]}')
        # print(request['displayName'])
 
    def auto_match(self):
        """寻找对局"""
        rest = "/lol-lobby/v2/lobby/matchmaking/search"
        requests.post(self.url + rest, verify=False)
 
    def accept_match(self):
        """接受对局"""
        rest = "/lol-matchmaking/v1/ready-check/accept"
        requests.post(self.url + rest, verify=False)
 
    def get_rune(self):
        """一键配置符文"""
        # 获取选择的英雄
        static_hero = requests.get(
            self.url + '/lol-lobby-team-builder/champ-select/v1/session',
            verify=False).json()
        judge_info = str(static_hero).find('progress')
        print(judge_info)
        if judge_info == -1:
            # 没有找到progress,为匹配对局
            print(static_hero)
            print('测试信息')
            try:
                name = []
                # static_hero['localPlayerCellId'] 大于4是红色方,小于等于4是蓝色方
                if static_hero['localPlayerCellId'] > 4:
                    for i in static_hero['myTeam']:
                        name.append(i)
                    choice_hero = (name[static_hero['localPlayerCellId'] - 5]['championId'])
                else:
                    for i in static_hero['myTeam']:
                        name.append(i)
                    print(name[static_hero['localPlayerCellId']]['championId'])
                    choice_hero = (name[static_hero['localPlayerCellId']]['championId'])
            except:
                print('请选择英雄后在配置符文')
                return
        else:
            lock_hero = requests.get(self.url + '/lol-champ-select-legacy/v1/session', verify=False).json()  # 找到progress,为自定义对局
            try:
                for i in lock_hero['actions']:
                    for j in i:
                        hero_id = j
                print(hero_id['championId'])
                choice_hero = hero_id['championId']
            except:
                print('请在选择英雄的时候在配置符文')
                return
        # 获取所有英雄信息
        hero_list = requests.get(
            self.url + '/lol-game-data/assets/v1/champion-summary.json',
            verify=False).json()
        # print(hero_list)
        for i in hero_list:
            if choice_hero == i['id']:
                print(i['id'])
                print(i['alias'])
                try:
                    file_rune = open('opgg/' + str(i['alias']).lower() + '.data')
                    file_runes = eval(file_rune.read())
                    primarystyleId = file_runes[0]['primary_page_id']
                    selectedperkids = file_runes[0]['primary_rune_ids'] + file_runes[0]['secondary_rune_ids'] + \
                                      file_runes[0]['stat_mod_ids']
                    substyleid = file_runes[0]['secondary_page_id']
                    # 取所有符文页:/lol-perks/v1/pages
                    # 取当前符文页:/lol-perks/v1/currentpage
                    rest = "/lol-perks/v1/currentpage"
                    text = requests.get(self.url + rest, verify=False)
                    info_rune = text.json()
                    rune_id = str(info_rune['id'])
                    add_del_rune = "/lol-perks/v1/pages"
                    if info_rune['isDeletable']:
                        # 删除符文:/lol-perks/v1/pages/     delete
                        requests.delete(self.url + add_del_rune + '/' + rune_id, verify=False)
                        print('检测到默认符文页,执行删除新建')
                        # 设置符文:/lol-perks/v1/pages      post
                        requests.post(self.url + add_del_rune, data=json.dumps(
                            {'name': i['name'], 'primaryStyleId': primarystyleId, 'selectedPerkIds': selectedperkids,
                             'subStyleId': substyleid}), verify=False).json()
                    else:
                        print('不存在默认符文页,直接新建!')
                        requests.post(self.url + add_del_rune, data=json.dumps(
                            {'name':  i['name'], 'primaryStyleId': primarystyleId, 'selectedPerkIds': selectedperkids,
                             'subStyleId': substyleid}), verify=False).json()
                except:
                    print('您的符文列表没有更新,或者更新失败,请查看opgg文件夹中的data文件是否有数据')
                    return
        else:
            print('请锁定英雄后在配置符文')
 
    def test_info(self):
        rest = '/lol-game-data/assets/v1/champion-summary.json'
        request = requests.get(self.url + rest, verify=False)
        info_list = request.json()
        print(info_list)
 
 
if __name__ == '__main__':
    lcu = LcuApi()
 
    try:
        lcu.get_info()
    except Exception as res:
        print(f'错误信息:{res},退出!')
        sys.exit()
    client_thread = threading.Thread(target=lcu.client_info, daemon=True)
    client_thread.start()
 
    while True:
        # os.system('cls')
        lcu.tips()
        try:
            user_put = int(input("请选择:"))
        except Exception as res:
            print(f'错误信息:{res},请选择正确的功能')
            continue
        if user_put == 1:
            lcu.friend()
        elif user_put == 2:
            # 让子线程停止堵塞
            event.set()
            os.popen('title 自动寻找与接受对局:已开启')
        elif user_put == 3:
            # 让子线程开启堵塞
            event.clear()
            os.popen('title 自动寻找与接受对局:已关闭')
        elif user_put == 4:
            lcu.get_rune()
        elif user_put == 5:
            runes_path.start_updata_rune()
            print('符文更新成功!')
        elif user_put == 9:
            print(lcu.get_info())
        elif user_put == 0:
            break

【runes_path.py】

 

 

温馨提示: 本文最后更新于2022-10-03 23:56:50,某些文章具有时效性,若有错误或已失效,请在下方 留言或联系 联系我
本源码仅供爱好者研究使用,请下载后24小时内删除!!!
© 版权声明