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

Revert "add event messaging on badge update and application delay" #4734

Merged
merged 1 commit into from
Aug 25, 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
55 changes: 2 additions & 53 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from tree_config_builder import ConfigException, MismatchTaskApiVersion, TreeConfigBuilder
from inventory import init_inventory
from sys import platform as _platform
from pgoapi.protos.POGOProtos.Enums import BadgeType_pb2
import struct


Expand Down Expand Up @@ -74,7 +73,6 @@ def __init__(self, config):
open(os.path.join(_base_dir, 'data', 'pokemon.json'))
)
self.item_list = json.load(open(os.path.join(_base_dir, 'data', 'items.json')))
# @var Metrics
self.metrics = Metrics(self)
self.latest_inventory = None
self.cell = None
Expand Down Expand Up @@ -139,7 +137,6 @@ def _setup_event_system(self):
if self.config.websocket_remote_control:
remote_control = WebsocketRemoteControl(self).start()

# @var EventManager
self.event_manager = EventManager(*handlers)
self._register_events()
if self.config.show_events:
Expand Down Expand Up @@ -579,15 +576,6 @@ def _register_events(self):
self.event_manager.register_event('pokestop_log')
self.event_manager.register_event('softban_log')

self.event_manager.register_event(
'badges',
parameters=('badge', 'level')
)
self.event_manager.register_event(
'player_data',
parameters=('player_data', )
)

def tick(self):
self.health_record.heartbeat()
self.cell = self.get_meta_cell()
Expand Down Expand Up @@ -848,7 +836,7 @@ def get_encryption_lib(self):
return full_path

def _setup_api(self):
# instantiate pgoapi @var ApiWrapper
# instantiate pgoapi
self.api = ApiWrapper(config=self.config)

# provide player position on the earth
Expand Down Expand Up @@ -1160,46 +1148,7 @@ def heartbeat(self):
request = self.api.create_request()
request.get_player()
request.check_awarded_badges()
responses = request.call()

if responses['responses']['GET_PLAYER']['success'] == True:
#we get the player_data anyway, might as well store it
self._player = responses['responses']['GET_PLAYER']['player_data']
self.event_manager.emit(
'player_data',
sender=self,
level='debug',
formatted='equipped_badges: {player_data}',
data={'player_data': self._player}
)
if responses['responses']['CHECK_AWARDED_BADGES']['success'] == True:
#store awarded_badges reponse to be used in a task or part of heartbeat
self._awarded_badges = responses['responses']['CHECK_AWARDED_BADGES']

if self._awarded_badges.has_key('awarded_badges'):
#todo: pull out the enum name and put into message
self.event_manager.emit(
'badges',
sender=self,
level='info',
formatted='awarded badge: {badge}, lvl {level}',
data={'badge': BadgeType_pb2._BADGETYPE.values_by_number[self._awarded_badges['awarded_badges']].name,
'level' : self._awarded_badges['awarded_badge_levels']}
)

#should work but gives errors :'(
#response = self.api.equip_badge(badge_type=self._awarded_badges['awarded_badges'])
response = {'responses' :"awaiting further testing on api call to equip_badge"}
self.event_manager.emit(
'badges',
sender=self,
level='info',
formatted='equiped badge: {badges}',
data={'badges': response['responses']}
)
human_behaviour.action_delay(3,10)


request.call()
try:
self.web_update_queue.put_nowait(True) # do this outside of thread every tick
except Queue.Full:
Expand Down