diff --git a/pokecli.py b/pokecli.py index 4d8eef1737..6ee13f88f0 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`' diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 2596b741d9..e9147e9d6f 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -1003,6 +1003,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 +1117,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',