From 6ddcd52c20d1d350287d32c93f30beaee72fc8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 5 Aug 2022 09:35:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/event/event_tcp_utils.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/business/jxstore/event/event_tcp_utils.go b/business/jxstore/event/event_tcp_utils.go index a54f32648..32a1d860f 100644 --- a/business/jxstore/event/event_tcp_utils.go +++ b/business/jxstore/event/event_tcp_utils.go @@ -492,8 +492,6 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) { v1 += byteSignSoundE if sounds := regexpSound.FindStringSubmatch(v1); len(sounds) > 0 { sound := sounds[1] - //先把结束标签消了 - resultV1 := strings.ReplaceAll(v1, byteSignSoundE, "") // 将语音包转换为十六进制 voice := "" for _, v := range strings.Split(sound, "2c") { @@ -507,17 +505,17 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) { voice += int16Sound } } - soundParam := strings.ReplaceAll(resultV1, sound, "") - soundStr = append(soundStr, strings.ReplaceAll(soundParam, byteSignSound, voice)) + soundStr = append(soundStr, voice) } } result = strings.ReplaceAll(result, byteSignSound, "*") result = strings.ReplaceAll(result, byteSignSoundE, "&") - for _, v := range soundStr { + for i := 0; i < len(soundStr); i++ { + fmt.Println("result=", result) start := strings.Index(result, "*") end := strings.Index(result, "&") - result = strings.Replace(result, result[start:end+1], v, 1) + result = strings.Replace(result, result[start:end+1], soundStr[i], 1) } } // 自动合成语音功能