Documentation
¶
Index ¶
- Constants
- Variables
- func SendToDingDing(api_key string, content map[string]any, proxy_address string) (err error)
- func SendToFeiShu(api_key string, content map[string]any, proxy_address string) (err error)
- func SendToWeiXinWork(api_key string, content map[string]any, proxy_address string) (err error)
- type OptionFunc
- type WebhookSender
Constants ¶
Variables ¶
View Source
var DICT_WEBHOOK_TYPE_TO_MESSAGE_TEMPLATE = map[string]map[string]map[string]any{ WEBHOOK_TYPE_WEIXIN_WORK: { MESSAGE_TYPE_TEXT: {"msgtype": "text", "text": map[string]string{"content": ""}}, MESSAGE_TYPE_MARKDOWN: {"msgtype": "markdown", "markdown": map[string]string{"content": ""}}, MESSAGE_TYPE_IMAGE: {"msgtype": "image", "image": map[string]string{"base64": "", "md5": ""}}, }, WEBHOOK_TYPE_DINGDING: { MESSAGE_TYPE_TEXT: {"msgtype": "text", "text": map[string]string{"content": ""}}, MESSAGE_TYPE_MARKDOWN: {"msgtype": "markdown", "markdown": map[string]string{"title": "新消息", "text": ""}}, }, WEBHOOK_TYPE_FEISHU: { MESSAGE_TYPE_TEXT: {"msg_type": "text", "content": map[string]string{"text": ""}}, MESSAGE_TYPE_MARKDOWN: {"msg_type": "text", "content": map[string]string{"text": ""}}, }, }
View Source
var DICT_WEBHOOK_TYPE_TO_SERVER_ADDRESS = map[string]string{ WEBHOOK_TYPE_WEIXIN_WORK: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=", WEBHOOK_TYPE_DINGDING: "https://oapi.dingtalk.com/robot/send?access_token=", WEBHOOK_TYPE_FEISHU: "https://open.feishu.cn/open-apis/bot/v2/hook/", }
Functions ¶
func SendToDingDing ¶
func SendToFeiShu ¶
Types ¶
type OptionFunc ¶
type OptionFunc func(*WebhookSender)
func WithMessageTitle ¶
func WithMessageTitle(s string) OptionFunc
钉钉机器人的 Markdown 类型支持指定消息标题,不指定时默认使用“新消息”作为标题
func WithOptions ¶
func WithOptions(options WebhookSender) OptionFunc
type WebhookSender ¶
type WebhookSender struct {
// contains filtered or unexported fields
}
func New ¶
func New(api_key string, options ...OptionFunc) *WebhookSender
func (*WebhookSender) SendMessage ¶
func (webhook_sender *WebhookSender) SendMessage(content map[string]any) (err error)
func (*WebhookSender) SendMessageMarkdown ¶
func (webhook_sender *WebhookSender) SendMessageMarkdown(content string) (err error)
推送Markdown类型消息
飞书机器人不支持Markdown格式降级为text类型 钉钉机器人的 Markdown 类型支持指定消息标题,不指定时默认使用“新消息”作为标题
func (*WebhookSender) SendMessageText ¶
func (webhook_sender *WebhookSender) SendMessageText(content string) (err error)
推送Text类型消息
Click to show internal directories.
Click to hide internal directories.