mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-03 18:47:41 +08:00
Merge pull request #36 from scjtqs/master
添加 xml 和 json 消息 的基础层支持。go-cqhttp 处修改需要
This commit is contained in:
commit
6328ae0e93
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.idea
|
@ -161,6 +161,24 @@ func NewUrlShare(url, title, content, image string) *ServiceElement {
|
|||||||
SubType: "UrlShare",
|
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 {
|
func (e *TextElement) Type() ElementType {
|
||||||
return Text
|
return Text
|
||||||
|
@ -347,6 +347,15 @@ func ToProtoElems(elems []IMessageElement, generalFlags bool) (r []*msg.Elem) {
|
|||||||
})
|
})
|
||||||
continue
|
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{
|
r = append(r, &msg.Elem{
|
||||||
RichMsg: &msg.RichMsg{
|
RichMsg: &msg.RichMsg{
|
||||||
Template1: append([]byte{1}, binary.ZlibCompress([]byte(e.Content))...),
|
Template1: append([]byte{1}, binary.ZlibCompress([]byte(e.Content))...),
|
||||||
@ -539,7 +548,7 @@ func (forMsg *ForwardMessage) CalculateValidationData(seq, random int32, groupCo
|
|||||||
FromUin: node.SenderId,
|
FromUin: node.SenderId,
|
||||||
MsgSeq: seq,
|
MsgSeq: seq,
|
||||||
MsgTime: node.Time,
|
MsgTime: node.Time,
|
||||||
MsgUid: 0x01000000000000000 | (int64(random) & 0xFFFF_FFFF),
|
MsgUid: 0x01000000000000000 | (int64(random) & 0xFFFFFFFF),
|
||||||
MutiltransHead: &msg.MutilTransHead{
|
MutiltransHead: &msg.MutilTransHead{
|
||||||
MsgId: 1,
|
MsgId: 1,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user