-
Notifications
You must be signed in to change notification settings - Fork 24
/
main_multi.py
78 lines (72 loc) · 2.62 KB
/
main_multi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
import sys
import main
import time
import push
import config
import random
import setting
from loghelper import log
from error import CookieError
# 搜索配置文件
def fund_config(ext: str) -> list:
file_name = []
for files in os.listdir(config.path):
if os.path.splitext(files)[1] == ext:
file_name.append(files)
return file_name
def main_multi(autorun: bool):
log.info("AutoMihoyoBBS Multi User mode")
log.info("正在搜索配置文件!")
config_list = fund_config('.yaml')
if len(config_list) == 0:
log.warning("未检测到配置文件,请确认config文件夹存在.yaml后缀名的配置文件!")
exit(1)
if autorun:
log.info(f"已搜索到{len(config_list)}个配置文件,正在开始执行!")
else:
log.info(f"已搜索到{len(config_list)}个配置文件,请确认是否无多余文件!\r\n{config_list}")
try:
input("请输入回车继续,需要重新搜索配置文件请Ctrl+C退出脚本")
except KeyboardInterrupt:
exit(0)
results = {"ok": [], "close": [], "error": [], "captcha": []}
for i in iter(config_list):
log.info(f"正在执行{i}")
setting.mihoyobbs_List_Use = []
config.config_Path = f"{config.path}/{i}"
try:
run_code, run_message = main.main()
except CookieError:
results["error"].append(i)
else:
if run_code == 0:
results["ok"].append(i)
elif run_code == 3:
results["captcha"].append(i)
else:
results["close"].append(i)
log.info(f"{i}执行完毕")
time.sleep(random.randint(3, 10))
print("")
push_message = f'脚本执行完毕,共执行{len(config_list)}个配置文件,成功{len(results["ok"])}个,' \
f'没执行{len(results["close"])}个,失败{len(results["error"])}个' \
f'\r\n没执行的配置文件: {results["close"]}\r\n执行失败的配置文件: {results["error"]}\r\n' \
f'触发原神验证码的配置文件: {results["captcha"]} '
log.info(push_message)
status = 0
if len(results["error"]) == len(config_list):
status = 1
elif len(results["error"]) != 0:
status = 2
elif len(results["captcha"]) != 0:
status = 3
push.push(status, push_message)
if __name__ == "__main__":
if (len(sys.argv) >= 2 and sys.argv[1] == "autorun") or os.getenv("AutoMihoyoBBS_autorun") == "1":
autorun = True
else:
autorun = False
main_multi(autorun)
exit(0)
pass