1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| from lcu_driver import Connector
connector = Connector()
async def get_summoner_data(connection): data = await connection.request('GET', '/lol-summoner/v1/current-summoner') summoner = await data.json() print(summoner) print(f"displayName: {summoner['displayName']}") print(f"summonerId: {summoner['summonerId']}") print(f"puuid: {summoner['puuid']}") print("-")
async def get_lockfile(connection): import os path = os.path.join(connection.installation_path.encode('gbk').decode('utf-8'), 'lockfile') if os.path.isfile(path): file = open(path, 'r') text = file.readline().split(':') file.close() print(connection.address) print(f'riot {text[3]}') return text[3] return None
async def create_custom_lobby(connection): custom = { 'customGameLobby': { 'configuration': { 'gameMode': 'TUTORIAL_MODULE_1', 'gameMutator': '', 'gameServerRegion': '', 'mapId': 11, 'mutators': {'id': 1}, 'spectatorPolicy': 'AllAllowed', 'teamSize': 5 }, 'lobbyName': 'PRACTICETOOL', 'lobbyPassword': '' }, 'isCustom': True } await connection.request('POST', '/lol-lobby/v2/lobby', data=custom)
async def add_bots_team1(connection): soraka = { 'championId': 102, 'botDifficulty': 'MEDIUM', 'teamId': '100' } await connection.request('POST', '/lol-lobby/v1/lobby/custom/bots', data=soraka)
async def add_bots_team2(connection): activedata = await connection.request('GET', '/lol-lobby/v2/lobby/custom/available-bots') champions = { bot['name']: bot['id'] for bot in await activedata.json() }
print("获取可使用的召唤师 :id--->name") for champion in champions: print(str(champions[champion]) + '--->' + champion)
team2 = ['诺克萨斯之手', '牛头酋长', '曙光女神', '武器大师', '瓦洛兰之盾'] for name in team2: bot = {'championId': champions[name], 'botDifficulty': 'MEDIUM', 'teamId': '200'} await connection.request('POST', '/lol-lobby/v1/lobby/custom/bots', data=bot)
@connector.ready async def connect(connection): await get_summoner_data(connection) await get_lockfile(connection) await create_custom_lobby(connection) await add_bots_team1(connection) await add_bots_team2(connection)
connector.start()
|