forked from bot/app
✨ 智障回复功能支持切断回复
This commit is contained in:
parent
206651da94
commit
a25c900d49
@ -22,6 +22,7 @@ driver = get_driver()
|
|||||||
group_reply_probability: dict[str, float] = {
|
group_reply_probability: dict[str, float] = {
|
||||||
}
|
}
|
||||||
default_reply_probability = 0.05
|
default_reply_probability = 0.05
|
||||||
|
cut_probability = 0.4 # 分几句话的概率
|
||||||
|
|
||||||
|
|
||||||
@on_alconna(
|
@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)
|
p = group_reply_probability.get(event.group_id, default_reply_probability)
|
||||||
|
|
||||||
if random.random() < p:
|
if random.random() < p:
|
||||||
await asyncio.sleep(random.random() * 2)
|
|
||||||
if reply := get_reply(kws):
|
if reply := get_reply(kws):
|
||||||
|
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)
|
await matcher.send(reply)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user