mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 13:29:25 +08:00
add: delay force enabled task which has cased many errors
This commit is contained in:
35
alas.py
35
alas.py
@@ -963,6 +963,9 @@ class AzurLaneAutoScript(AzurLaneAutoScript):
|
||||
except KeyError:
|
||||
return task
|
||||
|
||||
def is_force_enabled_task(self, task):
|
||||
return task in ["Research", "Reward", "Commission"]
|
||||
|
||||
def loop(self):
|
||||
if self.is_azur:
|
||||
CrackResource(self.config, self.device).ensure()
|
||||
@@ -1035,16 +1038,28 @@ class AzurLaneAutoScript(AzurLaneAutoScript):
|
||||
|
||||
if self.is_enabled_disable_task:
|
||||
if not self.repeated_failed_task_counter.count_once():
|
||||
msg = "This task has caused many errors already, disable it"
|
||||
logger.warning(msg)
|
||||
self.config.disable_task(task)
|
||||
self.failed_task_counter.reset_task(task)
|
||||
self.repeated_failed_task_counter.reset()
|
||||
handle_notify(
|
||||
self.config.Error_OnePushConfig,
|
||||
title=f"Alas <{self.config_name}> disabled `{self.get_task_name(task)}`",
|
||||
content=msg,
|
||||
)
|
||||
if not self.is_force_enabled_task(task):
|
||||
msg = "This task has caused many errors already, disable it"
|
||||
logger.warning(msg)
|
||||
self.config.disable_task(task)
|
||||
self.failed_task_counter.reset_task(task)
|
||||
self.repeated_failed_task_counter.reset()
|
||||
handle_notify(
|
||||
self.config.Error_OnePushConfig,
|
||||
title=f"Alas <{self.config_name}> disabled `{self.get_task_name(task)}`",
|
||||
content=msg,
|
||||
)
|
||||
else:
|
||||
msg = "This task has caused many errors already, but it is force enabled, delay it"
|
||||
logger.warning(msg)
|
||||
self.config.task_delay(target=datetime.now() + timedelta(hours=6), task=task)
|
||||
self.failed_task_counter.reset_task(task)
|
||||
self.repeated_failed_task_counter.reset()
|
||||
handle_notify(
|
||||
self.config.Error_OnePushConfig,
|
||||
title=f"Alas <{self.config_name}> delay `{self.get_task_name(task)}`",
|
||||
content=msg,
|
||||
)
|
||||
else:
|
||||
exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user