加入新的推送消息,加入验证码重试机制
This commit is contained in:
parent
5ee3d20195
commit
53056ad4f0
8
error.py
8
error.py
@ -4,3 +4,11 @@ class CookieError(Exception):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.info)
|
return repr(self.info)
|
||||||
|
|
||||||
|
|
||||||
|
class CaptchaError(Exception):
|
||||||
|
def __init__(self, info):
|
||||||
|
self.info = info
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return repr(self.info)
|
||||||
|
24
genshin.py
24
genshin.py
@ -3,15 +3,16 @@ import tools
|
|||||||
import config
|
import config
|
||||||
import random
|
import random
|
||||||
import setting
|
import setting
|
||||||
|
from error import *
|
||||||
from request import http
|
from request import http
|
||||||
from loghelper import log
|
from loghelper import log
|
||||||
from error import CookieError
|
|
||||||
from account import get_account_list
|
from account import get_account_list
|
||||||
|
|
||||||
|
|
||||||
class Genshin:
|
class Genshin:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.headers = setting.headers
|
self.headers = {}
|
||||||
|
self.headers.update(setting.headers)
|
||||||
self.headers['DS'] = tools.get_ds(web=True)
|
self.headers['DS'] = tools.get_ds(web=True)
|
||||||
self.headers['Referer'] = 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true' \
|
self.headers['Referer'] = 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true' \
|
||||||
f'&act_id={setting.genshin_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon'
|
f'&act_id={setting.genshin_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon'
|
||||||
@ -43,6 +44,17 @@ class Genshin:
|
|||||||
raise CookieError("BBS Cookie Errror")
|
raise CookieError("BBS Cookie Errror")
|
||||||
return data["data"]
|
return data["data"]
|
||||||
|
|
||||||
|
def check_in(self, account):
|
||||||
|
for i in range(3):
|
||||||
|
req = http.post(url=setting.genshin_Signurl, headers=self.headers,
|
||||||
|
json={'act_id': setting.genshin_Act_id, 'region': account[2], 'uid': account[1]})
|
||||||
|
data = req.json()
|
||||||
|
if data["retcode"] == 0 and data["data"]["success"] == 1:
|
||||||
|
time.sleep(random.randint(4, 10))
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
return req
|
||||||
|
|
||||||
# 签到
|
# 签到
|
||||||
def sign_account(self) -> str:
|
def sign_account(self) -> str:
|
||||||
return_data = "原神: "
|
return_data = "原神: "
|
||||||
@ -58,13 +70,12 @@ class Genshin:
|
|||||||
else:
|
else:
|
||||||
sign_days = is_data["total_sign_day"] - 1
|
sign_days = is_data["total_sign_day"] - 1
|
||||||
ok = True
|
ok = True
|
||||||
if is_data["is_sign"]:
|
if not is_data["is_sign"]:
|
||||||
log.info(f"旅行者{i[0]}今天已经签到过了~\r\n今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days])}")
|
log.info(f"旅行者{i[0]}今天已经签到过了~\r\n今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days])}")
|
||||||
sign_days += 1
|
sign_days += 1
|
||||||
else:
|
else:
|
||||||
time.sleep(random.randint(2, 8))
|
time.sleep(random.randint(2, 8))
|
||||||
req = http.post(url=setting.genshin_Signurl, headers=self.headers,
|
req = self.check_in(i)
|
||||||
json={'act_id': setting.genshin_Act_id, 'region': i[2], 'uid': i[1]})
|
|
||||||
data = req.json()
|
data = req.json()
|
||||||
if data["retcode"] == 0 and data["data"]["success"] == 0:
|
if data["retcode"] == 0 and data["data"]["success"] == 0:
|
||||||
log.info(f"旅行者{i[0]}签到成功~\r\n今天获得的奖励是"
|
log.info(f"旅行者{i[0]}签到成功~\r\n今天获得的奖励是"
|
||||||
@ -79,7 +90,8 @@ class Genshin:
|
|||||||
log.warning(s)
|
log.warning(s)
|
||||||
ok = False
|
ok = False
|
||||||
if ok:
|
if ok:
|
||||||
return_data += f"\n{i[0]}已连续签到{sign_days}天\n今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days - 1])}"
|
return_data += f"\n{i[0]}已连续签到{sign_days}天\n" \
|
||||||
|
f"今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days - 1])}"
|
||||||
else:
|
else:
|
||||||
return_data += f"\n{i[0]},本次签到失败"
|
return_data += f"\n{i[0]},本次签到失败"
|
||||||
if data["data"] != "" and data["data"]["success"] == 1:
|
if data["data"] != "" and data["data"]["success"] == 1:
|
||||||
|
10
main.py
10
main.py
@ -9,8 +9,8 @@ import setting
|
|||||||
import mihoyobbs
|
import mihoyobbs
|
||||||
import honkai3rd
|
import honkai3rd
|
||||||
import tearsofthemis
|
import tearsofthemis
|
||||||
|
from error import *
|
||||||
from loghelper import log
|
from loghelper import log
|
||||||
from error import CookieError
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -38,6 +38,7 @@ def main():
|
|||||||
if int(i["id"]) == 5:
|
if int(i["id"]) == 5:
|
||||||
setting.mihoyobbs_List_Use.append(i)
|
setting.mihoyobbs_List_Use.append(i)
|
||||||
# 米游社签到
|
# 米游社签到
|
||||||
|
ret_code = 0
|
||||||
if config.config["mihoyobbs"]["enable"]:
|
if config.config["mihoyobbs"]["enable"]:
|
||||||
bbs = mihoyobbs.Mihoyobbs()
|
bbs = mihoyobbs.Mihoyobbs()
|
||||||
if bbs.Task_do["bbs_Sign"] and bbs.Task_do["bbs_Read_posts"] and bbs.Task_do["bbs_Like_posts"] and \
|
if bbs.Task_do["bbs_Sign"] and bbs.Task_do["bbs_Read_posts"] and bbs.Task_do["bbs_Like_posts"] and \
|
||||||
@ -88,9 +89,12 @@ def main():
|
|||||||
if config.config["games"]["cn"]["genshin"]["auto_checkin"]:
|
if config.config["games"]["cn"]["genshin"]["auto_checkin"]:
|
||||||
log.info("正在进行原神签到")
|
log.info("正在进行原神签到")
|
||||||
genshin_help = genshin.Genshin()
|
genshin_help = genshin.Genshin()
|
||||||
return_data += "\n\n" + genshin_help.sign_account()
|
genshin_message = genshin_help.sign_account()
|
||||||
|
if "触发验证码" in genshin_message:
|
||||||
|
ret_code = 3
|
||||||
|
return_data += "\n\n" + genshin_message
|
||||||
time.sleep(random.randint(2, 8))
|
time.sleep(random.randint(2, 8))
|
||||||
return 0, return_data
|
return ret_code, return_data
|
||||||
elif config.config["account"]["cookie"] == "CookieError":
|
elif config.config["account"]["cookie"] == "CookieError":
|
||||||
raise CookieError('Cookie expires')
|
raise CookieError('Cookie expires')
|
||||||
else:
|
else:
|
||||||
|
@ -34,7 +34,7 @@ def main_multi(autorun: bool):
|
|||||||
input("请输入回车继续,需要重新搜索配置文件请Ctrl+C退出脚本")
|
input("请输入回车继续,需要重新搜索配置文件请Ctrl+C退出脚本")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
exit(0)
|
exit(0)
|
||||||
results = {"ok": [], "close": [], "error": []}
|
results = {"ok": [], "close": [], "error": [], "captcha": []}
|
||||||
for i in iter(config_list):
|
for i in iter(config_list):
|
||||||
log.info(f"正在执行{i}")
|
log.info(f"正在执行{i}")
|
||||||
setting.mihoyobbs_List_Use = []
|
setting.mihoyobbs_List_Use = []
|
||||||
@ -46,6 +46,8 @@ def main_multi(autorun: bool):
|
|||||||
else:
|
else:
|
||||||
if run_code == 0:
|
if run_code == 0:
|
||||||
results["ok"].append(i)
|
results["ok"].append(i)
|
||||||
|
elif run_code == 3:
|
||||||
|
results["captcha"].append(i)
|
||||||
else:
|
else:
|
||||||
results["close"].append(i)
|
results["close"].append(i)
|
||||||
log.info(f"{i}执行完毕")
|
log.info(f"{i}执行完毕")
|
||||||
@ -53,13 +55,16 @@ def main_multi(autorun: bool):
|
|||||||
print("")
|
print("")
|
||||||
push_message = f'脚本执行完毕,共执行{len(config_list)}个配置文件,成功{len(results["ok"])}个,' \
|
push_message = f'脚本执行完毕,共执行{len(config_list)}个配置文件,成功{len(results["ok"])}个,' \
|
||||||
f'没执行{len(results["close"])}个,失败{len(results["error"])}个' \
|
f'没执行{len(results["close"])}个,失败{len(results["error"])}个' \
|
||||||
f'\r\n没执行的配置文件: {results["close"]}\r\n执行失败的配置文件: {results["error"]}'
|
f'\r\n没执行的配置文件: {results["close"]}\r\n执行失败的配置文件: {results["error"]}\r\n' \
|
||||||
|
f'触发原神验证码的配置文件: {results["captcha"]} '
|
||||||
log.info(push_message)
|
log.info(push_message)
|
||||||
status = 0
|
status = 0
|
||||||
if len(results["error"]) == len(config_list):
|
if len(results["error"]) == len(config_list):
|
||||||
status = 1
|
status = 1
|
||||||
elif len(results["error"]) != 0:
|
elif len(results["error"]) != 0:
|
||||||
status = 2
|
status = 2
|
||||||
|
elif len(results["captcha"]) != 0:
|
||||||
|
status = 3
|
||||||
push.push(status, push_message)
|
push.push(status, push_message)
|
||||||
|
|
||||||
|
|
||||||
|
8
push.py
8
push.py
@ -27,6 +27,8 @@ def title(status):
|
|||||||
return "「米游社脚本」执行失败!"
|
return "「米游社脚本」执行失败!"
|
||||||
elif status == 2:
|
elif status == 2:
|
||||||
return "「米游社脚本」部分账号执行失败!"
|
return "「米游社脚本」部分账号执行失败!"
|
||||||
|
elif status == 3:
|
||||||
|
return "「米游社脚本」原神签到触发验证码!"
|
||||||
|
|
||||||
|
|
||||||
# telegram的推送
|
# telegram的推送
|
||||||
@ -112,11 +114,11 @@ def pushdeer(status, push_message):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# 钉钉群机器人
|
# 钉钉群机器人
|
||||||
def dingrobot(status, push_message):
|
def dingrobot(status, push_message):
|
||||||
api_url = cfg.get('dingrobot', 'webhook') # https://oapi.dingtalk.com/robot/send?access_token=XXX
|
api_url = cfg.get('dingrobot', 'webhook') # https://oapi.dingtalk.com/robot/send?access_token=XXX
|
||||||
secret = cfg.get('dingrobot', 'secret') # 安全设置 -> 加签 -> 密钥 -> SEC*
|
secret = cfg.get('dingrobot', 'secret') # 安全设置 -> 加签 -> 密钥 -> SEC*
|
||||||
|
|
||||||
if secret:
|
if secret:
|
||||||
timestamp = str(round(time.time() * 1000))
|
timestamp = str(round(time.time() * 1000))
|
||||||
sign_string = f"{timestamp}\n{secret}"
|
sign_string = f"{timestamp}\n{secret}"
|
||||||
@ -137,6 +139,7 @@ def dingrobot(status, push_message):
|
|||||||
).json()
|
).json()
|
||||||
log.info(f"推送结果:{rep.get('errmsg')}")
|
log.info(f"推送结果:{rep.get('errmsg')}")
|
||||||
|
|
||||||
|
|
||||||
# Bark
|
# Bark
|
||||||
def bark(status, push_message):
|
def bark(status, push_message):
|
||||||
rep = http.get(
|
rep = http.get(
|
||||||
@ -144,6 +147,7 @@ def bark(status, push_message):
|
|||||||
).json()
|
).json()
|
||||||
log.info(f"推送结果:{rep.get('message')}")
|
log.info(f"推送结果:{rep.get('message')}")
|
||||||
|
|
||||||
|
|
||||||
# gotify
|
# gotify
|
||||||
def gotify(status, push_message):
|
def gotify(status, push_message):
|
||||||
rep = http.post(
|
rep = http.post(
|
||||||
@ -156,6 +160,7 @@ def gotify(status, push_message):
|
|||||||
).json()
|
).json()
|
||||||
log.info(f"推送结果:{rep.get('errmsg')}")
|
log.info(f"推送结果:{rep.get('errmsg')}")
|
||||||
|
|
||||||
|
|
||||||
def push(status, push_message):
|
def push(status, push_message):
|
||||||
if not load_config():
|
if not load_config():
|
||||||
return 0
|
return 0
|
||||||
@ -179,5 +184,6 @@ def push(status, push_message):
|
|||||||
log.info("推送完毕......")
|
log.info("推送完毕......")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
push(0, f'推送验证{int(time.time())}')
|
push(0, f'推送验证{int(time.time())}')
|
||||||
|
Loading…
Reference in New Issue
Block a user