dingding

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

README

如何使用钉钉群的机器人来接收通知

  • 添加群机器人 点击 钉钉群设置->智能群助手->添加机器人,选择自定义,然后点击添加
    填写机器人名称安全设置,然后选择安全设置,有三类自定义关键词、加签、IP地址,任选一项然后点击完成
    得到一个Webhook,
  • 初始化 使用NewDing来进行初始化,第一个参数就是这个Webhook url,第二个参数是安全设置,CustomKey是对应的的自定义关键字,Sign是加签,IPCidr是IP地址,注意如果选择了安全设置,这时会得到一个签名,然后把这个签名作为第三个参数传入,如果安全设置不是选择的加签,则第三个参数为空字符串即可。注意如果想在消息通知中@某个人则需要把这个人加入群众并且tos参数要穿入此人注册钉钉的手机号

Example

var (
secret := "SEC..."
webhook := "https://oapi.dingtalk.com/robot/send?access_token=..."
)
func SendDing() {
   ding := NewDing(webhook, Sign, secret)
   err := ding.Send([]string{"..."}, "测试标题", "测试内容")

   if err != nil {
      t.Error(err)
   }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDing

func NewDing(webhookurl string, sl Secrue, secret string) notify.Sender

NewDing init a Dingding send conf

Types

type Ding

type Ding struct {
	MsgType string // text
	// contains filtered or unexported fields
}

Ding dingding alarm conf

func (*Ding) Send

func (d *Ding) Send(tos []string, title string, content string) error

Send to notify tos is phone number

type Result

type Result struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

Result post resp

type Secrue

type Secrue uint

Secrue dingding secrue setting pls reading https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq

const (
	// CustomKey Custom keywords
	CustomKey Secrue = iota + 1
	// Sign need sign up
	Sign
	// IPCdir IP addres
	IPCdir
)

type SendMsg

type SendMsg struct {
	MsgType string `json:"msgtype"`
	Text    text   `json:"text"`
	At      at     `json:"at"`
}

SendMsg post json data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL