{"id":21009356,"url":"https://github.com/shockerli/dingtalk","last_synced_at":"2025-03-13T15:27:11.973Z","repository":{"id":57564300,"uuid":"333635482","full_name":"shockerli/dingtalk","owner":"shockerli","description":"钉钉SDK（群机器人）","archived":false,"fork":false,"pushed_at":"2021-02-20T09:01:14.000Z","size":201,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T11:09:57.729Z","etag":null,"topics":["dingding","dingding-bot","dingtalk","dingtalk-golang-sdk","dingtalk-robot","dingtalk-sdk","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shockerli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-28T03:34:25.000Z","updated_at":"2021-02-20T09:01:16.000Z","dependencies_parsed_at":"2022-09-16T13:46:48.917Z","dependency_job_id":null,"html_url":"https://github.com/shockerli/dingtalk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fdingtalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fdingtalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fdingtalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shockerli%2Fdingtalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shockerli","download_url":"https://codeload.github.com/shockerli/dingtalk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243431057,"owners_count":20289826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dingding","dingding-bot","dingtalk","dingtalk-golang-sdk","dingtalk-robot","dingtalk-sdk","golang"],"created_at":"2024-11-19T09:16:28.686Z","updated_at":"2025-03-13T15:27:11.947Z","avatar_url":"https://github.com/shockerli.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dingtalk\n\n\u003e 钉钉群机器人SDK\n\n\n## 安装\n\n```go\ngo get github.com/shockerli/dingtalk\n```\n\n\n## 使用\n\n### 初始化配置\n\n```go\nvar robot = dingtalk.NewRobotCustom()\nrobot.SetWebhook(\"your_robot_webhook\")\nrobot.SetSecret(\"your_secret\") // 可选\n```\n\n### Text\n\n```go\nrobot.SendText(\"TEST: Text\")\n```\n\n### AtAll\n\n```go\nrobot.SendText(\"TEST: Text\u0026AtAll\", robot.AtAll())\n```\n\n### AtMobiles\n\n```go\nrobot.SendText(\"TEST: Text\u0026AtMobiles\", robot.AtMobiles(\"19900001111\"))\n```\n\n### Link\n\n```go\nrobot.SendLink(\n    \"TEST: Link\",\n    \"link content\",\n    \"https://github.com/shockerli\",\n    \"https://www.wangbase.com/blogimg/asset/202101/bg2021011601.jpg\",\n)\n```\n\n### Markdown\n\n```go\nrobot.SendMarkdown(\"TEST: Markdown\", markdown)\n\nrobot.SendMarkdown(\"TEST: Markdown\u0026AtAll\", markdown, robot.AtAll())\n\nrobot.SendMarkdown(\"TEST: Markdown\u0026AtMobiles\", markdown, robot.AtMobiles(\"19900001111\"))\n```\n\n### ActionCard\n\n```go\nrobot.SendActionCard(\n    \"TEST: ActionCard\u0026SingleCard\",\n    \"SingleCard content\",\n    robot.SingleCard(\"阅读全文\", \"https://github.com/shockerli\"),\n)\n\nrobot.SendActionCard(\n    \"TEST: ActionCard\u0026MultiCard\",\n    \"MultiCard content\",\n    robot.MultiCard(\"内容不错\", \"https://github.com/shockerli\"),\n    robot.MultiCard(\"不感兴趣\", \"https://github.com/shockerli\"),\n)\n\nrobot.SendActionCard(\n    \"TEST: ActionCard\u0026BtnOrientation\",\n    \"BtnOrientation content\",\n    robot.MultiCard(\"内容不错\", \"https://github.com/shockerli\"),\n    robot.MultiCard(\"不感兴趣\", \"https://github.com/shockerli\"),\n    robot.BtnOrientation(\"0\"),\n)\n\nrobot.SendActionCard(\n    \"TEST: ActionCard\u0026Image\",\n    \"![xxx](https://www.wangbase.com/blogimg/asset/202101/bg2021011601.jpg)\\n\\nSingleCard content with image\",\n    robot.SingleCard(\"阅读全文\", \"https://github.com/shockerli\"),\n)\n\nrobot.SendActionCard(\n    \"TEST: ActionCard\u0026HideAvatar\",\n    \"24565\\n\\n![xxx](https://www.wangbase.com/blogimg/asset/202101/bg2021011601.jpg)\\n\\nSingleCard content with image\",\n    robot.SingleCard(\"阅读全文\", \"https://github.com/shockerli\"),\n    robot.HideAvatar(\"1\"),\n)\n```\n\n### FeedCard\n\n```go\nrobot.SendFeedCard(\n    robot.FeedCard(\"3月15日起，Chromium 不能再调用谷歌 API\", \"https://bodhi.fedoraproject.org/updates/FEDORA-2021-48866282e5%29\", \"https://www.wangbase.com/blogimg/asset/202101/bg2021012506.jpg\"),\n    robot.FeedCard(\"考古学家在英国发现两枚11世纪北宋时期的中国硬币\", \"https://www.caitlingreen.org/2020/12/another-medieval-chinese-coin-from-england.html\", \"https://www.wangbase.com/blogimg/asset/202101/bg2021012208.jpg\"),\n)\n```\n\n### Outgoing\n\n```go\n// 获取HTTP请求Body\nvar contents = getRequestBody()\n\n// 解析Outgoing内容\nog, err := robot.ParseOutgoing(contents)\nif err != nil {\n    // ...\n}\n\n// 自定义业务逻辑，生成响应的Text消息内容\nvar res = doSomeThing(og)\n\n// 发送回复消息\nerr = robot.SendText(res, robot.WithOutgoing(og))\nif err != nil {\n    // ...\n}\n```\n\n\n## 获取群机器人Token\n\n- 选择自定义机器人\n\n  ![选择自定义机器人](assets/robot-select.png)\n\n- 设置机器人\n\n  ![设置机器人](assets/robot-setting.png)\n\n- 获取Webhook\u0026token\n\n  ![获取Webhook](assets/robot-token.png)\n\n\n\n## 测试\n\n1. 打开 `robot_test.go` 文件，修改 `your_robot_webhook` 和 `your_secret`；\n2. 运行单元测试 `go test -v *_test.go`；\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshockerli%2Fdingtalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshockerli%2Fdingtalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshockerli%2Fdingtalk/lists"}