From 1fca0787bec87b5c82e1248808f21b7e9c0ffa28 Mon Sep 17 00:00:00 2001 From: Cinte Date: Wed, 15 Jun 2022 23:16:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=AD=A3=E5=88=99=E5=BC=95=E5=85=A5=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 --- plugins/word_bank/word_hanlde.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/word_bank/word_hanlde.py b/plugins/word_bank/word_hanlde.py index c58784b3..10ec5ee2 100644 --- a/plugins/word_bank/word_hanlde.py +++ b/plugins/word_bank/word_hanlde.py @@ -293,7 +293,7 @@ async def get__builder(event, _problem, answer, idx): if f"__placeholder_{rand}_{idx}.jpg" not in os.listdir(data_dir / f"{event.group_id}"): break rand = random.randint(1, 10000) + random.randint(1, 114514) - strinfo = re.compile(f"\[CQ:image,file={r.group(1)},.*url={_x_list[0]}\?{_x_list[1]}.*\]") + strinfo = re.compile(f"\[CQ:image,file={r.group(1)},.*url={_x_list[0]}\?{_x_list[1]}.*?]") answer = strinfo.sub(f"[__placeholder_{idx}]", answer) await AsyncHttpx.download_file( img, data_dir / f"{event.group_id}" / f"__placeholder_{rand}_{idx}.jpg" From 0e8d7537d4e47a0b12d5836163bc9ee1678513f4 Mon Sep 17 00:00:00 2001 From: LambdaYH Date: Thu, 16 Jun 2022 00:43:32 +0800 Subject: [PATCH 2/2] fix wordbank --- plugins/word_bank/_rule.py | 2 +- plugins/word_bank/message_handle.py | 2 +- plugins/word_bank/word_hanlde.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/word_bank/_rule.py b/plugins/word_bank/_rule.py index 043289c1..fc6e7a6a 100644 --- a/plugins/word_bank/_rule.py +++ b/plugins/word_bank/_rule.py @@ -12,7 +12,7 @@ async def check(bot: Bot, event: Event, state: T_State) -> bool: list_img = get_message_img_file(event.json()) if list_img: for img_file in list_img: - strinfo = re.compile(f"{img_file},subType=\d*]") + strinfo = re.compile(f"{img_file},.*?]") msg = strinfo.sub(f'{img_file}]', msg) return bool( await WordBank.check(event.group_id, msg, event.is_tome()) diff --git a/plugins/word_bank/message_handle.py b/plugins/word_bank/message_handle.py index 09958210..92c838c2 100644 --- a/plugins/word_bank/message_handle.py +++ b/plugins/word_bank/message_handle.py @@ -23,7 +23,7 @@ async def _(event: GroupMessageEvent): list_img = get_message_img_file(event.json()) if list_img: for img_file in list_img: - strinfo = re.compile(f"{img_file},subType=\d*]") + strinfo = re.compile(f"{img_file},.*?]") msg = strinfo.sub(f'{img_file}]', msg) q = await WordBank.check( event.group_id, msg, event.is_tome() diff --git a/plugins/word_bank/word_hanlde.py b/plugins/word_bank/word_hanlde.py index 10ec5ee2..17d4e7b3 100644 --- a/plugins/word_bank/word_hanlde.py +++ b/plugins/word_bank/word_hanlde.py @@ -300,9 +300,9 @@ async def get__builder(event, _problem, answer, idx): ) _builder.set_placeholder(idx, f"__placeholder_{rand}_{idx}.jpg") idx += 1 - r_problem = re.search(rf"\[CQ:image,file=(.*?),url={_x}.*?]", _p) + r_problem = re.search(rf"\[CQ:image,file=(.*?)(,subType=\d)?,url={_x}.*?]", _p) if r_problem: - strinfo = re.compile(f",url={_x_list[0]}\?{_x_list[1]},subType=\d*?]") + strinfo = re.compile(f"(,subType=\d)?,url={_x_list[0]}\?{_x_list[1]}.*?]") _problem = strinfo.sub(f"]", _problem) _p = strinfo.sub(f"]", _p) problem += _p[: _p.find(f"[CQ:image,file={r_problem.group(1)}]")] + image(img)