diff --git a/pokecli.py b/pokecli.py index 4d8eef1737..740751727c 100644 --- a/pokecli.py +++ b/pokecli.py @@ -63,12 +63,30 @@ if sys.version_info >= (2, 7, 9): ssl._create_default_https_context = ssl._create_unverified_context +def yes_no( question ): + # raw_input returns the empty string for "enter" + yes = set(['yes','y', 'ye', '']) + no = set(['no','n']) + print question + choice = raw_input().lower() + if choice in yes: + return True + elif choice in no: + return False + else: + print "Please respond with 'yes' or 'no'" + return None + try: import pkg_resources pgoapi_version = pkg_resources.get_distribution("pgoapi").version if pgoapi_version != '2.13.0': - print "Run following command to get latest update: `pip install -r requirements.txt --upgrade`" - sys.exit(1) + yn=None + while yn==None: + yn = yes_no("Warning: A new pokemon API version is found. Do you want to keep the bot running on your own risk of loosing your account? Y/N") + if not yn: + sys.exit(1) + except pkg_resources.DistributionNotFound: print 'Seems you forgot to install python modules.' print 'Run: `pip install -r requirements.txt`' @@ -416,6 +434,14 @@ def _json_loader(filename): help="Username", default=None ) + add_config( + parser, + load, + short_flag="-hp", + long_flag="--hashendpoint", + help="hashendpoint", + default=None + ) add_config( parser, load, diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 2596b741d9..accc1ffc41 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -139,6 +139,10 @@ def __init__(self, db, config): self.inventory_refresh_threshold = 10 self.inventory_refresh_counter = 0 self.last_inventory_refresh = time.time() + + # Allow user to change hash service + if self.config.hashendpoint: + HashServer.endpoint = self.config.hashendpoint # Catch on/off self.catch_disabled = False @@ -1003,6 +1007,21 @@ def login(self): lat, lng = self.position[0:2] self.api.set_position(lat, lng, self.alt) # or should the alt kept to zero? + def yes_no( question ): + # raw_input returns the empty string for "enter" + yes = set(['yes','y', 'ye', '']) + no = set(['no','n']) + print question + choice = raw_input().lower() + if choice in yes: + return True + elif choice in no: + return False + else: + print "Please respond with 'yes' or 'no'" + return None + + while not quit_login: try: self.api.login( @@ -1102,7 +1121,11 @@ def login(self): level='info', formatted="We have detected a Pokemon API Change. Latest Niantic Version is: {}. Program Exiting...".format(officalAPI) ) - sys.exit(1) + yn=None + while yn==None: + yn = yes_no("Warning: A new pokemon API version is found. Do you want to keep the bot running on your own risk of loosing your account? Y/N") + if not yn: + sys.exit(1) else: self.event_manager.emit( 'security_check',