From 790f5a3dbe93cbc2332f8ece208c9935f38bad53 Mon Sep 17 00:00:00 2001 From: MoeSnowyFox Date: Sun, 17 Nov 2024 02:36:03 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BF=AE=E6=AD=A3=E5=B0=91=E9=87=8F?= =?UTF-8?q?=E4=BB=A3=E7=A0=81,=20=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/azure.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nonebot_plugin_marshoai/azure.py b/nonebot_plugin_marshoai/azure.py index e534e44..8bb0176 100644 --- a/nonebot_plugin_marshoai/azure.py +++ b/nonebot_plugin_marshoai/azure.py @@ -49,7 +49,7 @@ nickname_cmd = on_alconna( Args["name?", str], ) ) -refresh_data_cmd = on_alconna("refresh_data", permission=SUPERUSER) +refresh_data_cmd = on_command("refresh_data", permission=SUPERUSER) model_name = config.marshoai_default_model context = MarshoContext() @@ -181,7 +181,11 @@ async def marsho(target: MsgTarget, event: Event, text: Optional[UniMsg] = None) await UniMessage("*此模型不支持图片处理。").send() context_msg = context.build(target.id, target.private) if not context_msg and target.id not in loaded_target_list: - context_msg = list(await load_context_from_json(f"back_up_context_{target.id}", "contexts/backup")) + if target.private: + channel_id = "private_" + target.id + else: + channel_id = "group_" + target.id + context_msg = list(await load_context_from_json(f"back_up_context_{channel_id}", "contexts/backup")) loaded_target_list.append(target.id) context_msg = [get_prompt()] + context_msg target_list.append([target.id, target.private]) @@ -253,4 +257,8 @@ async def save_context(): for target_info in target_list: target_id, target_private = target_info contexts_data = context.build(target_id, target_private)[1:] - await save_context_to_json(f"back_up_context_{target_id}", contexts_data, "contexts/backup") + if target_private: + channel_id = "private_" + target_id + else: + channel_id = "group_" + target_id + await save_context_to_json(f"back_up_context_{channel_id}", contexts_data, "contexts/backup")