From f73f37aa32bff9600e95fd44c45ef58857afeabe Mon Sep 17 00:00:00 2001 From: Cinte Date: Sat, 2 Sep 2023 12:31:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B6=85=E8=BF=87?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=E4=BA=8E=E5=AD=97=E6=95=B0=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_bottle/__init__.py | 12 ++++++++---- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/nonebot_plugin_bottle/__init__.py b/nonebot_plugin_bottle/__init__.py index fc2e70b..3620070 100644 --- a/nonebot_plugin_bottle/__init__.py +++ b/nonebot_plugin_bottle/__init__.py @@ -200,11 +200,15 @@ async def _( if "__has_content__" not in state and message_text in cancel: await throw.finish("已取消扔漂流瓶操作。") - if maxlen != 0 and len(message_text) > maxlen: - await throw.finish("您漂流瓶的内容中,字符数量超出最大字符限制:"+str(maxlen)+"。您可以尝试减少漂流瓶内容。\n当前字符数量:"+len(message_text)) + if maxlen != 0 and ((msg_len := len(message_text)) > maxlen): + await throw.finish( + f"您漂流瓶的内容中,字符数量超出最大字符限制:{maxlen}。您可以尝试减少漂流瓶内容。\n当前字符数量:{msg_len}" + ) ba.add("cooldown", event.user_id) - if maxrt != 0 and message_text.count('\n') > maxrt: - await throw.finish("您漂流瓶的内容中,换行数量超出了最大换行限制。您可尝试减少换行数量。\n当前换行数量:"+message_text.count('\n')) + if maxrt != 0 and ((rt_cnt := message_text.count("\n")) > maxrt): + await throw.finish( + f"您漂流瓶的内容中,换行数量超出了最大换行限制:{maxrt}。您可尝试减少换行数量。\n当前换行数量:{rt_cnt}" + ) ba.add("cooldown", event.user_id) audit = await text_audit(text=message_text) if not audit == "pass": diff --git a/pyproject.toml b/pyproject.toml index a97074f..8b612db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nonebot_plugin_bottle" -version = "1.0.1.6" +version = "1.0.1.7" description = "Bottle post plugin in Nonebot" authors = ["Todysheep "] license = "GNU GPLv3"