Repository: PokemonGoF/PokemonGo-Bot

Issue:
Client stops when [move_to_map_pokemon_teleport_to]
<!--

STOP ! ! !

Read the following before creating anything (or you will have your issue/feature request closed without notice)

1. Please only create an ISSUE or a FEATURE REQUEST - don't mix the two together in one item
2. For a Feature Request please only fill out the FEATURE REQUEST section
3. For a Issue please only fill out the ISSUE section
4. Issues are NOT to be used for help/config problems/support - use the relevant slack channels as per the README
5. Provide a good summary in the title, don't just write problem, or awesome idea!
6. Delete all irrelevant sections not related to your issue/feature request (including this top section)

===============ISSUE SECTION===============

Before you create an Issue, please check the following:

1. Have you validated that your config.json is valid JSON? Use http://jsonlint.com/ to check.
2. Have you [searched our issue tracker](https://github.com/PokemonGoF/PokemonGo-Bot/issues?q=is%3Aissue+sort%3Aupdated-desc) to see if the issue already exists? If so, comment on that issue instead rather than creating a new issue.
3. Are you running on the `master` branch? We work on the `dev` branch and then add that functionality to `master` when it is stable. Your issue may be fixed on `dev` and there is no need for this issue, just wait and it will eventually be merged to `master`.
4. All Issue sections MUST be completed to help us determine the actual problem and find its cause
-->
### Expected Behavior

<!-- Tell us what you expect to happen -->

MoveToMapPokemon and [move_to_map_pokemon_teleport_to] should teleport without further problems. 
### Actual Behavior

<!-- Tell us what is happening -->

PokemonGoBot is initiated successfully and [bot_start], [level_up_reward], [next_egg_incubates] and [spun_pokestop] messages are printed as expected. However, when [move_to_map_pokemon_teleport_to] occurs the client stops and the stats at the end of the session are printed. Also, an error message is printed.
### Your FULL config.json (remove your username, password, gmapkey and any other private info)

<!-- Provide your FULL config file, feel free to use services such as pastebin.com to reduce clutter -->

```
{
    "auth_service": "ptc",
    "username": "my_username",
    "password": "my_password",
    "location": "somewhere",
    "gmapkey": "my_key",
    "tasks": [
      {
        "type": "HandleSoftBan"
      },
      {
        "type": "CollectLevelUpReward"
      },
      {
        "type": "IncubateEggs",
        "config": {
          "longer_eggs_first": true
        }
      },
      {
        "type": "TransferPokemon"
      },
      {
        "type": "EvolvePokemon",
        "config": {
            "evolve_all": "none",
            "first_evolve_by": "cp",
            "evolve_above_cp": 500,
            "evolve_above_iv": 0.8,
            "logic": "or",
            "evolve_speed": 20,
            "use_lucky_egg": false
        }
      },
      {
        "type": "RecycleItems",
        "config": {
          "item_filter": {
            "Pokeball":       { "keep" : 30 },
            "Potion":         { "keep" : 10 },
            "Super Potion":   { "keep" : 15 },
            "Hyper Potion":   { "keep" : 20 },
            "Revive":         { "keep" : 20 },
            "Razz Berry":     { "keep" : 30 }
          }
        }
      },
      {
        "type": "CatchVisiblePokemon"
      },
      {
        "type": "CatchLuredPokemon"
      },
      {
        "type": "SpinFort"
      },
      {
        "type": "MoveToMapPokemon",
        "config": {
          "address": "http://127.0.0.1:8000",
          "max_distance": 500,
          "min_time": 60,
          "min_ball": 50,
          "prioritize_vips": true,
          "snipe": true,
          "snipe_high_prio_only": true,
          "snipe_high_prio_threshold": 900,
          "update_map": true,
          "mode": "priority",
          "map_path": "raw_data",
          "catch": {
            "==========Legendaries==========": 0,
            "Aerodactyl": 1000,
            "Snorlax": 1000,
            "Articuno": 1000,
            "Zapdos": 1000,
            "Moltres": 1000,
            "Dratini": 1000,
            "Dragonair": 1000,
            "Dragonite": 1000,
            "Mewtwo": 1000,
            "Mew": 1000,

            "==========Region Locked==========": 0,
            "Farfetch'd": 1000,
            "Kangaskhan": 1000,
            "Mr. Mime": 1000,
            "Tauros": 1000,

            "==========Very Rare==========": 0,
            "Lapras": 1000,
            "Electabuzz": 1000,
            "Magmar": 1000,
            "Ditto": 1000,

            "==========Starters==========": 0,
            "Bulbasaur": 800,
            "Ivysaur": 900,
            "Venusaur": 1000,

            "Charmander": 800,
            "Charmeleon": 900,
            "Charizard": 1000,

            "Squirtle": 800,
            "Wartortle": 900,
            "Blastoise": 1000,

            "Pikachu": 900,
            "Raichu": 1000,

            "==========Semi Rare==========": 0,
            "Porygon": 1000,
            "Scyther": 1000,
            "Jynx": 1000,

            "==========Uncommon==========": 0,

            "Omanyte": 700,
            "Omastar": 900,

            "Seel": 700,
            "Dewgong": 900,

            "Grimer": 700,
            "Muk": 900,

            "Shellder": 700,
            "Cloyster": 900,

            "Gastly": 500,
            "Haunter": 700,
            "Gengar": 900,

            "Onix": 500,

            "Drowzee": 700,
            "Hypno": 900,

            "Vulpix": 900,
            "Ninetales": 1000,

            "Paras": 100,
            "Parasect": 500,

            "Growlithe": 500,
            "Arcanine": 700,

            "Tentacool": 100,
            "Tentacruel": 300,

            "Mankey": 100,
            "Primeape": 300,

            "Clefairy": 300,
            "Clefable": 500,

            "Jigglypuff": 300,
            "Wigglytuff": 500,

            "Venonat": 100,
            "Venomoth": 300,

            "Diglett": 100,
            "Dugtrio": 300,

            "Meowth": 100,
            "Persian": 300,

            "Psyduck": 100,
            "Golduck": 300,

            "Geodude": 500,
            "Graveler": 700,
            "Golem": 900,

            "Eevee": 900,
            "Vaporeon": 1000,
            "Jolteon": 1000,
            "Flareon": 1000,

            "Kabuto": 900,
            "Kabutops": 1000,

            "Magikarp": 300,
            "Gyarados": 1000,

            "Pinsir": 100,

            "Ponyta": 700,
            "Rapidash": 900,

            "Slowpoke": 300,
            "Slowbro": 500,

            "Magnemite": 700,
            "Magneton": 900,

            "Krabby": 100,
            "Kingler": 300,

            "Voltorb": 700,
            "Electrode": 900,

            "Exeggcute": 100,
            "Exeggcutor": 300,

            "Cubone": 700,
            "Marowak": 900,

            "Hitmonlee": 900,
            "Hitmonchan": 1000,

            "Lickitung": 1000,

            "Koffing": 300,
            "Weezing": 500,

            "Rhyhorn": 300,
            "Rhydon": 500,

            "Chansey": 1000,

            "Tangela": 300,

            "Horsea": 100,
            "Seadra": 300,

            "Goldeen": 100,
            "Seaking": 300,

            "Staryu": 100,
            "Starmie": 300,


            "==========T1 Evolvers==========": 0,
            "Caterpie": 10,
            "Metapod": 10,
            "Butterfree": 500,

            "Weedle": 10,
            "Kakuna": 10,
            "Beedrill": 500,

            "Pidgey": 10,
            "Pidgeotto": 10,
            "Pidgeot": 500,

            "==========T2 Evolvers==========": 0,
            "Nidoran F": 500,
            "Nidorina": 700,
            "Nidoqueen": 1000,

            "Nidoran M": 500,
            "Nidorino": 700,
            "Nidoking": 1000,

            "Oddish": 500,
            "Gloom": 700,
            "Vileplume": 1000,

            "Poliwag": 100,
            "Poliwhirl": 300,
            "Poliwrath": 500,

            "Abra": 1000,
            "Kadabra": 1000,
            "Alakazam": 1000,

            "Machop": 1000,
            "Machoke": 1000,
            "Machamp": 1000,

            "Bellsprout": 500,
            "Weepinbell": 700,
            "Victreebel": 900,

            "==========Trash==========": 0,

            "Rattata": 10,
            "Raticate": 100,

            "Spearow": 10,
            "Fearow": 100,

            "Ekans": 10,
            "Arbok": 100,

            "Sandshrew": 10,
            "Sandslash": 100,

            "Zubat": 10,
            "Golbat": 100,

            "Doduo": 10,
            "Dodrio": 100
          }
        }
      },
      {
        "type": "MoveToFort",
        "config": {
            "lure_attraction": true,
            "lure_max_distance": 2000
        }
      },
      {
        "type": "FollowSpiral",
        "config": {
          "diameter": 4,
          "step_size": 70
        }
      }
    ],
    "map_object_cache_time": 5,
    "forts": {
      "avoid_circles": true,
      "max_circle_size": 50
    },
    "websocket_server": false,
    "walk": 4.16,
    "action_wait_min": 1,
    "action_wait_max": 4,
    "debug": false,
    "test": false,
    "health_record": true,
    "location_cache": true,
    "distance_unit": "km",
    "reconnecting_timeout": 15,
    "evolve_captured": "NONE",
    "catch_randomize_reticle_factor": 1.0,
    "catch_randomize_spin_factor": 1.0,
    "catch": {
      "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
      "// Example of always catching Rattata:": {},
      "// Rattata": { "always_catch" : true }
    },
    "release": {
      "// any": {"release_below_cp": 0, "release_below_iv": 0, "logic": "or"},
      "any": {"keep_best_cp": 5},
      "any": { "release_below_iv": 0.9 },
      "// Example of always releasing Rattata:": {},
      "// Rattata": {"always_release": true},
      "// Example of keeping 3 stronger (based on CP) Pidgey:": {},
      "// Pidgey": {"keep_best_cp": 3},
      "// Example of keeping 2 stronger (based on IV) Zubat:": {},
      "// Zubat": {"keep_best_iv": 2},
      "// Also, it is working with any": {},
      "// any": {"keep_best_iv": 3},
      "// Example of keeping the 2 strongest (based on CP) and 3 best (based on IV) Zubat:": {},
      "// Zubat": {"keep_best_cp": 2, "keep_best_iv": 3}
    },
    "vips" : {
        "Any pokemon put here directly force to use Berry & Best Ball to capture, to secure the capture rate!": {},
        "any": {"catch_above_cp": 1200, "catch_above_iv": 0.9, "logic": "or" },
        "Lapras": {},
        "Moltres": {},
        "Zapdos": {},
        "Articuno": {},

        "// S-Tier pokemons (if pokemon can be evolved into tier, list the representative)": {},
        "Mewtwo": {},
        "Dragonite": {},
        "Snorlax": {},
        "// Mew evolves to Mewtwo": {},
        "Mew": {},
        "Arcanine": {},
        "Vaporeon": {},
        "Gyarados": {},
        "Exeggutor": {},
        "Muk": {},
        "Weezing": {},
        "Flareon": {}

    }
}
```
### Output when issue occurred

<!-- Provide a reasonable sample from your output log (not just the error message), feel free to use services such as pastebin.com to reduce clutter -->

```
2016-08-17 09:15:06,560 [       cli] [INFO] PokemonGO Bot v1.0
2016-08-17 09:15:06,562 [       cli] [WARNING] The evolve_captured argument is no longer supported. Please use the EvolvePokemon task instead
2016-08-17 09:15:06,562 [       cli] [WARNING] The walk argument is no longer supported. Please use the walk_max and walk_min variables instead
2016-08-17 09:15:06,562 [       cli] [INFO] Configuration initialized
2016-08-17 09:15:06,562 [pokemongo_bot.health_record.bot_event] [INFO] Health check is enabled. For more information:
2016-08-17 09:15:06,563 [pokemongo_bot.health_record.bot_event] [INFO] https://github.com/PokemonGoF/PokemonGo-Bot/tree/dev#analytics
2016-08-17 09:15:06,615 [requests.packages.urllib3.connectionpool] [INFO] Starting new HTTP connection (1): www.google-analytics.com
2016-08-17 09:15:07,089 [PokemonGoBot] [INFO] [set_start_location] Setting start location.
2016-08-17 09:15:07,089 [PokemonGoBot] [INFO] [x] Coordinates found in passed in location, not geocoding.
2016-08-17 09:15:07,089 [PokemonGoBot] [INFO] [location_found] Location found: 36.383385, 25.449896 (36.383385, 25.449896, 0.0)
2016-08-17 09:15:07,090 [PokemonGoBot] [INFO] [position_update] Now at (36.383385, 25.449896, 0)
2016-08-17 09:15:07,090 [PokemonGoBot] [INFO] [login_started] Login procedure started.
2016-08-17 09:15:09,223 [PokemonGoBot] [INFO] [login_successful] Login successful.
2016-08-17 09:15:10,872 [PokemonGoBot] [INFO] 
2016-08-17 09:15:10,872 [PokemonGoBot] [INFO] --- my_username ---
2016-08-17 09:15:10,873 [PokemonGoBot] [INFO] Level: 25 (Next Level: 10572 XP) (Total: 889428 XP)
2016-08-17 09:15:10,873 [PokemonGoBot] [INFO] Pokemon Captured: 2885 | Pokestops Visited: 2708
2016-08-17 09:15:10,873 [PokemonGoBot] [INFO] Pokemon Bag: 138/250
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] Items: 203/350
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] Stardust: 3742 | Pokecoins: 40
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] PokeBalls: 54 | GreatBalls: 2 | UltraBalls: 31 | MasterBalls: 0
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] RazzBerries: 3 | BlukBerries: 0 | NanabBerries: 0
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] LuckyEgg: 4 | Incubator: 0 | TroyDisk: 5
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] Potion: 15 | SuperPotion: 20 | HyperPotion: 16 | MaxPotion: 17
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] Incense: 4 | IncenseSpicy: 0 | IncenseCool: 0
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] Revive: 30 | MaxRevive: 0
2016-08-17 09:15:10,874 [PokemonGoBot] [INFO] 
2016-08-17 09:15:10,875 [PokemonGoBot] [INFO] Found encrypt.so! Platform: darwin Encrypt.so directory: /Users/my_username/PokemonGo-Bot
2016-08-17 09:15:10,875 [PokemonGoBot] [INFO] 
2016-08-17 09:15:12,409 [PokemonGoBot] [WARNING] The CatchVisiblePokemon & CatchLuredPokemon tasks have been replaced with CatchPokemon.  CatchPokemon has been enabled with default settings.
2016-08-17 09:15:12,652 [PokemonGoBot] [INFO] [bot_start] Starting bot...
2016-08-17 09:15:12,975 [CollectLevelUpReward] [INFO] [level_up_reward] Received level up reward: []
2016-08-17 09:15:12,976 [IncubateEggs] [INFO] [next_egg_incubates] Next egg incubates in 3.07 km
2016-08-17 09:15:15,566 [  SpinFort] [INFO] [spun_pokestop] Spun pokestop Γυάλινο Κτίριο. Experience awarded: 50. Items awarded: {u'Razz Berry': 1, u'Pokeball': 1, u'Greatball': 1}
2016-08-17 09:15:18,226 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Abra. (0.00km)
2016-08-17 09:15:18,226 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Abra
2016-08-17 09:15:18,469 [       cli] [INFO] 
2016-08-17 09:15:18,469 [       cli] [INFO] Ran for 0:00:11
2016-08-17 09:15:18,469 [       cli] [INFO] Total XP Earned: 50  Average: 15816.76/h
2016-08-17 09:15:18,469 [       cli] [INFO] Travelled 0.00km
2016-08-17 09:15:18,469 [       cli] [INFO] Visited 1 stops
2016-08-17 09:15:18,469 [       cli] [INFO] Encountered 0 pokemon, 0 caught, 0 released, 0 evolved, 0 never seen before
2016-08-17 09:15:18,469 [       cli] [INFO] Threw 0 pokeballs
2016-08-17 09:15:18,469 [       cli] [INFO] Earned 0 Stardust
2016-08-17 09:15:18,469 [       cli] [INFO] 
2016-08-17 09:15:18,469 [       cli] [INFO] Highest CP Pokemon: 
2016-08-17 09:15:18,470 [       cli] [INFO] Most Perfect Pokemon: 
Traceback (most recent call last):
  File "pokecli.py", line 570, in <module>
    main()
  File "pokecli.py", line 104, in main
    bot.tick()
  File "/Users/my_username/PokemonGo-Bot/pokemongo_bot/__init__.py", line 501, in tick
    if worker.work() == WorkerResult.RUNNING:
  File "/Users/my_username/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 267, in work
    self.snipe(pokemon)
  File "/Users/my_username/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 220, in snipe
    catch_worker = PokemonCatchWorker(pokemon, self.bot)
TypeError: __init__() takes exactly 4 arguments (3 given)
2016-08-17 09:15:18,496 [sentry.errors] [ERROR] Sentry responded with an error: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (url: https://app.getsentry.com/api/90254/store/)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/raven/transport/threaded.py", line 174, in send_sync
    super(ThreadedHTTPTransport, self).send(data, headers)
  File "/usr/local/lib/python2.7/site-packages/raven/transport/http.py", line 47, in send
    ca_certs=self.ca_certs,
  File "/usr/local/lib/python2.7/site-packages/raven/utils/http.py", line 66, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 494, in open
    response = self._open(req, data)
  File "/usr/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 512, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 466, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/site-packages/raven/utils/http.py", line 46, in https_open
    return self.do_open(ValidHTTPSConnection, req)
  File "/usr/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 1284, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1057, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1097, in _send_request
    self.endheaders(body)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1053, in endheaders
    self._send_output(message_body)
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 895, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128)
2016-08-17 09:15:18,497 [sentry.errors.uncaught] [ERROR] [u'TypeError: __init__() takes exactly 4 arguments (3 given)', u'  File "pokecli.py", line 570, in <module>', u'  File "pokecli.py", line 104, in main', u'  File "pokemongo_bot/__init__.py", line 501, in tick', u'  File "pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 267, in work', u'  File "pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 220, in snipe']
```
### Steps to Reproduce

<!-- Tell us the steps you have taken to reproduce the issue -->

1) open terminal and then:

$ cd /Users/my_username/PokemonGo-Bot
$ pip2 install -r requirements.txt
$ python pokecli.py -cf ./configs/config.json
### Other Information

OS: OS X El Capitán Version 10.11.6 (15G31)

<!-- Tell us what Operating system you're using --> 

Branch: dev

<!-- dev or master --> 

Git Commit: 7136348dda4217d8010aab4d8e6f1124cba64140

<!-- run 'git log -n 1 --pretty=format:"%H"' --> 

Python Version: Python 2.7.12

<!-- run 'python -V' and paste it here) --> 

Any other relevant files/configs (eg: path files) 

<!-- Anything else which may be of relevance -->

<!-- ===============END OF ISSUE SECTION=============== -->

<!-- Note: Delete these lines and everything BELOW if creating an Issue -->

<!-- ===============FEATURE REQUEST SECTION===============

Before you create a Feature Request, please check the following:

1. Have you [searched our feature tracker](https://github.com/PokemonGoF/PokemonGo-Bot/labels/Feature%20Request) first to ensure someone else hasn't already come up with the same great idea.  If so then be sure to +1 it 
2. While you're there, be sure to vote on other feature requests to let the devs know what is important to you.
-->

<!-- Note: Delete this line and everything ABOVE if creating a Feature Request -->
### Short Description

<!-- Tell us a short description of your request -->
### Possible solution

<!-- Tell us how you would include it in the current bot -->
### How it would help others

<!-- Tell us how you think it would help yourself and other users -->

<!-- ==========END OF FEATURE REQUEST SECTION========== -->



Discussion:
same behavior, just after fetch last merge.
/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 220, in snipe
    catch_worker = PokemonCatchWorker(pokemon, self.bot)
TypeError: **init**() takes exactly 4 arguments (3 given)

the incorrect line is 
catch_worker = PokemonCatchWorker(pokemon, self.bot)

should be
worker = PokemonCatchWorker(pokemon, self.bot, self.config)


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
@@ -212,7 +212,7 @@ def snipe(self, pokemon):
         last_position = self.bot.position[0:2]
         self.bot.heartbeat()
         self._teleport_to(pokemon)
-        catch_worker = PokemonCatchWorker(pokemon, self.bot)
+        catch_worker = PokemonCatchWorker(pokemon, self.bot, self.config)
         api_encounter_response = catch_worker.create_encounter_api_call()
         time.sleep(SNIPE_SLEEP_SEC)
         self._teleport_back(last_position)


Test patch: