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

dingtalk-robot-multi-platform

v0.0.5

Published

基于nodejs的跨平台钉钉机器人

Downloads

11

Readme

dingtalk-robot-multi-platform

基于 nodejs 的跨平台钉钉机器人

功能

  • 支持通过 API 发消息到钉钉群。
  • 支持 GitLab 的 webhook 功能转发消息到钉钉群,参考项目gitlab-dingtalk

使用

  1. 安装依赖
npm install dingtalk-robot-multi-platform -S
  1. 填写accessToken,初始化并发布消息
const accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
(async () => {
  const DingtalkRobot = require("dingtalk-robot-multi-platform");
  dingtalkRobot = new DingtalkRobot(accessToken);
  const res = await robot.sendText("hello world");
  console.log(res);
})();

消息类型

text 类型

robot.sendText("hello world");
robot.sendText("hello ding talk", true); // 抄送所有人

link 类型

// 发送链接,消息点击后跳转
robot.sendLink({
  text: "hello dingtalk",
  title: "hello wold",
  picUrl: "https://placeholdit.imgix.net/~text?txtsize=14&txt=FreeGroup.org+Cool&w=800&h=600",
  messageUrl: "http://baidu.com",
});

markdown 类型

robot.sendMarkdown({
  title: " 注意了! 注意了!",
  text: `
    > 说点啥呢。。。
   ![必须要截图](http://image.jpg)
   [点击看详情](http://www.taobao.cn/)
  `,
});

支持的 markdown 语法

标题

# 一级标题

## 二级标题

### 三级标题

#### 四级标题

##### 五级标题

###### 六级标题

引用

> A man who stands for nothing will fall for anything.

文字加粗、斜体
**bold**
_italic_

链接
[this is a link](http://name.com)

图片
![](http://name.com/pic.jpg)

无序列表

- item1
- item2

有序列表

1. item1
2. item2

发布其他消息

  • 参考:https://open.dingtalk.com/document/robots/custom-robot-access

原始消息类型

  • text 类型
const options = {
  at: {
    atMobiles: ["180xxxxxx"],
    atUserIds: ["user123"],
    isAtAll: false,
  },
  text: {
    content: "我就是我, @XXX 是不一样的烟火",
  },
  msgtype: "text",
};
  • link 类型
const options = {
  msgtype: "link",
  link: {
    text: "这个即将发布的新版本,创始人xx称它为红树林。而在此之前,每当面临重大升级,产品经理们都会取一个应景的代号,这一次,为什么是红树林",
    title: "时代的火车向前开",
    picUrl: "",
    messageUrl:
      "https://www.dingtalk.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI",
  },
};
  • markdown 类型
const options = {
  msgtype: "markdown",
  markdown: {
    title: "杭州天气",
    text: "#### 杭州天气 @150XXXXXXXX \n > 9度,西北风1级,空气良89,相对温度73%\n > ![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png)\n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n",
  },
  at: {
    atMobiles: ["150XXXXXXXX"],
    atUserIds: ["user123"],
    isAtAll: false,
  },
};
  • 整体跳转 ActionCard 类型
const options = {
  actionCard: {
    title: "乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身",
    text: `![screenshot](https://gw.alicdn.com/tfs/TB1ut3xxbsrBKNjSZFpXXcXhFXa-846-786.png)
 ### 乔布斯 20 年前想打造的苹果咖啡厅
 Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划`,
    btnOrientation: "0",
    singleTitle: "阅读全文",
    singleURL: "https://www.dingtalk.com/",
  },
  msgtype: "actionCard",
};
  • 独立跳转 ActionCard 类型
const options = {
  msgtype: "actionCard",
  actionCard: {
    title: "我 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身",
    text: "![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png) \n\n #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划",
    btnOrientation: "0",
    btns: [
      {
        title: "内容不错",
        actionURL: "https://www.dingtalk.com/",
      },
      {
        title: "不感兴趣",
        actionURL: "https://www.dingtalk.com/",
      },
    ],
  },
};
  • FeedCard 类型
const options = {
  msgtype: "feedCard",
  feedCard: {
    links: [
      {
        title: "时代的火车向前开1",
        messageURL: "https://www.dingtalk.com/",
        picURL: "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png",
      },
      {
        title: "时代的火车向前开2",
        messageURL: "https://www.dingtalk.com/",
        picURL: "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png",
      },
    ],
  },
};

调用

const DingtalkRobot = require("dingtalk-robot-multi-platform");
const options = {...}; // 根据类型生成 options
let robot = new DingTalkRobot("accessToken");
robot.send(options);