Skip to content

Commit

Permalink
Fix AFK/DND
Browse files Browse the repository at this point in the history
  • Loading branch information
xKynn committed Sep 18, 2019
1 parent bf23258 commit aeb8767
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions poeRPC.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, loop, account_name, cookies, logger):
self.afk = False
self.dnd = False
self.afk_message = ""
self.dnd_message = ""
self.account_name = account_name
self.current_rpc = {}
self.locations = {}
Expand Down Expand Up @@ -247,11 +248,11 @@ async def handle_log_event(self, log):
elif "DND mode is now" in message:
if message.split("DND mode is now O")[1][0] == "N":
self.dnd = True
self.afk_message = message.split('Autoreply "')[1][:-1]
self.dnd_message = message.split('Autoreply "')[1][:-1]
self.logger.info(f"DND: {self.afk_message}")
else:
self.dnd = False
self.afk_message = ""
self.dnd_message = ""
self.logger.info("DND: Turned Off")
self.last_latest_message = log.split('\n')[-1] or log.split('\n')[-2]
if event != LogEvents.LOGOUT:
Expand All @@ -262,11 +263,24 @@ async def handle_log_event(self, log):
self.current_rpc = {}
self.update_rpc('large_image', 'login_screen')
self.update_rpc('state', 'On Character Selection')
if self.afk or self.dnd:
if self.dnd:
self.update_rpc('details', f"DND: {self.afk_message}")
else:
self.update_rpc('details', f"AFK: {self.afk_message}")

def update_dnd():
self.update_rpc('details', f"DND: {self.dnd_message}")

def update_afk():
self.update_rpc('details', f"AFK: {self.afk_message}")

if not self.afk and "AFK" in self.current_rpc.get('details', '') \
or not self.dnd and "DND" in self.current_rpc.get('details', ''):
self.current_rpc.pop('details')

if self.dnd and self.afk and "AFK" not in self.current_rpc.get('details', ''):
update_afk()
elif self.afk and "AFK" not in self.current_rpc.get('details', ''):
update_afk()
elif self.dnd and "DND" not in self.current_rpc.get('details', ''):
update_dnd()

if ping:
state = self.current_rpc.get('state', '')
if not 'Ping' in state:
Expand Down

0 comments on commit aeb8767

Please sign in to comment.