From 46ba46b36ec1fe9399bbd299c1476e58d9fdd2b9 Mon Sep 17 00:00:00 2001 From: EightyDollars Date: Mon, 18 Sep 2023 11:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=AC=E6=8B=9B=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=A3=AE=E7=A9=BA=E5=B2=9B=E7=AD=BE=E5=88=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/__main__.py | 25 +++++ arknights_mower/command.py | 6 +- arknights_mower/solvers/base_schedule.py | 11 ++- arknights_mower/solvers/skland.py | 84 +++++++++++------ ui/src/components/MaaRecruit.vue | 114 ----------------------- 5 files changed, 89 insertions(+), 151 deletions(-) delete mode 100644 ui/src/components/MaaRecruit.vue diff --git a/arknights_mower/__main__.py b/arknights_mower/__main__.py index 974d62aac..90396f4f3 100644 --- a/arknights_mower/__main__.py +++ b/arknights_mower/__main__.py @@ -105,6 +105,25 @@ def set_maa_options(base_scheduler): logger.debug(f"更新Maa设置:{base_scheduler.maa_config}") +def set_recruit_options(base_scheduler): + conf = update_conf() + global recruit_config + recruit_config['recruit_enable'] = conf['recruit_enable'] + recruit_config['recruit_only_4'] = conf['recruit_only_4'] + recruit_config['recruit_robot'] = conf['recruit_robot'] + recruit_config['recruitment_time'] = conf['recruitment_time'] + base_scheduler.recruit_config = recruit_config + + logger.debug(f"更新公招设置:{base_scheduler.recruit_config}") + +def set_skland_options(base_scheduler): + conf = update_conf() + global skland_config + skland_config['skland_enable'] = conf['skland_enable'] + skland_config['skland_info'] = conf['skland_info'] + base_scheduler.skland_config = skland_config + + logger.debug(f"更新森空岛设置:{base_scheduler.skland_config}") def initialize(tasks, scheduler=None): from arknights_mower.solvers.base_schedule import BaseSchedulerSolver @@ -148,6 +167,8 @@ def initialize(tasks, scheduler=None): } set_maa_options(base_scheduler) + set_recruit_options(base_scheduler) + set_skland_options(base_scheduler) base_scheduler.ADB_CONNECT = config.ADB_CONNECT[0] base_scheduler.error = False @@ -217,6 +238,8 @@ def simulate(): remaining_time = (base_scheduler.tasks[0].time - datetime.now()).total_seconds() set_maa_options(base_scheduler) + set_recruit_options(base_scheduler) + set_skland_options(base_scheduler) if sleep_time > 540 and base_scheduler.maa_config['maa_enable'] == 1: subject = f"下次任务在{base_scheduler.tasks[0].time.strftime('%H:%M:%S')}" @@ -292,6 +315,8 @@ def load_state(file='state.json'): agent_base_config = {} maa_config = {} +recruit_config = {} +skland_config = {} def __init_params__(): diff --git a/arknights_mower/command.py b/arknights_mower/command.py index 1c879cb9f..27fdbe847 100644 --- a/arknights_mower/command.py +++ b/arknights_mower/command.py @@ -84,7 +84,7 @@ def shop(args: list[str] = [], device: Device = None): ShopSolver(device).run(args) -def recruit(args: list[str] = [], email_config={}, maa_config={}, device: Device = None): +def recruit(args: list[str] = [], email_config={}, recruit_config={}, device: Device = None): """ recruit [agents ...] 自动进行公共招募 @@ -93,9 +93,9 @@ def recruit(args: list[str] = [], email_config={}, maa_config={}, device: Device choose = {} result = {} if len(args) == 0: - choose, result = RecruitSolver(device).run(config.RECRUIT_PRIORITY, email_config, maa_config) + choose, result = RecruitSolver(device).run(config.RECRUIT_PRIORITY, email_config, recruit_config) else: - choose, result = RecruitSolver(device).run(args, email_config) + choose, result = RecruitSolver(device).run(args, email_config,recruit_config) return choose, result diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 61ccdf6b9..3122be95e 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -90,6 +90,8 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None: self.credit_fight = None self.exit_game_when_idle = False self.refresh_connecting = False + self.recruit_config = {} + self.skland_config = {} def run(self) -> None: """ @@ -2195,12 +2197,13 @@ def maa_plan_solver(self, tasks='All', one_time=False): logger.info("间隔未超过设定时间,不启动maa") else: """森空岛签到""" - # skland = SKLand() - # skland.attendance() + if self.skland_config['skland_enable']: + skland = SKLand(self.skland_config['skland_info']) + skland.attendance() """测试公招用""" - if 'Recruit' in tasks or tasks == 'All': - recruit([], self.email_config, self.maa_config) + if self.recruit_config['recruit_enable']: + recruit([], self.email_config, self.recruit_config) self.send_email('启动MAA') self.back_to_index() diff --git a/arknights_mower/solvers/skland.py b/arknights_mower/solvers/skland.py index 7795543b0..a3185c175 100644 --- a/arknights_mower/solvers/skland.py +++ b/arknights_mower/solvers/skland.py @@ -7,24 +7,27 @@ class SKLand: - def __init__(self): - self.account = [ - { - "name": "风味手扒鸡#5916", - "phone": "", - "password": "", - "uid": "", - "cred": "" - } - ] - + def __init__(self, skland_info): + self.account = [] + for item in skland_info: + if item["isCheck"] is False: + continue + if item['account'] != "" and item['password'] != "": + self.account.append({ + "name": "", + "phone": item['account'], + "password": item['password'], + "uid": "", + "cred": "" + }) self.url = { "get_cred": "https://zonai.skland.com/api/v1/user/auth/generate_cred_by_code", "token_by_phone_password": "https://as.hypergryph.com/user/auth/v1/token_by_phone_password", "check_cred_url": "https://zonai.skland.com/api/v1/user/check", "OAuth2": "https://as.hypergryph.com/user/oauth2/v2/grant", "get_cred_url": "https://zonai.skland.com/api/v1/user/auth/generate_cred_by_code", - "attendance": "https://zonai.skland.com/api/v1/game/attendance" + "attendance": "https://zonai.skland.com/api/v1/game/attendance", + "get_binding_player": "https://zonai.skland.com/api/v1/game/player/binding" } self.request_header = { @@ -62,14 +65,32 @@ def check_cred(self, account): if response_json.get("code") == 0: logger.debug("验证cred未过期") - return True + logger.debug("验证cred过期") - return False + + def get_binding_player(self, account): + if account['cred'] == "": + logger.error("获取绑定信息失败") + raise "获取绑定信息失败" + headers = self.request_header + headers["cred"] = account['cred'] + + response = requests.get(headers=headers, url=self.url.get("get_binding_player")) + response_json = self.respone_to_json(response) + + if response_json.get("code") == 0: + logger.info("获取玩家信息成功") + player_info = response_json.get('data').get('list')[0].get('bindingList')[0] + account['name'] = player_info.get('nickName') + account['uid'] = player_info.get('uid') + + logger.debug("获取玩家信息失败") def get_OAuth2_token(self, account): token = self.sign_by_phone(account) if token == "": - raise "登陆失败" + logger.error("token获取失败") + raise "token获取失败" data = { "token": token, @@ -97,18 +118,19 @@ def get_cred(self, account): response_json = self.respone_to_json(response) if response_json.get("code") == 0: - return response_json.get("data").get("cred") - - return "" + account['cred'] = response_json.get("data").get("cred") def attendance(self): for account in self.account: - if self.get_record(account['name']): - logger.info(f"{account['name']} 今日已经签到过了") + if self.get_record(account['phone']): + logger.info(f"{account['phone']} 今日已经签到过了") continue if self.check_cred(account) is False: - account['cred'] = self.get_cred(account) + self.get_cred(account) + + self.get_binding_player(account) + logger.info(account) data = { "uid": account["uid"], "gameId": 1 @@ -127,28 +149,30 @@ def attendance(self): elif response_json["code"] == 10001 and response_json["message"] == "请勿重复签到!": logger.info(f"{account['name']} 请勿重复签到!") award.append("请勿重复签到!") - self.get_award[account['name']] = award - self.record_attendance(account['name'], self.get_award[account['name']]) - + self.get_award[account['phone']] = award + self.record_attendance(account['phone'], self.get_award[account['phone']]) + if self.get_award: + logger.info(self.get_award) return self.get_award - def record_attendance(self, name, data): + def record_attendance(self, account, data): - data_row = [name, data, datetime.date.today()] + data_row = [account, data, datetime.date.today()] with open(self.record_path, 'a+') as f: csv_write = csv.writer(f) csv_write.writerow(data_row) - def get_record(self, name): + def get_record(self, account): + try: with open(self.record_path, 'r+') as f: csv_reader = csv.reader(f) for line in csv_reader: - if line[0] == name: - return True + if line: + if line[0] == account and line[2] == str(datetime.date.today()): + return True except: with open(self.record_path, 'a+') as f: return False return False - diff --git a/ui/src/components/MaaRecruit.vue b/ui/src/components/MaaRecruit.vue deleted file mode 100644 index 2521297d8..000000000 --- a/ui/src/components/MaaRecruit.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - - -