npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hubot-dingtalk

v1.5.0

Published

[Hubot](http://hubot.github.com/) 的`dingtalk`适配器,让钉钉机器人无缝接入`hubot`。

Downloads

15

Readme

hubot-dingtalk

Hubotdingtalk适配器,让钉钉机器人无缝接入hubot

注意: 需要先配置好hubot

目前支持:

  • 企业内部机器人(签名sign方式)
  • 自定义机器人(token匹配方式)

环境变量:

  • HUBOT_DINGTALK_AUTH_TYPE (认证类型:token,sign)
  • HUBOT_DINGTALK_TOKEN (认证类型为token时)
  • HUBOT_DINGTALK_SECRET (认证类型为sign时)
  • HUBOT_DINGTALK_MODE (会话类型,1:全部,2:单聊,3:群聊)
  • HUBOT_DINGTALK_BLACKLIST (会话黑名单,格式为cidyyyy==,cidxxxx=,优先极高)
  • HUBOT_DINGTALK_WHITELIST (会话白名单,格式为cidyyyy==,cidxxxx=)

Adapter 配置

添加自定义机器人

打开钉钉添加机器人页面,在底部找到POST 地址Token(需要开通Outgoing权限)

POST 地址

Adapter在启动之后会创建回调/hubot/dingtalk/message/用于接收消息。

POST 地址填入域名/hubot/dingtalk/message/

添加企业内部机器人

登录钉钉开发平台创建。

权限认证

1.token比较

配置环境变量:

  • HUBOT_DINGTALK_AUTH_TYPE=token
  • HUBOT_DINGTALK_TOKEN

HUBOT_DINGTALK_TOKEN对应钉钉自定义机器人outgoing回调token,用于校验POST 地址接收请求的有效性。

2.sign签名

配置环境变量:

  • HUBOT_DINGTALK_AUTH_TYPE=sign
  • HUBOT_DINGTALK_SECRET

HUBOT_DINGTALK_SECRET在企业机器人配置appSecret一栏。

会话控制

目前支持基础的会话控制,包含会话类型(单聊、群聊),会话黑白名单(基于conversationId

  • HUBOT_DINGTALK_MODE=1
  • HUBOT_DINGTALK_BLACKLIST=cidyyyy==,cidxxxx=
  • HUBOT_DINGTALK_WHITELIST=cidyyyy==,cidxxxx=

会优先使用黑名单,关于要使用哪种方式可以自由选取。

该方案目前是简单实现,conversationId的获取还没想到比较好的方式,因为时间问题,临时获取方式是在控制台中输出。

配置Webhook主动发送

在机器人目录conf目录(没有请创建),添加dingtalk-room.json文件。

同一个机器人在不同群的access_token是不一样的,所以要主动发送消息到群是要指定access_token

这里通过维护别名的方式来实现发送到指定群,room是自定义的名称,可以设置成群聊名称一样,envaccess_token的环境变量名称。

[
  {
    "room": "room1",
    "env": "HUBOT_DINGTALK_ACCESS_TOKEN"
  },
  {
    "room": "room2",
    "env": "HUBOT_DINGTALK_ACCESS_TOKEN2"
  }
]

如何发送?

调用robot.messageRoom时,传入你想要发送的群聊别名即可。

module.exports = (robot) ->
  robot.on "dingtalk", (params) ->
    robot.messageRoom 'room1', "response"

Todo

  • [x] 接入主动发消息webhook
  • [ ] 优化消息显示

反馈

| Github Issue | 钉钉群 | | --- | --- | | issues | |

如果喜欢的话

如果喜欢的话,欢迎请我喝一杯咖啡。star,follow也是对我工作的肯定和鼓励。