Skip to content

Commit

Permalink
Merge branch 'refactor-for-webui' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
brantje committed Aug 10, 2016
2 parents 01bc14d + 61df52f commit 41de6f7
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 13 deletions.
9 changes: 9 additions & 0 deletions brantje.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# coding: utf-8
from socketIO_client import SocketIO
s = SocketIO('localhost', 4000)
def echo(msg):
print msg

s.on('get_player_info:d.camata@gmail.com', echo)
s.emit('remote:send_request', {'account': 'd.camata@gmail.com', 'name': 'get_player_info'})

This comment has been minimized.

Copy link
@DimaVIII

DimaVIII Aug 10, 2016

@brantje your email?

s.wait(1)
25 changes: 20 additions & 5 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ def _register_events(self):
'cp',
'iv',
'iv_display',
'encounter_id',
'latitude',
'longitude',
'pokemon_id'
)
)
self.event_manager.register_event('no_pokeballs')
Expand Down Expand Up @@ -272,15 +276,25 @@ def _register_events(self):
)
self.event_manager.register_event(
'pokemon_vanished',
parameters=('pokemon',)
parameters=(
'pokemon',
'encounter_id',
'latitude',
'longitude',
'pokemon_id'
)
)
self.event_manager.register_event('pokemon_not_in_range')
self.event_manager.register_event('pokemon_inventory_full')
self.event_manager.register_event(
'pokemon_caught',
parameters=(
'pokemon',
'cp', 'iv', 'iv_display', 'exp'
'cp', 'iv', 'iv_display', 'exp',
'encounter_id',
'latitude',
'longitude',
'pokemon_id'
)
)
self.event_manager.register_event(
Expand Down Expand Up @@ -992,9 +1006,10 @@ def heartbeat(self):
pass

def update_web_location_worker(self):
while True:
self.web_update_queue.get()
self.update_web_location()
pass

This comment has been minimized.

Copy link
@CyberMew

CyberMew Aug 11, 2016

Any reason why this is added and commented? This breaks the UI map updates

This comment has been minimized.

Copy link
@readtimeout

readtimeout Aug 11, 2016

location cache not working now.
#3596

# while True:
# self.web_update_queue.get()
# self.update_web_location()

def get_inventory_count(self, what):
response_dict = self.get_inventory()
Expand Down
18 changes: 16 additions & 2 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def work(self, response_dict=None):
'cp': pokemon.cp,
'iv': pokemon.iv,
'iv_display': pokemon.iv_display,
'encounter_id': self.pokemon['encounter_id'],
'latitude': self.pokemon['latitude'],
'longitude': self.pokemon['longitude'],
'pokemon_id': pokemon.num
}
)

Expand Down Expand Up @@ -370,7 +374,13 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
self.emit_event(
'pokemon_vanished',
formatted='{pokemon} vanished!',
data={'pokemon': pokemon.name}
data={
'pokemon': pokemon.name,
'encounter_id': self.pokemon['encounter_id'],
'latitude': self.pokemon['latitude'],
'longitude': self.pokemon['longitude'],
'pokemon_id': pokemon.num
}
)
if self._pct(catch_rate_by_ball[current_ball]) == 100:
self.bot.softban = True
Expand All @@ -386,7 +396,11 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
'cp': pokemon.cp,
'iv': pokemon.iv,
'iv_display': pokemon.iv_display,
'exp': sum(response_dict['responses']['CATCH_POKEMON']['capture_award']['xp'])
'exp': sum(response_dict['responses']['CATCH_POKEMON']['capture_award']['xp']),
'encounter_id': self.pokemon['encounter_id'],
'latitude': self.pokemon['latitude'],
'longitude': self.pokemon['longitude'],
'pokemon_id': pokemon.num
}
)

Expand Down
8 changes: 4 additions & 4 deletions pokemongo_bot/socketio_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def remote_control(sid, command):
@sio.on('bot:send_reply')
def request_reply(sid, response):
event = response.pop('command')
account = response.pop('account')
account = response['account']
event = "{}:{}".format(event, account)
sio.emit(event, response)

@sio.on('bot:broadcast')
def bot_broadcast(sid, env):
event = env.pop('event')
account = env.pop('account')
event = env['event']
account = env['account']
event_name = "{}:{}".format(event, account)
sio.emit(event_name, data=env['data'])
sio.emit(event_name, data=env)
11 changes: 11 additions & 0 deletions pokemongo_bot/step_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ def step(self):
cLng = self.initLng + scaledDLng + random_lat_long_delta()

self.api.set_position(cLat, cLng, 0)
self.bot.event_manager.emit(
'position_update',
sender=self,
level='debug',
data={
'current_position': (cLat, cLng),
'last_position': (self.initLat, self.initLng),
'distance': '',
'distance_unit': ''
}
)
self.bot.heartbeat()

sleep(1) # sleep one second plus a random delta
Expand Down
9 changes: 7 additions & 2 deletions pokemongo_bot/websocket_remote_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ def on_remote_command(self, command):
command_handler()

def get_player_info(self):
player_info = self.bot.get_inventory()['responses']['GET_INVENTORY']
request = self.bot.api.create_request()
request.get_player()
request.get_inventory()
response_dict = request.call()
inventory = response_dict['responses'].get('GET_INVENTORY', {})
player_info = response_dict['responses'].get('GET_PLAYER', {})
self.sio.emit(
'bot:send_reply',
{
'result': player_info,
'result': {'inventory': inventory, 'player': player_info},
'command': 'get_player_info',
'account': self.bot.config.username
}
Expand Down

4 comments on commit 41de6f7

@VeNoMouS
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that debug really required in pokemongo_bot/step_walker.py? dirties up the console...

        self.bot.event_manager.emit(
            'position_update',
            sender=self,
            level='debug',
            data={
                'current_position': (cLat, cLng),
                'last_position': (self.initLat, self.initLng),
                'distance': '',
                'distance_unit': ''
            }
        )

@brantje
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need that for regular position updates in the web ui.

@VeNoMouS
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, the problem more is the pokemongo_bot/event_handlers/colored_logging_handler.py does not honor the config setting of debug set to false... , not so much your problem, just something I noticed... as cli now spamming with pos update debug..

@douglascamata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VeNoMouS remove the colored logger for now. It's broken af.

Please sign in to comment.