Skip to content

Commit

Permalink
Merge pull request #6180 from goedzo/API-Warning
Browse files Browse the repository at this point in the history
User Friendly Api warning (Dev)
  • Loading branch information
MerlionRock authored Aug 2, 2017
2 parents 424908f + 31e128f commit 82593eb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
22 changes: 20 additions & 2 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`'
Expand Down
21 changes: 20 additions & 1 deletion pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 82593eb

Please sign in to comment.