mirror of
https://github.com/TDSCDMAA/AutoMihoyoBBS.git
synced 2026-06-02 18:43:42 +08:00
米游社判断任务进度+崩坏3签到
This commit is contained in:
parent
287892669f
commit
6d5421646a
@ -6,7 +6,7 @@
|
||||
|
||||
* 此项目的用途
|
||||
|
||||
这是一个米游社的自动签到项目,包含了米游币和原神
|
||||
这是一个米游社的自动签到项目,包含了米游币和原神以及崩坏3
|
||||
|
||||
## 如何使用程序
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ mihoyobbs = {
|
||||
#多个讨论区签到
|
||||
"bbs_Singin_multi": True,
|
||||
#指定签到讨论区
|
||||
#1是崩坏3 2是原神 3是崩坏2 4是未定事件簿 5是米游社
|
||||
"bbs_Singin_multi_list": [2,5],
|
||||
#浏览3个帖子
|
||||
"bbs_Read_posts": True,
|
||||
@ -31,6 +32,8 @@ mihoyobbs = {
|
||||
}
|
||||
#原神自动签到
|
||||
genshin_AutoSingin = True
|
||||
#崩坏3自动签到
|
||||
honkai3rd_AutoSing = True
|
||||
|
||||
path = os.path.dirname(os.path.realpath(__file__)) + "/config"
|
||||
config_Path = f"{path}/config.json"
|
||||
@ -45,6 +48,7 @@ def Load_config():
|
||||
global mihoyobbs_Cookies
|
||||
global mihoyobbs
|
||||
global genshin_AutoSingin
|
||||
global honkai3rd_AutoSing
|
||||
enable_Config = data["enable_Config"]
|
||||
mihoyobbs_Login_ticket = data["mihoyobbs_Login_ticket"]
|
||||
mihoyobbs_Stuid = data["mihoyobbs_Stuid"]
|
||||
@ -59,6 +63,7 @@ def Load_config():
|
||||
mihoyobbs["bbs_Unlike"] = data["mihoyobbs"]["bbs_Unlike"]
|
||||
mihoyobbs["bbs_Share"] = data["mihoyobbs"]["bbs_Share"]
|
||||
genshin_AutoSingin = data["genshin_AutoSingin"]
|
||||
honkai3rd_AutoSing = data["honkai3rd_AutoSing"]
|
||||
f.close()
|
||||
tools.log.info("Config加载完毕")
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"enable_Config": true,
|
||||
"config_Version": 1,
|
||||
"config_Version": 2,
|
||||
"mihoyobbs_Login_ticket": "",
|
||||
"mihoyobbs_Stuid": "",
|
||||
"mihoyobbs_Stoken": "",
|
||||
@ -15,5 +15,6 @@
|
||||
"bbs_Unlike": true,
|
||||
"bbs_Share": true
|
||||
},
|
||||
"genshin_AutoSingin": true
|
||||
"genshin_AutoSingin": true,
|
||||
"honkai3rd_AutoSing": false
|
||||
}
|
||||
64
genshin.py
64
genshin.py
@ -22,13 +22,14 @@ class genshin:
|
||||
'x-rpc-device_id': tools.Get_deviceid()
|
||||
}
|
||||
self.acc_List = self.Getacc_list()
|
||||
self.sing_Give = self.Get_singgive()
|
||||
if (len(self.acc_List) != 0):
|
||||
self.sing_Give = self.Get_singgive()
|
||||
|
||||
#获取绑定的账号列表
|
||||
def Getacc_list(self) -> list:
|
||||
tools.log.info("正在获取米哈游账号绑定的游戏账号列表...")
|
||||
temp_List = []
|
||||
req = httpx.get(setting.genshin_Accinfo_url, headers=self.headers)
|
||||
req = httpx.get(setting.genshin_Account_info_url, headers=self.headers)
|
||||
data = req.json()
|
||||
if (data["retcode"] != 0):
|
||||
tools.log.warn("获取账号列表失败!")
|
||||
@ -38,6 +39,12 @@ class genshin:
|
||||
tools.log.info(f"已获取到{len(temp_List)}个原神账号信息")
|
||||
return (temp_List)
|
||||
|
||||
#获取签到的奖励名称
|
||||
def Get_item(self, raw_data:dict) ->str:
|
||||
temp_Name = raw_data["name"]
|
||||
temp_Cnt = raw_data["cnt"]
|
||||
return (f"{temp_Name}x{temp_Cnt}")
|
||||
|
||||
#获取已经签到奖励列表
|
||||
def Get_singgive(self) -> list:
|
||||
tools.log.info("正在获取签到奖励列表...")
|
||||
@ -59,36 +66,33 @@ class genshin:
|
||||
exit()
|
||||
return (data["data"])
|
||||
|
||||
#获取签到的奖励名称
|
||||
def Get_item(self, raw_data:dict) ->str:
|
||||
temp_Name = raw_data["name"]
|
||||
temp_Cnt = raw_data["cnt"]
|
||||
return (f"{temp_Name}x{temp_Cnt}")
|
||||
|
||||
#签到
|
||||
def Sing_acc(self):
|
||||
for i in self.acc_List:
|
||||
tools.log.info(f"正在为旅行者{i[0]}进行签到...")
|
||||
time.sleep(random.randint(2, 6))
|
||||
is_data = self.Is_sing(region = i[2], uid = i[1])
|
||||
if (is_data["first_bind"] == True):
|
||||
tools.log.warn(f"旅行者{i[0]}是第一次绑定米游社,请先手动签到一次")
|
||||
else:
|
||||
sing_Days = is_data["total_sign_day"] - 1
|
||||
if (is_data["is_sign"] == True):
|
||||
tools.log.info(f"旅行者{i[0]}今天已经签到过了~\r\n今天获得的奖励是{self.Get_item(self.sing_Give[sing_Days])}")
|
||||
if (len(self.acc_List) != 0):
|
||||
for i in self.acc_List:
|
||||
tools.log.info(f"正在为旅行者{i[0]}进行签到...")
|
||||
time.sleep(random.randint(2, 6))
|
||||
is_data = self.Is_sing(region = i[2], uid = i[1])
|
||||
if (is_data["first_bind"] == True):
|
||||
tools.log.warn(f"旅行者{i[0]}是第一次绑定米游社,请先手动签到一次")
|
||||
else:
|
||||
time.sleep(random.randint(2, 6))
|
||||
req = httpx.post(url=setting.genshin_Singurl, headers=self.headers,
|
||||
json={'act_id': setting.genshin_Act_id, 'region': i[2], 'uid': i[1]})
|
||||
data = req.json()
|
||||
if (data["retcode"] == 0):
|
||||
if (sing_Days == 0):
|
||||
tools.log.info(f"旅行者{i[0]}签到成功~\r\n今天获得的奖励是{self.Get_item(self.sing_Give[sing_Days])}")
|
||||
else:
|
||||
tools.log.info(f"旅行者{i[0]}签到成功~\r\n今天获得的奖励是{self.Get_item(self.sing_Give[sing_Days + 1])}")
|
||||
elif (data["retcode"] == -5003):
|
||||
sing_Days = is_data["total_sign_day"] - 1
|
||||
if (is_data["is_sign"] == True):
|
||||
tools.log.info(f"旅行者{i[0]}今天已经签到过了~\r\n今天获得的奖励是{self.Get_item(self.sing_Give[sing_Days])}")
|
||||
else:
|
||||
tools.log.warn("账号签到失败!")
|
||||
print (req.text)
|
||||
time.sleep(random.randint(2, 6))
|
||||
req = httpx.post(url=setting.genshin_Singurl, headers=self.headers,
|
||||
json={'act_id': setting.genshin_Act_id, 'region': i[2], 'uid': i[1]})
|
||||
data = req.json()
|
||||
if (data["retcode"] == 0):
|
||||
if (sing_Days == 0):
|
||||
tools.log.info(f"旅行者{i[0]}签到成功~\r\n今天获得的奖励是{self.Get_item(self.sing_Give[sing_Days])}")
|
||||
else:
|
||||
tools.log.info(f"旅行者{i[0]}签到成功~\r\n今天获得的奖励是{self.Get_item(self.sing_Give[sing_Days + 1])}")
|
||||
elif (data["retcode"] == -5003):
|
||||
tools.log.info(f"旅行者{i[0]}今天已经签到过了~\r\n今天获得的奖励是{self.Get_item(self.sing_Give[sing_Days])}")
|
||||
else:
|
||||
tools.log.warn("账号签到失败!")
|
||||
print (req.text)
|
||||
else:
|
||||
tools.log.warn("账号没有绑定任何原神账号!")
|
||||
|
||||
93
honkai3rd.py
Normal file
93
honkai3rd.py
Normal file
@ -0,0 +1,93 @@
|
||||
import time
|
||||
import httpx
|
||||
import tools
|
||||
import config
|
||||
import random
|
||||
import setting
|
||||
|
||||
class honkai3rd:
|
||||
def __init__(self) -> None:
|
||||
self.headers = {
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'DS': tools.Get_ds(web=True, web_old=True),
|
||||
'Origin': 'https://webstatic.mihoyo.com',
|
||||
'x-rpc-app_version': setting.mihoyobbs_Version_old,
|
||||
'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',
|
||||
'x-rpc-client_type': setting.mihoyobbs_Client_type_web,
|
||||
'Referer': 'https://webstatic.mihoyo.com/bh3/event/euthenia/index.html?bbs_presentation_style=fullscreen&bbs_game_role_required=bh3_cn&bbs_auth_required=true&act_id=e202104072769&utm_source=bbs&utm_medium=mys&utm_campaign=icon',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language': 'zh-CN,en-US;q=0.8',
|
||||
'X-Requested-With': 'com.mihoyo.hyperion',
|
||||
"Cookie": config.mihoyobbs_Cookies,
|
||||
'x-rpc-device_id': tools.Get_deviceid()
|
||||
}
|
||||
self.acc_List = self.Getacc_list()
|
||||
|
||||
#获取绑定的账号列表
|
||||
def Getacc_list(self) -> list:
|
||||
tools.log.info("正在获取米哈游账号绑定的游戏账号列表...")
|
||||
temp_List = []
|
||||
req = httpx.get(setting.honkai3rd_Account_info_url, headers=self.headers)
|
||||
data = req.json()
|
||||
if (data["retcode"] != 0):
|
||||
tools.log.warn("获取账号列表失败!")
|
||||
exit()
|
||||
for i in data["data"]["list"]:
|
||||
temp_List.append([i["nickname"], i["game_uid"], i["region"]])
|
||||
tools.log.info(f"已获取到{len(temp_List)}个崩坏3账号信息")
|
||||
return (temp_List)
|
||||
|
||||
#获取签到的奖励名称
|
||||
def Get_item(self, raw_data:dict) ->str:
|
||||
temp_Name = raw_data["name"]
|
||||
temp_Cnt = raw_data["cnt"]
|
||||
return (f"{temp_Name}x{temp_Cnt}")
|
||||
|
||||
#获取今天已经签到了的dict
|
||||
def Get_today_item(self,raw_data:list) -> dict:
|
||||
#用range进行循环,当staus等于0的时候上一个就是今天签到的dict
|
||||
for i in range(len(raw_data)):
|
||||
if (raw_data[i]["status"] == 0):
|
||||
return (raw_data[i-1])
|
||||
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])
|
||||
|
||||
#判断签到
|
||||
def Is_sing(self, region:str, uid:str, nickname:str):
|
||||
req = httpx.get(setting.honkai3rd_Is_singurl.format(setting.honkai3rd_Act_id, region, uid), headers=self.headers)
|
||||
data = req.json()
|
||||
if (data["retcode"] != 0):
|
||||
tools.log.warn("获取账号签到信息失败!")
|
||||
print (req.text)
|
||||
exit()
|
||||
today_Item = self.Get_today_item(data["data"]["sign"]["list"])
|
||||
if (today_Item["status"] == 1):
|
||||
return (True)
|
||||
else:
|
||||
tools.log.info(f"舰长{nickname}今天已经签到过了~\r\n今天获得的奖励是{self.Get_item(today_Item)}")
|
||||
return (False)
|
||||
|
||||
#签到
|
||||
def Sing_acc(self):
|
||||
if (len(self.acc_List) != 0):
|
||||
for i in self.acc_List:
|
||||
tools.log.info(f"正在为舰长{i[0]}进行签到...")
|
||||
time.sleep(random.randint(2, 6))
|
||||
is_data = self.Is_sing(region = i[2], uid = i[1], nickname = i[0])
|
||||
if (is_data == True):
|
||||
time.sleep(random.randint(2, 6))
|
||||
req = httpx.post(url=setting.honkai3rd_SingUrl, headers=self.headers,
|
||||
json={'act_id': setting.honkai3rd_Act_id, 'region': i[2], 'uid': i[1]})
|
||||
data = req.json()
|
||||
if (data["retcode"] == 0):
|
||||
today_Item = self.Get_today_item(data["data"]["list"])
|
||||
tools.log.info(f"舰长{i[0]}签到成功~\r\n今天获得的奖励是{self.Get_item(today_Item)}")
|
||||
elif (data["retcode"] == -5003):
|
||||
tools.log.info(f"舰长{i[0]}今天已经签到过了~")
|
||||
else:
|
||||
tools.log.warn("账号签到失败!")
|
||||
print (req.text)
|
||||
else:
|
||||
tools.log.warn("账号没有绑定任何崩坏3账号!")
|
||||
9
main.py
9
main.py
@ -4,6 +4,7 @@ import config
|
||||
import genshin
|
||||
import setting
|
||||
import mihoyobbs
|
||||
import honkai3rd
|
||||
|
||||
def main():
|
||||
#初始化,加载配置
|
||||
@ -36,12 +37,20 @@ def main():
|
||||
bbs.Share()
|
||||
else:
|
||||
tools.log.info("米游社功能未启用!")
|
||||
#原神签到
|
||||
if(config.genshin_AutoSingin == True):
|
||||
tools.log.info("正在进行原神签到")
|
||||
genshin_Help = genshin.genshin()
|
||||
genshin_Help.Sing_acc()
|
||||
else:
|
||||
tools.log.info("原神签到功能未启用!")
|
||||
#崩坏3签到
|
||||
if (config.honkai3rd_AutoSing == True):
|
||||
tools.log.info("正在进行崩坏3签到")
|
||||
honkai3rd_Help = honkai3rd.honkai3rd()
|
||||
honkai3rd_Help.Sing_acc()
|
||||
else:
|
||||
tools.log.info("崩坏3签到功能未启用!")
|
||||
else:
|
||||
tools.log.warn ("Config未启用!")
|
||||
|
||||
|
||||
117
mihoyobbs.py
117
mihoyobbs.py
@ -21,12 +21,59 @@ class mihoyobbs:
|
||||
"Host": "bbs-api.mihoyo.com",
|
||||
"User-Agent": "okhttp/4.8.0"
|
||||
}
|
||||
self.postsList = self.Getlist()
|
||||
self.Task_do = {
|
||||
"bbs_Sign": False,
|
||||
"bbs_Read_posts": False,
|
||||
"bbs_Like_posts": False,
|
||||
"bbs_Share": False
|
||||
}
|
||||
self.Get_taskslist()
|
||||
#如果这三个任务都做了就没必要获取帖子了
|
||||
if (self.Task_do["bbs_Read_posts"] == True and self.Task_do["bbs_Like_posts"] == True and self.Task_do["bbs_Share"] == True):
|
||||
pass
|
||||
else:
|
||||
self.postsList = self.Getlist()
|
||||
|
||||
#获取任务列表,用来判断还有哪些漏做了
|
||||
#获取任务列表,用来判断做了哪些任务
|
||||
def Get_taskslist(self):
|
||||
temp_List = []
|
||||
#ToDo
|
||||
tools.log.info("正在获取任务列表")
|
||||
req = httpx.get(url=setting.bbs_Taskslist, headers=self.headers)
|
||||
data = req.json()
|
||||
if ("err" in data["message"]):
|
||||
tools.log.info("获取任务列表失败,你的cookie可能已过期,请重新设置cookie。")
|
||||
config.Clear_cookies()
|
||||
exit()
|
||||
else:
|
||||
#如果当日可获取米游币数量为0直接判断全部任务都完成了
|
||||
if (data["data"]["can_get_points"] == 0):
|
||||
self.Task_do["bbs_Sign"] = True
|
||||
self.Task_do["bbs_Read_posts"] = True
|
||||
self.Task_do["bbs_Like_posts"] = True
|
||||
self.Task_do["bbs_Share"] = True
|
||||
else:
|
||||
#如果第0个大于或等于62则直接判定任务没做
|
||||
if (data["data"]["states"][0]["mission_id"] >= 62):
|
||||
pass
|
||||
else:
|
||||
for i in data["data"]["states"]:
|
||||
#58是讨论区签到
|
||||
if (i["mission_id"] == 58):
|
||||
if (i["is_get_award"] == True):
|
||||
self.Task_do["bbs_Sign"] = True
|
||||
#59是看帖子
|
||||
elif (i["mission_id"] == 59):
|
||||
if (i["is_get_award"] == True):
|
||||
self.Task_do["bbs_Read_posts"] = True
|
||||
#60是给帖子点赞
|
||||
elif (i["mission_id"] == 60):
|
||||
if (i["is_get_award"] == True):
|
||||
self.Task_do["bbs_Like_posts"] = True
|
||||
#61是分享帖子
|
||||
elif (i["mission_id"] == 61):
|
||||
if (i["is_get_award"] == True):
|
||||
self.Task_do["bbs_Share"] = True
|
||||
#分享帖子,是最后一个任务,到这里了下面都是一次性任务,直接跳出循环
|
||||
break
|
||||
|
||||
#获取要帖子列表
|
||||
def Getlist(self) -> list:
|
||||
@ -43,6 +90,7 @@ class mihoyobbs:
|
||||
|
||||
#进行签到操作
|
||||
def Singin(self):
|
||||
#签到这里暂时不设置判断,防止要签到的其他社区没有签到成功
|
||||
tools.log.info("正在签到......")
|
||||
for i in setting.mihoyobbs_List_Use:
|
||||
req = httpx.post(url=setting.bbs_Signurl.format(i["id"]), data="" ,headers=self.headers)
|
||||
@ -57,38 +105,47 @@ class mihoyobbs:
|
||||
|
||||
#看帖子
|
||||
def Readposts(self):
|
||||
tools.log.info("正在看帖......")
|
||||
for i in range(3):
|
||||
req = httpx.get(url=setting.bbs_Detailurl.format(self.postsList[i][0]), headers=self.headers)
|
||||
data = req.json()
|
||||
if data["message"] == "OK":
|
||||
tools.log.info("看帖:{} 成功".format(self.postsList[i][1]))
|
||||
time.sleep(random.randint(2, 6))
|
||||
if (self.Task_do["bbs_Read_posts"] == False):
|
||||
tools.log.info("正在看帖......")
|
||||
for i in range(3):
|
||||
req = httpx.get(url=setting.bbs_Detailurl.format(self.postsList[i][0]), headers=self.headers)
|
||||
data = req.json()
|
||||
if data["message"] == "OK":
|
||||
tools.log.info("看帖:{} 成功".format(self.postsList[i][1]))
|
||||
time.sleep(random.randint(2, 6))
|
||||
else:
|
||||
tools.log.info("看帖任务已经完成过了~")
|
||||
|
||||
#点赞
|
||||
def Likeposts(self):
|
||||
tools.log.info("正在点赞......")
|
||||
for i in range(5):
|
||||
req = httpx.post(url=setting.bbs_Likeurl, headers=self.headers,
|
||||
json={"post_id": self.postsList[i][0], "is_cancel": False})
|
||||
data = req.json()
|
||||
if (data["message"] == "OK"):
|
||||
tools.log.info("点赞:{} 成功".format(self.postsList[i][1]))
|
||||
#判断取消点赞是否打开
|
||||
if (config.mihoyobbs["bbs_Unlike"] == True):
|
||||
time.sleep(random.randint(2, 6))
|
||||
if (self.Task_do["bbs_Like_posts"] == False):
|
||||
tools.log.info("正在点赞......")
|
||||
for i in range(5):
|
||||
req = httpx.post(url=setting.bbs_Likeurl, headers=self.headers,
|
||||
json={"post_id": self.postsList[i][0], "is_cancel": True})
|
||||
json={"post_id": self.postsList[i][0], "is_cancel": False})
|
||||
data = req.json()
|
||||
if (data["message"] == "OK"):
|
||||
tools.log.info("取消点赞:{} 成功".format(self.postsList[i][1]))
|
||||
time.sleep(random.randint(2, 6))
|
||||
tools.log.info("点赞:{} 成功".format(self.postsList[i][1]))
|
||||
#判断取消点赞是否打开
|
||||
if (config.mihoyobbs["bbs_Unlike"] == True):
|
||||
time.sleep(random.randint(2, 6))
|
||||
req = httpx.post(url=setting.bbs_Likeurl, headers=self.headers,
|
||||
json={"post_id": self.postsList[i][0], "is_cancel": True})
|
||||
data = req.json()
|
||||
if (data["message"] == "OK"):
|
||||
tools.log.info("取消点赞:{} 成功".format(self.postsList[i][1]))
|
||||
time.sleep(random.randint(2, 6))
|
||||
else:
|
||||
tools.log.info("点赞任务已经完成过了~")
|
||||
|
||||
#分享操作
|
||||
def Share(self):
|
||||
tools.log.info("正在分享......")
|
||||
req = httpx.get(url=setting.bbs_Shareurl.format(random.choice(self.postsList)[0]), headers=self.headers)
|
||||
data = req.json()
|
||||
if data["message"] == "OK":
|
||||
tools.log.info("分享:{} 成功".format(random.choice(self.postsList)[1]))
|
||||
time.sleep(random.randint(2, 6))
|
||||
if (self.Task_do["bbs_Share"] == False):
|
||||
tools.log.info("正在分享......")
|
||||
req = httpx.get(url=setting.bbs_Shareurl.format(self.postsList[0][0]), headers=self.headers)
|
||||
data = req.json()
|
||||
if data["message"] == "OK":
|
||||
tools.log.info("分享:{} 成功".format(self.postsList[0][1]))
|
||||
time.sleep(random.randint(2, 6))
|
||||
else:
|
||||
tools.log.info("分享任务已经完成过了~")
|
||||
@ -51,7 +51,13 @@ bbs_Likeurl = "https://bbs-api.mihoyo.com/apihub/sapi/upvotePost" # post json
|
||||
|
||||
#原神自动签到相关的设置
|
||||
genshin_Act_id = "e202009291139501"
|
||||
genshin_Accinfo_url = "https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_cn"
|
||||
genshin_Account_info_url = "https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_cn"
|
||||
genshin_Singlisturl = "https://api-takumi.mihoyo.com/event/bbs_sign_reward/home?act_id={}"
|
||||
genshin_Is_singurl = "https://api-takumi.mihoyo.com/event/bbs_sign_reward/info?act_id={}®ion={}&uid={}"
|
||||
genshin_Singurl = "https://api-takumi.mihoyo.com/event/bbs_sign_reward/sign"
|
||||
|
||||
#崩坏3自动签到相关的设置
|
||||
honkai3rd_Act_id = "e202104072769"
|
||||
honkai3rd_Account_info_url = "https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=bh3_cn"
|
||||
honkai3rd_Is_singurl = "https://api-takumi.mihoyo.com/common/euthenia/index?act_id={}®ion={}&uid={}"
|
||||
honkai3rd_SingUrl = "https://api-takumi.mihoyo.com/common/euthenia/sign"
|
||||
Loading…
Reference in New Issue
Block a user