1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

严谨一点,校验下json格式的富文本,其他非xml和json的富文本 写入text

This commit is contained in:
scjtqs 2020-09-06 10:50:13 +08:00
parent abb9e6d636
commit e8b715ea6e
2 changed files with 8 additions and 2 deletions

1
go.mod
View File

@ -4,5 +4,6 @@ go 1.14
require (
github.com/golang/protobuf v1.4.2
github.com/tidwall/gjson v1.6.1 // indirect
google.golang.org/protobuf v1.25.0
)

View File

@ -6,6 +6,7 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/utils"
"github.com/golang/protobuf/proto"
"github.com/tidwall/gjson"
"math"
"reflect"
"regexp"
@ -504,10 +505,14 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
}
if isOk := strings.Contains(content, "<?xml"); isOk {
res = append(res, NewRichXml(content, int64(elem.RichMsg.ServiceId)))
continue
} else {
if gjson.Valid(content) {
res = append(res, NewRichJson(content))
continue
}
//res = append(res, NewText(content))
}
res = append(res, NewText(content))
}
}
if elem.CustomFace != nil {