You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
580 B

package message
import (
"encoding/json"
)
// 钉钉消息结构体
type text struct {
Content string `json:"content" validate:"required"`
}
// 文本消息
type textMessage struct {
message
text `json:"text" validate:"required"`
}
func (t *textMessage) String() string {
str, _ := json.Marshal(t)
return string(str)
}
func (t *textMessage) MessageType() string {
return "text"
}
// NewTextMessage 文本对象
func NewTextMessage(context string) *textMessage {
msg := &textMessage{}
msg.MsgType = msg.MessageType()
msg.text = text{Content: context}
return msg
}