Esempio n. 1
0
def do_one():
    while True:
        account = account_manager.get_account()
        worker = wrap_account(account, account_manager)
        map_objects = worker.do_get_map_objects(pos)
        pokestops = inrange_pokstops(map_objects, pos)
        for pokestop in pokestops:
            worker.do_pokestop_details(pokestop)
            time.sleep(random.uniform(0.8, 1.8))  # Do not let Niantic throttle
            worker.do_spin_pokestop(pokestop, pos)
            break
Esempio n. 2
0
def create_fnord(pos, worker_number, _seen_raid_defender, _forced_update):
    account = account_manager.get_account(False)
    worker = wrap_account(account, account_manager)
    with_alt = with_gmaps_altitude(pos, args.gmaps_key)
    the_thread = Thread(target=safe_do_work,
                        name="fnord" + str(account_manager),
                        args=(worker, with_alt, worker_number,
                              _seen_raid_defender, _forced_update))
    the_thread.start()
    threads.append(the_thread)
    time.sleep(15)
    return pos is not None
Esempio n. 3
0
async def create_scanner_acct(account_manager, allsteps, count):
    steps = []
    step = next(allsteps, None)
    while step is not None and len(steps) < count:
        steps.append(step)
        step = next(allsteps, None)

    account = await account_manager.get_account()
    worker = wrap_account(account, account_manager)
    asyncio.ensure_future(safe_do_work(worker, iter(steps)))
    await asyncio.sleep(2)
    return step is not None
Esempio n. 4
0
def create_fnord(pos, worker_number, forced_update):
    account = account_manager.get_account(False)
    worker = wrap_account(account, account_manager)
    with_alt = with_gmaps_altitude(pos, args.gmaps_key)
    the_thread = Thread(target=safe_do_work,
                        args=(worker, with_alt, worker_number,
                              args.account_search_interval,
                              args.account_rest_interval, forced_update))
    the_thread.start()
    threads.append(the_thread)
    time.sleep(2)
    return pos is not None
Esempio n. 5
0
async def start():
    account_manager = await AsyncAccountManager.create_standard(args, loop)

    scanners = []
    for stream in streams:
        account = await account_manager.get_account()
        scanner = wrap_account(account, account_manager)
        scanners.append(scanner)
        asyncio.ensure_future(
            beh_safe_do_gym_scan(scanner, gym_moves_generator(stream)))
        asyncio.sleep(2)

    log.info(u"exiting scanner")
Esempio n. 6
0
def create_scanner_acct(allsteps, count):
    steps = []
    step = next(allsteps, None)
    while step is not None and len(steps) < count:
        steps.append(step)
        step = next(allsteps, None)

    account = account_manager.get_account()
    worker = wrap_account(account, account_manager)
    the_thread = Thread(target=safe_do_work, args=(worker, iter(steps)))
    the_thread.start()
    threads.append(the_thread)
    time.sleep(2)
    return step is not None
Esempio n. 7
0
async def start():
    account_manager = await AsyncAccountManager.create_standard(args, loop)
    all_scanned_gyms = {}
    for crook in args.crooks:
        crook_gyms = most_recent_trainer_gyms(crook)
        gym_map = find_top_n(crook_gyms, all_scanned_gyms, 30)
        #gym_map = filter_for_geofence(gym_map, args.geofence, args.fencename)
        print("There are {} gyms in scan with fence {}".format(str(len(gym_map)), str(args.fencename)))
        scanners = []
        for idx, stream in gym_map.items():
            account = await account_manager.get_account()
            scanner = wrap_account(account, account_manager)
            scanners.append(scanner)
            asyncio.ensure_future(beh_safe_scanner_bot(scanner, cycle([stream])))
            await asyncio.sleep(2)

    log.info("exiting scanner")
    sys.exit()
Esempio n. 8
0
async def start():
    missing_name = [x for x in elements if not x.name]
    if len(missing_name) > 0:
        account_manager = await AsyncAccountManager.create_standard(args, loop)
        account = await account_manager.get_account()
        worker = wrap_account(account, account_manager)
        travel_time = worker.getlayer(TravelTime2)
        travel_time.use_fast_speed()
        for missing in missing_name:
            gym_pos = step_position(missing.coords, -1, 1)
            map_objects = worker.do_get_map_objects(gym_pos)
            gyms = inrange_gyms(map_objects, gym_pos)
            fort = find_gym(gyms, missing.id)
            if fort:
                beh_do_process_single_gmo_gym(worker, fort, gym_pos)
            else:
                log.info("Gym {} not found in real map data".format(
                    str(missing)))
        log.info("Gym names updated, re-run")
        exit(-1)

    for elem in elements:
        print("{};{};{};{}".format(elem.name, elem.as_map_link(),
                                   elem.coords[0], elem.coords[1]))
