Example #1
0
def spin_pokestop_update_inventory(api, fort, step_location, account):
    time.sleep(random.uniform(0.8, 1.8))  # Do not let Niantic throttle
    spin_response = spin_pokestop_request(api, fort, step_location, account)
    time.sleep(random.uniform(2, 4))  # Do not let Niantic throttle
    if not spin_response:
        return False

    # Check for reCaptcha
    captcha_url = spin_response['responses']['CHECK_CHALLENGE'][
        'challenge_url']
    if len(captcha_url) > 1:
        log.debug('Account encountered a reCaptcha.')
        return False

    spin_result = spin_response['responses']['FORT_SEARCH']['result']
    if spin_result is 1:
        awards = get_awarded_items(
            spin_response['responses']['FORT_SEARCH']['items_awarded'])
        log.info('Got {} items ({} balls) from Pokestop.'.format(
            awards['total'], awards['balls']))
        return True
    elif spin_result is 2:
        log.debug('Pokestop was not in range to spin.')
    elif spin_result is 3:
        log.debug('Failed to spin Pokestop. Has recently been spun.')
    elif spin_result is 4:
        log.debug('Failed to spin Pokestop. Inventory is full.')
    elif spin_result is 5:
        log.debug('Maximum number of Pokestops spun for this day.')
    else:
        log.debug('Failed to spin a Pokestop. Unknown result %d.', spin_result)
    return False
Example #2
0
def gxp_spin_stops(forts, pgacc, step_location):
    for f in forts:
        if f.type == 1 and pokestop_spinnable(f, step_location):
            time.sleep(random.uniform(0.8, 1.8))
            response = spin_pokestop_request(pgacc, f, step_location)
            time.sleep(random.uniform(2, 4))  # Don't let Niantic throttle.

            # Check for reCaptcha.
            if pgacc.has_captcha():
                log.debug('Account encountered a reCaptcha.')
                return

            spin_result = response['FORT_SEARCH'].result
            if spin_result is 1:
                awards = parse_awarded_items(
                    response['FORT_SEARCH'].items_awarded)
                log.info('GXP: Got {} items ({} balls) from Pokestop.'.format(
                    awards['total'], awards['balls']))
                cleanup_inventory(pgacc)
                return True
            elif spin_result is 2:
                log.debug('GXP: Pokestop was not in range to spin.')
            elif spin_result is 3:
                log.debug(
                    'GXP: Failed to spin Pokestop. Has recently been spun.')
            elif spin_result is 4:
                log.debug('GXP: Failed to spin Pokestop. Inventory is full.')
                cleanup_inventory(pgacc)
            elif spin_result is 5:
                log.debug(
                    'GXP: Maximum number of Pokestops spun for this day.')
            else:
                log.debug('GXP: Failed to spin a Pokestop. Unknown result %d.',
                          spin_result)