{"id":17685527,"url":"https://github.com/ineo6/hubot-dingtalk","last_synced_at":"2025-07-30T19:34:13.064Z","repository":{"id":69238064,"uuid":"194387707","full_name":"ineo6/hubot-dingtalk","owner":"ineo6","description":"hubot-dingtalk：支持钉钉Outgoing","archived":false,"fork":false,"pushed_at":"2020-07-18T03:09:43.000Z","size":168,"stargazers_count":32,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-15T06:27:51.843Z","etag":null,"topics":["adapter","dingtalk","dingtalk-robot","hubot","hubot-dingtalk"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ineo6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-29T09:25:28.000Z","updated_at":"2023-04-19T09:57:33.000Z","dependencies_parsed_at":"2023-02-27T23:46:28.697Z","dependency_job_id":null,"html_url":"https://github.com/ineo6/hubot-dingtalk","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ineo6%2Fhubot-dingtalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ineo6%2Fhubot-dingtalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ineo6%2Fhubot-dingtalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ineo6%2Fhubot-dingtalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ineo6","download_url":"https://codeload.github.com/ineo6/hubot-dingtalk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246552948,"owners_count":20795835,"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":["adapter","dingtalk","dingtalk-robot","hubot","hubot-dingtalk"],"created_at":"2024-10-24T10:28:06.038Z","updated_at":"2025-04-01T09:30:31.273Z","avatar_url":"https://github.com/ineo6.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hubot-dingtalk\n\n[Hubot](http://hubot.github.com/) 的`dingtalk`适配器，让钉钉机器人无缝接入`hubot`。\n\n**注意: 需要先配置好`hubot`。**\n\n目前支持：\n\n- 企业内部机器人（签名sign方式）\n- 自定义机器人（token匹配方式）\n\n环境变量：\n\n- `HUBOT_DINGTALK_AUTH_TYPE` (认证类型：token,sign)\n- `HUBOT_DINGTALK_TOKEN` (认证类型为token时)\n- `HUBOT_DINGTALK_SECRET` (认证类型为sign时)\n- `HUBOT_DINGTALK_MODE` (会话类型，1:全部，2:单聊，3:群聊)\n- `HUBOT_DINGTALK_BLACKLIST` (会话黑名单，格式为`cidyyyy==,cidxxxx=`，优先极高)\n- `HUBOT_DINGTALK_WHITELIST` (会话白名单，格式为`cidyyyy==,cidxxxx=`)\n\n## Adapter 配置\n\n### 添加自定义机器人\n\n打开钉钉添加机器人页面，在底部找到`POST 地址`和`Token`（需要开通Outgoing权限）\n\n#### POST 地址\n\n`Adapter`在启动之后会创建回调`/hubot/dingtalk/message/`用于接收消息。\n\n在`POST 地址`填入`域名/hubot/dingtalk/message/`\n\n### 添加企业内部机器人\n\n登录钉钉开发平台创建。\n\n#### 权限认证\n\n1.token比较\n\n配置环境变量：\n\n- `HUBOT_DINGTALK_AUTH_TYPE=token`\n- `HUBOT_DINGTALK_TOKEN`\n\n`HUBOT_DINGTALK_TOKEN`对应钉钉自定义机器人`outgoing`回调`token`，用于校验`POST 地址`接收请求的有效性。\n\n\n2.sign签名\n\n配置环境变量：\n\n- `HUBOT_DINGTALK_AUTH_TYPE=sign`\n- `HUBOT_DINGTALK_SECRET`\n\n`HUBOT_DINGTALK_SECRET`在企业机器人配置`appSecret`一栏。\n\n#### 会话控制\n\n目前支持基础的会话控制，包含会话类型（单聊、群聊），会话黑白名单（基于`conversationId`）\n\n- `HUBOT_DINGTALK_MODE=1`\n- `HUBOT_DINGTALK_BLACKLIST=cidyyyy==,cidxxxx=`\n- `HUBOT_DINGTALK_WHITELIST=cidyyyy==,cidxxxx=`\n\n会优先使用黑名单，关于要使用哪种方式可以自由选取。\n\n该方案目前是简单实现，`conversationId`的获取还没想到比较好的方式，因为时间问题，临时获取方式是在控制台中输出。\n\n## 配置Webhook主动发送\n\n在机器人目录`conf`目录（没有请创建），添加`dingtalk-room.json`文件。\n\n同一个机器人在不同群的`access_token`是不一样的，所以要主动发送消息到群是要指定`access_token`。\n\n这里通过维护别名的方式来实现发送到指定群，`room`是自定义的名称，可以设置成群聊名称一样，`env`是`access_token`的环境变量名称。\n\n```json\n[\n  {\n    \"room\": \"room1\",\n    \"env\": \"HUBOT_DINGTALK_ACCESS_TOKEN\"\n  },\n  {\n    \"room\": \"room2\",\n    \"env\": \"HUBOT_DINGTALK_ACCESS_TOKEN2\"\n  }\n]\n```\n\n### 如何发送？\n\n调用`robot.messageRoom`时，传入你想要发送的群聊别名即可。\n\n```coffeescript\nmodule.exports = (robot) -\u003e\n  robot.hear \"dingtalk\", (params) -\u003e\n    robot.messageRoom 'room1', \"response\"\n```\n\n这段代码使用了`coffeescript`，所以建立的文件扩展名必须是`.coffee`，当然你也可以转换为`js`语法，然后放到`.js`的文件里。\n\n## Todo\n\n- [x] 接入主动发消息webhook\n- [ ] 优化消息显示\n\n## 反馈\n\n| Github Issue | 钉钉群  |\n| --- | --- |\n| [issues](https://github.com/ineo6/hubot-dingtalk/issues) | \u003cimg src=\"https://cdn.jsdelivr.net/gh/ineo6/hubot-dingtalk/dingtalk-group.JPG\" width=\"260\" /\u003e  |\n\n## 如果喜欢的话\n\n如果喜欢的话，欢迎请我喝一杯咖啡。`star`,`follow`也是对我工作的肯定和鼓励。\n\n\u003cimg src=\"https://cdn.jsdelivr.net/gh/ineo6/hubot-dingtalk/wechat-like.jpeg\" alt=\"wechat-like\" width=256 height=256 /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fineo6%2Fhubot-dingtalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fineo6%2Fhubot-dingtalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fineo6%2Fhubot-dingtalk/lists"}