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 🙏

© 2026 – Pkg Stats / Ryan Hefner

feishu-bot-message-wrapper

v1.0.1

Published

一个简单快速的飞书消息发送命令行工具,基于飞书官方SDK构建

Readme

飞书消息发送工具

一个简单快速的飞书消息发送命令行工具,基于 @larksuiteoapi/node-sdkcommander.js 构建。

✨ 特性

  • 🚀 简单易用 - 支持多种配置方式(命令行参数、环境变量、配置文件)
  • 📨 多种消息类型 - 支持文本、富文本、图片、文件、音频、视频、表情包、卡片等消息类型
  • 🎴 卡片模板 - 支持飞书官方卡片模板功能
  • 🔄 消息去重 - 支持 UUID 去重,防止重复发送
  • 🛡️ 智能验证 - 完整的参数验证和错误处理
  • 📚 丰富的帮助 - 基于 commander.js 的详细帮助信息

🚀 快速开始

1. 安装依赖

bun install

2. 配置认证信息

方式一:环境变量

export FEISHU_APP_ID="your_app_id"
export FEISHU_APP_SECRET="your_app_secret"
export FEISHU_RECEIVE_ID="your_receive_id"

方式二:配置文件

创建 ~/.config/feishu-bot-config.json

{
  "appId": "your_app_id",
  "appSecret": "your_app_secret",
  "receiveId": "your_receive_id",
  "receiveIdType": "open_id"
}

3. 发送消息

# 发送文本消息
bun run index.ts --message "Hello World"

# 发送富文本消息
bun run index.ts --message-type post --message "富文本消息"

# 指定接收者
bun run index.ts --message "Hello" --receive-id "ou_xxx"

📋 支持的消息类型

  • text - 文本消息
  • post - 富文本消息
  • image - 图片消息
  • file - 文件消息
  • audio - 语音消息
  • media - 视频消息
  • sticker - 表情包消息
  • interactive - 卡片消息
  • share_chat - 分享群名片
  • share_user - 分享个人名片
  • system - 系统消息

🛠️ 使用指南

基本用法

# 查看帮助信息
bun run index.ts --help

# 查看版本信息
bun run index.ts --version

# 发送文本消息
bun run index.ts --message "这是一条测试消息"

# 发送富文本消息
bun run index.ts --message-type post --message "这是一条富文本消息"

# 发送卡片消息
bun run index.ts --message-type interactive --message "这是一条卡片消息"

# 指定接收者ID类型
bun run index.ts --receive-id-type "chat_id" --message "群聊消息"

高级功能

卡片模板消息

# 使用模板发送消息
bun run index.ts \
  --template-id "your_template_id" \
  --template-variable '{"title":"标题","content":"内容"}' \
  --receive-id "ou_xxx"

消息去重

# 使用UUID防止重复发送
bun run index.ts \
  --message "重要消息" \
  --uuid "unique-identifier" \
  --receive-id "ou_xxx"

完整参数示例

bun run index.ts \
  --app-id "your_app_id" \
  --app-secret "your_app_secret" \
  --receive-id "your_receive_id" \
  --receive-id-type "open_id" \
  --message "Hello World" \
  --message-type "text" \
  --config "./config.json" \
  --uuid "unique-identifier"

⚙️ 配置方式

工具支持三种配置方式,优先级从高到低:

  1. 命令行参数 - 最高优先级
  2. 环境变量 - 中等优先级
  3. 配置文件 - 最低优先级

环境变量列表

  • FEISHU_APP_ID - 飞书应用ID
  • FEISHU_APP_SECRET - 飞书应用Secret
  • FEISHU_RECEIVE_ID - 接收者ID
  • FEISHU_RECEIVE_ID_TYPE - 接收者ID类型

配置文件格式

默认配置文件路径:~/.config/feishu-bot-config.json

{
  "appId": "your_app_id",
  "appSecret": "your_app_secret",
  "receiveId": "your_receive_id",
  "receiveIdType": "open_id"
}

🎯 命令行选项

基于 commander.js 提供丰富的命令行选项:

Options:
  --app-id <id>              飞书应用ID
  --app-secret <secret>      飞书应用Secret
  --receive-id <id>          接收者ID
  --receive-id-type <type>   接收者ID类型 (open_id, union_id, user_id, email, chat_id)
  --message <text>           消息内容
  --message-type <type>      消息类型
  --config <path>            配置文件路径
  --uuid <uuid>              消息去重标识符
  --template-id <id>         消息卡片模板ID
  --template-variable <json> 模板变量JSON
  -h, --help                 显示帮助信息
  -V, --version              显示版本信息

📦 依赖项

  • @larksuiteoapi/node-sdk - 飞书官方SDK
  • commander.js - 命令行界面框架
  • bun - JavaScript 运行时和包管理器

🔧 开发

项目结构

feishu_bot_message_wrapper/
├── index.ts                 # 主程序入口
├── package.json            # 项目配置
├── README.md               # 项目说明
├── USAGE.md                # 使用指南
├── FIX_REPORT.md           # 修复报告
└── CLAUDE.md              # Claude 配置

运行脚本

# 启动开发服务器
bun run start

# 构建项目
bun run build

# 运行测试
bun run test

🧪 测试

确保配置正确的环境变量后,可以运行以下命令测试:

# 测试文本消息
bun run index.ts --message "测试消息"

# 测试富文本消息
bun run index.ts --message-type post --message "富文本测试"

# 测试卡片消息
bun run index.ts --message-type interactive --message "卡片测试"

📚 官方文档

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License


注意:使用前请确保已在飞书开放平台创建应用并获取相应的 App ID 和 App Secret。