2021-06-06 04:16:28 +00:00
|
|
|
|
import time
|
|
|
|
|
import tools
|
|
|
|
|
import config
|
|
|
|
|
import random
|
|
|
|
|
import setting
|
2021-06-13 02:33:38 +00:00
|
|
|
|
from request import http
|
2022-01-06 05:49:25 +00:00
|
|
|
|
from loghelper import log
|
2022-04-23 00:47:10 +00:00
|
|
|
|
from account import get_account_list
|
2021-06-06 04:16:28 +00:00
|
|
|
|
|
2021-10-25 14:53:34 +00:00
|
|
|
|
|
2022-01-30 03:58:31 +00:00
|
|
|
|
class Honkai3rd:
|
2021-06-06 04:16:28 +00:00
|
|
|
|
def __init__(self) -> None:
|
|
|
|
|
self.headers = {
|
2021-10-25 14:53:34 +00:00
|
|
|
|
'Accept': 'application/json, text/plain, */*',
|
2022-01-06 05:49:25 +00:00
|
|
|
|
'DS': tools.get_ds(web=True, web_old=True),
|
2021-10-25 14:53:34 +00:00
|
|
|
|
'Origin': 'https://webstatic.mihoyo.com',
|
|
|
|
|
'x-rpc-app_version': setting.mihoyobbs_Version_old,
|
2021-11-01 12:21:30 +00:00
|
|
|
|
'User-Agent': 'Mozilla/5.0 (Linux; Android 9; Unspecified Device) AppleWebKit/537.36 (KHTML, like Gecko) '
|
|
|
|
|
'Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 miHoYoBBS/2.3.0',
|
2021-10-25 14:53:34 +00:00
|
|
|
|
'x-rpc-client_type': setting.mihoyobbs_Client_type_web,
|
2021-11-01 12:21:30 +00:00
|
|
|
|
'Referer': f'https://webstatic.mihoyo.com/bh3/event/euthenia/index.html?bbs_presentation_style=fullscreen'
|
|
|
|
|
f'&bbs_game_role_required=bh3_cn&bbs_auth_required=t'
|
|
|
|
|
f'rue&act_id={setting.honkai3rd_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon',
|
2021-10-25 14:53:34 +00:00
|
|
|
|
'Accept-Encoding': 'gzip, deflate',
|
|
|
|
|
'Accept-Language': 'zh-CN,en-US;q=0.8',
|
|
|
|
|
'X-Requested-With': 'com.mihoyo.hyperion',
|
2022-04-26 07:49:55 +00:00
|
|
|
|
"Cookie": config.cookies,
|
2022-01-06 05:49:25 +00:00
|
|
|
|
'x-rpc-device_id': tools.get_device_id()
|
2021-10-25 14:53:34 +00:00
|
|
|
|
}
|
2022-04-23 00:47:10 +00:00
|
|
|
|
self.acc_List = get_account_list("bh3_cn", self.headers)
|
2022-01-30 03:58:31 +00:00
|
|
|
|
self.sign_day = 0
|
2021-06-06 04:16:28 +00:00
|
|
|
|
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 获取今天已经签到了的dict
|
2022-01-30 03:58:31 +00:00
|
|
|
|
def get_today_item(self, raw_data: list):
|
2021-11-01 12:21:30 +00:00
|
|
|
|
# 用range进行循环,当status等于0的时候上一个就是今天签到的dict
|
2021-06-06 04:16:28 +00:00
|
|
|
|
for i in range(len(raw_data)):
|
2021-06-06 13:19:28 +00:00
|
|
|
|
if raw_data[i]["status"] == 0:
|
2022-01-30 03:58:31 +00:00
|
|
|
|
self.sign_day = i - 1
|
2021-10-25 14:53:34 +00:00
|
|
|
|
return raw_data[i - 1]
|
2022-01-30 03:58:31 +00:00
|
|
|
|
self.sign_day = i
|
2021-06-06 13:19:28 +00:00
|
|
|
|
if raw_data[i]["status"] == 1:
|
|
|
|
|
return raw_data[i]
|
|
|
|
|
if i == int(len(raw_data) - 1) and raw_data[i]["status"] != 0:
|
|
|
|
|
return raw_data[i]
|
2021-06-06 04:16:28 +00:00
|
|
|
|
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 签到
|
2022-01-30 03:58:31 +00:00
|
|
|
|
def sign_account(self):
|
2022-04-23 00:47:10 +00:00
|
|
|
|
return_data = "崩坏3: "
|
2022-02-01 16:59:27 +00:00
|
|
|
|
if len(self.acc_List) == 0:
|
|
|
|
|
log.warning("账号没有绑定任何崩坏3账号!")
|
|
|
|
|
return_data += "\n并没有绑定任何崩坏3账号"
|
|
|
|
|
else:
|
2021-06-06 04:16:28 +00:00
|
|
|
|
for i in self.acc_List:
|
2022-02-01 16:59:27 +00:00
|
|
|
|
log.info(f"正在为舰长 {i[0]} 进行签到...")
|
2022-04-23 00:47:10 +00:00
|
|
|
|
req = http.get(setting.honkai3rd_Is_signurl.format(setting.honkai3rd_Act_id, i[2], i[1]),
|
|
|
|
|
headers=self.headers)
|
2022-02-01 16:59:27 +00:00
|
|
|
|
data = req.json()
|
2022-02-02 05:43:54 +00:00
|
|
|
|
re_message = ""
|
2022-02-01 16:59:27 +00:00
|
|
|
|
if data["retcode"] != 0:
|
2022-02-02 05:43:54 +00:00
|
|
|
|
re_message = f"舰长 {i[0]} 获取账号签到信息失败!"
|
|
|
|
|
log.warning(re_message)
|
2022-02-01 16:59:27 +00:00
|
|
|
|
print(req.text)
|
|
|
|
|
continue
|
|
|
|
|
today_item = self.get_today_item(data["data"]["sign"]["list"])
|
|
|
|
|
# 判断是否已经签到
|
|
|
|
|
if today_item["status"] == 0:
|
2022-02-02 05:43:54 +00:00
|
|
|
|
re_message = f"舰长 {i[0]} 今天已经签到过了~\t已连续签到{self.sign_day}天\t今天获得的奖励是{tools.get_item(today_item)}"
|
|
|
|
|
log.info(re_message)
|
2022-02-01 16:59:27 +00:00
|
|
|
|
else:
|
2021-08-06 00:53:51 +00:00
|
|
|
|
time.sleep(random.randint(2, 8))
|
2021-08-03 02:35:55 +00:00
|
|
|
|
req = http.post(url=setting.honkai3rd_SignUrl, headers=self.headers,
|
2021-10-25 14:53:34 +00:00
|
|
|
|
json={'act_id': setting.honkai3rd_Act_id, 'region': i[2], 'uid': i[1]})
|
2021-06-06 04:16:28 +00:00
|
|
|
|
data = req.json()
|
2021-06-06 13:19:28 +00:00
|
|
|
|
if data["retcode"] == 0:
|
2022-01-30 03:58:31 +00:00
|
|
|
|
today_item = self.get_today_item(data["data"]["list"])
|
2022-02-02 05:43:54 +00:00
|
|
|
|
re_message = f"舰长 {i[0]} 签到成功~\t已连续签到{self.sign_day}天\t今天获得的奖励是{tools.get_item(today_item)}"
|
|
|
|
|
log.info(re_message)
|
2021-06-08 12:43:30 +00:00
|
|
|
|
elif data["retcode"] == -5003:
|
2022-02-02 05:43:54 +00:00
|
|
|
|
re_message = f"舰长 {i[0]} 今天已经签到过了~\t已连续签到{self.sign_day}天\t今天获得的奖励是{tools.get_item(today_item)}"
|
|
|
|
|
log.info(re_message)
|
2021-06-06 04:16:28 +00:00
|
|
|
|
else:
|
2022-02-02 05:43:54 +00:00
|
|
|
|
re_message = f"舰长 {i[0]} 本次签到失败!"
|
|
|
|
|
log.warning(re_message)
|
2021-10-25 14:53:34 +00:00
|
|
|
|
print(req.text)
|
2022-02-02 05:43:54 +00:00
|
|
|
|
return_data += re_message
|
2022-01-30 03:58:31 +00:00
|
|
|
|
return return_data
|