From a25c900d49f40062f129a9abe7b5cf10f5cc6706 Mon Sep 17 00:00:00 2001 From: snowy Date: Sun, 2 Jun 2024 01:41:46 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=99=BA=E9=9A=9C=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=8A=9F=E8=83=BD=E6=94=AF=E6=8C=81=E5=88=87=E6=96=AD?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_smart_reply/matchers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/liteyuki/plugins/liteyuki_smart_reply/matchers.py b/liteyuki/plugins/liteyuki_smart_reply/matchers.py index bf2f7b0e..ad50b201 100644 --- a/liteyuki/plugins/liteyuki_smart_reply/matchers.py +++ b/liteyuki/plugins/liteyuki_smart_reply/matchers.py @@ -22,6 +22,7 @@ driver = get_driver() group_reply_probability: dict[str, float] = { } default_reply_probability = 0.05 +cut_probability = 0.4 # 分几句话的概率 @on_alconna( @@ -79,7 +80,14 @@ async def _(event: T_MessageEvent, bot: Bot, state: T_State, matcher: Matcher): p = group_reply_probability.get(event.group_id, default_reply_probability) if random.random() < p: - await asyncio.sleep(random.random() * 2) if reply := get_reply(kws): - await matcher.send(reply) + reply = reply.replace("。", "||").replace(",", "||").replace("!", "||").replace("?", "||") + if random.random() < cut_probability: + replies = reply.split("||") + for r in replies: + await asyncio.sleep(random.random() * 2) + await matcher.send(r) + else: + await asyncio.sleep(random.random() * 3) + await matcher.send(reply) return