Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added debug event 'forts_found' #5040

Merged
merged 3 commits into from
Sep 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ def _register_events(self):
'player_data',
parameters=('player_data', )
)
self.event_manager.register_event(
'forts_found',
parameters=('json')
)

def tick(self):
self.health_record.heartbeat()
Expand Down Expand Up @@ -737,6 +741,26 @@ def update_web_location(self, cells=[], lat=None, lng=None, alt=None):
json.dump({'lat': lat, 'lng': lng, 'alt': alt, 'start_position': self.start_position}, outfile)
except IOError as e:
self.logger.info('[x] Error while opening location file: %s' % e)
def emit_forts_event(self,response_dict):
map_objects = response_dict.get(
'responses', {}
).get('GET_MAP_OBJECTS', {})
status = map_objects.get('status', None)

map_cells = []
if status and status == 1:
map_cells = map_objects['map_cells']

if map_cells and len(map_cells):
for cell in map_cells:
if "forts" in cell and len(cell["forts"]):
self.event_manager.emit(
'forts_found',
sender=self,
level='debug',
formatted='Found forts {json}',
data={'json': json.dumps(cell["forts"])}
)

def find_close_cells(self, lat, lng):
cellid = get_cell_ids(lat, lng)
Expand Down Expand Up @@ -1308,6 +1332,9 @@ def get_map_objects(self, lat, lng, timestamp, cellid):
since_timestamp_ms=timestamp,
cell_id=cellid
)
self.emit_forts_event(self.last_map_object)
#if self.last_map_object:
# print self.last_map_object
self.last_time_map_object = time.time()

return self.last_map_object
Expand Down