From 6a64c1ffd60512c178059c9ea64cf954890b1b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 2 Dec 2022 20:28:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=84=E7=90=86{name}?= =?UTF-8?q?=E5=92=8C{segment}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/thesaurus/chat.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index f5886e61..00e78571 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -6,8 +6,10 @@ import ( "io" "io/fs" "math/rand" + "strings" "github.com/FloatTech/floatbox/ctxext" + "github.com/FloatTech/floatbox/process" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/fumiama/jieba" @@ -192,6 +194,11 @@ func randreply(m map[string][]string) zero.Handler { key := ctx.State["matched"].(string) val := m[key] text := val[rand.Intn(len(val))] - ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) + text = strings.ReplaceAll(text, "{name}", ctx.CardOrNickName(ctx.Event.UserID)) + id := ctx.Event.MessageID + for _, t := range strings.Split(text, "{segment}") { + process.SleepAbout1sTo2s() + id = ctx.SendChain(message.Reply(id), message.Text(t)) + } } }