From 8838923ea188a5462b4bbeecd6ab181a81d85fce Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Thu, 1 Sep 2022 08:29:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89ua=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools.py b/tools.py index 3527e60..1f83e28 100644 --- a/tools.py +++ b/tools.py @@ -50,6 +50,7 @@ def get_ds2(q: str, b: str) -> str: def get_device_id() -> str: return str(uuid.uuid3(uuid.NAMESPACE_URL, config.config["account"]["cookie"])) + # 获取签到的奖励名称 def get_item(raw_data: dict) -> str: temp_name = raw_data["name"] @@ -64,6 +65,18 @@ def next_day() -> int: return next_day_time +# 获取ua 防止出现多个miHoYoBBS +def get_useragent() -> str: + if config.config["games"]["cn"]["useragent"] == "": # 没设置自定义ua就返回默认ua + return setting.headers['User-Agent'] + if "miHoYoBBS" in config.config["games"]["cn"]["useragent"]: # 防止出现多个miHoYoBBS + i = config.config["games"]["cn"]["useragent"].index("miHoYoBBS") + if config.config["games"]["cn"]["useragent"][i - 1] == " ": + i = i-1 + return f'{config.config["games"]["cn"]["useragent"][:i]} miHoYoBBS/{setting.mihoyobbs_Version}' + return f'{config.config["games"]["cn"]["useragent"]} miHoYoBBS/{setting.mihoyobbs_Version}' + + # 获取Openssl版本 def get_openssl_version() -> int: try: