Skip to content

Commit

Permalink
utilize inventory instead of api (#5101)
Browse files Browse the repository at this point in the history
  • Loading branch information
rawgni authored and solderzzc committed Sep 2, 2016
1 parent 45e8703 commit 722fe3b
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions pokemongo_bot/websocket_remote_control.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import threading
import logging
from socketIO_client import SocketIO, BaseNamespace

from pokemongo_bot import inventory

class WebsocketRemoteControl(object):

Expand All @@ -15,6 +16,7 @@ def __init__(self, bot):
self.on_remote_command
)
self.thread = threading.Thread(target=self.process_messages)
self.logger = logging.getLogger(type(self).__name__)

def start(self):
self.thread.start()
Expand Down Expand Up @@ -42,17 +44,14 @@ def on_remote_command(self, command):
command_handler()

def get_player_info(self):
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': {'inventory': inventory, 'player': player_info},
'command': 'get_player_info',
'account': self.bot.config.username
}
)
try:
self.sio.emit(
'bot:send_reply',
{
'result': {'inventory': inventory.jsonify_inventory(), 'player': self.bot._player},
'command': 'get_player_info',
'account': self.bot.config.username
}
)
except Exception as e:
self.logger.error(e)

0 comments on commit 722fe3b

Please sign in to comment.