Skip to content

Commit

Permalink
fix: 修复超过换行于字数限制的提示
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdaYH committed Sep 2, 2023
1 parent 06c740c commit f73f37a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions nonebot_plugin_bottle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "GNU GPLv3"
Expand Down

0 comments on commit f73f37a

Please sign in to comment.