Skip to content

Commit

Permalink
refactor:调整公招等任务调用的时机
Browse files Browse the repository at this point in the history
  • Loading branch information
EightyDollars committed Nov 4, 2023
1 parent 863964a commit 290b717
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 37 deletions.
36 changes: 22 additions & 14 deletions arknights_mower/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,20 +337,28 @@ def simulate():
set_recruit_options(base_scheduler, new_conf)
set_skland_options(base_scheduler, new_conf)

if sleep_time > 540 and base_scheduler.maa_config["maa_enable"] == 1:
subject = (
f"下次任务在{base_scheduler.tasks[0].time.strftime('%H:%M:%S')}"
)
context = f"下一次任务:{base_scheduler.tasks[0].plan}"
logger.info(context)
logger.info(subject)
body = task_template.render(
tasks=[
obj.format(timezone_offset) for obj in base_scheduler.tasks
]
)
base_scheduler.send_message(body, subject, "html")
base_scheduler.maa_plan_solver()
if sleep_time > 540:
if base_scheduler.daily_mission is False:
base_scheduler.daily_mission = base_scheduler.read_report()
base_scheduler.mail_plan_solver()
if base_scheduler.skland_config["skland_enable"] == 1:
base_scheduler.skland_plan_solover()
if base_scheduler.recruit_config['recruit_enable'] == 1:
base_scheduler.recruit_plan_solver()
if base_scheduler.maa_config["maa_enable"] == 1:
subject = (
f"下次任务在{base_scheduler.tasks[0].time.strftime('%H:%M:%S')}"
)
context = f"下一次任务:{base_scheduler.tasks[0].plan}"
logger.info(context)
logger.info(subject)
body = task_template.render(
tasks=[
obj.format(timezone_offset) for obj in base_scheduler.tasks
]
)
base_scheduler.send_message(body, subject, "html")
base_scheduler.maa_plan_solver()
elif sleep_time > 0:
subject = f"休息 {format_time(remaining_time)},到{base_scheduler.tasks[0].time.strftime('%H:%M:%S')}开始工作"
context = f"下一次任务:{base_scheduler.tasks[0].plan}"
Expand Down
2 changes: 1 addition & 1 deletion arknights_mower/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def recruit(args: list[str] = [], send_message_config={}, recruit_config={}, dev


def daily_report(device: Device = None):
ReportSolver(device).run()
return ReportSolver(device).run()


def mission(args: list[str] = [], device: Device = None):
Expand Down
34 changes: 15 additions & 19 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from email.mime.multipart import MIMEMultipart

from .skland import SKLand
from ..command import recruit, daily_report
from ..command import recruit, daily_report, mail
from ..data import agent_list, base_room_list, ocr_error
from ..utils import character_recognize, detector, segment
from ..utils.digit_reader import DigitReader
Expand Down Expand Up @@ -92,9 +92,10 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None:
self.refresh_connecting = False
self.recruit_config = {}
self.skland_config = {}
self.sk_time = None

self.recruit_time = None

self.daily_mission = False
def run(self) -> None:
"""
:param clue_collect: bool, 是否收取线索
Expand Down Expand Up @@ -2288,30 +2289,16 @@ def append_maa_task(self, type):
})
def maa_plan_solver(self, tasks='All', one_time=False):
try:
if not one_time and 'last_execution' in self.maa_config and self.maa_config['last_execution'] is not None and datetime.now() - timedelta(
if not one_time and 'last_execution' in self.maa_config and self.maa_config[
seconds=self.maa_config['maa_execution_gap'] * 3600) < self.maa_config['last_execution']:
logger.info("间隔未超过设定时间,不启动maa")
else:
daily_report()

"""森空岛签到"""
try:
if self.skland_config['skland_enable']:
skland = SKLand(self.skland_config['skland_info'])
skland.attendance()
except RuntimeError as e:
logger.info("森空岛签到失败:{}".format(e.__str__()))

"""测试公招用"""
if self.recruit_config['recruit_enable']:
recruit([], self.send_message_config, self.recruit_config)

self.send_message('启动MAA')
self.back_to_index()
# 任务及参数请参考 docs/集成文档.md
self.initialize_maa()
if tasks == 'All':
tasks = ['StartUp','Fight', 'Visit', 'Mall', 'Award','Depot']
tasks = ['StartUp', 'Fight', 'Visit', 'Mall', 'Award', 'Depot']
# tasks = ['StartUp', 'Fight', 'Recruit', 'Visit', 'Mall', 'Award']
for maa_task in tasks:
if maa_task == 'Recruit':
Expand Down Expand Up @@ -2466,4 +2453,13 @@ def maa_plan_solver(self, tasks='All', one_time=False):
def skland_plan_solover(self):
skland = SKLand(self.skland_config['skland_info'])
skland.attendance()
del self.tasks[0]

def recruit_plan_solver(self):
recruit([], self.send_message_config, self.recruit_config)

def read_report(self):
return daily_report()

def mail_plan_solver(self):
mail([])

11 changes: 8 additions & 3 deletions arknights_mower/solvers/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None:
'riic_orundum_order': "贸易站合成玉订单",
}

def run(self) -> None:

def run(self) -> bool:
if self.is_today_recorded():
return
return True
try:
super().run()
return self.record_report()
except TypeError:
logger.error("基报识别失败 润!")
except PermissionError:
logger.error("基报记录访问失败")
return False

def is_today_recorded(self) -> bool:
if os.path.exists(self.record_path) is not True:
Expand Down Expand Up @@ -150,7 +153,7 @@ def read_report(self):
self.report_res[item] = res

self.report_res['riic_iron_number'] = int(int(self.report_res['riic_iron']) / 500)
self.record_report()


def record_report(self):
logger.debug(f"存入数据{self.report_res}")
Expand All @@ -164,3 +167,5 @@ def record_report(self):
csv_writer.writerow(self.riic_key_str)
csv_writer.writerow(self.report_res)
file.close()
logger.info("{}的基报记录完成".format(self.report_res['riic_date']))
return True

0 comments on commit 290b717

Please sign in to comment.