Documentation
¶
Overview ¶
Package dingtalk 是钉钉群自定义机器人出站通道。Webhook 地址只能是 https://oapi.dingtalk.com/robot/send?access_token=…; 加签时 timestamp 是毫秒,签名是以 secret 为 key 对 "timestamp\nsecret" 做 HmacSHA256 后 Base64, 拼在 Webhook 地址后面(×tamp=…&sign=…);返回 errcode 为 0 才算成功。
Index ¶
- Constants
- func Sign(timestampMillis int64, secret string) string
- func WebhookURL(raw string) (string, string, error)
- type Channel
- func (c *Channel) CheckConfig(conf *models.NotificationConf) error
- func (c *Channel) Close(context.Context) error
- func (c *Channel) Healthy() bool
- func (c *Channel) Init(_ context.Context, conf *models.NotificationConf) error
- func (c *Channel) OnInbound(notify.InboundHandler)
- func (c *Channel) Send(ctx context.Context, n notify.Notification) error
- func (c *Channel) SupportsInbound() bool
- func (c *Channel) Type() string
Constants ¶
const ( Host = "oapi.dingtalk.com" Path = "/robot/send" )
Host 与 Path 是钉钉自定义机器人的发送地址。
const Type = "dingtalk"
Type 是通道类型名。
Variables ¶
This section is empty.
Functions ¶
func WebhookURL ¶
WebhookURL 校验钉钉 Webhook 地址:只能是 https://oapi.dingtalk.com/robot/send、带 access_token; 返回规整后的地址与 access_token。
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel 是钉钉群机器人通道(只出站)。
func (*Channel) CheckConfig ¶
func (c *Channel) CheckConfig(conf *models.NotificationConf) error
CheckConfig 只检查配置、不发请求:保存配置前调用。
func (*Channel) Init ¶
Init 解析配置:webhook_url 必填;secret(加签密钥,SEC 开头)可选;msg_type 为 markdown(默认)或 text。
func (*Channel) SupportsInbound ¶
SupportsInbound 恒为 false。