zhangqian
2024-06-04 c6c500d7044c5e4785fc856a5a1253b0604a8147
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
package dingtalkrobot
 
import "fmt"
 
type message interface {
    String() string
}
 
type MarkdownMessage struct {
    MsgType  string   `json:"msgtype"`
    Markdown markdown `json:"markdown"`
}
 
type markdown struct {
    Title string `json:"title"`
    Text  string `json:"text"`
}
 
func (m *MarkdownMessage) String() string {
    return fmt.Sprintf("markdown message, title: %v, content: %v", m.Markdown.Title, m.Markdown.Text)
}
 
func NewMarkdownMessage(title string, content string) *MarkdownMessage {
    return &MarkdownMessage{
        MsgType: "markdown",
        Markdown: markdown{
            Title: title,
            Text:  content,
        },
    }
}