1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-03 10:37:46 +08:00

Merge pull request #36 from scjtqs/master

添加 xml 和 json 消息 的基础层支持。go-cqhttp 处修改需要
This commit is contained in:
Mrs4s 2020-09-01 16:19:49 +08:00 committed by GitHub
commit 6328ae0e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea

View File

@ -161,6 +161,24 @@ func NewUrlShare(url, title, content, image string) *ServiceElement {
SubType: "UrlShare",
}
}
func NewXmlMsg(template string, ResId int64) *ServiceElement {
if ResId == 0 {
ResId = 60 //默认值60
}
return &ServiceElement{
Id: int32(ResId),
Content: template,
SubType: "xml",
}
}
func NewJsonMsg(template string) *ServiceElement {
return &ServiceElement{
Id: 1,
Content: template,
SubType: "json",
}
}
func (e *TextElement) Type() ElementType {
return Text

View File

@ -347,6 +347,15 @@ func ToProtoElems(elems []IMessageElement, generalFlags bool) (r []*msg.Elem) {
})
continue
}
if e.SubType == "json" {
r = append(r, &msg.Elem{
LightApp: &msg.LightAppElem{
Data: append([]byte{1}, binary.ZlibCompress([]byte(e.Content))...),
MsgResid: []byte{1},
},
})
continue
}
r = append(r, &msg.Elem{
RichMsg: &msg.RichMsg{
Template1: append([]byte{1}, binary.ZlibCompress([]byte(e.Content))...),
@ -539,7 +548,7 @@ func (forMsg *ForwardMessage) CalculateValidationData(seq, random int32, groupCo
FromUin: node.SenderId,
MsgSeq: seq,
MsgTime: node.Time,
MsgUid: 0x01000000000000000 | (int64(random) & 0xFFFF_FFFF),
MsgUid: 0x01000000000000000 | (int64(random) & 0xFFFFFFFF),
MutiltransHead: &msg.MutilTransHead{
MsgId: 1,
},