Skip to content
This repository was archived by the owner on May 4, 2025. It is now read-only.

Commit c9d2ef7

Browse files
committed
异步化获取夸赞名单与昵称函数
1 parent ff6369c commit c9d2ef7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nonebot_plugin_marshoai/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async def get_praises():
143143
) # 夸赞名单文件使用localstore存储
144144
if not praises_file.exists():
145145
async with aiofiles.open(praises_file, "w", encoding="utf-8") as f:
146-
json.dump(_praises_init_data, f, ensure_ascii=False, indent=4)
146+
await f.write(json.dumps(_praises_init_data, ensure_ascii=False, indent=4))
147147
async with aiofiles.open(praises_file, "r", encoding="utf-8") as f:
148148
data = json.loads(await f.read())
149149
praises_json = data
@@ -214,8 +214,8 @@ async def set_nickname(user_id: str, name: str):
214214
data[user_id] = name
215215
if name == "" and user_id in data:
216216
del data[user_id]
217-
with open(filename, "w", encoding="utf-8") as f:
218-
json.dump(data, f, ensure_ascii=False, indent=4)
217+
async with aiofiles.open(filename, "w", encoding="utf-8") as f:
218+
await f.write(json.dumps(data, ensure_ascii=False, indent=4))
219219
return data
220220

221221

0 commit comments

Comments
 (0)