Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feishu-webhook-bot

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feishu-webhook-bot

### 飞书 webhook 机器人

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

feishu-webhook-bot

飞书 webhook 机器人

飞书群组机器人分为两种。

一种是单向的基于 webhook 机器人,优点是配置简单,群组设置里就能配置好。缺点是只能单向发送消息,没有交互能力。

另一种是后台配置的应用型机器人,优点是具备交互能力,缺点是有一定的学习成本。

这个 bot 是 webhook 型。

Usage

npm i --save feishu-webhook-bot

yarn add feishu-webhook-bot

创建一个 bot 对象来调用方法:

const Bot = require("feishu-webhook-bot");

// class 第一个参数是群组设置里的 webhook 地址,设置了签名校验的话,第二个参数传入密钥。
const bot = new Bot(
  "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
);

// 返回一个 Promise Promise 结果是飞书返回的 Response { StatusCode: 0, StatusMessage: 'success' }
bot.sendText("hello world!");

API

sendTet(text) 官方文档

发送一个文本消息

参数类型说明
textString需要发送的文本

Example:

bot.sendText("hello world!");

alt send_text

sendRich(richContent) 官方文档

发送一个复杂文本消息

参数类型说明
richContentObject对象

richContent

参数类型说明
titleString标题
contentArray内容二维数组,每个数组代表一行消息

content

[[{ tag: "text", "text": "hello" }] ]
单行消息数组内容为内容对象,tag 支持 4 种类型: text, a, at, img

text

{ tag: "text", "text": "hello" }
text: 文本内容 [必填]
un_escape: 是否解码 [可选]

a

{ tag: "a", text: "链接", href: "https://xx.xx" }
text: 链接内容 [必填]
href: 地址 [可选]

at

{ tag: "at", user_id: "all", use_name: "所有人" }
user_id: open_id,union_id 或 user_id [必填]
user_name: 用户姓名 [可选]

img

{ image_key: "xxxxxxxxxxxxxx" }
image_key: 上传到飞书的文件 key [必填]

Example:

bot.sendRich({
  title: "rich title",
  content: [
    [
      {
        tag: "text",
        text: "测试",
      },
      {
        tag: "a",
        href: "http://github.com",
        text: "测试",
      },
    ],
    [
      {
        tag: "at",
        user_id: "all",
      },
    ],
  ],
});

alt send_rich

FAQs

Package last updated on 05 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc