• Stars
    star
    196
  • Rank 198,553 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

dingtalk

Go codecov Go Report Card Release GoDoc

English

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

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

文档

钉钉文档

特性

  • Text 消息

  • Link 消息

  • Markdown 消息

  • ActionCard 消息

  • FeedCard 消息

安装

Docker 安装

docker pull catchzeng/dingtalk

二进制安装

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

go install 安装

# Go 1.16+
go install github.com/CatchZeng/[email protected]

# Go version < 1.16
go get -u github.com/CatchZeng/[email protected]

使用方法

配置文件

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

access_token: "1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f"
secret: "SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68"

环境变量

$ export ACCESS_TOKEN="1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f"
$ export SECRET="SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68"
$ dingtalk link -i "标题" -e "信息" -u "https://makeoptim.com/" -p "https://makeoptim.com/assets/img/logo.png" -a

你也可以为环境变量设置一个前缀

$ export DINGTALK_ENV_PREFIX="DINGTALK_"
$ export DINGTALK_ACCESS_TOKEN="1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f"
$ export DINGTALK_SECRET="SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68"
$ dingtalk link -i "标题" -e "信息" -u "https://makeoptim.com/" -p "https://makeoptim.com/assets/img/logo.png" -a

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://makeoptim.com/" -p "https://makeoptim.com/assets/img/logo.png" -a'
            }
        }
    }
}

作为 module

go get github.com/CatchZeng/dingtalk
package main

import (
    "log"

    "github.com/CatchZeng/dingtalk/pkg/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"
$ dingtalk markdown -D -i "杭州天气" -e '## 杭州天气 @150XXXXXXXX
 > 9度,西北风1级,空气良89,相对温度73%
 > ![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png)
 > ###### 10点20分发布 [天气](https://www.dingtalk.com)' -t 1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f -s SECb90923e19e58b466481e9e7b7a5bxxxxxx4531axxxxxxad3967fb29f0eae5c68

{"msgtype":"markdown","markdown":{"title":"杭州天气","text":"## 杭州天气 @150XXXXXXXX\n \u003e 9度,西北风1级,空气良89,相对温度73%\n \u003e ![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png)\n \u003e ###### 10点20分发布 [天气](https://www.dingtalk.com)"},"at":{"atMobiles":[],"isAtAll":false}}

-D 参数:打印发送的消息内容

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:
  -t, --access_token string   access_token
  -m, --atMobiles strings     atMobiles
  -D, --debug                 debug
  -h, --help                  help for dingtalk
  -a, --isAtAll               isAtAll
  -s, --secret string         secret

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

Stargazers

Stargazers over time

More Repositories

1

Localizable.strings2Excel

Python command line tool for conversion between iOS strings files and excel files & between android strings.xml files and excl files. & strings files to android strings.xml files.
Python
554
star
2

CATClearProjectTool

Clear objective-c project unused classes.
Objective-C
156
star
3

feishu

feishu 是飞书机器人的 go 实现。支持 Docker、Jenkinsfile、命令行模式,module 模式;支持加签安全设置、链式语法创建消息;支持文本(text)、富文本(post)、图片(image)、群名片(share_chat)、消息卡片(interactive)消息类型。
Go
64
star
4

SwiftPopup

Swift fully customized popup view controller.
Swift
43
star
5

CATCurveProgressView

iOS curve (circular、arc、circle) progress view, supports gradient color, any angle, IBDesignable & IBInspectable, etc..
Objective-C
36
star
6

CATLog

An iOS log system,contains many excellent features,based on Xcodecolors and KZLinkedConsole.
Objective-C
27
star
7

AdaptationKit

📱 screen auto adaptation solution.
Swift
24
star
8

AppThinning

Make app thinner. Help you find large files and compress png, gif, jpg, svg files. 应用程序瘦身工具,帮助你找到大文件,压缩png、gif、jpg、svg等文件。
JavaScript
22
star
9

InteractiveCircularMenu

Interactive Circular Menu
Swift
19
star
10

CATSecurity

iOS & Java (Android、Java Web...) encryption-decryption(AES,RSA, MD5) and coder-decoder(Base64).
Java
18
star
11

object-detection-api

Make it easy to train and deploy Object Detection(SSD) and Image Segmentation(Mask R-CNN) Model Using TensorFlow Object Detection API.
Jupyter Notebook
18
star
12

bing_images

Python library to fetch image urls based on keywords and download from Bing.com.
Python
17
star
13

CATRadarView

iOS radar view
Objective-C
16
star
14

JoystickView

iOS Joystick View
Swift
15
star
15

tensorflow-unet-labelme

Build U-NET with TensorFlow 2 and train a dataset annotated with labelme
Jupyter Notebook
14
star
16

GradientMaster

A IBDesignable UIView class with a gradient rendered and customizable in the storyboard (effect, direction,...) and support gradient animation.
Swift
13
star
17

com.catchzeng.testplugin

Cordova iOS Plugin Demo
Objective-C
12
star
18

Ripples

Ripple animation for iOS. It is very useful for bluetooth app.
Swift
8
star
19

ImportSourceEditor

Xcode Source Editor Extension to quickly import your headers.(快速导入头文件Xcode Source Editor 插件)
Objective-C
8
star
20

DeleteLine

Delete Line Xcode Source Editor Extension (删除选中行的Xcode Source Editor 插件)
Objective-C
6
star
21

middleware-center

middleware center for JavaScript, just like http://koajs.com middleware.
JavaScript
3
star
22

SwiftBluetooth

A simple framework for building BLE apps.
Swift
3
star
23

PragmaMarkSourceEditor

#pragma mark Xcode Source Editor Extension (快速添加定义的#pragma mark 的Xcode Source Editor 插件)
Objective-C
3
star
24

typescript-design-patterns

Design pattern implementations in TypeScript. 设计模式 TypeScript 实现。
TypeScript
2
star
25

ContinuousIntegration

continuous integration
2
star
26

CatchZengBlog

CSS
2
star
27

MiddlewareCenter

Swift Middleware Center
Swift
2
star
28

go-demos

go demos
Go
2
star
29

MVCRefactoring

MVC Refactoring demo
Objective-C
2
star
30

awesome-istio

😎 A curated list of awesome things related to istio
2
star
31

deep-learning-papers-with-code

深度学习论文翻译、详解、代码实现。包括分类论文,检测论文等。Deep learning papers translation, detailed explanation, and code implementation, including classification papers, detection papers, etc.
1
star
32

CatchZeng

1
star
33

SwiftPlaygrounds

Apple SwiftPlaygrounds
Shell
1
star
34

AppThinning-Desktop

https://github.com/CatchZeng/AppThinning desktop version.
Vue
1
star
35

PragmaMark

iOS Xcode pragma mark plugin
Objective-C
1
star
36

pass-the-GAIQ-certification-exam-using-mind-map

Pass the Google Analytics Individual Qualification certification exam using Mind Map.
1
star
37

py_pkg

py_pkg
Python
1
star
38

SwiftBluetoothAndroid

Android BLE
Java
1
star
39

RoundedCornerView

Simple rounded corner view,supporting all all radius(topLeft,topRight,bottomLeft,bottomRight) and IBDesignable.
Shell
1
star
40

SizeClassDemo

a demo of SizeClass to help iOS developer use it quickly.
Objective-C
1
star