|
@@ -22,20 +22,50 @@ type NotifyService struct {
|
|
|
|
|
|
|
|
|
|
|
|
-func (e *NotifyService) SendTextMessage(content string) (err error) {
|
|
|
+func (e *NotifyService) SendTextMessage(content string, atMobiles []string, isAtAll bool) (err error) {
|
|
|
msg := map[string]interface{}{
|
|
|
"msgtype": "text",
|
|
|
"text": map[string]string{
|
|
|
"content": content,
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ "at": map[string]interface{}{
|
|
|
+ "atMobiles": atMobiles,
|
|
|
+ "isAtAll": isAtAll,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ return SendMessage(msg)
|
|
|
+}
|
|
|
+
|
|
|
+func (e *NotifyService) SendLinkMessage(content, title, picUrl, messageUrl string) (err error) {
|
|
|
+ msg := map[string]interface{}{
|
|
|
+ "msgtype": "link",
|
|
|
+ "link": map[string]string{
|
|
|
+ "text": content,
|
|
|
+ "title": title,
|
|
|
+ "picUrl": picUrl,
|
|
|
+ "messageUrl": messageUrl,
|
|
|
+ },
|
|
|
}
|
|
|
return SendMessage(msg)
|
|
|
}
|
|
|
|
|
|
+func (e *NotifyService) SendMarkdownMessage(content, title string, atMobiles []string, isAtAll bool) (err error) {
|
|
|
+ msg := map[string]interface{}{
|
|
|
+ "msgtype": "markdown",
|
|
|
+ "markdown": map[string]string{
|
|
|
+ "text": content,
|
|
|
+ "title": title,
|
|
|
+ },
|
|
|
+ "at": map[string]interface{}{
|
|
|
+ "atMobiles": atMobiles,
|
|
|
+ "isAtAll": isAtAll,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ return SendMessage(msg)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func SendMessage(msg interface{}) error {
|
|
|
body := bytes.NewBuffer(nil)
|
|
|
err := json.NewEncoder(body).Encode(msg)
|