From 36b09b8e941fa96c8508bbdc15b58fc5d6579cd3 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: Mon, 30 Jan 2023 18:36:47 +0800 Subject: [PATCH] =?UTF-8?q?tts=20append=20=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/ai_reply/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index 4e5d206f..96a88b24 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -2,6 +2,7 @@ package aireply import ( + "regexp" "strconv" "time" @@ -59,6 +60,7 @@ func init() { // 插件主体 ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功")) }) + endpre := regexp.MustCompile(`\pP$`) ent.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser). Handle(func(ctx *zero.Ctx) { msg := ctx.ExtractPlainText() @@ -72,7 +74,12 @@ func init() { // 插件主体 ctx.SendChain(message.Text("ERROR: ", err)) return } - rec, err := speaker.Speak(ctx.Event.UserID, func() string { return reply }) + rec, err := speaker.Speak(ctx.Event.UserID, func() string { + if !endpre.MatchString(reply) { + return reply + "。" + } + return reply + }) if err != nil { ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply)) return