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

weworkbot

v1.2.3

Published

企业微信群聊机器人

Downloads

35

Readme

weworkbot

企业微信群聊机器人, Node js >= v10

官方文档地址

https://developer.work.weixin.qq.com/document/path/91770

安装

npm i weworkbot

注意

因为企业微信限制了每个机器人最大以20条/分钟发送,所以集成了bull队列用来控制发送频率。如果没有用过bull的话,可以参考一下bull的文档。

使用

import { WeWorkBot } from 'weworkbot'
const { mdContent } = require('./content')

/**
 * 项目依赖bull队列来做限流,这里需要传入一个bull队列的实例,请自己实例化这个队列实例
  并保证将限流设置为
  limiter: {
    max: 1,
    duration: 3000,
    groupKey: 'key' // 每个机器人一个限流
  },
 */
WeWorkBot.setQueue(que)

const bot = new WeWorkBot({
  key: 'xxxx',
})

/** 发送文本消息 */
bot.sendText({
  content: '文本测试消息',
  mentioned_list: ['@all'],
})

/** 发送markdown消息 */
bot.sendMarkDown(mdContent)

/** 发送图片消息 */
bot.sendImage('test/test_file.jpg')

/** 发送图文消息 */
bot.sendNews([
  {
    title: '测试图文标题',
    url: 'https://www.qq.com',
    description: '测试图文描述',
    picurl:
      'http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png',
  },
])

/** 上传并发送文件 */
bot
  .upload({
    filePath: 'test/test_file.jpg',
  })
  .then((mid) => {
    bot.sendFile(mid)
  })

文本通知模版卡片

|字段|类型|必须|说明| |:------|:-----------|:---|:---| |card_type|String|是|模版卡片的模版类型,文本通知模版卡片的类型为text_notice| |source|Object|否|卡片来源样式信息,不需要来源样式可不填写| |source.icon_url|String|否|来源图片的url| |source.desc|String|否|来源图片的描述,建议不超过13个字| |source.desc_color|Int|否|来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色| |main_title|Object|是|模版卡片的主要内容,包括一级标题和标题辅助信息| |main_title.title|String|否|一级标题,建议不超过26个字。模版卡片主要内容的一级标题main_title.title和二级普通文本sub_title_text必须有一项填写| |main_title.desc|String|否|标题辅助信息,建议不超过30个字| |emphasis_content|Object|否|关键数据样式| |emphasis_content.title|String|否|关键数据样式的数据内容,建议不超过10个字| |emphasis_content.desc|String|否|关键数据样式的数据描述内容,建议不超过15个字| |quote_area|Object|否|引用文献样式,建议不与关键数据共用| |quote_area.type|Int|否|引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序| |quote_area.url|String|否|点击跳转的url,quote_area.type是1时必填| |quote_area.appid|String|否|点击跳转的小程序的appid,quote_area.type是2时必填| |quote_area.pagepath|String|否|点击跳转的小程序的pagepath,quote_area.type是2时选填| |quote_area.title|String|否|引用文献样式的标题| |quote_area.quote_text|String|否|引用文献样式的引用文案| |sub_title_text|String|否|二级普通文本,建议不超过112个字。模版卡片主要内容的一级标题main_title.title和二级普通文本sub_title_text必须有一项填写| |horizontal_content_list|Object[]|否|二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6| |horizontal_content_list.type|Int|否|链接类型,0或不填代表是普通文本,1 代表跳转url,2 代表下载附件,3 代表@员工| |horizontal_content_list.keyname|String|是|二级标题,建议不超过5个字| |horizontal_content_list.value|String|否|二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过26个字| |horizontal_content_list.url|String|否|链接跳转的url,horizontal_content_list.type是1时必填| |horizontal_content_list.media_id|String|否|附件的media_id

图文展示模版卡片

|字段|类型|必须|说明| |:------|:-----------|:---|:---| |card_type|String|是|模版卡片的模版类型,图文展示模版卡片的类型为news_notice| |source|Object|否|卡片来源样式信息,不需要来源样式可不填写| |source.icon_url|String|否|来源图片的url| |source.desc|String|否|来源图片的描述,建议不超过13个字| |source.desc_color|Int|否|来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色| |main_title|Object|是|模版卡片的主要内容,包括一级标题和标题辅助信息| |main_title.title|String|是|一级标题,建议不超过26个字| |main_title.desc|String|否|标题辅助信息,建议不超过30个字| |card_image|Object|是|图片样式| |card_image.url|String|是|图片的url| |card_image.aspect_ratio|Float|否|图片的宽高比,宽高比要小于2.25,大于1.3,不填该参数默认1.3| |image_text_area|Object|否|左图右文样式| |image_text_area.type|Int|否|左图右文样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序| |image_text_area.url|String|否|点击跳转的url,image_text_area.type是1时必填| |image_text_area.appid|String|否|点击跳转的小程序的appid,必须是与当前应用关联的小程序,image_text_area.type是2时必填| |image_text_area.pagepath|String|否|点击跳转的小程序的pagepath,image_text_area.type是2时选填| |image_text_area.title|String|否|左图右文样式的标题| |image_text_area.desc|String|否|左图右文样式的描述| |image_text_area.image_url|String|是|左图右文样式的图片url| |quote_area|Object|否|引用文献样式,建议不与关键数据共用| |quote_area.type|Int|否|引用文献样式区域点击事件,0或不填代表没有点击事件,1 代表跳转url,2 代表跳转小程序| |quote_area.url|String|否|点击跳转的url,quote_area.type是1时必填| |quote_area.appid|String|否|点击跳转的小程序的appid,quote_area.type是2时必填| |quote_area.pagepath|String|否|点击跳转的小程序的pagepath,quote_area.type是2时选填| |quote_area.title|String|否|引用文献样式的标题| |quote_area.quote_text|String|否|引用文献样式的引用文案| |vertical_content_list|Object[]|否|卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过4| |vertical_content_list.title|String|是|卡片二级标题,建议不超过26个字| |vertical_content_list.desc|String|否|二级普通文本,建议不超过112个字| |horizontal_content_list|Object[]|否|二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6| |horizontal_content_list.type|Int|否|模版卡片的二级标题信息内容支持的类型,1是url,2是文件附件| |horizontal_content_list.keyname|String|是|二级标题,建议不超过5个字| |horizontal_content_list.value|String|否|二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过26个字| |horizontal_content_list.url|String|否|链接跳转的url,horizontal_content_list.type是1时必填| |horizontal_content_list.media_id|String|否|附件的media_id