Пример #1
0
    slack_webhook_url = str(os.environ.get('SLACK_WEBHOOK_URL', env.get('SLACK_WEBHOOK_URL')))
    step_limit = float(os.environ.get('STEPS_AWAY', env.get('STEPS_AWAY')))
    # const vars
    step_size = 0.0025
    

    # debug vars, used to test slack integration w/o waiting
    use_cache = False
    cached_filename = 'cached_pokedata.json'
    search_timeout = 30

    position, address = get_pos_by_name(location_name)
    logger.info('location_name: %s', address)

    api = PGoApi()
    pokesearch = Pokesearch(api, auth_service, username, password, position)
    pokeslack = Pokeslack(rarity_limit, slack_webhook_url)

    if not use_cache or not os.path.exists(cached_filename):
        logger.info('searching starting at latlng: (%s, %s)', position[0], position[1])
        pokesearch.login()
        while True:
            pokemons = []
            for pokemon in pokesearch.search(position[0], position[1], step_limit, step_size):
                pokemon_position = (pokemon['latitude'], pokemon['longitude'], 0)
                distance = vincenty(position, pokemon_position).miles
                expires_in = pokemon['disappear_time'] - datetime.utcnow()
                logger.info("adding pokemon: %s - %s, rarity: %s, expires in: %s, distance: %s miles", pokemon['pokemon_id'], pokemon['name'], pokemon['rarity'], expires_in, distance)
                pokeslack.try_send_pokemon(pokemon, position, distance, debug=False)
                pokemons.append(pokemon)
            with open(cached_filename, 'w') as fp:
Пример #2
0
        os.environ.get('SLACK_WEBHOOK_URL', env.get('SLACK_WEBHOOK_URL')))

    # const vars
    step_size = 0.0025
    step_limit = 5

    # debug vars, used to test slack integration w/o waiting
    use_cache = False
    cached_filename = 'cached_pokedata.json'
    search_timeout = 30

    position, address = get_pos_by_name(location_name)
    logger.info('location_name: %s', address)

    api = PGoApi()
    pokesearch = Pokesearch(api, auth_service, username, password, position)
    pokeslack = Pokeslack(rarity_limit, slack_webhook_url)

    if not use_cache or not os.path.exists(cached_filename):
        logger.info('searching starting at latlng: (%s, %s)', position[0],
                    position[1])
        pokesearch.login()
        while True:
            pokemons = []
            for pokemon in pokesearch.search(position[0], position[1],
                                             step_limit, step_size):
                pokemon_position = (pokemon['latitude'], pokemon['longitude'],
                                    0)
                distance = vincenty(position, pokemon_position).miles
                expires_in = pokemon['disappear_time'] - datetime.utcnow()
                logger.info(
Пример #3
0
    location_name = config.location_name
    rarity_limit = config.rarity_limit
    slack_webhook_url = config.slack_webhook_url
    num_steps = config.num_steps

    # debug vars, used to test slack integration w/o waiting
    use_cache = False
    cached_filename = 'cached_pokedata.json'
    search_timeout = 30

    position, address = get_pos_by_name(location_name)
    config.position = position
    logger.info('location_name: %s', address)

    api = PGoApi()
    pokesearch = Pokesearch(api, auth_service, username, password, position)
    pokeslack = Pokeslack(rarity_limit, slack_webhook_url)

    if not use_cache or not os.path.exists(cached_filename):
        logger.info('searching starting at latlng: (%s, %s)', position[0], position[1])
        pokesearch.login()
        while True:
            pokemons = []
            for pokemon in pokesearch.search(position, num_steps):
                logger.info('adding pokemon: %s', pokemon)
                pokeslack.try_send_pokemon(pokemon, debug=False)
                pokemons.append(pokemon)
            with open(cached_filename, 'w') as fp:
                json.dump(pokemons, fp, default=json_serializer, indent=4)
            logging.info('done searching, waiting %s seconds...', search_timeout)
            time.sleep(search_timeout)