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

Fixed 'pokemon_caught' event #5539

Merged
merged 5 commits into from
Sep 19, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ If you do not want any data to be gathered, you can turn off this feature by set
* rawgni
* Breeze Ro
* bruno-kenji
* Gobberwart

## Disclaimer
©2016 Niantic, Inc. ©2016 Pokémon. ©1995–2016 Nintendo / Creatures Inc. / GAME FREAK inc. © 2016 Pokémon/Nintendo Pokémon and Pokémon character names are trademarks of Nintendo. The Google Maps Pin is a trademark of Google Inc. and the trade dress in the product design is a trademark of Google Inc. under license to The Pokémon Company. Other trademarks are the property of their respective owners.
Expand Down
29 changes: 10 additions & 19 deletions pokemongo_bot/event_handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,21 @@ def get_player_stats(self):
return ("Stats not loaded yet\n")

def get_event(self, event, formatted_msg, data):
msg = None
if event == 'level_up':
msg = "level up ({})".format(data["current_level"])
elif event == 'pokemon_caught':
if isinstance(self.pokemons, list): # alert_catch is a plain list
if data["pokemon"] in self.pokemons or "all" in self.pokemons:
trigger = None
if data["pokemon"] in self.pokemons:
trigger = self.pokemons[data["pokemon"]]
elif "all" in self.pokemons:
trigger = self.pokemons["all"]
if trigger:
if ((not "operator" in trigger or trigger["operator"] == "and") and data["cp"] >= trigger["cp"] and data["iv"] >= trigger["iv"]) or \
("operator" in trigger and trigger["operator"] == "or" and (data["cp"] >= trigger["cp"] or data["iv"] >= trigger["iv"])):
msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"], data["cp"], data["iv"])
else:
return "Catch error 1"
else: # alert_catch is a dict
if data["pokemon"] in self.pokemons:
trigger = self.pokemons[data["pokemon"]]
elif "all" in self.pokemons:
trigger = self.pokemons["all"]
else:
return
if (not "operator" in trigger or trigger["operator"] == "and") and data["cp"] >= trigger["cp"] and data[
"iv"] >= trigger["iv"] or ("operator" in trigger and trigger["operator"] == "or" and (
data["cp"] >= trigger["cp"] or data["iv"] >= trigger["iv"])):
msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"], data["cp"], data["iv"])
else:
return "Catch error 2"
elif event == 'egg_hatched':
msg = "Egg hatched with a {} CP: {}, IV: {} {}".format(data["name"], data["cp"], data["iv_ads"],
data["iv_pct"])
msg = "Egg hatched with a {} CP: {}, IV: {} {}".format(data["name"], data["cp"], data["iv_ads"], data["iv_pct"])
elif event == 'bot_sleep':
msg = "I am too tired, I will take a sleep till {}.".format(data["wake"])
elif event == 'catch_limit':
Expand Down