Skip to content

Latest commit

 

History

History
172 lines (116 loc) · 5.41 KB

READMEEN.md

File metadata and controls

172 lines (116 loc) · 5.41 KB

dingtalk

Go codecov Go Report Card Release GoDoc

中文

DingTalk (dingding) is the go implementation of the DingTalk robot. Support Docker, Jenkinsfile,command line mode, module mode, signature security settings, chain syntax to create messages, support text, link, markdown、ActionCard、FeedCard message types.

Doc

ding-doc

Feature

Install

with Docker

docker pull catchzeng/dingtalk

binary

Go to releases to download the binary executable file of the corresponding platform, and then add it to the PATH environment variable.

with go get

go get github.com/manjoc/dingtalk

Usage

config.yaml

You can create config.yaml under $/HOME/.dingtalk and fill in the default values of access_token and secret.

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'
            }
        }
    }
}

Use as module

package main

import (
    "log"

    "github.com/manjoc/dingtalk"
)

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

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

Use as command line tool

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