From 9275da65e6b39cc959d9f409e8cb3114494c0b54 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 01/23] API update fixes (i2f etc) and lured pokemon catching --- pokemongo_bot/__init__.py | 19 +++--- .../cell_workers/pokemon_catch_worker.py | 60 ++++++++++++++----- .../cell_workers/seen_fort_worker.py | 38 +++++++++++- pokemongo_bot/logger.py | 11 ++-- pokemongo_bot/polyline_stepper.py | 4 +- pokemongo_bot/spiral_navigator.py | 12 ++-- requirements.txt | 2 +- 7 files changed, 104 insertions(+), 42 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 255b1afd65..096ca29f2b 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -27,7 +27,7 @@ class PokemonGoBot(object): @property def position(self): - return (i2f(self.api._position_lat), i2f(self.api._position_lng), 0) + return self.api._position_lat, self.api._position_lng, 0 def __init__(self, config): self.config = config @@ -69,9 +69,9 @@ def process_cells(self, work_on_forts=True): def update_web_location(self, cells=[], lat=None, lng=None, alt=None): # we can call the function with no arguments and still get the position and map_cells if lat == None: - lat = i2f(self.api._position_lat) + lat = self.api._position_lat if lng == None: - lng = i2f(self.api._position_lng) + lng = self.api._position_lng if alt == None: alt = 0 @@ -426,7 +426,7 @@ def _set_starting_position(self): has_position = True return except: - logger.log('[x] The location given using -l could not be parsed. Checking for a cached location.') + logger.log('[x] The location given in the config could not be parsed. Checking for a cached location.') pass if self.config.location_cache and not has_position: @@ -460,20 +460,17 @@ def _set_starting_position(self): def _get_pos_by_name(self, location_name): # Check if the given location is already a coordinate. if ',' in location_name: - possibleCoordinates = re.findall("[-]?\d{1,3}[.]\d{6,7}", location_name) - if len(possibleCoordinates) == 2: + possible_coordinates = re.findall("[-]?\d{1,3}[.]\d{6,7}", location_name) + if len(possible_coordinates) == 2: # 2 matches, this must be a coordinate. We'll bypass the Google geocode so we keep the exact location. logger.log( '[x] Coordinates found in passed in location, not geocoding.') - return (float(possibleCoordinates[0]), float(possibleCoordinates[1]), float("0.0")) + return float(possible_coordinates[0]), float(possible_coordinates[1]), float("0.0") geolocator = GoogleV3(api_key=self.config.gmapkey) loc = geolocator.geocode(location_name, timeout=10) - #self.log.info('Your given location: %s', loc.address.encode('utf-8')) - #self.log.info('lat/long/alt: %s %s %s', loc.latitude, loc.longitude, loc.altitude) - - return (loc.latitude, loc.longitude, loc.altitude) + return float(loc.latitude), float(loc.longitude), float(loc.altitude) def heartbeat(self): # Remove forts that we can now spin again. diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 8c9ed14483..82ce6a2a90 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -20,33 +20,38 @@ def __init__(self, pokemon, bot): self.pokemon_list = bot.pokemon_list self.item_list = bot.item_list self.inventory = bot.inventory + self.spawn_point_guid = '' + self.response_key = '' + self.response_status_key = '' def work(self): + encounter_id = self.pokemon['encounter_id'] - spawnpoint_id = self.pokemon['spawnpoint_id'] - player_latitude = self.pokemon['latitude'] - player_longitude = self.pokemon['longitude'] - self.api.encounter(encounter_id=encounter_id, spawnpoint_id=spawnpoint_id, - player_latitude=player_latitude, player_longitude=player_longitude) - response_dict = self.api.call() + + response_dict = self.create_encounter_api_call() if response_dict and 'responses' in response_dict: - if 'ENCOUNTER' in response_dict['responses']: - if 'status' in response_dict['responses']['ENCOUNTER']: - if response_dict['responses']['ENCOUNTER']['status'] is 7: + if self.response_key in response_dict['responses']: + if self.response_status_key in response_dict['responses'][self.response_key]: + if response_dict['responses'][self.response_key][self.response_status_key] is 7: if self.config.initial_transfer: logger.log('Pokemon Bag is full!', 'red') return PokemonCatchWorker.BAG_FULL else: raise RuntimeError('Pokemon Bag is full!') - if response_dict['responses']['ENCOUNTER']['status'] is 1: + if response_dict['responses'][self.response_key][self.response_status_key] is 1: cp = 0 total_IV = 0 - if 'wild_pokemon' in response_dict['responses']['ENCOUNTER']: - pokemon = response_dict['responses']['ENCOUNTER']['wild_pokemon'] - catch_rate = response_dict['responses']['ENCOUNTER']['capture_probability']['capture_probability'] # 0 = pokeballs, 1 great balls, 3 ultra balls - + if 'wild_pokemon' in response_dict['responses'][self.response_key] or 'pokemon_data' in \ + response_dict['responses'][self.response_key]: + if self.response_key == 'ENCOUNTER': + pokemon = response_dict['responses'][self.response_key]['wild_pokemon'] + else: + pokemon = response_dict['responses'][self.response_key] + + catch_rate = response_dict['responses'][self.response_key]['capture_probability'][ + 'capture_probability'] # 0 = pokeballs, 1 great balls, 3 ultra balls if 'pokemon_data' in pokemon and 'cp' in pokemon['pokemon_data']: cp = pokemon['pokemon_data']['cp'] @@ -126,7 +131,7 @@ def work(self): self.api.use_item_capture( item_id=berry_id, encounter_id = encounter_id, - spawn_point_guid = spawnpoint_id + spawn_point_id = self.spawn_point_guid ) response_dict = self.api.call() if response_dict and response_dict['status_code'] is 1 and 'item_capture_mult' in response_dict['responses']['USE_ITEM_CAPTURE']: @@ -164,7 +169,7 @@ def work(self): self.api.catch_pokemon(encounter_id=encounter_id, pokeball=pokeball, normalized_reticle_size=1.950, - spawn_point_guid=spawnpoint_id, + spawn_point_id=self.spawn_point_guid, hit_pokemon=1, spin_modifier=1, NormalizedHitPosition=1) @@ -377,3 +382,26 @@ def _get_release_config_for(self, pokemon): if not release_config: release_config = {} return release_config + + def create_encounter_api_call(self): + + encounter_id = self.pokemon['encounter_id'] + player_latitude = self.pokemon['latitude'] + player_longitude = self.pokemon['longitude'] + + if 'spawn_point_id' in self.pokemon: + spawn_point_id = self.pokemon['spawn_point_id'] + self.spawn_point_guid = spawn_point_id + self.response_key = 'ENCOUNTER' + self.response_status_key = 'status' + self.api.encounter(encounter_id=encounter_id, spawn_point_id=spawn_point_id, + player_latitude=player_latitude, player_longitude=player_longitude) + else: + fort_id = self.pokemon['fort_id'] + self.spawn_point_guid = fort_id + self.response_key = 'DISK_ENCOUNTER' + self. response_status_key = 'result' + self.api.disk_encounter(encounter_id=encounter_id, fort_id=fort_id, + player_latitude=player_latitude, player_longitude=player_longitude) + + return self.api.call() diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index a48baab781..e35ac75b87 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -6,6 +6,7 @@ from pokemongo_bot import logger from pokemongo_bot.human_behaviour import sleep +from pokemongo_bot.cell_workers import PokemonCatchWorker from utils import format_time @@ -17,6 +18,10 @@ def __init__(self, fort, bot): self.position = bot.position self.config = bot.config self.item_list = bot.item_list + self.pokemon_list = bot.pokemon_list + self.inventory = bot.inventory + self.pokeball_inventory = bot.pokeball_inventory + self.item_inventory_count = bot.item_inventory_count self.rest_time = 50 def work(self): @@ -34,9 +39,28 @@ def work(self): fort_name = fort_details['name'].encode('utf8', 'replace') else: fort_name = 'Unknown' - logger.log('Now at Pokestop: ' + fort_name + ' - Spinning...', + logger.log('Now at Pokestop: ' + fort_name, 'cyan') - sleep(2) + if self.config.mode != 'farm' and 'lure_info' in self.fort: + # Check if the lure has a pokemon active + if 'encounter_id' in self.fort['lure_info']: + logger.log("Found a lure on this pokestop! Catching pokemon...", 'cyan') + + pokemon = { + 'encounter_id': self.fort['lure_info']['encounter_id'], + 'fort_id': self.fort['id'], + 'latitude': self.fort['latitude'], + 'longitude': self.fort['longitude'] + } + + self.catch_pokemon(pokemon) + + else: + logger.log('Found a lure, but there is no pokemon present.', 'yellow') + sleep(2) + + logger.log('Spinning ...', 'cyan') + self.api.fort_search(fort_id=self.fort['id'], fort_latitude=lat, fort_longitude=lng, @@ -120,6 +144,16 @@ def work(self): sleep(2) return 0 + def catch_pokemon(self, pokemon): + worker = PokemonCatchWorker(pokemon, self) + return_value = worker.work() + + if return_value == PokemonCatchWorker.BAG_FULL: + worker = InitialTransferWorker(self) + worker.work() + + return return_value + @staticmethod def closest_fort(current_lat, current_long, forts): print x diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 636f7e371e..1dc27d900f 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,13 +1,16 @@ import time + try: import lcd + lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False -def log(string, color = 'white'): + +def log(string, color='white'): colorHex = { 'red': '91m', 'green': '92m', @@ -16,9 +19,9 @@ def log(string, color = 'white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] '+ string) + print('[' + time.strftime("%H:%M:%S") + '] ' + string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if(string): + if (string): lcd.message(string) diff --git a/pokemongo_bot/polyline_stepper.py b/pokemongo_bot/polyline_stepper.py index df7157e153..2640e47fe7 100644 --- a/pokemongo_bot/polyline_stepper.py +++ b/pokemongo_bot/polyline_stepper.py @@ -10,7 +10,7 @@ class PolylineStepper(Stepper): def _walk_to(self, speed, lat, lng, alt): - origin = ','.join([str(i2f(self.api._position_lat)), str(i2f(self.api._position_lng))]) + origin = ','.join([str(self.api._position_lat), str(self.api._position_lng)]) destination = ','.join([str(lat), str(lng)]) polyline_walker = PolylineWalker(origin, destination, speed) proposed_origin = polyline_walker.points[0] @@ -29,7 +29,7 @@ def _walk_to(self, speed, lat, lng, alt): cLat, cLng = polyline_walker.get_pos()[0] self.api.set_position(cLat, cLng, alt) self.bot.heartbeat() - self._work_at_position(i2f(self.api._position_lat), i2f(self.api._position_lng), alt, False) + self._work_at_position(self.api._position_lat, self.api._position_lng, alt, False) sleep(1) # sleep one second plus a random delta if proposed_lat != self.api._position_lat and proposed_lng != self.api._position_lng: logger.log('[#] Using _old_walk_to to go from the proposed destination : {} to {}' diff --git a/pokemongo_bot/spiral_navigator.py b/pokemongo_bot/spiral_navigator.py index ca89b6e6ae..b07c8c2020 100644 --- a/pokemongo_bot/spiral_navigator.py +++ b/pokemongo_bot/spiral_navigator.py @@ -62,15 +62,15 @@ def take_step(self): ) dist = distance( - i2f(self.api._position_lat), - i2f(self.api._position_lng), + self.api._position_lat, + self.api._position_lng, point['lat'], point['lng'] ) if self.cnt == 1: - logger.log('Walking from ' + str((i2f(self.api._position_lat), i2f( - self.api._position_lng))) + " to " + str([point['lat'], point['lng']]) + " " + format_dist(dist, + logger.log('Walking from ' + str((self.api._position_lat, + self.api._position_lng)) + " to " + str([point['lat'], point['lng']]) + " " + format_dist(dist, self.config.distance_unit)) if step_walker.step(): @@ -79,8 +79,8 @@ def take_step(self): self.api.set_position(point['lat'], point['lng']) if distance( - i2f(self.api._position_lat), - i2f(self.api._position_lng), + self.api._position_lat, + self.api._position_lng, point['lat'], point['lng'] ) <= 1 or (self.config.walk > 0 and step_walker == None): diff --git a/requirements.txt b/requirements.txt index f8e4ae8370..0eb44fb82c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git@v1.1.0#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From 4003a1a4e128dd72d48d0e1b76155cf40363972b Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 11:29:46 +0200 Subject: [PATCH 02/23] Fix PogoAPI to a recent commit --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0eb44fb82c..cd60f8c2bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From af485bba94927afc8f938af3a09e5040db6b7e82 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 03/23] API update fixes (i2f etc) and lured pokemon catching --- pokemongo_bot/cell_workers/move_to_fort_worker.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pokemongo_bot/cell_workers/move_to_fort_worker.py b/pokemongo_bot/cell_workers/move_to_fort_worker.py index bfe71a2123..39c87dfe0a 100644 --- a/pokemongo_bot/cell_workers/move_to_fort_worker.py +++ b/pokemongo_bot/cell_workers/move_to_fort_worker.py @@ -2,7 +2,6 @@ from pokemongo_bot.human_behaviour import sleep from pokemongo_bot import logger from pokemongo_bot.step_walker import StepWalker -from pokemongo_bot.worker_result import WorkerResult class MoveToFortWorker(object): From a05d1a1596e1c8c304667c92e0c84c4763b3f26d Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 13:55:16 +0200 Subject: [PATCH 04/23] Various bugfixes --- pokemongo_bot/__init__.py | 9 +++++++-- pokemongo_bot/cell_workers/seen_fort_worker.py | 3 ++- pokemongo_bot/logger.py | 11 ++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 096ca29f2b..3b359d1fa2 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -168,7 +168,7 @@ def work_on_cell(self, cell, position, work_on_forts=1): if worker.work() == WorkerResult.RUNNING: return - RecycleItemsWorker(self).work() + # RecycleItemsWorker(self).work() worker = CatchVisiblePokemonWorker(self, cell) if worker.work() == WorkerResult.RUNNING: @@ -272,7 +272,12 @@ def _print_character_info(self): currency_1 = "0" currency_2 = "0" - player = response_dict['responses']['GET_PLAYER']['player_data'] + if response_dict: + player = response_dict['responses']['GET_PLAYER']['player_data'] + else: + logger.log("The API didn't return player info, servers are unstable - retrying.", 'red') + sleep(5) + self._print_character_info() # @@@ TODO: Convert this to d/m/Y H:M:S creation_date = datetime.datetime.fromtimestamp( diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index e35ac75b87..35355a0b35 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -20,8 +20,9 @@ def __init__(self, fort, bot): self.item_list = bot.item_list self.pokemon_list = bot.pokemon_list self.inventory = bot.inventory - self.pokeball_inventory = bot.pokeball_inventory + self.current_inventory = bot.current_inventory self.item_inventory_count = bot.item_inventory_count + self.metrics = bot.metrics self.rest_time = 50 def work(self): diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 1dc27d900f..636f7e371e 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,16 +1,13 @@ import time - try: import lcd - lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False - -def log(string, color='white'): +def log(string, color = 'white'): colorHex = { 'red': '91m', 'green': '92m', @@ -19,9 +16,9 @@ def log(string, color='white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] ' + string) + print('[' + time.strftime("%H:%M:%S") + '] '+ string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if (string): + if(string): lcd.message(string) From c63cabadf1d25c9e060d4df745e351cc5a4f9aa9 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 05/23] API update fixes (i2f etc) and lured pokemon catching --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 2 +- pokemongo_bot/logger.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 82ce6a2a90..219d7c5b99 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -131,7 +131,7 @@ def work(self): self.api.use_item_capture( item_id=berry_id, encounter_id = encounter_id, - spawn_point_id = self.spawn_point_guid + spawn_point_id = spawnpoint_id ) response_dict = self.api.call() if response_dict and response_dict['status_code'] is 1 and 'item_capture_mult' in response_dict['responses']['USE_ITEM_CAPTURE']: diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 636f7e371e..1dc27d900f 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,13 +1,16 @@ import time + try: import lcd + lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False -def log(string, color = 'white'): + +def log(string, color='white'): colorHex = { 'red': '91m', 'green': '92m', @@ -16,9 +19,9 @@ def log(string, color = 'white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] '+ string) + print('[' + time.strftime("%H:%M:%S") + '] ' + string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if(string): + if (string): lcd.message(string) From 9abc69d0976cf2cb57f84f4eeef8c95444308256 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 06/23] API update fixes (i2f etc) and lured pokemon catching --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cd60f8c2bd..0eb44fb82c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From e96ad197c93619f6a4e818715d2a4aab03b3efca Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 11:29:46 +0200 Subject: [PATCH 07/23] Fix PogoAPI to a recent commit --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0eb44fb82c..cd60f8c2bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From b74198be840c08afa821cad55f0ae71077f8d764 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 11:49:21 +0200 Subject: [PATCH 08/23] Added missing method --- pokemongo_bot/cell_workers/pokemon_catch_worker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 219d7c5b99..38ede1b84f 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -131,7 +131,7 @@ def work(self): self.api.use_item_capture( item_id=berry_id, encounter_id = encounter_id, - spawn_point_id = spawnpoint_id + spawn_point_id = self.spawn_point_guid ) response_dict = self.api.call() if response_dict and response_dict['status_code'] is 1 and 'item_capture_mult' in response_dict['responses']['USE_ITEM_CAPTURE']: @@ -400,8 +400,8 @@ def create_encounter_api_call(self): fort_id = self.pokemon['fort_id'] self.spawn_point_guid = fort_id self.response_key = 'DISK_ENCOUNTER' - self. response_status_key = 'result' + self.response_status_key = 'result' self.api.disk_encounter(encounter_id=encounter_id, fort_id=fort_id, player_latitude=player_latitude, player_longitude=player_longitude) - return self.api.call() + return self.api.call() \ No newline at end of file From 0d68d3d4efcb6e060e0d4627e282bff01210c723 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 09/23] API update fixes (i2f etc) and lured pokemon catching --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cd60f8c2bd..0eb44fb82c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From a6a2a235f4f7d874e6882b724d8964c190c5d77b Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 11:29:46 +0200 Subject: [PATCH 10/23] Fix PogoAPI to a recent commit --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0eb44fb82c..cd60f8c2bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From 14957c2e76b5abd75be330e13bc14a035c8234ea Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 13:55:16 +0200 Subject: [PATCH 11/23] Various bugfixes --- pokemongo_bot/logger.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 1dc27d900f..636f7e371e 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,16 +1,13 @@ import time - try: import lcd - lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False - -def log(string, color='white'): +def log(string, color = 'white'): colorHex = { 'red': '91m', 'green': '92m', @@ -19,9 +16,9 @@ def log(string, color='white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] ' + string) + print('[' + time.strftime("%H:%M:%S") + '] '+ string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if (string): + if(string): lcd.message(string) From 930515b8f4e5f37b76fe244daaa6f41875ac0276 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 12/23] API update fixes (i2f etc) and lured pokemon catching --- pokemongo_bot/logger.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 636f7e371e..1dc27d900f 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,13 +1,16 @@ import time + try: import lcd + lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False -def log(string, color = 'white'): + +def log(string, color='white'): colorHex = { 'red': '91m', 'green': '92m', @@ -16,9 +19,9 @@ def log(string, color = 'white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] '+ string) + print('[' + time.strftime("%H:%M:%S") + '] ' + string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if(string): + if (string): lcd.message(string) From dfd7f13d0eb866b9cd4098073753fc01b738fa4e Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 13:55:16 +0200 Subject: [PATCH 13/23] Various bugfixes --- pokemongo_bot/logger.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 1dc27d900f..636f7e371e 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,16 +1,13 @@ import time - try: import lcd - lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False - -def log(string, color='white'): +def log(string, color = 'white'): colorHex = { 'red': '91m', 'green': '92m', @@ -19,9 +16,9 @@ def log(string, color='white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] ' + string) + print('[' + time.strftime("%H:%M:%S") + '] '+ string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if (string): + if(string): lcd.message(string) From 45985a3a857fdf4616e686102b4027d3fa46c3b5 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 14/23] API update fixes (i2f etc) and lured pokemon catching --- pokemongo_bot/cell_workers/move_to_fort_worker.py | 15 +++++++++------ pokemongo_bot/logger.py | 11 +++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pokemongo_bot/cell_workers/move_to_fort_worker.py b/pokemongo_bot/cell_workers/move_to_fort_worker.py index 39c87dfe0a..b008f96595 100644 --- a/pokemongo_bot/cell_workers/move_to_fort_worker.py +++ b/pokemongo_bot/cell_workers/move_to_fort_worker.py @@ -28,12 +28,15 @@ def work(self): if dist > 10: logger.log('[x] Need to move closer to Pokestop') - step_walker = StepWalker( - self.bot, - self.config.walk, - lat, - lng - ) + if self.config.walk > 0: + step_walker = StepWalker( + self.bot, + self.config.walk, + self.api._position_lat, + self.api._position_lng, + position[0], + position[1] + ) if not step_walker.step(): return WorkerResult.RUNNING diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 636f7e371e..1dc27d900f 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,13 +1,16 @@ import time + try: import lcd + lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False -def log(string, color = 'white'): + +def log(string, color='white'): colorHex = { 'red': '91m', 'green': '92m', @@ -16,9 +19,9 @@ def log(string, color = 'white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] '+ string) + print('[' + time.strftime("%H:%M:%S") + '] ' + string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if(string): + if (string): lcd.message(string) From 3a874d24f7be88458ec54d965bd37d2b84fc45d0 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 15/23] API update fixes (i2f etc) and lured pokemon catching --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cd60f8c2bd..0eb44fb82c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From 1c392642717884300b453c12ce3357d910712b97 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 11:29:46 +0200 Subject: [PATCH 16/23] Fix PogoAPI to a recent commit --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0eb44fb82c..cd60f8c2bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From 904e9fd85b4500abf833f6cc01f17c4f0a00ec75 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 02:01:08 +0200 Subject: [PATCH 17/23] API update fixes (i2f etc) and lured pokemon catching --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cd60f8c2bd..0eb44fb82c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From 3795e7c2a4e09b3295c9a5aa73b6abbc2a14f40e Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 11:29:46 +0200 Subject: [PATCH 18/23] Fix PogoAPI to a recent commit --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0eb44fb82c..cd60f8c2bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e git+https://github.com/tejado/pgoapi.git#egg=pgoapi +-e git+https://github.com/tejado/pgoapi.git@81e786cabf027a1c8fbd1e9a07e1c11aa3d8ee8b#egg=pgoapi geopy==1.11.0 protobuf==3.0.0b4 requests==2.10.0 From 2196035cd14d2607c02fef6add9cdda75e7bbc2f Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 13:55:16 +0200 Subject: [PATCH 19/23] Various bugfixes --- pokemongo_bot/logger.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pokemongo_bot/logger.py b/pokemongo_bot/logger.py index 1dc27d900f..636f7e371e 100644 --- a/pokemongo_bot/logger.py +++ b/pokemongo_bot/logger.py @@ -1,16 +1,13 @@ import time - try: import lcd - lcd = lcd.lcd() # Change this to your i2c address lcd.set_addr(0x23) except: lcd = False - -def log(string, color='white'): +def log(string, color = 'white'): colorHex = { 'red': '91m', 'green': '92m', @@ -19,9 +16,9 @@ def log(string, color='white'): 'cyan': '96m' } if color not in colorHex: - print('[' + time.strftime("%H:%M:%S") + '] ' + string) + print('[' + time.strftime("%H:%M:%S") + '] '+ string) else: - print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033[' + colorHex[color] + string.decode('utf-8') + '\033[0m') + print('[' + time.strftime("%H:%M:%S") + '] ' + u'\033['+ colorHex[color] + string.decode('utf-8') + '\033[0m') if lcd: - if (string): + if(string): lcd.message(string) From 29ebb51d7836b511d0201634938111344db5332b Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 14:43:06 +0200 Subject: [PATCH 20/23] Merging with recent commits --- pokemongo_bot/polyline_stepper.py | 2 +- pylint-recursive.py | 2 +- setup.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/polyline_stepper.py b/pokemongo_bot/polyline_stepper.py index 2640e47fe7..052f46eacf 100644 --- a/pokemongo_bot/polyline_stepper.py +++ b/pokemongo_bot/polyline_stepper.py @@ -5,7 +5,7 @@ from cell_workers.utils import i2f from human_behaviour import sleep from polyline_walker import PolylineWalker - +from stepper import Stepper class PolylineStepper(Stepper): diff --git a/pylint-recursive.py b/pylint-recursive.py index 82c4664e97..ef79a95cbf 100644 --- a/pylint-recursive.py +++ b/pylint-recursive.py @@ -53,7 +53,7 @@ def check(module): print "Passed: " + str(passed) + " Failed: " + str(failed) print "\n" print "Showing errors:" - if failed > 0: + if (str(failed)): for err in errors: print err diff --git a/setup.py b/setup.py index 6ccf893c0d..f0a267c497 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from distutils.core import setup from pip.req import parse_requirements install_reqs = parse_requirements("requirements.txt", session=False) From cea97a08db212ea501cbecaaa38c8fc2c830313b Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 16:27:57 +0200 Subject: [PATCH 21/23] Restored RecycleItemsWorker call --- pokemongo_bot/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 3b359d1fa2..21954d62bb 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -168,7 +168,7 @@ def work_on_cell(self, cell, position, work_on_forts=1): if worker.work() == WorkerResult.RUNNING: return - # RecycleItemsWorker(self).work() + RecycleItemsWorker(self).work() worker = CatchVisiblePokemonWorker(self, cell) if worker.work() == WorkerResult.RUNNING: From 8b59c21e8685baf1d4f2fbc64ad7155851baf947 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 16:53:57 +0200 Subject: [PATCH 22/23] Merged with latest commit --- .../cell_workers/move_to_fort_worker.py | 16 +++++++--------- pokemongo_bot/polyline_stepper.py | 3 +-- pylint-recursive.py | 2 +- setup.py | 1 - 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/pokemongo_bot/cell_workers/move_to_fort_worker.py b/pokemongo_bot/cell_workers/move_to_fort_worker.py index b008f96595..bfe71a2123 100644 --- a/pokemongo_bot/cell_workers/move_to_fort_worker.py +++ b/pokemongo_bot/cell_workers/move_to_fort_worker.py @@ -2,6 +2,7 @@ from pokemongo_bot.human_behaviour import sleep from pokemongo_bot import logger from pokemongo_bot.step_walker import StepWalker +from pokemongo_bot.worker_result import WorkerResult class MoveToFortWorker(object): @@ -28,15 +29,12 @@ def work(self): if dist > 10: logger.log('[x] Need to move closer to Pokestop') - if self.config.walk > 0: - step_walker = StepWalker( - self.bot, - self.config.walk, - self.api._position_lat, - self.api._position_lng, - position[0], - position[1] - ) + step_walker = StepWalker( + self.bot, + self.config.walk, + lat, + lng + ) if not step_walker.step(): return WorkerResult.RUNNING diff --git a/pokemongo_bot/polyline_stepper.py b/pokemongo_bot/polyline_stepper.py index 052f46eacf..b6dbd78d44 100644 --- a/pokemongo_bot/polyline_stepper.py +++ b/pokemongo_bot/polyline_stepper.py @@ -2,10 +2,9 @@ from math import ceil import logger -from cell_workers.utils import i2f from human_behaviour import sleep from polyline_walker import PolylineWalker -from stepper import Stepper + class PolylineStepper(Stepper): diff --git a/pylint-recursive.py b/pylint-recursive.py index ef79a95cbf..82c4664e97 100644 --- a/pylint-recursive.py +++ b/pylint-recursive.py @@ -53,7 +53,7 @@ def check(module): print "Passed: " + str(passed) + " Failed: " + str(failed) print "\n" print "Showing errors:" - if (str(failed)): + if failed > 0: for err in errors: print err diff --git a/setup.py b/setup.py index f0a267c497..6ccf893c0d 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from distutils.core import setup from pip.req import parse_requirements install_reqs = parse_requirements("requirements.txt", session=False) From a466bcd8d9eefe8109024713a235f5086e6ec93f Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 27 Jul 2016 20:09:49 +0200 Subject: [PATCH 23/23] Fixed arguments in method call --- pokemongo_bot/cell_workers/seen_fort_worker.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index 35355a0b35..b22a9ff264 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -146,12 +146,13 @@ def work(self): return 0 def catch_pokemon(self, pokemon): - worker = PokemonCatchWorker(pokemon, self) + worker = PokemonCatchWorker(pokemon, self.bot) return_value = worker.work() - if return_value == PokemonCatchWorker.BAG_FULL: - worker = InitialTransferWorker(self) - worker.work() + # Disabled for now, importing InitialTransferWorker fails. + # if return_value == PokemonCatchWorker.BAG_FULL: + # worker = InitialTransferWorker(self) + # worker.work() return return_value