MCPcopy Index your code
hub / github.com/CatchZeng/dingtalk

github.com/CatchZeng/dingtalk @v1.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.5.0 ↗ · + Follow
109 symbols 312 edges 34 files 53 documented · 49% 1 cross-repo links updated 3y agov1.5.0 · 2022-04-20★ 2245 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

  • [x] Text message

  • [x] Link message

  • [x] Markdown message

  • [x] ActionCard message

  • [x] FeedCard message

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 install

# Go 1.16+
go install github.com/CatchZeng/dingtalk@v1.5.0

# Go version < 1.16
go get -u github.com/CatchZeng/dingtalk@v1.5.0

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"

environment variables

$ export ACCESS_TOKEN=1c53e149ba5de6597cxxxxxx0e901fdxxxxxx80b8ac141e4a75afdc44c85ca4f
$ export 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'
            }
        }
    }
}

Use as 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)
}

Use as command line tool

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: print the message content

Help

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

Extension points exported contracts — how you extend this code

Message (Interface)
Message interface [7 implementers]
pkg/dingtalk/message.go

Core symbols most depended-on inside this repo

Send
called by 8
pkg/dingtalk/client.go
NewMarkdownMessage
called by 7
pkg/dingtalk/markdown.go
NewTextMessage
called by 7
pkg/dingtalk/text.go
NewActionCardMessage
called by 7
pkg/dingtalk/actionCard.go
runActionCardCmd
called by 7
cmd/dingtalk/actionCard.go
newClient
called by 7
cmd/dingtalk/root.go
NewLinkMessage
called by 5
pkg/dingtalk/link.go
runLinkCmd
called by 5
cmd/dingtalk/link.go

Shape

Function 66
Struct 23
Method 18
Interface 1
TypeAlias 1

Languages

Go100%

Modules by API surface

pkg/dingtalk/actionCard.go7 symbols
test/mocks/message/message.go6 symbols
pkg/dingtalk/text.go6 symbols
pkg/dingtalk/markdown.go6 symbols
pkg/dingtalk/feedCard.go6 symbols
pkg/dingtalk/link.go5 symbols
cmd/dingtalk/root.go5 symbols
pkg/dingtalk/text_test.go4 symbols
pkg/dingtalk/message.go4 symbols
pkg/dingtalk/markdown_test.go4 symbols
pkg/dingtalk/client.go4 symbols
pkg/dingtalk/actionCard_test.go4 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add dingtalk \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact