async def check_matchmaking_errors(connection: LeagueConnection):
    ''' Reutrns the matchmaking errors if exists '''
    future = connection.async_get("/lol-matchmaking/v1/search/errors")
    await asyncio.sleep(0)
    res = future.result()
    if res.status_code == 200:
        if res.json() == []:
            return None
        return res.json()
Exemple #2
0
async def get_username(connection: LeagueConnection):
    ''' Parses the username '''
    future = connection.async_get('/lol-login/v1/login-platform-credentials')
    await asyncio.sleep(0)
    res = future.result()
    res_json = res.json()
    if 'username' not in res_json:
        return None
    return res_json['username']
Exemple #3
0
async def get_blue_essence(connection: LeagueConnection):
    ''' Parses the blue essence value '''
    future = connection.async_get('/lol-store/v1/wallet')
    await asyncio.sleep(0)
    res = future.result()
    res_json = res.json()
    if 'ip' not in res_json:
        return -1
    return res_json['ip']
async def check_search_state(connection: LeagueConnection):
    ''' Reutrns the current search state'''
    future = connection.async_get(
        "/lol-lobby/v2/lobby/matchmaking/search-state")
    await asyncio.sleep(0)
    res = future.result()
    res_json = res.json()
    if res_json["errors"] != []:
        return None
    return res_json["searchState"]
Exemple #5
0
async def check_gameflow(connection: LeagueConnection):
    '''
    Returns the current gamflow phase.
    Return values might include Lobby, EndOfGame, ReadyCheck,
    ChampSelect, WaitingForStats, Reconnect, PreEndOfGame, EndOfGame
    '''
    future = connection.async_get('/lol-gameflow/v1/session')
    await asyncio.sleep(0)
    res = future.result()
    if res.status_code == 404:
        return None
    return res.json()
Exemple #6
0
async def get_summoner_data(connection: LeagueConnection):
    ''' Parses the data of current sumoner '''
    future = connection.async_get('/lol-summoner/v1/current-summoner')
    await asyncio.sleep(1)
    res = future.result()
    json_ = res.json()
    return (
        json_['summonerLevel'] if 'summonerLevel' in json_ else -1,
        json_['percentCompleteForNextLevel'] if 'percentCompleteForNextLevel' in json_ else 0,
        json_['profileIconId'] if 'profileIconId' in json_ else -1,
        json_['summonerId'] if 'summonerId' in json_ else -1
    )
Exemple #7
0
async def get_tutorial_status(logger: Logger, connection: LeagueConnection, gathering_data_limit):
    ''' Parses the tutorial status '''
    start_time = time.time()
    while True:
        if time.time() - start_time >= gathering_data_limit:
            return ('UNLOCKED', 'LOCKED', 'LOCKED')
        await init_tutorial(logger, connection)
        future = connection.async_get('/lol-npe-tutorial-path/v1/tutorials')
        await asyncio.sleep(0)
        res = future.result()
        res_json = res.json()
        if res_json == []:
            await asyncio.sleep(1)
            continue
        return res_json[0]["status"], res_json[1]["status"], res_json[2]["status"]
