From 0be19375278eb4c78c9298e8b4cc6498d0c692a7 Mon Sep 17 00:00:00 2001 From: EightyDollars Date: Sat, 18 Nov 2023 02:03:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E5=AF=B9163?= =?UTF-8?q?=EF=BC=8C126=E5=90=8E=E7=BC=80=E7=9A=84=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 13 ++++++++++++- ui/src/components/Email.vue | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 4da85f84b..582c0eb83 100755 --- a/server.py +++ b/server.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import datetime +import re import pandas as pd import requests @@ -417,15 +418,25 @@ def get_half_month_data(): logger.info("report.csv正在被占用") + @app.route("/test-email") @require_token def test_email(): + host_smtp = "" + if re.findall(r'^[\w]{1,19}@(qq).((com)|(cn))$', conf["account"], re.IGNORECASE): + host_smtp = "smtp.qq.com" + elif re.findall(r'^[\w]{1,19}@(163).((com)|(cn))$', conf["account"], re.IGNORECASE): + host_smtp = "smtp.163.com" + elif re.findall(r'^[\w]{1,19}@(126).((com)|(cn))$', conf["account"], re.IGNORECASE): + host_smtp = "smtp.126.com" + + print(host_smtp) msg = MIMEMultipart() msg.attach(MIMEText("arknights-mower测试邮件", "plain")) msg["Subject"] = conf["mail_subject"] + "测试邮件" msg["From"] = conf["account"] try: - s = smtplib.SMTP_SSL("smtp.qq.com", 465, timeout=10.0) + s = smtplib.SMTP_SSL(host_smtp, 465, timeout=10.0) s.login(conf["account"], conf["pass_code"]) s.sendmail(conf["account"], conf["account"], msg.as_string()) except Exception as e: diff --git a/ui/src/components/Email.vue b/ui/src/components/Email.vue index 1f01b163d..fd665379d 100644 --- a/ui/src/components/Email.vue +++ b/ui/src/components/Email.vue @@ -41,7 +41,7 @@ async function test_email() { label-width="96" label-align="left" > - + From c32a7083c5c065a400f03fc437d50a75b73e7ca1 Mon Sep 17 00:00:00 2001 From: EightyDollars Date: Sat, 18 Nov 2023 23:37:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9A=E6=AF=8F=E6=97=A5=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=BC=9A=E4=B8=8D=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/__main__.py | 25 +++++++------ arknights_mower/solvers/base_schedule.py | 46 +++++++++++++----------- arknights_mower/solvers/report.py | 5 +-- arknights_mower/solvers/skland.py | 7 +++- server.py | 11 +----- ui/src/components/Email.vue | 2 +- 6 files changed, 52 insertions(+), 44 deletions(-) diff --git a/arknights_mower/__main__.py b/arknights_mower/__main__.py index 33636375a..215c31fd0 100644 --- a/arknights_mower/__main__.py +++ b/arknights_mower/__main__.py @@ -28,7 +28,7 @@ def main(c, p, o={}, child_conn=None): from arknights_mower.utils.log import init_fhlr from arknights_mower.utils import config - + global plan global conf global operators @@ -351,18 +351,23 @@ def simulate(): if sleep_time > 540: # 刷新时间以鹰历为准 - if base_scheduler.daily_report: - base_scheduler.daily_report = base_scheduler.report_plan_solver() - # if base_scheduler.daily_skland and base_scheduler.skland_config['skland_enable']: - # base_scheduler.daily_report = base_scheduler.skland_plan_solover() - # base_scheduler.daily_skland=False - if base_scheduler.skland_config['skland_enable']: - base_scheduler.skland_plan_solover() - if base_scheduler.daily_mail: - base_scheduler.daily_report = base_scheduler.mail_plan_solver() + if base_scheduler.daily_report < (datetime.now() - timedelta(hours=4)).date(): + if base_scheduler.report_plan_solver(): + base_scheduler.daily_report = (datetime.now() - timedelta(hours=4)).date() + + if base_scheduler.skland_config['skland_enable'] and base_scheduler.daily_skland < ( + datetime.now() - timedelta(hours=4)).date(): + if base_scheduler.skland_plan_solover(): + base_scheduler.daily_skland = (datetime.now() - timedelta(hours=4)).date() + + if base_scheduler.check_mail_enable and base_scheduler.daily_mail < ( + datetime.now() - timedelta(hours=8)).date(): + if base_scheduler.mail_plan_solver(): + base_scheduler.daily_mail = (datetime.now() - timedelta(hours=8)).date() 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')}" diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index dc9fdd6fe..2e53a75da 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -46,7 +46,6 @@ stage_drop = {} - class BaseSchedulerSolver(BaseSolver, BaseMixin): """ 收集基建的产物:物资、赤金、信赖 @@ -78,14 +77,14 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None: self.recruit_config = {} self.skland_config = {} self.recruit_time = None - self.daily_mission = False - self.daily_report = False - self.daily_skland = True - self.daily_mail = False + + self.daily_report = (datetime.now() - timedelta(days=1, hours=4)).date() + self.daily_skland = (datetime.now() - timedelta(days=1, hours=4)).date() + self.daily_mail = (datetime.now() - timedelta(days=1, hours=8)).date() + self.check_mail_enable = True self.report_enable = True - @property def party_time(self): return self._party_time @@ -489,7 +488,8 @@ def infra_main(self): logger.info(f"记录本次无人机使用时间为:{datetime.now()}") self.drone_time = datetime.now() if self.reload_room is not None and ( - self.reload_time is None or self.reload_time < datetime.now() - timedelta(hours=self.maa_config['maa_execution_gap'])): + self.reload_time is None or self.reload_time < datetime.now() - timedelta( + hours=self.maa_config['maa_execution_gap'])): self.reload() logger.info(f"记录本次补货时间为:{datetime.now()}") self.todo_task = True @@ -503,7 +503,8 @@ def infra_main(self): self.collect_notification = True else: return self.handle_error() - def translate_room(self,room): + + def translate_room(self, room): if "room" in room: parts = room.split("_") return f"B{parts[1]}0{parts[2]}" @@ -516,6 +517,7 @@ def translate_room(self,room): return "控制中枢" else: return "会客室" + def agent_get_mood(self, skip_dorm=False, force=False): # 暂时规定纠错只适用于主班表 need_read = set( @@ -528,7 +530,7 @@ def agent_get_mood(self, skip_dorm=False, force=False): _mood_data = self.get_agent_from_room(room) mood_info = [f"干员: {item['agent']}, 心情: {round(item['mood'], 3)}" for item in _mood_data] logger.info(f'房间 {self.translate_room(room)} {mood_info}') - #logger.info(f'房间 {room} 心情为:{_mood_data}') + # logger.info(f'房间 {room} 心情为:{_mood_data}') break except Exception as e: if error_count > 3: raise e @@ -735,7 +737,9 @@ def plan_solver(self): _time = result[op.current_index]['time'] - timedelta(minutes=10) elif op.current_mood() > 0.25 + op.lower_limit and op.depletion_rate != 0: _time = datetime.now() + timedelta( - hours=(op.current_mood() - op.lower_limit- 0.25) / op.depletion_rate) - timedelta(minutes=10) + hours=( + op.current_mood() - op.lower_limit - 0.25) / op.depletion_rate) - timedelta( + minutes=10) self.back() # plan 是空的是因为得动态生成 exhaust_type = op.name @@ -1107,7 +1111,8 @@ def clue(self) -> None: # 如果启用 MAA,则在线索交流结束后购物 if self.maa_config['maa_enable'] and self.party_time is not None: if find_next_task(self.tasks, task_type=TaskTypes.MAA_MALL) is None: - self.tasks.append(SchedulerTask(time=self.party_time - timedelta(milliseconds=1), task_type=TaskTypes.CLUE_PARTY)) + self.tasks.append( + SchedulerTask(time=self.party_time - timedelta(milliseconds=1), task_type=TaskTypes.CLUE_PARTY)) self.tasks.append(SchedulerTask(time=self.party_time, task_type=TaskTypes.MAA_MALL)) self.back(interval=2) @@ -1360,7 +1365,6 @@ def drone(self, room: str, not_customize=False, not_return=False, adjust_time=Fa self.back(interval=2, rebuild=False) self.back(interval=2) - # 用于制造站切换产物,请注意在调用该函数前有足够的无人机,并补足相应制造站产物,目前仅支持中级作战记录与赤金之间的切换 # def 制造站切换产物(self, room: str, 目标产物: str, not_customize=False, not_return=False): # # 点击进入该房间 @@ -1466,7 +1470,6 @@ def drone(self, room: str, not_customize=False, not_return=False, adjust_time=Fa # self.tap((self.recog.w * 3 // 4, self.recog.h * 5 // 6), interval=1) # 确认数量 # self.tap((self.recog.w * 3 // 4, self.recog.h * 7 // 10), interval=1) # 确认更改 - def get_arrange_order(self) -> ArrangeOrder: best_score, best_order = 0, None for order in ArrangeOrder: @@ -1758,11 +1761,12 @@ def get_order_remaining_time(self): def current_room_changed(self, instance): logger.info(f"{instance.name} 房间变动") - ref_rooms = instance.refresh_order_room[1] if instance.refresh_order_room[1] else list(self.op_data.run_order_rooms.keys()) + ref_rooms = instance.refresh_order_room[1] if instance.refresh_order_room[1] else list( + self.op_data.run_order_rooms.keys()) for ref_room in ref_rooms: self.refresh_run_order_time(ref_room) - def refresh_run_order_time(self,room): + def refresh_run_order_time(self, room): logger.debug("检测到插拔房间人员变动!") run_order_task = find_next_task(self.tasks, datetime.now() + timedelta(minutes=15), task_type=TaskTypes.RUN_ORDER, @@ -2109,12 +2113,14 @@ def append_maa_task(self, type): "force_shopping_if_credit_full": self.maa_config['mall_ignore_when_full'] }) elif type == 'Depot': - self.MAA.append_task('Depot',{ + self.MAA.append_task('Depot', { "enable": self.maa_config['maa_depot_enable'] - }) + }) + 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[ + 'last_execution'] is not None and datetime.now() - timedelta( seconds=self.maa_config['maa_execution_gap'] * 3600) < self.maa_config['last_execution']: logger.info("间隔未超过设定时间,不启动maa") else: @@ -2278,11 +2284,11 @@ def maa_plan_solver(self, tasks='All', one_time=False): def skland_plan_solover(self): return SKLand(self.skland_config['skland_info']).start() - def recruit_plan_solver(self): if ('last_execution' not in self.recruit_config or self.recruit_config['last_execution'] is None - or self.recruit_config['last_execution'] <= (datetime.now() - timedelta(seconds=self.recruit_config['recruit_execution_gap'] * 3600))): + or self.recruit_config['last_execution'] <= ( + datetime.now() - timedelta(seconds=self.recruit_config['recruit_execution_gap'] * 3600))): recruit([], self.send_message_config, self.recruit_config) self.recruit_config['last_execution'] = datetime.now() logger.info("下一次公开招募执行时间在{}小时之后".format(self.recruit_config['recruit_execution_gap'])) diff --git a/arknights_mower/solvers/report.py b/arknights_mower/solvers/report.py index 870324595..550412db1 100644 --- a/arknights_mower/solvers/report.py +++ b/arknights_mower/solvers/report.py @@ -52,9 +52,10 @@ def run(self): logger.info("康康大基报") try: super().run() + return True except: - return False - return True + pass + return False def transition(self) -> bool: if self.scene() == Scene.INDEX: diff --git a/arknights_mower/solvers/skland.py b/arknights_mower/solvers/skland.py index d4366e433..18bf7487e 100644 --- a/arknights_mower/solvers/skland.py +++ b/arknights_mower/solvers/skland.py @@ -65,12 +65,14 @@ def __init__(self, skland_info): 'vName': '' } self.sign_token = '' + self.all_recorded = True def start(self): for item in self.account_list: if item['isCheck']: if self.has_record(item['account']): continue + self.all_recorded = False self.save_param(self.get_cred_by_token(self.log(item))) for i in self.get_binding_list(): body = { @@ -103,6 +105,8 @@ def start(self): f'{i.get("nickName")}获得了{res["name"]}×{j.get("count") or 1}') if len(self.reward) > 0: return self.record_log() + if self.all_recorded: + return True return False def save_param(self, cred_resp): @@ -197,10 +201,11 @@ def record_log(self): for item in self.reward: res_df = pd.DataFrame(item, index=[date_str]) res_df.to_csv(self.record_path, mode='a', header=False, encoding='gbk') - return True except: pass + return True + def has_record(self, phone: str): try: if os.path.exists(self.record_path) is False: diff --git a/server.py b/server.py index 8e8c3734c..292a96501 100755 --- a/server.py +++ b/server.py @@ -439,21 +439,12 @@ def get_half_month_data(): @app.route("/test-email") @require_token def test_email(): - host_smtp = "" - if re.findall(r'^[\w]{1,19}@(qq).((com)|(cn))$', conf["account"], re.IGNORECASE): - host_smtp = "smtp.qq.com" - elif re.findall(r'^[\w]{1,19}@(163).((com)|(cn))$', conf["account"], re.IGNORECASE): - host_smtp = "smtp.163.com" - elif re.findall(r'^[\w]{1,19}@(126).((com)|(cn))$', conf["account"], re.IGNORECASE): - host_smtp = "smtp.126.com" - - print(host_smtp) msg = MIMEMultipart() msg.attach(MIMEText("arknights-mower测试邮件", "plain")) msg["Subject"] = conf["mail_subject"] + "测试邮件" msg["From"] = conf["account"] try: - s = smtplib.SMTP_SSL(host_smtp, 465, timeout=10.0) + s = smtplib.SMTP_SSL("smtp.qq.com", 465, timeout=10.0) s.login(conf["account"], conf["pass_code"]) s.sendmail(conf["account"], conf["account"], msg.as_string()) except Exception as e: diff --git a/ui/src/components/Email.vue b/ui/src/components/Email.vue index fd665379d..1f01b163d 100644 --- a/ui/src/components/Email.vue +++ b/ui/src/components/Email.vue @@ -41,7 +41,7 @@ async function test_email() { label-width="96" label-align="left" > - +