mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
增加处理{name}和{segment}
This commit is contained in:
parent
3b1ad2250f
commit
6a64c1ffd6
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user