From ed65033cf1c1c2923f643825012b9f60e928bd69 Mon Sep 17 00:00:00 2001 From: jk6589jk <30636113+jk6589jk@users.noreply.github.com> Date: Mon, 23 May 2022 22:06:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=8D=E8=AF=BB?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=A4=8D=E8=AF=BB=E5=9B=BE=E7=89=87=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IMAGE_PATH = Path() / "resources" / "image" TEMP_PATH = Path() / "resources" / "temp" image()默认读取在 resource/img 目录下,读写路径不同,导致找不到图片 打断打断施法!,rst.endswith("打断施法!")在复读内容含有图片时会报错 --- plugins/fudu.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/fudu.py b/plugins/fudu.py index 031eafcd0..f548d4b2f 100755 --- a/plugins/fudu.py +++ b/plugins/fudu.py @@ -1,5 +1,5 @@ from nonebot.adapters.onebot.v11.permission import GROUP -from configs.path_config import TEMP_PATH +from configs.path_config import IMAGE_PATH from utils.image_utils import get_img_hash import random from utils.message_builder import image @@ -106,7 +106,10 @@ async def _(event: GroupMessageEvent): "fudu", "FUDU_PROBABILITY" ) and not _fudu_list.is_repeater(event.group_id): if random.random() < 0.2: - await fudu.finish("[[_task|fudu]]打断施法!") + if msg.endswith("打断施法!"): + await fudu.finish("[[_task|fudu]]打断" + msg) + else: + await fudu.finish("[[_task|fudu]]打断施法!") _fudu_list.set_repeater(event.group_id) if img and msg: rst = msg + image(f"compare_{event.group_id}_img.jpg", "temp") @@ -117,17 +120,15 @@ async def _(event: GroupMessageEvent): else: rst = "" if rst: - if rst.endswith("打断施法!"): - rst = "打断" + rst - await fudu.send("[[_task|fudu]]" + rst) + await fudu.finish("[[_task|fudu]]" + rst) async def get_fudu_img_hash(url, group_id): try: if await AsyncHttpx.download_file( - url, TEMP_PATH / f"compare_{group_id}_img.jpg" + url, IMAGE_PATH / "temp" / f"compare_{group_id}_img.jpg" ): - img_hash = get_img_hash(TEMP_PATH / f"compare_{group_id}_img.jpg") + img_hash = get_img_hash(IMAGE_PATH / "temp" / f"compare_{group_id}_img.jpg") return str(img_hash) else: logger.warning(f"复读下载图片失败...") From 9c8f2e7aa0c6fe5f5130466e28c0da65dc2095a9 Mon Sep 17 00:00:00 2001 From: jk6589jk <30636113+jk6589jk@users.noreply.github.com> Date: Tue, 24 May 2022 14:01:08 +0800 Subject: [PATCH 2/2] Update fudu.py --- plugins/fudu.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/fudu.py b/plugins/fudu.py index f548d4b2f..0de3d20f2 100755 --- a/plugins/fudu.py +++ b/plugins/fudu.py @@ -1,5 +1,5 @@ from nonebot.adapters.onebot.v11.permission import GROUP -from configs.path_config import IMAGE_PATH +from configs.path_config import TEMP_PATH from utils.image_utils import get_img_hash import random from utils.message_builder import image @@ -112,9 +112,9 @@ async def _(event: GroupMessageEvent): await fudu.finish("[[_task|fudu]]打断施法!") _fudu_list.set_repeater(event.group_id) if img and msg: - rst = msg + image(f"compare_{event.group_id}_img.jpg", "temp") + rst = msg + image(TEMP_PATH / f"compare_{event.group_id}_img.jpg") elif img: - rst = image(f"compare_{event.group_id}_img.jpg", "temp") + rst = image(TEMP_PATH / f"compare_{event.group_id}_img.jpg") elif msg: rst = msg else: @@ -126,9 +126,9 @@ async def _(event: GroupMessageEvent): async def get_fudu_img_hash(url, group_id): try: if await AsyncHttpx.download_file( - url, IMAGE_PATH / "temp" / f"compare_{group_id}_img.jpg" + url, TEMP_PATH / f"compare_{group_id}_img.jpg" ): - img_hash = get_img_hash(IMAGE_PATH / "temp" / f"compare_{group_id}_img.jpg") + img_hash = get_img_hash(TEMP_PATH / f"compare_{group_id}_img.jpg") return str(img_hash) else: logger.warning(f"复读下载图片失败...")