Multi-account

This commit is contained in:
Pesy Wu 2023-05-19 07:05:25 +00:00
parent 4430f02341
commit 221952a2e0

51
main.py
View File

@ -21,7 +21,14 @@ sentry_sdk.init(
)
# Running in Github Action, use this to get the config
config = json.loads(os.environ.get('config'))
conf = json.loads(os.environ.get('config'))
if type(conf) == type(list()):
pass
elif type(conf) == type(dict()):
ls = []
ls.append(conf)
conf = ls
# Options
sct_status = os.environ.get('sct') # https://sct.ftqq.com/
@ -35,26 +42,34 @@ class RunError(Exception):
pass
token = config['token']
client_type = config['type']
try:
ver_info = r.get('https://sdk-static.mihoyo.com/hk4e_cn/mdk/launcher/api/resource?key=eYd89JmJ&launcher_id=18', timeout=60).text
version = json.loads(ver_info)['data']['game']['latest']['version']
print(f'从官方API获取到云·原神最新版本号{version}')
except:
version = config['version']
android = config['android']
deviceid = config['deviceid']
devicename = config['devicename']
devicemodel = config['devicemodel']
appid = config['appid']
bbsid = re.findall(r'oi=[0-9]+', token)[0].replace('oi=', '')
version = '3.8.0'
NotificationURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/listNotifications?status=NotificationStatusUnread&type=NotificationTypePopup&is_sort=true'
WalletURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/wallet/wallet/get'
AnnouncementURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/getAnnouncementInfo'
headers = {
if __name__ == '__main__':
for config in conf:
if config == '':
# Verify config
raise RunError(
f"请在Settings->Secrets->Actions页面中新建名为config的变量并将你的配置填入后再运行")
else:
token = config['token']
client_type = config['type']
android = config['android']
deviceid = config['deviceid']
devicename = config['devicename']
devicemodel = config['devicemodel']
appid = config['appid']
if token == '' or android == 0 or deviceid == '' or devicemodel == '' or appid == 0:
raise RunError(f'请确认您的配置文件配置正确再运行本程序!')
headers = {
'x-rpc-combo_token': token,
'x-rpc-client_type': str(client_type),
'x-rpc-app_version': str(version),
@ -69,16 +84,8 @@ headers = {
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/4.9.0'
}
if __name__ == '__main__':
if config == '':
# Verify config
raise RunError(
f"请在Settings->Secrets->Actions页面中新建名为config的变量并将你的配置填入后再运行")
else:
if token == '' or android == 0 or deviceid == '' or devicemodel == '' or appid == 0:
raise RunError(f'请确认您的配置文件配置正确再运行本程序!')
}
bbsid = re.findall(r'oi=[0-9]+', token)[0].replace('oi=', '')
wait_time = random.randint(1, 3600) # Random Sleep to Avoid Ban
print(f'为了避免同一时间签到人数太多导致被官方怀疑,开始休眠 {wait_time}')
time.sleep(wait_time)