DingTalk (dingding) is the go implementation of the DingTalk robot. DingTalk(dingding) 是钉钉机器人的 go 实现

dingtalk

Go codecov Go Report Card Release GoDoc

English

DingTalk(dingding) 是钉钉机器人的 go 实现。支持 Docker、Jenkinsfile、命令行模式,module 模式;支持加签安全设置,支持链式语法创建消息;支持文本、链接、Markdown、ActionCard、FeedCard 消息类型。

注:使用飞书的小伙伴,可以使用飞书(feishu)版

文档

钉钉文档

特性

安装

Docker 安装

docker pull catchzeng/dingtalk

二进制安装

releases 下载相应平台的二进制可执行文件,然后加入到 PATH 环境变量即可。

go get 安装

go get github.com/CatchZeng/dingtalk

使用方法

配置文件

可以在 $/HOME/.dingtalk 下创建 config.yaml 填入 access_tokensecret 默认值。

access_token: "1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f"
secret: "SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68"

Docker

docker run catchzeng/dingtalk dingtalk text -t 1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f -s SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68 -c "docker test"

Jenkinsfile

pipeline {
    agent {
        docker {
            image 'catchzeng/dingtalk:latest'
        }
    }
    environment {
        DING_TOKEN = '1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f'
        DING_SECRET = 'SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68'
    }
    stages {
        stage('notify') {
            steps {
                sh 'dingtalk link -t ${DING_TOKEN} -s ${DING_SECRET} -i "标题" -e "信息" -u "https://catchzeng.com/" -p "https://catchzeng.com/img/avatar-hux.jpg" -a'
            }
        }
    }
}

作为 module

package main

import (
    "log"

    "github.com/CatchZeng/dingtalk"
)

func main() {
	  accessToken := "1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f"
    secret := "SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68"
    client := dingtalk.NewClient(accessToken, secret)

    msg := dingtalk.NewTextMessage().SetContent("测试文本&at 某个人").SetAt([]string{"177010xxx60"}, false)
    client.Send(msg)
}

命令行工具

Demo

dingtalk text -t 1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f -s SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68 -c "测试命令行 & at 某个人" -m "177010xxx60","177010xxx61"

Help

$ dingtalk -h
dingtalk is a command line tool for DingTalk

Usage:
  dingtalk [command]

Available Commands:
  actionCard  send actionCard message with DingTalk robot
  feedCard    send feedCard message with DingTalk robot
  help        Help about any command
  link        send link message with DingTalk robot
  markdown    send markdown message with DingTalk robot
  text        send text message with DingTalk robot
  version     dingtalk version

Flags:
  -m, --atMobiles strings   atMobiles
  -h, --help                help for dingtalk
  -a, --isAtAll             isAtAll
  -s, --secret string       secret
  -t, --token string        access_token

Use "dingtalk [command] --help" for more information about a command.

Stargazers

Stargazers over time

Owner
Catch Zeng
AI (Machine Learning) and DevOps enthusiast.
Catch Zeng
Similar Resources

A simple robot to ban users who send as channel in group chats.

GoLang Telegram Bot GoLang Telegram Bot, written in GoLang via gotgbot library. You can even use this repository as a template to make your own GoLang

Dec 14, 2021

A trading robot, that can submit basic orders in an automated fashion.

A trading robot, that can submit basic orders in an automated fashion.

Source: https://github.com/harunnryd/btrade Issues: https://github.com/harunnryd/btrade/issues Twitter: @harunnryd LinkedIn: @harunnryd btrade is a ro

Jan 26, 2022

Go-wechat-robot-sender - Using command line to send msg to Wechat enterprise by Go

Go-wechat-robot-sender - Using command line to send msg to Wechat enterprise by Go

Jan 28, 2022

BotHub - BotHub is a web-based robot editor built in go with support for go and python

Robot Simulator This is an application to simulate toy robot moving on a square

May 16, 2022

BotHub is a web-based robot editor built in go with support for go and python.

Robot Simulator This is an application to simulate toy robot moving on a square tabletop, The robot is free to roam around the surface of the table, b

