Skip to content

Commit

Permalink
修改公招以及森空岛签到逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
EightyDollars committed Sep 18, 2023
1 parent 2cd173a commit 46ba46b
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 151 deletions.
25 changes: 25 additions & 0 deletions arknights_mower/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')}"
Expand Down Expand Up @@ -292,6 +315,8 @@ def load_state(file='state.json'):

agent_base_config = {}
maa_config = {}
recruit_config = {}
skland_config = {}


def __init_params__():
Expand Down
6 changes: 3 additions & 3 deletions arknights_mower/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...]
自动进行公共招募
Expand All @@ -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

Expand Down
11 changes: 7 additions & 4 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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()
Expand Down
84 changes: 54 additions & 30 deletions arknights_mower/solvers/skland.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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

114 changes: 0 additions & 114 deletions ui/src/components/MaaRecruit.vue

This file was deleted.

0 comments on commit 46ba46b

Please sign in to comment.