text stringlengths 1 93.6k |
|---|
# If not found in environment, try to read from config.yml
|
try:
|
with open("config.yml", "r", encoding="utf-8") as config_file:
|
config_data = yaml.load(config_file, Loader=yaml.FullLoader)
|
return config_data
|
except FileNotFoundError:
|
return default_value
|
sentry_sdk.init(
|
"https://425d7b4536f94c9fa540fe34dd6609a2@o361988.ingest.sentry.io/6352584",
|
traces_sample_rate=1.0,
|
)
|
conf = ReadConf("MHYY_CONFIG")["accounts"]
|
if not conf:
|
logger.error("请正确配置环境变量或者config.yml后再运行本脚本!")
|
os._exit(0)
|
logger.info(f"检测到 {len(conf)} 个账号,正在进行任务……")
|
# Options
|
sct_status = os.environ.get("sct") # https://sct.ftqq.com/
|
sct_key = os.environ.get("sct_key")
|
sct_url = f"https://sctapi.ftqq.com/{sct_key}.send?title=MHYY-AutoCheckin 自动推送"
|
sct_msg = ""
|
class RunError(Exception):
|
pass
|
if __name__ == "__main__":
|
if not os.environ.get("MHYY_DEBUG", False):
|
wait_time = random.randint(10, 60) # Random Sleep to Avoid Ban
|
logger.info(f"为了避免同一时间签到人数太多导致被官方怀疑,开始休眠 {wait_time} 秒")
|
time.sleep(wait_time)
|
try:
|
ver_info = httpx.get(
|
"https://hyp-api.mihoyo.com/hyp/hyp-connect/api/getGameBranches?game_ids[]=1Z8W5NHUQb&launcher_id=jGHBHlcOq1",
|
timeout=60,
|
verify=False,
|
).text
|
version = json.loads(ver_info)["data"]["game_branches"][0]["main"]["tag"]
|
logger.info(f"从官方API获取到云·原神最新版本号:{version}")
|
except Exception as e:
|
version = "5.0.0"
|
logger.warning(f"获取版本号失败,使用默认版本:{version}")
|
for config in conf:
|
# 各种API的URL
|
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 config == "":
|
# Verify config
|
raise RunError(
|
f"请在Settings->Secrets->Actions页面中新建名为config的变量,并将你的配置填入后再运行!"
|
)
|
else:
|
token = config["token"]
|
client_type = config["type"]
|
sysver = config["sysver"]
|
deviceid = config["deviceid"]
|
devicename = config["devicename"]
|
devicemodel = config["devicemodel"]
|
appid = config["appid"]
|
headers = {
|
"x-rpc-combo_token": token,
|
"x-rpc-client_type": str(client_type),
|
"x-rpc-app_version": str(version),
|
"x-rpc-sys_version": str(sysver),
|
"x-rpc-channel": "cyydmihoyo",
|
"x-rpc-device_id": deviceid,
|
"x-rpc-device_name": devicename,
|
"x-rpc-device_model": devicemodel,
|
"x-rpc-vendor_id": "1",
|
"x-rpc-cg_game_biz": "hk4e_cn",
|
"x-rpc-op_biz": "clgm_cn",
|
"x-rpc-language": "zh-cn",
|
"Host": "api-cloudgame.mihoyo.com",
|
"Connection": "Keep-Alive",
|
"Accept-Encoding": "gzip",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0",
|
}
|
bbsid = re.findall(r"oi=[0-9]+", token)[0].replace("oi=", "")
|
region = config.get("region", "cn")
|
if region == "os":
|
headers["x-rpc-channel"] = "mihoyo"
|
headers["x-rpc-cg_game_biz"] = "hk4e_global"
|
headers["x-rpc-op_biz"] = "clgm_global"
|
headers["x-rpc-cg_game_id"] = "9000254"
|
headers["x-rpc-app_id"] = "600493"
|
headers["User-Agent"] = "okhttp/4.10.0"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.