May 16, 2022

Go language implementation of a blockchain based on the BDLS BFT protocol. The implementation was adapted from Ethereum and Sperax implementation

BDLS protocol based PoS Blockchain Most functionalities of this client is similar to the Ethereum golang implementation. If you do not find your quest

Oct 14, 2022

CVE-2021-4034 - A Golang implementation of clubby789's implementation of CVE-2021-4034

CVE-2021-4034 January 25, 2022 | An00bRektn This is a golang implementation of C

Feb 3, 2022

An implementation of JOSE standards (JWE, JWS, JWT) in Go

Go JOSE Package jose aims to provide an implementation of the Javascript Object Signing and Encryption set of standards. This includes support for JSO

Dec 18, 2022

goRBAC provides a lightweight role-based access control (RBAC) implementation in Golang.

goRBAC goRBAC provides a lightweight role-based access control implementation in Golang. For the purposes of this package: * an identity has one or mo

Dec 29, 2022

This is an implementation of JWT in golang!

jwt This is a minimal implementation of JWT designed with simplicity in mind. What is JWT? Jwt is a signed JSON object used for claims based authentic

Oct 25, 2022

Golang implementation of JSON Web Tokens (JWT)

jwt-go A go (or 'golang' for search engine friendliness) implementation of JSON Web Tokens NEW VERSION COMING: There have been a lot of improvements s

Jan 6, 2023

Platform-Agnostic Security Tokens implementation in GO (Golang)

Golang implementation of PASETO: Platform-Agnostic Security Tokens This is a 100% compatible pure Go (Golang) implementation of PASETO tokens. PASETO

Jan 2, 2023

s3fs provides a S3 implementation for Go1.16 filesystem interface.

S3 FileSystem (fs.FS) implementation.Since S3 is a flat structure, s3fs simulates directories by using prefixes and "/" delim. ModTime on directories is always zero value.

Nov 9, 2022

[NO LONGER MAINTAINED} oauth 2 server implementation in Go

hero hero is a feature rich oauth 2 server implementation in Go. Features User account management Client management oauth 2 rfc 6749 compliant Configu

Nov 18, 2022

OAuth 1.0a implementation in Go

Package oauth1a Summary An implementation of OAuth 1.0a in Go1. API reference Installing Run: go get github.com/kurrik/oauth1a Include in your source

Aug 23, 2022

OAuth 1.0 implementation in go (golang).

