1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 12:03:50 +08:00

optimization cqcode converter.

This commit is contained in:
Mrs4s 2020-12-03 15:02:36 +08:00
parent 1fbaa6107d
commit 93d0d87fbb

View File

@ -1,7 +1,6 @@
package coolq
import (
"bufio"
"bytes"
"crypto/md5"
"encoding/base64"
@ -353,16 +352,14 @@ func (bot *CQBot) ConvertStringMessage(msg string, group bool) (r []message.IMes
cqCode = []rune{}
tempText = []rune{}
}()
reader := strings.NewReader(string(cqCode))
buf := bufio.NewReader(reader)
t, _ := buf.ReadString(',')
t = t[0 : len(t)-1]
params := make(map[string]string)
for buf.Buffered() > 0 {
p, _ := buf.ReadString(',')
if strings.HasSuffix(p, ",") {
p = p[0 : len(p)-1]
s := strings.SplitN(string(cqCode), ",", -1)
if len(s) == 0 {
return
}
t := s[0]
params := make(map[string]string)
for i := 1; i < len(s); i++ {
p := s[i]
p = strings.TrimSpace(p)
if p == "" {
continue