Repository: PokemonGoF/PokemonGo-Bot

Issue:
dev snipe feature broken ?
bdcf2519d63555ac32246439fd17672896ee64e4
with 
#3014 (fix)

and its messing up the previous location 
before bdcf2519d63555ac32246439fd17672896ee64e4 it was working very nice but now when you run multiple bots and search  in the map additional to snipe its messing things really up

``````
2016-08-08 11:51:39,398 [RecycleItems] [INFO] [item_discarded] Discarded 1x Potion (maximum 0).
2016-08-08 11:51:40,042 [RecycleItems] [INFO] [item_discarded] Discarded 2x Revive (maximum 0).
2016-08-08 11:51:40,579 [TransferPokemon] [INFO] [future_pokemon_release] Releasing Magikarp (CP 10/IV 0.44) based on rule: CP < 9 OR IV < 0.97
2016-08-08 11:51:41,302 [TransferPokemon] [INFO] [pokemon_release] Exchanged Magikarp [CP 10] [IV 0.44] for candy.
2016-08-08 11:51:52,028 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Pikachu. (0.73km)
2016-08-08 11:51:52,028 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Pikachu
2016-08-08 11:51:54,583 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_back] Teleporting back to previous location (40.7707074943, -73.9768963862)
2016-08-08 11:52:05,896 [PokemonCatchWorker] [INFO] [pokemon_appeared] A wild Pikachu appeared! [CP 193] [Potential 0.49] [S/A/D 1/13/8]
2016-08-08 11:52:08,793 [PokemonCatchWorker] [INFO] [vip_pokemon] This is a VIP pokemon. Catch!!!
2016-08-08 11:52:09,372 [PokemonCatchWorker] [INFO] [threw_berry] Threw a Razz Berry! Catch rate now: 30.03
2016-08-08 11:52:09,372 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Ultraball, with chance 54.05 (49 left)
2016-08-08 11:52:10,404 [PokemonCatchWorker] [INFO] [pokemon_caught] Captured Pikachu! [CP 193] [Potential 0.49] [1/13/8] [+210 exp]
2016-08-08 11:52:15,906 [MoveToFort] [INFO] [moving_to_lured_fort] Moving towards pokestop Heckscher Ballfields - 0.06km (attraction of lure 0.13km)
2016-08-08 11:52:15,907 [MoveToFort] [INFO] [arrived_at_fort] Arrived at fort.
2016-08-08 11:52:17,648 [  SpinFort] [INFO] [spun_pokestop] Spun pokestop Heckscher Ballfields. Experience awarded: 50. Items awarded: {u'Pokeball': 2, u'Greatball': 1}
2016-08-08 11:52:20,653 [TransferPokemon] [INFO] [future_pokemon_release] Releasing Pikachu (CP 193/IV 0.49) based on rule: CP < 9 OR IV < 0.97
2016-08-08 11:52:21,306 [TransferPokemon] [INFO] [pokemon_release] Exchanged Pikachu [CP 193] [IV 0.49] for candy.
2016-08-08 11:52:29,412 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Squirtle. (12947.95km)
2016-08-08 11:52:29,413 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Squirrel
2016-08-08 11:52:32,048 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_back] Teleporting back to previous location (22.3365302665, 114.136735939)
2016-08-08 11:52:40,143 [PokemonCatchWorker] [INFO] [pokemon_appeared] A wild Squirtle appeared! [CP 479] [Potential 0.38] [S/A/D 2/14/1]
2016-08-08 11:52:43,994 [PokemonCatchWorker] [INFO] [vip_pokemon] This is a VIP pokemon. Catch!!!
2016-08-08 11:52:44,592 [PokemonCatchWorker] [WARNING] [softban] Failed to use berry. You may be soft banned
2016-08-08 11:52:44,592 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Ultraball, with chance 24.99 (48 left)
2016-08-08 11:52:45,808 [PokemonCatchWorker] [INFO] [pokemon_vanished] Squirrel vanished!
2016-08-08 11:52:51,299 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Chirpy Chris  - 12946.65km
2016-08-08 11:52:58,057 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_updated_map] Updated PokemonGo-Map to 22.3366325493, 114.135584819
2016-08-08 11:53:02,498 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Dratini. (2884.30km)
2016-08-08 11:53:02,498 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Dratini
2016-08-08 11:53:05,115 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_back] Teleporting back to previous location (35.7132828916, 139.715192221)
2016-08-08 11:53:17,727 [PokemonCatchWorker] [INFO] [pokemon_appeared] A wild Dratini appeared! [CP 147] [Potential 0.53] [S/A/D 15/2/7]
2016-08-08 11:53:20,305 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Pokeball, with chance 49.83 (124 left)
2016-08-08 11:53:21,303 [PokemonCatchWorker] [INFO] [pokemon_vanished] Dratini vanished!
2016-08-08 11:53:26,917 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop 法鼓山道場 - 2883.31km
2016-08-08 11:53:50,589 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Pikachu. (10841.11km)
2016-08-08 11:53:50,589 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Pikachu
2016-08-08 11:53:53,144 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_back] Teleporting back to previous location (40.7693945909, -73.9763454099)
2016-08-08 11:54:05,427 [PokemonCatchWorker] [INFO] [pokemon_appeared] A wild Pikachu appeared! [CP 496] [Potential 0.64] [S/A/D 1/14/14]
2016-08-08 11:54:09,085 [PokemonCatchWorker] [INFO] [vip_pokemon] This is a VIP pokemon. Catch!!!
2016-08-08 11:54:09,639 [PokemonCatchWorker] [WARNING] [softban] Failed to use berry. You may be soft banned
2016-08-08 11:54:09,640 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Ultraball, with chance 23.91 (47 left)
2016-08-08 11:54:10,677 [PokemonCatchWorker] [INFO] [pokemon_vanished] Pikachu vanished!
2016-08-08 11:54:16,196 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop 林春雄墓碑 - 10839.83km
2016-08-08 11:54:28,813 [PokemonCatchWorker] [INFO] [pokemon_appeared] A wild Rattata appeared! [CP 159] [Potential 0.56] [S/A/D 12/8/5]
2016-08-08 11:54:31,142 [PokemonCatchWorker] [INFO] [threw_pokeball] Used Pokeball, with chance 45.14 (123 left)
2016-08-08 11:54:32,142 [PokemonCatchWorker] [INFO] [pokemon_vanished] Rattata vanished!
2016-08-08 11:54:38,123 [  SpinFort] [INFO] [pokestop_empty] Found nothing in pokestop Michelle Bernstein Landmark.
2016-08-08 11:54:38,124 [  SpinFort] [INFO] [pokestop_searching_too_often] Possibly searching too often, take a rest.
2016-08-08 11:54:38,124 [  SpinFort] [INFO] [softban] Probably got softban.
2016-08-08 11:54:49,836 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Porygon. (16173.26km)
2016-08-08 11:54:49,836 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Polygon
2016-08-08 11:54:52,406 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_back] Teleporting back to previous location (-6.22584795679, 106.797881332)
2016-08-08 11:55:02,804 [PokemonCatchWorker] [INFO] [pokemon_appeared] A 
```..
``````



Discussion:

Resolving patch:
diff --git a/pokemongo_bot/cell_workers/move_to_map_pokemon.py b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
--- a/pokemongo_bot/cell_workers/move_to_map_pokemon.py
+++ b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
@@ -7,13 +7,13 @@
         When the worker fails.
         Returns:
             message: Failure message.
-    
+
     move_to_map_pokemon_updated_map
         When worker updates the PokemonGo-Map.
         Returns:
             lat: Latitude
             lon: Longitude
-    
+
     move_to_map_pokemon_teleport_to
         When trainer is teleported to a Pokemon.
         Returns:
@@ -22,7 +22,7 @@
             poke_lat: Latitude of the Pokemon
             poke_lon: Longitude of the Pokemon
             disappears_in: Number of seconds before the Pokemon disappears
-            
+
     move_to_map_pokemon_encounter
         When a trainer encounters a Pokemon by teleporting or walking.
         Returns:
@@ -31,7 +31,7 @@
             poke_lat: Latitude of the Pokemon
             poke_lon: Longitude of the Pokemon
             disappears_in: Number of seconds before the Pokemon disappears
-    
+
     move_to_map_pokemon_move_towards
         When a trainer moves toward a Pokemon.
         Returns:
@@ -40,7 +40,7 @@
             poke_lat: Latitude of the Pokemon
             poke_lon: Longitude of the Pokemon
             disappears_in: Number of seconds before the Pokemon disappears
-    
+
     move_to_map_pokemon_teleport_back
         When a trainer teleports back to thier previous location.
         Returns:
@@ -184,11 +184,11 @@ def update_map_location(self):
 
         # update map when 500m away from center and last update longer than 2 minutes away
         now = int(time.time())
-        if (dist > UPDATE_MAP_MIN_DISTANCE_METERS and 
+        if (dist > UPDATE_MAP_MIN_DISTANCE_METERS and
             now - self.last_map_update > UPDATE_MAP_MIN_TIME_SEC):
             requests.post(
-                '{}/next_loc?lat={}&lon={}'.format(self.config['address'], 
-                                                   self.bot.position[0], 
+                '{}/next_loc?lat={}&lon={}'.format(self.config['address'],
+                                                   self.bot.position[0],
                                                    self.bot.position[1]))
             self.emit_event(
                 'move_to_map_pokemon_updated_map',
@@ -202,16 +202,18 @@ def update_map_location(self):
 
     def snipe(self, pokemon):
         """Snipe a Pokemon by teleporting.
-        
+
         Args:
             pokemon: Pokemon to snipe.
         """
+        last_position = self.bot.position[0:2]
         self.bot.heartbeat()
         self._teleport_to(pokemon)
         catch_worker = PokemonCatchWorker(pokemon, self.bot)
         api_encounter_response = catch_worker.create_encounter_api_call()
         time.sleep(SNIPE_SLEEP_SEC)
-        self._teleport_back()
+        self._teleport_back(last_position)
+        self.bot.api.set_position(last_position[0], last_position[1], 0)
         time.sleep(SNIPE_SLEEP_SEC)
         self.bot.heartbeat()
         catch_worker.work(api_encounter_response)
@@ -263,34 +265,34 @@ def work(self):
 
     def _emit_failure(self, msg):
         """Emits failure to event log.
-        
+
         Args:
             msg: Message to emit
         """
         self.emit_event(
-            'move_to_map_pokemon_fail', 
+            'move_to_map_pokemon_fail',
             formatted='Failure! {message}',
             data={'message': msg}
         )
-        
+
     def _emit_log(self, msg):
         """Emits log to event log.
-        
+
         Args:
             msg: Message to emit
         """
         self.emit_event(
-            'move_to_map_pokemon', 
+            'move_to_map_pokemon',
             formatted='{message}',
             data={'message': msg}
         )
-        
+
     def _pokemon_event_data(self, pokemon):
         """Generates parameters used for the Bot's event manager.
-        
+
         Args:
             pokemon: Pokemon object
-        
+
         Returns:
             Dictionary with Pokemon's info.
         """
@@ -298,14 +300,14 @@ def _pokemon_event_data(self, pokemon):
         return {
             'poke_name': pokemon['name'],
             'poke_dist': (format_dist(pokemon['dist'], self.unit)),
-            'poke_lat': pokemon['latitude'], 
+            'poke_lat': pokemon['latitude'],
             'poke_lon': pokemon['longitude'],
             'disappears_in': (format_time(pokemon['disappear_time'] - now))
         }
-    
+
     def _teleport_to(self, pokemon):
         """Teleports trainer to a Pokemon.
-        
+
         Args:
             pokemon: Pokemon to teleport to.
         """
@@ -316,7 +318,7 @@ def _teleport_to(self, pokemon):
         )
         self.bot.api.set_position(pokemon['latitude'], pokemon['longitude'], 0)
         self._encountered(pokemon)
-        
+
     def _encountered(self, pokemon):
         """Emit event when trainer encounters a Pokemon.
 
@@ -329,23 +331,21 @@ def _encountered(self, pokemon):
             data=self._pokemon_event_data(pokemon)
         )
 
-    def _teleport_back(self):
-        """Teleports trainer back to their last position."""        
-        last_position = self.bot.position[0:2]
+    def _teleport_back(self, last_position):
+        """Teleports trainer back to their last position."""
         self.emit_event(
             'move_to_map_pokemon_teleport_back',
             formatted=('Teleporting back to previous location ({last_lat}, '
-                       '{last_long})'),
+                       '{last_lon})'),
             data={'last_lat': last_position[0], 'last_lon': last_position[1]}
         )
-        self.bot.api.set_position(last_position[0], last_position[1], 0)
-        
+
     def _move_to(self, pokemon):
         """Moves trainer towards a Pokemon.
-        
+
         Args:
             pokemon: Pokemon to move to.
-        
+
         Returns:
             StepWalker
         """


Test patch: