Repository: PokemonGoF/PokemonGo-Bot

Issue:
Bot crashes if     "enable_social": false,  
### Expected Behavior

```
"enable_social": false,  
```

social should be turned off
### Actual Behavior

Bot crashes

bot runs without any problems if "enable_social": true,  
### Your FULL config.json (remove your username, password, gmapkey and any other private info)

{
    "auth_service": "ptc",
    "username": "",
    "password": "",
    "location": "",
    "gmapkey": "",
    "websocket_server": false,
    "heartbeat_threshold": 10,
    "enable_social": false,  
    "tasks": [
    {
      "type": "HandleSoftBan"
    },
          {
        "type": "SleepSchedule",
        "config": {
          "enabled": true,
          "time": "22:54",
          "duration":"7:46",
          "time_random_offset": "00:24",
          "duration_random_offset": "00:43"
        }
      },

```
   {
    "type": "RandomPause",
    "config": {
      "enabled": false,
      "min_duration": "00:00:10",
      "max_duration": "00:10:00",
      "min_interval": "00:10:00",
      "max_interval": "02:00:00"
    }
  },
  {
    "type": "CompleteTutorial",
    "config": {
      "enabled": true,
      "// set a name": "",
      "nickname": "SugarBison2"
    }
  },

{
  "type": "CollectLevelUpReward"
},
  {
    "type": "IncubateEggs",
    "config": {
      "longer_eggs_first": true,
      "min_interval": 120,
      "infinite": [2,5,10],
      "breakable": [2,5,10]
    }
  },
{
    "type": "TransferPokemon",
    "config": {
      "min_free_slot": 5,
      "transfer_wait_min": 1,
      "transfer_wait_max": 4
    }
  },

{
    "type": "RecycleItems",
    "config": {
      "min_empty_space": 15,
      "max_balls_keep": 150,
      "max_potions_keep": 50,
      "max_berries_keep": 70,
      "max_revives_keep": 70,
      "item_filter": {
        "Pokeball":       { "keep" : 100 },
        "Potion":         { "keep" : 10 },
        "Super Potion":   { "keep" : 20 },
        "Hyper Potion":   { "keep" : 30 },
        "Revive":         { "keep" : 30 },
        "Razz Berry":     { "keep" : 100 }
      },
      "recycle_wait_min": 1,
      "recycle_wait_max": 4
    }
  },
    {
      "type": "CatchPokemon",
      "config": {
        "catch_visible_pokemon": true,
        "catch_lured_pokemon": true,
        "min_ultraball_to_keep": 5,
        "catch_throw_parameters": {
          "excellent_rate": 0.1,
          "great_rate": 0.5,
          "nice_rate": 0.3,
          "normal_rate": 0.1,
          "spin_success_rate" : 0.6
        },
              "catch_simulation": {
                "flee_count": 3,
                "flee_duration": 2,
                "catch_wait_min": 2,
                "catch_wait_max": 6,
                "berry_wait_min": 2,
                "berry_wait_max": 3,
                "changeball_wait_min": 2,
                "changeball_wait_max": 3
              }
      }
    },
{
    "type": "SpinFort",
    "config": {
      "spin_wait_min": 2,
      "spin_wait_max": 3
    }
  }, 

    {
        "type": "PokemonOptimizer",
        "config": {
            "enabled": true,
                "// the 'transfer' parameter activate or deactivate the transfer of pokemons": {},
                "// at false, no pokemon is going to be transfered, ever": {},
                "// at false, you will still get the log information of what the optimizer": {},
                "// would have transfered if the parameter was true": {},
            "transfer": true,
                "// 'transfer_wait_min' and 'transfer_wait_max' are the minimum and maximum": {},
                "// time to wait when transferring a pokemon": {},
            "transfer_wait_min": 2,
            "transfer_wait_max": 4,
                "// the 'evolve' parameter activate or deactivate the evolution of pokemons": {},
                "// at false, no pokemon is going to be evolved, ever": {},
                "// at false, you will still get the log information of what the": {},
                "// optimizer would have evolved if the parameter was true": {},
            "evolve": true,
                "// Time in seconds to wait between two evolve": {},
            "evolve_time": 20,
                "// the 'evolve_for_xp' parameter let you choose if you want the optimizer": {},
                "// to use your candies to evolve low quality pokemons in order to maximize your xp": {},
                "// at false, the optimizer will still use candies to evolve your best Pokemons": {},
            "evolve_for_xp": true,
                "// the 'evolve_only_with_lucky_egg' parameter let you choose if you want the optimizer": {},
                "// to only Evolve Pokemons when a lucky egg is available": {},
            "evolve_only_with_lucky_egg": false,
                "// the 'evolve_count_for_lucky_egg' parameter let you define the minimum": {},
                "// number of Pokemons that must evolve before using a lucky egg": {},
                "// If that number is not reached, and evolve_only_with_lucky_egg is true, evolution will be skipped": {},
                "// If that number is not reached, and evolve_only_with_lucky_egg is false,": {},
                "// evolution will be performed without using a lucky egg": {},
            "evolve_count_for_lucky_egg": 92,
                "// the 'may_use_lucky_egg' parameter let you choose if you want the optimizer": {},
                "// to use a lucky egg right before evolving Pokemons. At false; the optimizer": {},
                "// is free to evolve Pokemons even if you do not have any lucky egg.": {},
            "may_use_lucky_egg": true,
                "// the 'keep' parameter let you define what pokemons you consider are the 'best'. These Pokemons": {},
                "// will be keep and evolved. Note that Pokemons are evaluated inside their whole family": {},
                "// Multiple way of ranking can be defined. Following configuration let you keep the best iv,": {},
                "// the best ncp and the best cp": {},
            "keep": [
                {
                        "// Following setting let you keep the best iv of the family": {},
                        "// the 'top' parameter allow you to define how many Pokemons you want to keep": {},
                        "// at the top of your ranking. If several Pokemons get the same score, they are": {},
                        "// considered equal. Thus, top=1 might result in keeping more than 1 Pokemon.": {},
                    "top": 1,
                        "// the 'evolve' parameter let you choose if you want to evolve the Pokemons you keep": {},
                    "evolve": true,
                        "// the 'sort' parameter define how you want to rank your pokemons": {},
                        "// Critera are sorted fro, the most important to the least important.": {},
                        "// Available criteria are:": {},
                        "// 'iv' = individual value": {},
                        "// 'ivcp' = iv weigted so that for equal iv, attack > defense > stamina": {},
                        "// 'cp' = combat power (can be increased with candies)": {},
                        "// 'cp_exact' = combar power (not rounded)": {},
                        "// 'ncp' (normalized cp) or 'cp_percent' = ratio cp / max_cp": {},
                        "// 'iv_attack' = attach component of iv": {},
                        "// 'iv_defense' = defense component of iv": {},
                        "// 'iv_stamina' = stamina component of iv": {},
                        "// 'dps' = raw dps based on the moves of the pokemon": {},
                        "// 'dps_attack' = average dps when attacking": {},
                        "// 'attack_perfection' = ratio dps_attack / best_dps_attack. Return same order as 'dps_attack'": {},
                        "// 'dps_defense' = average dps when defending": {},
                        "// 'defense_perfection' = ratio dps_defense / best_dps_defense. Return same order as 'dps_defense'": {},
                        "// 'hp' = current health points": {},
                        "// 'hp_max' = max health points": {},
                        "// Note that the more criteria you add to this list, the less likely Pokemons": {},
                        "// will be equals": {},
                    "sort": ["iv"]
                },
                {
                    "// Following setting let you keep keep the best normalized cp of the family": {},
                    "// That is the Pokemon with higher CP once fully evolved": {},
                    "top": 1,
                    "evolve": true,
                    "sort": ["ncp"]
                },
                {
                    "// Following setting let you keep keep the best cp of the family.": {},
                    "// But will not evolve it further (in favor of the best ncp)": {},
                    "// It will only applies to the family of 'Dragonite', 'Arcanine' and 'Muk'": {},
                    "// Other families are not following this setting": {},
                    "names": ["Dragonite", "Arcanine", "Muk"],
                    "top": 1,
                    "evolve": false,
                    "sort": ["cp"]
                }
            ]
        }
  },


{
  "type": "MoveToMapPokemon",
    "config": {
      "address": "http://10.120.36.50:5000",
      "max_distance": 500,
      "min_ball": 50,
      "prioritize_vips": true,
      "snipe": true,
      "snipe_high_prio_only": true,
      "snipe_high_prio_threshold": 400,
      "update_map": false,
      "mode": "priority",
      "map_path": "raw_data",
      "walker": "StepWalker",
      "max_extra_dist_fort": 10,
      "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": 900,
      "Electabuzz": 900,
      "Magmar": 900,
      "Ditto": 900,

      "==========Starters==========": 0,

      "Ivysaur": 600,
      "Venusaur": 1000,


      "Charmeleon": 600,
      "Charizard": 1000,


      "Wartortle": 600,
      "Blastoise": 1000,

      "Pikachu": 600,
      "Raichu": 1000,

      "==========Semi Rare==========": 0,


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

      "Omastar": 500,

      "Dewgong": 500,

      "Muk": 500,

      "Cloyster": 500,

      "Haunter": 500,
      "Gengar": 1000,

      "Hypno": 600,


      "Ninetales": 600,

      "Wigglytuff": 500,

      "Dugtrio": 500,

      "Vaporeon": 800,
      "Jolteon": 800,
      "Flareon": 800,

      "Kabutops": 500,

      "Gyarados": 800,

      "Rapidash": 500,

      "Slowbro": 500,


      "Magneton": 500,

      "Kingler": 500,

      "Electrode": 500,

      "Exeggcutor": 500,


      "Lickitung": 500,

      "Weezing": 500,

      "Rhydon": 500,

      "Chansey": 800,


      "Seadra": 600,

      "Seaking": 500,

      "Starmie": 800,


      "==========T1 Evolvers==========": 0,
      "Butterfree": 500,

      "Beedrill": 500,



      "==========T2 Evolvers==========": 0,

      "Vileplume": 600,


      "Poliwrath": 800,


      "Kadabra": 600,
      "Alakazam": 800,


      "Machamp": 800,


      "Victreebel": 800
    }
  }
},
  {
    "type": "MoveToFort",
    "config": {
      "lure_attraction": true,
      "lure_max_distance": 2000,
      "walker": "StepWalker"
    }
  },
  {
    "type": "FollowSpiral",
    "config": {
      "diameter": 4,
      "step_size": 70
    }
  }
```

  ],
   "map_object_cache_time": 5,
    "forts": {
      "avoid_circles": true,
      "max_circle_size": 50,
      "cache_recent_forts": true
    },

  "walk_min": 13,
  "walk_max": 23,
  "alt_min": 500,
  "alt_max": 1000,
  "gps_default_altitude": 8.0,
  "replicate_gps_xy_noise": false,
  "replicate_gps_z_noise": false,
  "gps_xy_noise_range": 0.000125,
  "gps_z_noise_range": 12.5,
  "action_wait_min": 1,
  "action_wait_max": 5,
  "debug": false,
  "test": false,
  "health_record": false,
  "location_cache": true,
  "distance_unit": "km",
  "reconnecting_timeout": 1,
  "daily_catch_limit": 800,
  "logging_color": true,
  "catch_randomize_reticle_factor": 1.0,
  "catch_randomize_spin_factor": 1.0,
   "catch_throw_parameters": {
      "excellent_rate": 0.7,
      "great_rate": 0.5,
      "nice_rate": 0.3,
      "normal_rate": 0.1,
      "spin_success_rate" : 0.8
    },
  "catch": {
    "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or" },

```
"// Pokemons with example": { "always_catch": true },
"// Gets filtered with release parameters": {},

"// Legendary pokemons (Goes under S-Tier)": {},
"Lapras": { "always_catch": true },
"Moltres": { "always_catch": true },
"Zapdos": { "always_catch": true },
"Articuno": { "always_catch": true },

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

"// Growlithe evolves to Arcanine": {},
"Growlithe": { "always_catch": true },
"// Dragonair evolves to Dragonite": {},
"Dragonair": { "always_catch": true },
"// Grimer evolves to Muk": {},
"Grimer": { "always_catch": true },

"// Magikarp evolves to Gyarados": {},
"Magikarp": { "always_catch": true },
"// Exeggcute evolves to Exeggutor": {},
"Exeggcute": { "always_catch": true },
"// Eevee evolves to many versions, like Vaporeon, Flareon": {},
"Eevee": { "always_catch": true },

"// A-Tier pokemons": {},
"Slowbro": { "always_catch": true },
"Victreebel": { "always_catch": true },
"Machamp": { "always_catch": true },
"Poliwrath": { "always_catch": true },
"Clefable": { "always_catch": true },
"Nidoking": { "always_catch": true },
"Venusaur": { "always_catch": true },
"Charizard": { "always_catch": true },
"Golduck": { "always_catch": true },
"Nidoqueen": { "always_catch": true },
"Vileplume": { "always_catch": true },
"Blastoise": { "always_catch": true },
"Omastar":  { "always_catch": true },
"Aerodactyl": { "always_catch": true },
"Golem": { "always_catch": true },
"Wigglytuff": { "always_catch": true },
"Dewgong": { "always_catch": true },
"Ninetales": { "always_catch": true },
"Magmar": { "always_catch": true },
"Kabutops": { "always_catch": true },
"Electabuzz": { "always_catch": true },
"Starmie": { "always_catch": true },
"Jolteon": { "always_catch": true },
"Rapidash": { "always_catch": true },
"Pinsir": { "always_catch": true },
"Scyther": { "always_catch": true },
"Tentacruel": { "always_catch": true },
"Gengar": { "always_catch": true },
"Hypno": { "always_catch": true },
"Pidgeot": { "always_catch": true },
"Rhydon": { "always_catch": true },
"Seaking": { "always_catch": true },
"Kangaskhan": { "always_catch": true }
```

 },

  "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

