From 01e551036eba5b899b1ec02b01faa34600ad43fb Mon Sep 17 00:00:00 2001 From: POLAR me Date: Mon, 6 Jan 2025 03:32:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(alas):=20=E8=B0=83=E6=95=B4=20GameStuckErro?= =?UTF-8?q?r=20=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在修改心情报错后,影响了原先的战败报错 --- alas.py | 68 ++++++++++++++++++++++++---------- module/handler/info_handler.py | 1 + 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/alas.py b/alas.py index c5741c27a..5fc6798c2 100644 --- a/alas.py +++ b/alas.py @@ -93,17 +93,41 @@ class AzurLaneAutoScript: logger.warning(e) self.config.task_call('Restart') return True + except (GameStuckError, GameTooManyClickError) as e: logger.error(e) self.save_error_log() - logger.warning(f'Game stuck, {self.device.package} will be restarted in 10 seconds') - logger.warning('If you are playing by hand, please stop Alas') from module.handler.info_handler import InfoHandler info_handler = InfoHandler(config=self.config,device=self.device) - info_handler.handle_urgent_commission() - self.config.task_call('Restart') - self.device.sleep(10) - return False + if info_handler.handle_urgent_commission(): + logger.warning("======OtherLogin_Sleep Over,now restart======") + self.config.task_call('Restart') + self.device.sleep(10) + return False + logger.warning(f'Game stuck, {self.device.package} will be restarted in 10 seconds') + logger.warning('If you are playing by hand, please stop Alas') + + if self.AutoRestart_Enabled and self.GameRestartBecauseErrorTimes < self.AutoRestart_AttemptsToRestart: + if self.AutoRestart_NotifyWhenAutoRestart: + handle_notify( + self.config.Error_OnePushConfig, + title=f"Alas <{self.config_name}> auto restarted", + content=f"Command \"{command}\" failed because GameStuckError/GameTooManyClickError, but alas auto restarted", + ) + self.config.task_call('Restart') + self.GameRestartBecauseErrorTimes += 1 + logger.critical(f'left Restart Time: {self.AutoRestart_AttemptsToRestart-self.GameRestartBecauseErrorTimes}') + self.device.sleep(10) + return False + else: + self.GameRestartBecauseErrorTimes = 0 + handle_notify( + self.config.Error_OnePushConfig, + title=f"Alas <{self.config_name}> crashed", + content=f"<{self.config_name}> GameStuckError/GameTooManyClickError", + ) + exit(1) + except GameBugError as e: logger.warning(e) self.save_error_log() @@ -112,11 +136,14 @@ class AzurLaneAutoScript: self.config.task_call('Restart') self.device.sleep(10) return False + except GamePageUnknownError: logger.info('Game server may be under maintenance or network may be broken, check server status now') self.checker.check_now() if self.checker.is_available(): - if self.AutoRestart_Enabled and self.GameRestartBecauseErrorTimes <= self.AutoRestart_AttemptsToRestart: + logger.critical('Game page unknown') + self.save_error_log() + if self.AutoRestart_Enabled and self.GameRestartBecauseErrorTimes < self.AutoRestart_AttemptsToRestart: if self.AutoRestart_NotifyWhenAutoRestart: handle_notify( self.config.Error_OnePushConfig, @@ -131,21 +158,21 @@ class AzurLaneAutoScript: return False else: self.GameRestartBecauseErrorTimes = 0 - logger.critical('Game page unknown') - self.save_error_log() handle_notify( self.config.Error_OnePushConfig, title=f"Alas <{self.config_name}> crashed", content=f"<{self.config_name}> GamePageUnknownError", ) - logger.info('Restart to reset Game page in 10 seconds') - self.device.sleep(10) - from module.handler.login import LoginHandler - LoginHandler(self.config, self.device).app_restart() - return False + exit(1) + # logger.info('Restart to reset Game page in 10 seconds') + # self.device.sleep(10) + # from module.handler.login import LoginHandler + # LoginHandler(self.config, self.device).app_restart() + else: self.checker.wait_until_available() return False + except ScriptError as e: logger.exception(e) logger.critical('This is likely to be a mistake of developers, but sometimes just random issues') @@ -155,8 +182,10 @@ class AzurLaneAutoScript: content=f"<{self.config_name}> ScriptError", ) exit(1) + except RequestHumanTakeover: - if self.AutoRestart_Enabled and self.GameRestartBecauseErrorTimes <= self.AutoRestart_AttemptsToRestart: + logger.critical('Request human takeover') + if self.AutoRestart_Enabled and self.GameRestartBecauseErrorTimes < self.AutoRestart_AttemptsToRestart: if self.AutoRestart_NotifyWhenAutoRestart: handle_notify( self.config.Error_OnePushConfig, @@ -170,7 +199,6 @@ class AzurLaneAutoScript: return False else: self.GameRestartBecauseErrorTimes = 0 - logger.critical('Request human takeover') handle_notify( self.config.Error_OnePushConfig, title=f"Alas <{self.config_name}> crashed", @@ -179,7 +207,10 @@ class AzurLaneAutoScript: exit(1) except MapWalkError as e: - if self.AutoRestart_Enabled and self.GameRestartBecauseErrorTimes <= self.AutoRestart_AttemptsToRestart: + logger.critical('MapWalkError') + logger.exception(e) + self.save_error_log() + if self.AutoRestart_Enabled and self.GameRestartBecauseErrorTimes < self.AutoRestart_AttemptsToRestart: if self.AutoRestart_NotifyWhenAutoRestart: handle_notify( self.config.Error_OnePushConfig, @@ -193,9 +224,6 @@ class AzurLaneAutoScript: return False else: self.GameRestartBecauseErrorTimes = 0 - logger.critical('MapWalkError') - logger.exception(e) - self.save_error_log() handle_notify( self.config.Error_OnePushConfig, title=f"Alas <{self.config_name}> crashed", diff --git a/module/handler/info_handler.py b/module/handler/info_handler.py index 34815168d..71af6ae88 100644 --- a/module/handler/info_handler.py +++ b/module/handler/info_handler.py @@ -178,6 +178,7 @@ class InfoHandler(ModuleBase): release_resources() self.device.release_during_wait() self.device.sleep(60*40) + return True # Check game client existence after 3s to 6s # Hot fixes will kill AL if you clicked the confirm button