From 311178189f89e24be658553a499e1d4ab7c537ed Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 25 Nov 2023 20:09:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9C=AA=E6=9C=9F?= =?UTF-8?q?=E6=9C=9B=E7=9A=84QQ=E7=BE=A4BOT=E5=90=AF=E5=8A=A8=E5=92=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6BOM=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 2 +- util/cmd_config.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 61474e52c..0c8345f81 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -372,7 +372,7 @@ def initBot(cfg, prov): global qq_bot, qqbot_loop qqbot_loop = asyncio.new_event_loop() - if cc.get("qqbot_appid", None) is not None and cc.get("qqbot_secret", None) is not None: + if cc.get("qqbot_appid", '') != '' and cc.get("qqbot_secret", '') != '': gu.log("- 启用QQ群机器人 -", gu.LEVEL_INFO) thread_inst = threading.Thread(target=run_qqbot, args=(qqbot_loop, qq_bot,), daemon=False) thread_inst.start() diff --git a/util/cmd_config.py b/util/cmd_config.py index 0312505ee..03d81c43c 100644 --- a/util/cmd_config.py +++ b/util/cmd_config.py @@ -5,7 +5,7 @@ cpath = "cmd_config.json" def check_exist(): if not os.path.exists(cpath): - with open(cpath, "w", encoding="utf-8") as f: + with open(cpath, "w", encoding="utf-8-sig") as f: json.dump({}, f, indent=4, ensure_ascii=False) f.flush() @@ -14,7 +14,7 @@ class CmdConfig(): @staticmethod def get(key, default=None): check_exist() - with open(cpath, "r", encoding="utf-8") as f: + with open(cpath, "r", encoding="utf-8-sig") as f: d = json.load(f) if key in d: return d[key] @@ -24,16 +24,16 @@ class CmdConfig(): @staticmethod def get_all(): check_exist() - with open(cpath, "r", encoding="utf-8") as f: + with open(cpath, "r", encoding="utf-8-sig") as f: return json.load(f) @staticmethod def put(key, value): check_exist() - with open(cpath, "r", encoding="utf-8") as f: + with open(cpath, "r", encoding="utf-8-sig") as f: d = json.load(f) d[key] = value - with open(cpath, "w", encoding="utf-8") as f: + with open(cpath, "w", encoding="utf-8-sig") as f: json.dump(d, f, indent=4, ensure_ascii=False) f.flush() @@ -41,7 +41,7 @@ class CmdConfig(): def init_attributes(keys: list, init_val = ""): check_exist() conf_str = '' - with open(cpath, "r", encoding="utf-8") as f: + with open(cpath, "r", encoding="utf-8-sig") as f: conf_str = f.read() if conf_str.startswith(u'/ufeff'): conf_str = conf_str.encode('utf8')[3:].decode('utf8') @@ -52,6 +52,6 @@ class CmdConfig(): d[k] = init_val _tag = True if _tag: - with open(cpath, "w", encoding="utf-8") as f: + with open(cpath, "w", encoding="utf-8-sig") as f: json.dump(d, f, indent=4, ensure_ascii=False) f.flush() \ No newline at end of file