ding

package module
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 10 Imported by: 0

README

ding

一款非常简单的钉钉群机器人发送通知的Go模块


安装

go get -u github.com/wanghuiyt/ding

钉钉群机器人设置为 "加签" 验证 (如何开启钉钉群机器人)



例子

普通消息

d := ding.Webhook{
    AccessToken: "8c03f234ddf2axxxxxxxxxxxx",
    Secret:      "SECefded9b38b761fxxxxxxxx",
}
err := d.SendMessage("这是普通的群消息")

Done!



使用

import "github.com/wanghuiyt/ding"

普通消息
d := ding.Webhook{
    AccessToken: "8c03f234ddf2axxxxxxxxxxxx",
    Secret:      "SECefded9b38b761fxxxxxxxx",
}
err := d.SendMessage("这是普通的群消息")

@特定人的消息
d := ding.Webhook{
    AccessToken: "8c03f234ddf2axxxxxxxxxxxx",
    Secret:      "SECefded9b38b761fxxxxxxxx",
    EnableAt:    true,
}
err := d.SendMessage("Harvey, 你的程序挂了", "1856362xxxx")
...
err = d.SendMessage("Harvey, Bob 和 Bella, 你们的程序挂了", "1856362xxxx", "1867800xxxx", "1715372xxxx")
img-at
@所有人的消息

必须同时开启 EnableAtAtAll

d := ding.Webhook{
    AccessToken: "8c03f234ddf2axxxxxxxxxxxx",
    Secret:      "SECefded9b38b761fxxxxxxxx",
    EnableAt:    true, // 开启艾特
    AtAll:       true, // 艾特所有人
}
err := d.SendMessage("这是@所有人的消息")
i

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Webhook

type Webhook struct {
	AccessToken string
	Secret      string
	EnableAt    bool
	AtAll       bool
}

func (*Webhook) SendMessage

func (t *Webhook) SendMessage(s string, at ...string) error

SendMessage Function to send message

Jump to

Keyboard shortcuts

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