Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "catch" and "release" config settings no longer crash the bot. #935

Merged
merged 1 commit into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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