-
Notifications
You must be signed in to change notification settings - Fork 158
/
music.go
59 lines (47 loc) · 1.03 KB
/
music.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package messages
import (
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
)
type Music struct {
*Message
}
func NewMusic(items *power.HashMap) *Music {
m := &Music{
NewMessage(items),
}
m.Type = "music"
m.Properties = []string{
"title",
"description",
"url",
"hq_url",
"thumb_media_id",
"format",
}
m.JsonAliases = &object.HashMap{
"musicurl": "url",
"hqmusicurl": "hq_url",
}
m.OverrideToXmlArray()
return m
}
// Override ToXmlArray
func (msg *Music) OverrideToXmlArray() {
msg.ToXmlArray = func() *object.HashMap {
music := &object.HashMap{
"Music": &object.HashMap{
"Title": msg.Get("title", ""),
"Description": msg.Get("description", ""),
"MusicUrl": msg.Get("url", ""),
"HQMusicUrl": msg.Get("hq_url", ""),
},
}
thumbMediaID := msg.Get("thumb_media_id", nil)
if thumbMediaID != nil {
musicObject := (*music)["Music"].(*object.HashMap)
(*musicObject)["ThumbMediaId"] = thumbMediaID
}
return music
}
}