Traceback (most recent call last):
  File "pokecli.py", line 703, in <module>
    main()
  File "pokecli.py", line 118, in main
    bot.tick()
  File "/home/beltoft/PokemonGo-Bot/pokemongo_bot/**init**.py", line 568, in tick
    if worker.work() == WorkerResult.RUNNING:
  File "/home/beltoft/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 292, in work
    pokemon_list = self.get_pokemon_from_social()
  File "/home/beltoft/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 105, in get_pokemon_from_social
    if not self.bot.mqtt_pokemon_list or len(self.bot.mqtt_pokemon_list) <= 0:
AttributeError: 'PokemonGoBot' object has no attribute 'mqtt_pokemon_list'
Wed Aug 24 13:22:27 CEST 2016 Pokebot  Stopped.
### Steps to Reproduce

set  "enable_social": true 
to 

 "enable_social": false
### Other Information

OS: 
ubuntu 14.04 LTS

Branch: 
newest dev 



Discussion:
Looks like if social is disabled, we don't set mqtt_pokemon_list and move_to_map_pokemon just assumes it is set. 

what does this social do by the way?

Crowdsourcing pokemon data.

which branch? I'm cloning both going to do some testing to see, I think what will be done is we will only allow users who use the social feature to view the map and normal users will just be locked out, this way it's fair to everyone.


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
@@ -102,6 +102,8 @@ def initialize(self):
             )
         self.alt = uniform(self.bot.config.alt_min, self.bot.config.alt_max)
     def get_pokemon_from_social(self):
+    	if not hasattr(self.bot, 'mqtt_pokemon_list'):
+            return []
         if not self.bot.mqtt_pokemon_list or len(self.bot.mqtt_pokemon_list) <= 0:
             return []
 


Test patch: