Skip to content

Commit

Permalink
Dynamically update Plat8 message
Browse files Browse the repository at this point in the history
Mimic the client by initially sending an empty Plat8 request and then
using the returned string.
  • Loading branch information
Noctem committed Mar 1, 2017
1 parent 3271ae6 commit 066b0cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion aiopogo/rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from networking.envelopes.signal_log_pb2 import SignalLog
from networking.platform.requests.send_encrypted_signature_request_pb2 import SendEncryptedSignatureRequest
from networking.platform.requests.plat_eight_request_pb2 import PlatEightRequest
from networking.platform.responses.plat_eight_response_pb2 import PlatEightResponse

RPC_SESSIONS = SessionManager()

Expand Down Expand Up @@ -256,7 +257,8 @@ async def _build_main_request(self, subrequests, player_position=None):
try:
if request.requests[0].request_type in (RequestType.Value('GET_MAP_OBJECTS'), RequestType.Value('GET_PLAYER')):
plat_eight = PlatEightRequest()
plat_eight.field1 = '90f6a704505bccac73cec99b07794993e6fd5a12'
if self.state.message8:
plat_eight.field1 = self.state.message8
plat8 = request.platform_requests.add()
plat8.type = 8
plat8.request_message = plat_eight.SerializeToString()
Expand Down Expand Up @@ -358,6 +360,14 @@ def _parse_main_response(self, response_raw, subrequests):
response_proto_dict = protobuf_to_dict(response_proto)
response_proto_dict = self._parse_sub_responses(subrequests, response_proto_dict)

if not self.state.message8 and 'platform_returns' in response_proto_dict:
for plat_response in response_proto_dict['platform_returns']:
if plat_response['type'] == 8:
resp = PlatEightResponse()
resp.ParseFromString(plat_response['response'])
self.state.message8 = resp.message
break

if not response_proto_dict:
raise MalformedNianticResponseException('Could not convert protobuf to dict.')

Expand Down Expand Up @@ -419,6 +429,7 @@ def __init__(self):
self.rand = Rand()
self.session_hash = urandom(16)
self.course = random.uniform(0, 359.99)
self.message8 = None

def get_course(self):
self.course = random.triangular(0, 359.99, self.course)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
author = 'David Christenson',
author_email='mail@noctem.xyz',
description = 'Asynchronous Pokemon API lib',
version = '1.2',
version = '1.2.1',
url = 'https://github.com/Noctem/aiopogo',
packages = find_packages(),
install_requires = reqs,
Expand Down

0 comments on commit 066b0cd

Please sign in to comment.