1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 09:09:26 +08:00

add: migrate detect others' login

This commit is contained in:
0O0o0oOoO00
2025-09-16 23:13:11 +08:00
parent 19a843b1f0
commit 87f392cabc
17 changed files with 199 additions and 1 deletions

37
alas.py
View File

@@ -591,6 +591,7 @@ from module.scheduler_watcher import *
from datetime import datetime, timedelta
from module.counter import MaxCounter
from typing import Dict
from module.device.my_assets import my_OTHERS_LOGIN_CONFIRM
class FailedTaskCounter:
@@ -745,6 +746,40 @@ class AzurLaneAutoScript(AzurLaneAutoScript):
)
exit(1)
def delay_all_tasks(self):
target = datetime.now() + timedelta(minutes=self.config.others_login.interval)
self.config.task_delay(target=target, task=self.config.task.command)
for i in self.config.pending_task:
self.config.task_delay(target=target, task=i.command)
for i in self.config.waiting_task:
if i.next_run < target:
self.config.task_delay(target=target, task=i.command)
def handle_OthersLogin(self, e) -> bool:
logger.warning("Detected others' login")
self.delay_all_tasks()
method = self.config.Optimization_WhenTaskQueueEmpty
if method == "goto_main":
self.config.Optimization_WhenTaskQueueEmpty = "stay_there"
logger.warning("You should never goto main when you need to delay tasks as others login, change to stay there instead.")
self.device.click(my_OTHERS_LOGIN_CONFIRM)
if method == "stay_there":
self.device.click(my_OTHERS_LOGIN_CONFIRM)
if self.config.others_login.need_notify:
handle_notify(
self.config.Error_OnePushConfig,
title=f"Alas <{self.config_name}>: account's owner logs in",
content=f"Delay some tasks to {datetime.now() + timedelta(minutes=self.config.others_login.interval, seconds=-1)}",
)
self.config.save()
self.config.update()
return True
def run(self, command, skip_first_screenshot=False):
try:
if not skip_first_screenshot:
@@ -767,6 +802,8 @@ class AzurLaneAutoScript(AzurLaneAutoScript):
return self.handle_ScriptError(e)
except RequestHumanTakeover as e:
return self.handle_RequestHumanTakeover(e)
except OthersLogin as e:
return self.handle_OthersLogin(e)
except Exception as e:
return self.handle_Exception(e)