Skip to content

Commit

Permalink
feat: xml消息
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Nov 23, 2024
1 parent 53bc9c0 commit 566cbd2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions message/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ func (e *LightAppElement) BuildElement() []*message.Elem {
}}
}

func (e *XMLElement) BuildElement() []*message.Elem {
return []*message.Elem{{
RichMsg: &message.RichMsg{
ServiceId: proto.Some(int32(e.ServiceID)),
Template1: append([]byte{0x01}, binary.ZlibCompress([]byte(e.Content))...),
},
}}
}

func (e *ForwardMessage) BuildElement() []*message.Elem {
fileID := utils.NewUUID()
extra := MultiMsgLightAppExtra{
Expand Down
23 changes: 23 additions & 0 deletions message/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ type (
Content string
}

XMLElement struct {
ServiceID int
Content string
}

ForwardMessage struct {
IsGroup bool
SelfID uint32
Expand Down Expand Up @@ -333,6 +338,20 @@ func NewLightApp(content string) *LightAppElement {
}
}

func NewXML(content string) *XMLElement {
return &XMLElement{
ServiceID: 35,
Content: content,
}
}

func NewXMLWithID(id int, content string) *XMLElement {
return &XMLElement{
ServiceID: id,
Content: content,
}
}

func NewForward(resid string, nodes []*ForwardNode) *ForwardMessage {
return &ForwardMessage{
ResID: resid,
Expand Down Expand Up @@ -429,6 +448,10 @@ func (e *LightAppElement) Type() ElementType {
return LightApp
}

func (e *XMLElement) Type() ElementType {
return Service
}

func (e *ForwardMessage) Type() ElementType {
return Forward
}
9 changes: 9 additions & 0 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ func ParseMessageElements(msg []*message.Elem) []IMessageElement {
})
}

if elem.RichMsg != nil && elem.RichMsg.ServiceId.Unwrap() == 35 {
if elem.RichMsg.Template1 != nil {
res = append(res, &XMLElement{
ServiceID: 35,
Content: utils.B2S(binary.ZlibUncompress(elem.LightAppElem.Data[1:])),
})
}
}

if elem.LightAppElem != nil && len(elem.LightAppElem.Data) > 1 {
var content []byte
if elem.LightAppElem.Data[0] == 0 {
Expand Down

0 comments on commit 566cbd2

Please sign in to comment.