Skip to content

Commit

Permalink
Filter out disabled or closed forts
Browse files Browse the repository at this point in the history
Niantic will disabled some PokeStops on certain times.
These forts can not be spinned when closed, stop wasting time on them.
  • Loading branch information
davidakachaos committed Jun 12, 2017
1 parent 227c52e commit d268c5a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, db, config):
self.catch_disabled = False

self.capture_locked = False # lock catching while moving to VIP pokemon

# Inform bot if there's a response
self.empty_response = False

Expand Down Expand Up @@ -963,9 +963,9 @@ def check_session(self, position):

def login(self):
status = {}
retry = 0
retry = 0
quit_login = False

self.event_manager.emit(
'login_started',
sender=self,
Expand All @@ -974,7 +974,7 @@ def login(self):
)
lat, lng = self.position[0:2]
self.api.set_position(lat, lng, self.alt) # or should the alt kept to zero?

while not quit_login:
try:
self.api.login(
Expand Down Expand Up @@ -1555,7 +1555,7 @@ def heartbeat(self):
except:
self.logger.warning('Error occured in heatbeat, retying')
self.empty_response = True

if not self.empty_response:
if responses['responses']['GET_PLAYER']['success'] == True:
# we get the player_data anyway, might as well store it
Expand Down Expand Up @@ -1622,6 +1622,19 @@ def get_forts(self, order_by_distance=False):
forts = [fort
for fort in self.cell['forts']
if 'latitude' in fort and 'type' in fort]
# Need to filter out disabled forts!
forts = filter(lambda x: x["enabled"] is True, forts)
forts = filter(lambda x: 'closed' not in fort, forts)

if order_by_distance:
forts.sort(key=lambda x: distance(
self.position[0],
self.position[1],
x['latitude'],
x['longitude']
))

return forts

if order_by_distance:
forts.sort(key=lambda x: distance(
Expand Down

0 comments on commit d268c5a

Please sign in to comment.