Exemplo n.º 1
0
def delete_pre_end_of_game(connection: LeagueConnection):
    ''' Deletes pre end of game sequence event '''
    res = connection.get('/lol-pre-end-of-game/v1/currentSequenceEvent')
    res_json = res.json()
    name = res_json['name']
    connection.post('/lol-pre-end-of-game/v1/complete/%s' % name)
    connection.delete('/lol-pre-end-of-game/v1/registration/%s' % name)
Exemplo n.º 2
0
def create_lobby(connection: LeagueConnection, queue_id):
    ''' Creates a lobby with the queue id given '''
    data = {"queueId": queue_id}
    if queue_id in [2000, 2010, 2020]:
        connection.post('/lol-lobby/v2/matchmaking/quick-search', json=data)
        return None
    res = connection.post('/lol-lobby/v2/lobby', json=data)
    res = res.json()
    if 'errorCode' in res:
        return res['message']
    return None
Exemplo n.º 3
0
def change_icon(logger: Logger, connection: LeagueConnection, icon_id):
    ''' Changes the summoner icon '''
    while get_icon(connection) != icon_id:
        json = {
            'profileIconId': icon_id
        }
        try:
            logger.log("Changing summoner icon")
            connection.put('/lol-summoner/v1/current-summoner/icon', json=json)
        except requests.RequestException:
            pass
        time.sleep(1)
Exemplo n.º 4
0
async def init_tutorial(logger: Logger, connection: LeagueConnection):
    ''' Initializes tutorial '''
    logger.log('Initiating tutorial...')
    future1 = connection.async_patch('/lol-npe-tutorial-path/v1/tutorials/init')
    future2 = connection.async_post('/telemetry/v1/events/new_player_experience',
                                    json={"eventName": "show_screen",
                                          "plugin": "rcp-fe-lol-new-player-experience",
                                          "screenName": "npe_tutorial_modules"})
    future3 = connection.async_put('/lol-npe-tutorial-path/v1/settings',
                                   json={"hasSeenTutorialPath": True,
                                         "hasSkippedTutorialPath": False,
                                         "shouldSeeNewPlayerExperience": False})
    future1.result()
    future2.result()
    future3.result()
Exemplo n.º 5
0
    def __init__(self, logger, settings):
        self.settings = settings
        self.logger = logger
        self.riot_connection = RiotConnection()
        self.league_connection = LeagueConnection()

        self.state = None
Exemplo n.º 6
0
def catalog(connection: LeagueConnection, item_type):
    ''' Parses the item catalog for a item type '''
    url = '/lol-store/v1/catalog?inventoryType=["%s"]' % item_type
    res = connection.get(url)
    if not res.ok:
        return None
    return res.json()
Exemplo n.º 7
0
def get_queue_id(connection: LeagueConnection):
    ''' Returns the current queue id if exists else returns -1 '''
    res = connection.get('/lol-lobby/v2/lobby')
    res_json = res.json()
    if res.status_code == 404:
        return -1
    return res_json["gameConfig"]["queueId"]
Exemplo n.º 8
0
def get_icon(connection: LeagueConnection):
    ''' Parses the current summoner icon '''
    try:
        res = connection.get('/lol-summoner/v1/current-summoner')
        res_json = res.json()
        return res_json["profileIconId"]
    except requests.RequestException:
        return -1
Exemplo n.º 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
    ]
Exemplo n.º 10
0
def buy(connection: LeagueConnection, item_id, val):
    ''' Buys a specific item from the store '''
    data = {
        'items': [{
            'itemKey': {
                'inventoryType': 'CHAMPION',
                'itemId': item_id
            },
            'purchaseCurrencyInfo': {
                'currencyType': 'IP',
                'price': val,
                'purchasable': True,
            },
            'quantity': 1
        }]
    }
    connection.post('/lol-purchase-widget/v1/purchaseItems', json=data)
Exemplo n.º 11
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']
Exemplo n.º 12
0
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()
Exemplo n.º 13
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']
Exemplo n.º 14
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
Exemplo n.º 15
0
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"]
Exemplo n.º 16
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()
Exemplo n.º 17
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
    )
Exemplo n.º 18
0
def get_champion_select_data(connection: LeagueConnection):
    ''' Checks if in champ select '''
    res = connection.get('/lol-champ-select/v1/session')
    res_json = res.json()
    if res.status_code == 404:
        return None
    completed_list = []
    for action_list in res_json['actions']:
        for action in action_list:
            completed_list.append(action['completed'])
    if all(completed_list):
        return None
    return res_json
Exemplo n.º 19
0
def get_honor_data(connection: LeagueConnection):
    ''' Gets a random player data for honoring if exists '''
    res = connection.get('/lol-honor-v2/v1/ballot')
    res_json = res.json()
    players = res_json['eligiblePlayers']
    if players == []:
        return None
    game_id = res_json['gameId']
    player = random.choice(players)
    data = {
        'gameId': game_id,
        'summonerId': player['summonerId'],
    }
    return data
Exemplo n.º 20
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"]
Exemplo n.º 21
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
Exemplo n.º 22
0
    def __init__(self, master):
        LogWriter(self)
        import pygubu  # pylint:disable=import-outside-toplevel

        self.accounts = []

        self.master = master

        self.master.title('Auto watcher client')
        self.builder = builder = pygubu.Builder()
        self.builder.add_from_file('main_frame.ui')
        self.mainwindow = builder.get_object('main_frame', master)
        # self.master.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.builder.connect_callbacks(self)
        self.init_checkboxes()

        self.macro = Macro(RiotConnection(), LeagueConnection())
Exemplo n.º 23
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
Exemplo n.º 24
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'
Exemplo n.º 25
0
async def delete_lobby(connection: LeagueConnection):
    ''' Deletes the current lobby '''
    connection.async_delete('/lol-lobby/v2/lobby')
Exemplo n.º 26
0
def honor(connection: LeagueConnection, data):
    ''' Honors a player account of the given player data '''
    connection.post('/lol-honor-v2/v1/honor-player', json=data)
Exemplo n.º 27
0
def get_pickable_champs(connection: LeagueConnection):
    ''' Fetches pickable champions, probably depricaed in patch 9.24 '''
    res = connection.get('/lol-champ-select/v1/pickable-champions')
    res_json = res.json()
    return res_json['championIds']
Exemplo n.º 28
0
def skip_stats(connection: LeagueConnection):
    ''' Skips waiting for stats '''
    connection.post('/lol-end-of-game/v1/state/dismiss-stats')
Exemplo n.º 29
0
def reconnect(connection: LeagueConnection):
    ''' Reconnects to the game '''
    connection.post('/lol-gameflow/v1/reconnect')
Exemplo n.º 30
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()