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

Detect and alert for permaban #3944

Merged
merged 1 commit into from
Aug 14, 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 CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@
* extink
* Quantra
* pmquan
* net8q
8 changes: 8 additions & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from pokemongo_bot.base_dir import _base_dir
from pokemongo_bot.health_record import BotEvent
from pokemongo_bot.plugin_loader import PluginLoader
from pokemongo_bot.api_wrapper import PermaBannedException

try:
from demjson import jsonlint
Expand Down Expand Up @@ -137,6 +138,13 @@ def handle_sigint(*args):
)
time.sleep(30)

except PermaBannedException:
bot.event_manager.emit(
'api_error',
sender=bot,
level='info',
formatted='Probably permabanned, Game Over ! Play again at https://club.pokemon.com/us/pokemon-trainer-club/sign-up/'
)
except GeocoderQuotaExceeded:
raise Exception("Google Maps API key over requests limit.")
except Exception as e:
Expand Down
11 changes: 11 additions & 0 deletions pokemongo_bot/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

from human_behaviour import sleep

class PermaBannedException(Exception):
pass

class ApiWrapper(PGoApi):
def __init__(self):
PGoApi.__init__(self)
Expand Down Expand Up @@ -77,6 +80,14 @@ def is_response_valid(self, result, request_callers):
if not isinstance(result['responses'], dict):
return False

try:
# Permaban symptom is empty response to GET_INVENTORY and status_code = 3
if result['status_code'] == 3 and 'GET_INVENTORY' in request_callers and not result['responses']['GET_INVENTORY']:
raise PermaBannedException
except KeyError:
# Still wrong
return False

# the response can still programatically be valid at this point
# but still be wrong. we need to check if the server did sent what we asked it
for request_caller in request_callers:
Expand Down