From bef37901279e1f2baa004d184bcf6c4f471ee2e6 Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Sat, 18 Jan 2025 02:39:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/qq_plugins/check.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/qq_plugins/check.py b/src/qq_plugins/check.py index 1c724fb..b41c8b6 100644 --- a/src/qq_plugins/check.py +++ b/src/qq_plugins/check.py @@ -22,6 +22,22 @@ async def check_value_in_menu(event: Event) -> bool: else: return True + +def change_chatai_yaml_availability_to(is_available): + with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f1: + dic_temp = yaml.load(f1, Loader=yaml.FullLoader) + dic_temp['chat_ai']['active'] = is_available + with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'w', encoding='utf-8') as f1: + yaml.dump(dic_temp, f1) + print(dic_temp) + f1.close() + +def is_ai(): + with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f: + state = yaml.load(f.read(), Loader=yaml.FullLoader).get('chat_ai').get('active') + return state + + rule = Rule(check_value_in_menu) @@ -78,16 +94,3 @@ async def change_ai_availability(message: MessageEvent): await ai_is_available.finish("成功开启语言模型对话功能。一起来聊天吧~") -def change_chatai_yaml_availability_to(is_available): - with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f1: - dic_temp = yaml.load(f1, Loader=yaml.FullLoader) - dic_temp['chat_ai']['active'] = is_available - with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'w', encoding='utf-8') as f1: - yaml.dump(dic_temp, f1) - print(dic_temp) - f1.close() - -def is_ai(): - with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f: - state = yaml.load(f.read(), Loader=yaml.FullLoader).get('chat_ai').get('active') - return state \ No newline at end of file