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

add: LightAppElement.

This commit is contained in:
Mrs4s 2020-09-02 15:24:01 +08:00
parent 6328ae0e93
commit 56d3e65e98
2 changed files with 23 additions and 12 deletions

View File

@ -92,6 +92,10 @@ type ForwardElement struct {
ResId string
}
type LightAppElement struct {
Content string
}
func NewText(s string) *TextElement {
return &TextElement{Content: s}
}
@ -161,7 +165,7 @@ func NewUrlShare(url, title, content, image string) *ServiceElement {
SubType: "UrlShare",
}
}
func NewXmlMsg(template string, ResId int64) *ServiceElement {
func NewRichXml(template string, ResId int64) *ServiceElement {
if ResId == 0 {
ResId = 60 //默认值60
}
@ -172,7 +176,7 @@ func NewXmlMsg(template string, ResId int64) *ServiceElement {
}
}
func NewJsonMsg(template string) *ServiceElement {
func NewRichJson(template string) *ServiceElement {
return &ServiceElement{
Id: 1,
Content: template,
@ -180,6 +184,10 @@ func NewJsonMsg(template string) *ServiceElement {
}
}
func NewLightApp(content string) *LightAppElement {
return &LightAppElement{Content: content}
}
func (e *TextElement) Type() ElementType {
return Text
}
@ -232,6 +240,10 @@ func (e *ShortVideoElement) Type() ElementType {
return Video
}
func (e *LightAppElement) Type() ElementType {
return LightApp
}
var faceMap = map[int]string{
14: "微笑",
1: "撇嘴",

View File

@ -82,6 +82,7 @@ const (
File
Voice
Video
LightApp
)
func (s *Sender) IsAnonymous() bool {
@ -347,21 +348,19 @@ 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))...),
ServiceId: e.Id,
},
})
case *LightAppElement:
r = append(r, &msg.Elem{
LightApp: &msg.LightAppElem{
Data: append([]byte{1}, binary.ZlibCompress([]byte(e.Content))...),
MsgResid: []byte{1},
},
})
}
}
if generalFlags {
@ -459,7 +458,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
}
if content != "" {
// TODO: 解析具体的APP
return append(res, NewText(content))
return append(res, &LightAppElement{Content: content})
}
}
if elem.VideoFile != nil {