diff --git a/src/ai_chat/config/example.chat_ai.yaml b/src/ai_chat/config/example.chat_ai.yaml new file mode 100644 index 0000000..94fcb8f --- /dev/null +++ b/src/ai_chat/config/example.chat_ai.yaml @@ -0,0 +1,4 @@ +chat_ai: + url: "" + key: "" + active: "False" # True为启动ai功能,False为关闭功能 \ No newline at end of file diff --git a/src/ai_chat/config/example.openai.yaml b/src/ai_chat/config/example.openai.yaml deleted file mode 100644 index 2e6ca53..0000000 --- a/src/ai_chat/config/example.openai.yaml +++ /dev/null @@ -1,3 +0,0 @@ -chat_ai: - url: "" - key: "" \ No newline at end of file diff --git a/src/qq_plugins/check.py b/src/qq_plugins/check.py index 698ecd3..7c9ce19 100644 --- a/src/qq_plugins/check.py +++ b/src/qq_plugins/check.py @@ -5,8 +5,10 @@ from nonebot import on_message from nonebot.adapters.qq import Message from nonebot.adapters import Bot, Event from src.ai_chat import ai_chat +import os +import yaml -menu = ['/今日运势','/天气','/图','/点歌','/摸摸头','/群老婆','/今日老婆', '/待办', '/test', '我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办"] +menu = ['/今日运势','/天气','/图','/点歌','/摸摸头','/群老婆','/今日老婆', '/待办', '/test', '我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办", "/openai"] async def check_value_in_menu(event: Event) -> bool: value = event.get_plaintext().strip().split(" ") if value[0] in menu: @@ -15,6 +17,8 @@ async def check_value_in_menu(event: Event) -> bool: return True rule = Rule(check_value_in_menu) +with open(os.getcwd() +'/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f: + is_ai = yaml.load(f.read(), Loader=yaml.FullLoader).get('chat_ai').get('active') check = on_message(rule=to_me() & rule ,block=True) @check.handle() @@ -22,8 +26,10 @@ async def check(bot: Bot, event: Event): print(event.get_plaintext()) msg = ai_chat.gpt(event.get_plaintext()) print(msg) - await bot.send(message=msg,event=event) - # await bot.send(message=Message(random.choice(text_list)),event=event) + if is_ai == "True": + await bot.send(message=msg,event=event) + else: + await bot.send(message=Message(random.choice(text_list)),event=event) text_list = [ "是什么呢?猫猫没有识别到,喵~"+'\n'+"(๑>ڡ<)☆ 给个准信,别让我瞎猜",