diff --git a/.gitignore b/.gitignore index e76bf87..14d737c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ chat_history.json /chat_bot.db-wal /chat_bot.db-shm error.log -.log \ No newline at end of file +*.log +.mp4 \ No newline at end of file diff --git a/src/qq_plugins/check.py b/src/qq_plugins/check.py index a1d859c..10923ce 100644 --- a/src/qq_plugins/check.py +++ b/src/qq_plugins/check.py @@ -20,7 +20,7 @@ with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8 menu = ['/今日运势','/图','/点歌','/摸摸头','/群老婆','/今日老婆', "/开启ai","/关闭ai","/角色列表","/添加人设", "/更新人设", "/删除人设", "/切换人设", "/管理员注册", - '/待办', '/test','/天气','我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf", "/奶龙", "/repo", "/info", "/B站搜索", "/BV搜索"] + '/待办', '/test','/天气','我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf", "/奶龙", "/repo", "/info", "/B站搜索", "/BV搜索", "/喜报", "/悲报"] async def check_value_in_menu(message: MessageEvent) -> bool: diff --git a/src/qq_plugins/good_bad_news.py b/src/qq_plugins/good_bad_news.py new file mode 100644 index 0000000..21e998f --- /dev/null +++ b/src/qq_plugins/good_bad_news.py @@ -0,0 +1,37 @@ +from pathlib import Path +from nonebot.rule import to_me +from nonebot.plugin import on_command +from nonebot.adapters.qq import Message, MessageEvent, MessageSegment +import urllib.parse, requests +import httpx + +good_news = on_command("喜报", rule=to_me(), priority=10, block=True, aliases={"悲报"}) +@good_news.handle() +async def good_news_img(message: MessageEvent): + if message.get_plaintext().startswith("/喜报"): + content = message.get_plaintext().replace("/喜报", "").strip() + url = "https://cdn.uuuix.com/api/v1/xbs/xb.php?" + else: + content = message.get_plaintext().replace("/悲报", "").strip() + url = "https://cdn.uuuix.com/api/v1/xbs/biob.php?" + + params = { + 'msg': content + } + + await good_news.send("图片绘制中,请稍后~\n技术支持: JianDan大佬\nwww·uuuix·com") + + query = urllib.parse.urlencode(params) + response = requests.get(url + query).json() + + if response['code'] != 1: + await good_news.finish("请输入 /喜(悲)报+内容 哦。") + + img_url = response['url'] + # try: + # await good_news.finish(MessageSegment.image(img_url)) + # except BaseException: + # await good_news.finish("出错啦,请重试。") + + await good_news.finish(MessageSegment.image(img_url)) +