Skip to content

Commit

Permalink
Merge pull request #1 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
Rebase from Main Repo
  • Loading branch information
MerlionRock authored Aug 3, 2017
2 parents 424908f + 400292b commit 1be2f1d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
30 changes: 28 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 Expand Up @@ -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,
Expand Down
25 changes: 24 additions & 1 deletion pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 1be2f1d

Please sign in to comment.