Skip to content

Commit

Permalink
Fix: Handle empty mail list (#4011)
Browse files Browse the repository at this point in the history
  • Loading branch information
LmeSzinc committed Jul 19, 2024
1 parent 11e3580 commit 0fe1479
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion module/freebies/mail_white.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from module.base.decorator import cached_property
from module.base.timer import Timer
from module.combat.assets import GET_ITEMS_1, GET_ITEMS_2
from module.freebies.assets import *
from module.logger import logger
Expand Down Expand Up @@ -28,6 +29,9 @@ def mail_select_setting(self):

def _mail_enter(self, skip_first_screenshot=True):
"""
Returns:
int: If having mails
Page:
in: page_main_white or MAIL_MANAGE
out: MAIL_BATCH_CLAIM
Expand All @@ -36,6 +40,7 @@ def _mail_enter(self, skip_first_screenshot=True):
self.interval_clear([
MAIL_MANAGE
])
timeout = Timer(0.6, count=1)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
Expand All @@ -45,7 +50,12 @@ def _mail_enter(self, skip_first_screenshot=True):
# End
if self.appear(MAIL_BATCH_CLAIM, offset=(20, 20)):
logger.info('Mail entered')
break
return True
if self.appear(GOTO_MAIN_WHITE, offset=(20, 20)):
timeout.start()
if timeout.reached():
logger.info('Mail empty')
return False

# Click
if self.appear_then_click(MAIL_MANAGE, offset=(30, 30), interval=3):
Expand Down Expand Up @@ -186,6 +196,9 @@ def mail_claim(
in: page_main_white or MAIL_MANAGE
out: MAIL_BATCH_CLAIM
"""
if not self._mail_enter():
return

if merit:
logger.hr('Mail merit', level=2)
self._mail_enter()
Expand Down

0 comments on commit 0fe1479

Please sign in to comment.