OAuth 1.0 Library for Go (If you need an OAuth 2.0 library, check out: https://godoc.org/golang.org/x/oauth2) Developing your own apps, with this libr

Nov 22, 2022

A golang implementation of a console-based trading bot for cryptocurrency exchanges

A golang implementation of a console-based trading bot for cryptocurrency exchanges

Golang Crypto Trading Bot A golang implementation of a console-based trading bot for cryptocurrency exchanges. Usage Download a release or directly bu

Dec 30, 2022

Pure Go termbox implementation

IMPORTANT This library is somewhat not maintained anymore. But I'm glad that it did what I wanted the most. It moved people away from "ncurses" mindse

Dec 28, 2022

go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config

HOCON (Human-Optimized Config Object Notation) Configuration library for working with the Lightbend's HOCON format. HOCON is a human-friendly JSON sup

Dec 3, 2022
Comments
  • 测试发现MarkDown类型不能@人

    测试发现MarkDown类型不能@人

    `package main

    import ( "fmt"

    "github.com/CatchZeng/dingtalk/pkg/dingtalk"
    

    )

    func main() { accessToken := "xxxxxxxxxxx" secret := "xxxxxxxxxxxxxxxxxxxxx0279c94f59fdbc3650" client := dingtalk.NewClient(accessToken, secret)

    msg := dingtalk.NewMarkdownMessage().SetMarkdown("这是TITLE","测试文本").SetAt([]string{"158XXXXX46"}, false)
    _, _, _ = client.Send(msg)
    

    }`

  • 取不到命令执行的返回值,不能知道成功还是失败

    取不到命令执行的返回值,不能知道成功还是失败

    我已经事先发送多条推送,已经无法推送了,我想获取返回内容,这样我可以重新加入队列中重新执行。

    send message to dingtalk error = send too fast, exceed 20 times per minute

    在linux上,我试着获取命令的打印结果,但是获取不到。

    result=`dingtalk text -t "1a8d1b0e794546aba9ba38566ca8436bd1eecf79757e72552bde0XXXXX" -c "【通知】test"`
    

    这样也不行

    dingtalk text -t "1a8d1b0e794546aba9ba38566ca8436bd1eecf79757e72552bde0XXXXX" -c "【通知】test"
    if [ $? -eq 0 ]; then
        echo "successfully"
    else
        echo "failed"
    fi
    
  • 求助:window 命令行 at 多人如何调用

    求助:window 命令行 at 多人如何调用

    dingtalk text -c test -t xxx -m "1xxxx","1xxx"

    dingtalk text -c test -t xxx -m "1xxxx" "1xxx"

    dingtalk text -c test -t xxx -m ["1xxxx","1xxx"]

    dingtalk text -c test -t xxx -m [1xxxx,1xxx]

    dingtalk text -c test -t xxx -m "[1xxxx,1xxx]"

    以上命令均试过,无法 at 多人,还请说下正确的格式

A trading robot, that can submit basic orders in an automated fashion.
A trading robot, that can submit basic orders in an automated fashion.

Source: https://github.com/harunnryd/btrade Issues: https://github.com/harunnryd/btrade/issues Twitter: @harunnryd LinkedIn: @harunnryd btrade is a ro

Jan 26, 2022
A golang implementation of a console-based trading bot for cryptocurrency exchanges
A golang implementation of a console-based trading bot for cryptocurrency exchanges

Golang Crypto Trading Bot A golang implementation of a console-based trading bot for cryptocurrency exchanges. Usage Download a release or directly bu

Dec 30, 2022
Full-native go implementation of Telegram API
Full-native go implementation of Telegram API

MTProto Full-native implementation of MTProto protocol on Golang! english русский 简体中文 Features Full native implementation All code, from sending requ

Jan 1, 2023
Golang Implementation of RLBot

RLBotGo This repository holds a library for making Rocket League bots in Go! It provides: An easy to use interface for writing bots An example bot usi

Jan 1, 2023
GoAlgoTrade is a Go implementation of PyAlgoTrade.

GoAlgoTrade is a Go implementation of PyAlgoTrade.

Dec 6, 2022
A golang implementation of a console-based trading bot for cryptocurrency exchanges
A golang implementation of a console-based trading bot for cryptocurrency exchanges

Golang Crypto Trading Bot A golang implementation of a console-based trading bot for cryptocurrency exchanges. Usage Download a release or directly bu

Jun 4, 2022
Telego is Telegram Bot API library for Golang with full API implementation (one-to-one)
Telego is Telegram Bot API library for Golang with full API implementation (one-to-one)

Telego • Go Telegram Bot API Telego is Telegram Bot API library for Golang with full API implementation (one-to-one) The goal of this library was to c

Jan 5, 2023
basicbots is a programming game where you program your robot to compete against other robot.
basicbots is a programming game where you program your robot to compete against other robot.

basicbots What is baiscbots? basicbots is a programming game where you program your robot to compete agaist other robots. What is the inspiration? My

Jan 8, 2022
A general-purpose bot library inspired by Hubot but written in Go. :robot:

Joe Bot ?? A general-purpose bot library inspired by Hubot but written in Go. Joe is a library used to write chat bots in the Go programming language.

Dec 24, 2022
Automatic combat robot for golang
Automatic combat robot for golang

此项目分开源与商用版本,商用版可选择多种打拳模式。 模式:论事式,对比式,打拳式,阴阳人式,死为大式 而且vvvip用户可以根据并发,稳定,扩展,生态等等因素来选择不同语言版本的robot。 怎么定价还没想好但是想写点什么 并且此项目支持多国语言,方便国际友人打拳。 目前暂定中文,英语,日语(多看小

Dec 2, 2021