mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
add: LightAppElement.
This commit is contained in:
parent
6328ae0e93
commit
56d3e65e98
@ -92,6 +92,10 @@ type ForwardElement struct {
|
|||||||
ResId string
|
ResId string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LightAppElement struct {
|
||||||
|
Content string
|
||||||
|
}
|
||||||
|
|
||||||
func NewText(s string) *TextElement {
|
func NewText(s string) *TextElement {
|
||||||
return &TextElement{Content: s}
|
return &TextElement{Content: s}
|
||||||
}
|
}
|
||||||
@ -161,7 +165,7 @@ func NewUrlShare(url, title, content, image string) *ServiceElement {
|
|||||||
SubType: "UrlShare",
|
SubType: "UrlShare",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func NewXmlMsg(template string, ResId int64) *ServiceElement {
|
func NewRichXml(template string, ResId int64) *ServiceElement {
|
||||||
if ResId == 0 {
|
if ResId == 0 {
|
||||||
ResId = 60 //默认值60
|
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{
|
return &ServiceElement{
|
||||||
Id: 1,
|
Id: 1,
|
||||||
Content: template,
|
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 {
|
func (e *TextElement) Type() ElementType {
|
||||||
return Text
|
return Text
|
||||||
}
|
}
|
||||||
@ -232,6 +240,10 @@ func (e *ShortVideoElement) Type() ElementType {
|
|||||||
return Video
|
return Video
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *LightAppElement) Type() ElementType {
|
||||||
|
return LightApp
|
||||||
|
}
|
||||||
|
|
||||||
var faceMap = map[int]string{
|
var faceMap = map[int]string{
|
||||||
14: "微笑",
|
14: "微笑",
|
||||||
1: "撇嘴",
|
1: "撇嘴",
|
||||||
|
@ -82,6 +82,7 @@ const (
|
|||||||
File
|
File
|
||||||
Voice
|
Voice
|
||||||
Video
|
Video
|
||||||
|
LightApp
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Sender) IsAnonymous() bool {
|
func (s *Sender) IsAnonymous() bool {
|
||||||
@ -347,21 +348,19 @@ 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))...),
|
||||||
ServiceId: e.Id,
|
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 {
|
if generalFlags {
|
||||||
@ -459,7 +458,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
|
|||||||
}
|
}
|
||||||
if content != "" {
|
if content != "" {
|
||||||
// TODO: 解析具体的APP
|
// TODO: 解析具体的APP
|
||||||
return append(res, NewText(content))
|
return append(res, &LightAppElement{Content: content})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if elem.VideoFile != nil {
|
if elem.VideoFile != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user