Esempio n. 9
0
def do_work(worker, pos, worker_number, initial_map_objects,
            seen_raid_defender, is_forced_update):
    next_ps = datetime.now() + timedelta(
        minutes=5,
        seconds=(100 * worker_number))  # always 5 minutes t be clear
    level = worker.account_info()["level"]

    numscans = 0
    while not is_forced_update.isSet():
        if stop_at and datetime.now() > stop_at:
            log.info("Reached stop-at time, exiting")
            return True

        map_objects = worker.do_get_map_objects(pos)
        reg_gyms = inrange_gyms(map_objects, pos)
        while len(reg_gyms) == 0:
            log.info(
                "There are no visible gyms at this position {}, replacing account"
                .format(pos))
            time.sleep(5)
            account = account_manager.get_account(False)
            worker = wrap_account(account, account_manager)
            map_objects = worker.do_get_map_objects(pos)
            reg_gyms = inrange_gyms(map_objects, pos)

        if len(reg_gyms) == 0 and len(
                cells_with_pokemon_data(map_objects)) > 0:
            log.info(
                "There are no visible gyms at this position {}, exiting thread"
                .format(pos))
            return True

        level = beh_handle_level_up(worker, level)

        behaviour = worker.account_info().behaviour
        if is_pokestop(behaviour) and datetime.now() > next_ps:
            beh_spin_nearby_pokestops(worker, map_objects, pos)
            next_ps = time_of_next_pokestop_spin(behaviour)
            beh_random_bag_cleaning(worker, L20_ITEM_LIMITS)

        numscans += 1

        gyms = raid_gyms(map_objects, pos)
        log.info("There are {} gyms, {} raid gyms in view at {}".format(
            str(len(reg_gyms)), str(len(gyms)), str(pos)))

        next_scan = []
        for gym in gyms:
            lat = gym.latitude
            lng = gym.longitude
            raid_info = gym.raid_info
            raid_seed = raid_info.raid_seed
            gym_id = gym.id
            gym_name = None
            if gym_id in all_gyms:
                gym_name = all_gyms[gym_id]
            if raid_info.HasField("raid_pokemon"):
                pokemon = raid_info.raid_pokemon.pokemon_id
                pokemon_name = pokemons[str(pokemon)]["name"]
            else:
                pokemon = 0
                pokemon_name = None
            when = datetime.utcfromtimestamp(raid_info.raid_battle_ms / 1000)
            cet_when = when + timedelta(hours=2)
            next_scan.append(cet_when + timedelta(seconds=20))
            short_time = cet_when.strftime("%H:%M")
            level = raid_info.raid_level
            fence_name = location_fences.fence_name(lat, lng)
            if not fence_name:
                fence_name = ""

            if pokemon and raid_seed not in seen_raid_defender:
                google = "https://maps.google.com/?q={},{}".format(lat, lng)
                try:
                    _msg = "{} raid{}@{}/{} {} {}".format(
                        pokemon_name, str(level), gym_name, fence_name,
                        short_time, google)
                    log.info(_msg)
                except UnicodeEncodeError:
                    _msg = "{} raid{}@{} {} {}".format(pokemon_name,
                                                       str(level), fence_name,
                                                       short_time, google)
                    log.warn(_msg)
                if level > 0 or pokemon == 68:
                    pokemonhandler.s2msg(_msg)
                seen_raid_defender.add(raid_seed)

        real_sleep = 30 * 60
        if len(next_scan) > 0:
            actual_sleep_to = min(next_scan)
            actual_sleep_seconds = (actual_sleep_to - datetime.now()).seconds
            real_sleep = min(real_sleep, actual_sleep_seconds)
        log.info(
            "Waiting {} seconds for next thing to happen".format(real_sleep))
        time.sleep(real_sleep)
        rnd_sleep(1)
Esempio n. 10
0
        id_ = gym["gym_id"]
        if id_ not in all_scanned_gyms:
            result[id_] = gym
            all_scanned_gyms[id_] = gym
        if len(result) > n:
            break
    return result

all_scanned_gyms = {}
for crook in args.crooks:
    crook_gyms = most_recent_trainer_gyms(crook)
    gym_map = find_top_n(crook_gyms, all_scanned_gyms, 30)
    #gym_map = filter_for_geofence(gym_map, args.geofence, args.fencename)
    print("There are {} gyms in scan with fence {}".format(str(len(gym_map)), str(args.fencename)))
    scanners = []
    threads = []
    for idx, stream in gym_map.items():
        account = account_manager.get_account(False)
        scanner = wrap_account(account, account_manager)
        scanners.append(scanner)
        thread = Thread(target=beh_safe_scanner_bot, args=(scanner, cycle([stream])))
        threads.append(thread)
        thread.start()
        time.sleep(2)

for thread in threads:
    thread.join()

log.info("exiting scanner")
sys.exit()