From c9d2ef78853bd141f72aab11cb70496839979349 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Sat, 29 Mar 2025 12:53:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=8C=96=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=A4=B8=E8=B5=9E=E5=90=8D=E5=8D=95=E4=B8=8E=E6=98=B5=E7=A7=B0?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nonebot_plugin_marshoai/util.py b/nonebot_plugin_marshoai/util.py index 6fd384b..9d69efa 100755 --- a/nonebot_plugin_marshoai/util.py +++ b/nonebot_plugin_marshoai/util.py @@ -143,7 +143,7 @@ async def get_praises(): ) # 夸赞名单文件使用localstore存储 if not praises_file.exists(): async with aiofiles.open(praises_file, "w", encoding="utf-8") as f: - json.dump(_praises_init_data, f, ensure_ascii=False, indent=4) + await f.write(json.dumps(_praises_init_data, ensure_ascii=False, indent=4)) async with aiofiles.open(praises_file, "r", encoding="utf-8") as f: data = json.loads(await f.read()) praises_json = data @@ -214,8 +214,8 @@ async def set_nickname(user_id: str, name: str): data[user_id] = name if name == "" and user_id in data: del data[user_id] - with open(filename, "w", encoding="utf-8") as f: - json.dump(data, f, ensure_ascii=False, indent=4) + async with aiofiles.open(filename, "w", encoding="utf-8") as f: + await f.write(json.dumps(data, ensure_ascii=False, indent=4)) return data