Exemple #8
0
async def get_missions(connection: LeagueConnection, gathering_data_limit, get_fwotd=False):
    ''' Parses the missions data '''
    start_time = time.time()
    while True:
        if time.time() - start_time >= gathering_data_limit:
            raise LogoutNeededException
        future = connection.async_get('/lol-missions/v1/missions')
        await asyncio.sleep(0)
        res = future.result()
        res_json = res.json()
        if res_json == []:
            await asyncio.sleep(5)
            continue
        rewards_data = []
        for reward in NPE_REWARDS:
            rewards_data.append(
                next(filter(lambda x, r=reward: x['internalName'] == r, res_json), None))
        try:
            if get_fwotd:
                fwotd = sorted(filter(
                    lambda x: x['internalName'] == 'fwotd_mission', res_json
                ), key=lambda x: x['lastUpdatedTimestamp'], reverse=True)[0]
                if fwotd['status'] == 'COMPLETED':
                    if fwotd['completedDate'] in [0, -1]:
                        raise FwotdDataParseException
                rewards_data.append(fwotd)
        except (IndexError, KeyError, FwotdDataParseException):
            await asyncio.sleep(5)
            continue
        try:
            rewards_data.append(sorted(filter(
                lambda x: x['internalName'] == 'prestige_02_v3', res_json
            ), key=lambda x: x['lastUpdatedTimestamp'])[0])
        except IndexError:
            await asyncio.sleep(5)
            continue

        rewards = {}
        for reward_data in rewards_data:
            rewards[reward_data['internalName']] = {
                'internalName': reward_data['internalName'],
                'id': reward_data['id'],
                'status': reward_data['status'],
                'completed_date': reward_data['completedDate']
            }
        return rewards
Exemple #9
0
async def trackers_opt_int(connection: LeagueConnection):
    ''' Opt into all the missions in trackers '''
    future = connection.async_get('/lol-missions/v1/series')
    await asyncio.sleep(0)
    res = future.result()
    res_json = res.json()
    missions = list(
        filter(
            lambda m: m['displayType'] == 'TRACKER' and m['status'] ==
            'PENDING', res_json))
    _ = [
        connection.async_put('/lol-missions/v2/player/opt',
                             json={
                                 "seriesId": mission['id'],
                                 "option": "OPT_IN"
                             }) for mission in missions
    ]
Exemple #10
0
async def worlds_opt_in(connection: LeagueConnection):
    ''' Opt into worlds mission '''
    future = connection.async_get('/lol-missions/v1/series')
    await asyncio.sleep(0)
    res = future.result()
    res_json = res.json()
    worlds = list(
        filter(lambda m: m['internalName'] == 'Worlds2019B_series', res_json))
    if worlds == []:
        return
    if worlds[0]['status'] == 'PENDING':
        future = connection.async_put('/lol-missions/v2/player/opt',
                                      json={
                                          "seriesId": worlds[0]['id'],
                                          "option": "OPT_IN"
                                      })
        await asyncio.sleep(0)
        future.result()
    return
Exemple #11
0
async def check_session(connection: LeagueConnection):
    ''' Checks the session of an account '''
    future = connection.async_get('/lol-login/v1/session')
    await asyncio.sleep(0)
    res = future.result()

    if res.status_code == 404:
        raise NoSessionException

    res_json = res.json()
    if res_json["state"] == "IN_PROGRESS":
        return "in_progress"
    if 'isNewPlayer' not in res_json:
        return 'succeed'
    if res_json['isNewPlayer']:
        return 'new_player'
    if res_json['state'] == 'ERROR':
        if res_json['error']['messageId'] == 'ACCOUNT_BANNED':
            raise AccountBannedException
    return 'succeed'
Exemple #12
0
async def get_champions(connection: LeagueConnection):
    ''' Parses the champions data '''
    future = connection.async_get('/lol-champions/v1/owned-champions-minimal')
    await asyncio.sleep(0)
    res = future.result()
    res_json = res.json()

    available_names = []
    owned_names = []
    owned = []

    if "errorCode" in res_json:
        return [], [], []
    for champ in res_json:
        if champ["active"]:
            available_names.append(champ["alias"])
        if champ["ownership"]["owned"]:
            owned.append(champ["id"])
            owned_names.append(champ["alias"])
    return owned, owned_names, available_names
Exemple #13
0
async def get_active_boosts(connection: LeagueConnection):
    ''' Returns the data of active boosts    '''
    future = connection.async_get('/lol-active-boosts/v1/active-boosts')
    await asyncio.sleep(0)
    res = future.result()
    return res.json()
Exemple #14
0
def get_match_list(connection: LeagueConnection):
    ''' Parses the match list data '''
    return connection.async_get('/lol-match-history/v1/matchlist')