2025-01-17 20:06:31 +00:00
|
|
|
import os
|
2025-01-23 17:32:46 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
2025-01-17 20:06:31 +00:00
|
|
|
import yaml
|
2025-01-14 16:28:26 +00:00
|
|
|
import random
|
2025-01-14 07:09:00 +00:00
|
|
|
from nonebot import on_message
|
2025-01-17 20:06:31 +00:00
|
|
|
from nonebot.rule import Rule, to_me
|
|
|
|
|
from nonebot.plugin import on_command, on_keyword
|
2025-01-23 17:32:46 +00:00
|
|
|
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment
|
2025-01-16 14:40:22 +00:00
|
|
|
from src.ai_chat import ai_chat
|
2025-01-22 03:25:47 +00:00
|
|
|
from src.my_sqlite.models.chat import GroupChatRole
|
2025-01-14 07:09:00 +00:00
|
|
|
|
2025-01-19 07:22:46 +00:00
|
|
|
with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f1:
|
|
|
|
|
chat = yaml.load(f1, Loader=yaml.FullLoader).get('chat_ai')
|
|
|
|
|
admin_password = chat.get('admin_password')
|
2025-01-17 17:51:23 +00:00
|
|
|
|
2025-01-19 07:22:46 +00:00
|
|
|
|
2025-01-22 03:25:47 +00:00
|
|
|
menu = ['/今日运势','/图','/点歌','/摸摸头','/群老婆','/今日老婆', "/开启ai","/关闭ai","/角色列表","/添加人设", "/更新人设", "/删除人设", "/切换人设", "/管理员注册",
|
2025-01-23 17:32:46 +00:00
|
|
|
'/待办', '/test','/天气','我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf", "/奶龙", "/repo"]
|
2025-01-22 03:25:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
async def check_value_in_menu(message: MessageEvent) -> bool:
|
|
|
|
|
value = message.get_plaintext().strip().split(" ")
|
2025-01-14 07:09:00 +00:00
|
|
|
if value[0] in menu:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
|
2025-01-17 18:39:12 +00:00
|
|
|
|
2025-01-23 17:32:46 +00:00
|
|
|
check = on_message(rule=to_me() & Rule(check_value_in_menu) ,block=True, priority=10)
|
2025-01-14 07:09:00 +00:00
|
|
|
@check.handle()
|
2025-01-22 03:25:47 +00:00
|
|
|
async def handle_function(message: MessageEvent):
|
|
|
|
|
|
|
|
|
|
member_openid, group_openid,content = message.author.id, message.group_openid,message.get_plaintext()
|
|
|
|
|
status = await GroupChatRole.is_on(group_openid)
|
|
|
|
|
if status:
|
|
|
|
|
msg = await ai_chat.deepseek_chat(group_openid,content)
|
|
|
|
|
await check.finish(msg)
|
2025-01-17 03:28:22 +00:00
|
|
|
else:
|
2025-01-22 03:25:47 +00:00
|
|
|
await check.finish(message=Message(random.choice(text_list)))
|
2025-01-14 16:28:26 +00:00
|
|
|
|
|
|
|
|
text_list = [
|
|
|
|
|
"是什么呢?猫猫没有识别到,喵~"+'\n'+"(๑>ڡ<)☆ 给个准信,别让我瞎猜",
|
|
|
|
|
"是想让我干嘛呢?猫猫一头雾水,喵~" + '\n' + "(๑•̀ㅂ•́)و✧ 直接跟我说,别这么含蓄,喵~",
|
|
|
|
|
"是啥意思呀?猫猫完全没搞懂,喵~" + '\n' + "(๑・.・๑) 别折腾我啦,说明白,喵~",
|
|
|
|
|
"是特殊信号?猫猫听不懂,喵~" + '\n' + "(๑・̀︶・́)و 下个明确指令,喵~",
|
|
|
|
|
"难道是新指令?猫猫一脸茫然,喵~" + '\n' + "(๑>ڡ<)☆ 说详细点,别这么隐晦,喵~",
|
2025-01-14 17:48:32 +00:00
|
|
|
]
|
|
|
|
|
|
2025-01-17 20:06:31 +00:00
|
|
|
|
2025-01-23 17:32:46 +00:00
|
|
|
love = on_keyword({"我喜欢你", "❤"}, rule=to_me(), priority=2, block=True)
|
2025-01-14 17:48:32 +00:00
|
|
|
@love.handle()
|
|
|
|
|
async def spread_love():
|
|
|
|
|
await love.finish("我也喜欢你。")
|
|
|
|
|
|
|
|
|
|
test = on_command("test", rule=to_me(), priority=10, block=True)
|
|
|
|
|
@test.handle()
|
|
|
|
|
async def bot_on_ready():
|
|
|
|
|
await test.finish("\nBoost & Magnum, ready fight!!!")
|
|
|
|
|
|
2025-01-23 17:32:46 +00:00
|
|
|
nai_loong = on_keyword({"奶龙"}, rule=to_me(), priority=1, block=True)
|
2025-01-23 13:50:17 +00:00
|
|
|
@nai_loong.handle()
|
|
|
|
|
async def not_nai_loong():
|
2025-01-23 17:34:52 +00:00
|
|
|
await nai_loong.finish(message=Message(random.choice(text_list_nailoong)))
|
2025-01-23 13:50:17 +00:00
|
|
|
|
2025-01-23 17:34:52 +00:00
|
|
|
text_list_nailoong = [
|
2025-01-23 13:50:17 +00:00
|
|
|
"我是?你是?😨",
|
|
|
|
|
"你才是奶龙😡",
|
|
|
|
|
"你是奶龙?🤔我是奶龙?😨你才是奶龙!😱",
|
|
|
|
|
"今夜星光闪闪✨️我爱你的心满满🤩",
|
|
|
|
|
"唐",
|
|
|
|
|
]
|
2025-01-23 17:32:46 +00:00
|
|
|
|
2025-01-23 17:34:52 +00:00
|
|
|
repository = on_command("repo", rule=to_me(), priority=10, block=True)
|
2025-01-23 17:32:46 +00:00
|
|
|
@repository.handle()
|
|
|
|
|
async def github_repo():
|
|
|
|
|
|
|
|
|
|
content = "👆三叶草bot仓库地址\n一起来搭个机器人吧😆"
|
|
|
|
|
msg = Message([
|
|
|
|
|
MessageSegment.file_image(Path("src/image/github_repo/SanYeCao-Nonebot.png")),
|
|
|
|
|
MessageSegment.text(content),
|
|
|
|
|
])
|
|
|
|
|
await repository.finish(msg)
|