Skip to content

Commit

Permalink
Missing "catch" and "release" config settings no longer crash the bot. (
Browse files Browse the repository at this point in the history
  • Loading branch information
x1024 authored and MFizz committed Jul 29, 2016
1 parent 32d07f6 commit f7cc5aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def init_config():
help="(Batch mode) Pass \"all\" or a list of pokemons to evolve (e.g., \"Pidgey,Weedle,Caterpie\"). Bot will start by attempting to evolve all pokemons. Great after popping a lucky egg!",
type=str,
default=[])

parser.add_argument(
"-cm",
"--cp_min",
Expand Down Expand Up @@ -168,12 +168,16 @@ def init_config():
for key in config.__dict__:
if key in load:
config.__dict__[key] = load[key]

if 'catch' in load:
config.catch = load['catch']
else:
config.catch = {}

if 'release' in load:
config.release = load['release']
else:
config.release = {}

if config.auth_service not in ['ptc', 'google']:
logging.error("Invalid Auth service specified! ('ptc' or 'google')")
Expand All @@ -188,7 +192,7 @@ def init_config():
config.item_filter= config.item_filter.split(",")

# create web dir if not exists
try:
try:
os.makedirs(web_dir)
except OSError:
if not os.path.isdir(web_dir):
Expand Down
8 changes: 6 additions & 2 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ def should_capture_pokemon(self, pokemon_name, cp, iv, response_dict):
def _get_catch_config_for(self, pokemon):
catch_config = self.config.catch.get(pokemon)
if not catch_config:
catch_config = self.config.catch['any']
catch_config = self.config.catch.get('any')
if not catch_config:
catch_config = {}
return catch_config

def should_release_pokemon(self, pokemon_name, cp, iv, response_dict):
Expand Down Expand Up @@ -366,5 +368,7 @@ def should_release_pokemon(self, pokemon_name, cp, iv, response_dict):
def _get_release_config_for(self, pokemon):
release_config = self.config.release.get(pokemon)
if not release_config:
release_config = self.config.release['any']
release_config = self.config.release.get('any')
if not release_config:
release_config = {}
return release_config

0 comments on commit f7cc5aa

Please sign in to comment.