Multi-account

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

45
main.py
View File

@ -21,7 +21,14 @@ sentry_sdk.init(
) )
# Running in Github Action, use this to get the config # 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 # Options
sct_status = os.environ.get('sct') # https://sct.ftqq.com/ sct_status = os.environ.get('sct') # https://sct.ftqq.com/
@ -35,25 +42,33 @@ class RunError(Exception):
pass pass
token = config['token']
client_type = config['type']
try: try:
ver_info = r.get('https://sdk-static.mihoyo.com/hk4e_cn/mdk/launcher/api/resource?key=eYd89JmJ&launcher_id=18', timeout=60).text 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'] version = json.loads(ver_info)['data']['game']['latest']['version']
print(f'从官方API获取到云·原神最新版本号{version}') print(f'从官方API获取到云·原神最新版本号{version}')
except: except:
version = config['version'] 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'
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'] android = config['android']
deviceid = config['deviceid'] deviceid = config['deviceid']
devicename = config['devicename'] devicename = config['devicename']
devicemodel = config['devicemodel'] devicemodel = config['devicemodel']
appid = config['appid'] appid = config['appid']
if token == '' or android == 0 or deviceid == '' or devicemodel == '' or appid == 0:
bbsid = re.findall(r'oi=[0-9]+', token)[0].replace('oi=', '') raise RunError(f'请确认您的配置文件配置正确再运行本程序!')
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 = { headers = {
'x-rpc-combo_token': token, 'x-rpc-combo_token': token,
'x-rpc-client_type': str(client_type), 'x-rpc-client_type': str(client_type),
@ -70,15 +85,7 @@ headers = {
'Accept-Encoding': 'gzip', 'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/4.9.0' 'User-Agent': 'okhttp/4.9.0'
} }
bbsid = re.findall(r'oi=[0-9]+', token)[0].replace('oi=', '')
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'请确认您的配置文件配置正确再运行本程序!')
wait_time = random.randint(1, 3600) # Random Sleep to Avoid Ban wait_time = random.randint(1, 3600) # Random Sleep to Avoid Ban
print(f'为了避免同一时间签到人数太多导致被官方怀疑,开始休眠 {wait_time}') print(f'为了避免同一时间签到人数太多导致被官方怀疑,开始休眠 {wait_time}')
time.sleep(wait_time) time.sleep(wait_time)