-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_kind.go
245 lines (208 loc) · 5.47 KB
/
message_kind.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
package wxcom
// text struct is used to compose text message push from message client.
type text struct {
message *Message
content string
safe int
enableIdTrans int
}
// build method create the new Message client.
func (t *text) build() *Message {
msg := t.message.clone()
msg.msgType = "text"
msg.content = t.content
msg.safe = t.safe
msg.enableIdTrans = t.enableIdTrans
return msg
}
// SetSafe method sets the text message is confident.
func (t *text) SetSafe(safe int) *text {
t.safe = safe
return t
}
// SetEnableIdTrans method sets the text message enable id translation.
func (t *text) SetEnableIdTrans(enableIdTrans int) *text {
t.enableIdTrans = enableIdTrans
return t
}
// ToJson method return text message string.
func (t *text) ToJson() string {
return t.build().toJson()
}
// Send method does Send text message.
func (t *text) Send() (*RespMessage, error) {
return t.build().send()
}
// image struct is used to compose image message push from message client.
type image struct {
message *Message
mediaId string
safe int
}
// build method create the new Message client.
func (i *image) build() *Message {
msg := i.message.clone()
msg.msgType = "image"
msg.mediaId = i.mediaId
msg.safe = i.safe
return msg
}
// SetSafe method sets the image message is confident.
func (i *image) SetSafe(safe int) *image {
i.safe = safe
return i
}
// ToJson method return image message string.
func (i *image) ToJson() string {
return i.build().toJson()
}
// Send method does sendWithRetry image message.
func (i *image) Send() (*RespMessage, error) {
return i.build().send()
}
// voice struct is used to compose voice message push from message client.
type voice struct {
message *Message
mediaId string
}
// build method create the new Message client.
func (v *voice) build() *Message {
msg := v.message.clone()
msg.msgType = "voice"
msg.mediaId = v.mediaId
return msg
}
// ToJson method return voice message string.
func (v *voice) ToJson() string {
return v.build().toJson()
}
// Send method does Send voice message.
func (v *voice) Send() (*RespMessage, error) {
return v.build().send()
}
// video struct is used to compose video message push from message client.
type video struct {
message *Message
mediaId string
title string
description string
safe int
}
// build method create the new Message client.
func (v *video) build() *Message {
msg := v.message.clone()
msg.msgType = "video"
msg.mediaId = v.mediaId
msg.title = v.title
msg.description = v.description
msg.safe = v.safe
return msg
}
// SetTitle method sets the video message title.
func (v *video) SetTitle(title string) *video {
v.title = title
return v
}
// SetDescription method sets the video message description.
func (v *video) SetDescription(description string) *video {
v.description = description
return v
}
// SetSafe method sets the video message is confident.
func (v *video) SetSafe(safe int) *video {
v.safe = safe
return v
}
// ToJson method return video message string.
func (v *video) ToJson() string {
return v.build().toJson()
}
// Send method does sendWithRetry video message.
func (v *video) Send() (*RespMessage, error) {
return v.build().send()
}
// file struct is used to compose file message push from message client.
type file struct {
message *Message
mediaId string
safe int
}
// build method create the new Message client.
func (f *file) build() *Message {
msg := f.message.clone()
msg.msgType = "file"
msg.mediaId = f.mediaId
msg.safe = f.safe
return msg
}
// SetSafe method sets the file message is confident.
func (f *file) SetSafe(safe int) *file {
f.safe = safe
return f
}
// ToJson method return file message string.
func (f *file) ToJson() string {
return f.build().toJson()
}
// Send method does sendWithRetry file message.
func (f *file) Send() (*RespMessage, error) {
return f.build().send()
}
// textcard struct is used to compose textcard message push from message client.wx_message
type textcard struct {
message *Message
title string
description string
url string
btnTxt string
enableIdTrans int
}
// build method create the new Message client.
func (t *textcard) build() *Message {
msg := t.message.clone()
msg.msgType = "textcard"
msg.title = t.title
msg.description = t.description
msg.url = t.url
msg.btnTxt = t.btnTxt
msg.enableIdTrans = t.enableIdTrans
return msg
}
// SetBtnTxt method sets the textcard message btn txt.
func (t *textcard) SetBtnTxt(btnTxt string) *textcard {
t.btnTxt = btnTxt
return t
}
// SetEnableIdTrans method sets the textcard message enable id translation.
func (t *textcard) SetEnableIdTrans(enableIdTrans int) *textcard {
t.enableIdTrans = enableIdTrans
return t
}
// ToJson method return textcard message string.
func (t *textcard) ToJson() string {
return t.build().toJson()
}
// Send method does sendWithRetry textcard message.
func (t *textcard) Send() (*RespMessage, error) {
return t.build().send()
}
// markdown struct is used to compose markdown message push from message client.
type markdown struct {
message *Message
content string
}
// build method create the new Message client.
func (m *markdown) build() *Message {
msg := m.message.clone()
msg.msgType = "markdown"
msg.content = m.content
return msg
}
// ToJson method return markdown message string.
func (m *markdown) ToJson() string {
return m.build().toJson()
}
// Send method does Send markdown message.
func (m *markdown) Send() (*RespMessage, error) {
return m.build().send()
}