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

@zhin.js/adapter-line

v2.0.0

Published

Zhin.js adapter for LINE Messaging API

Readme

@zhin.js/adapter-line

Zhin.js 适配器 — LINE Messaging API (Webhook 模式)

功能

  • 接收并解析 LINE Webhook 事件(text、image、video、audio、file、location、sticker)
  • 支持私聊、群组、多人聊天(room)三种场景
  • Reply API / Push API 发送消息
  • HMAC-SHA256 签名验证

前置条件

  1. LINE Developers Console 创建 Messaging API Channel
  2. 获取 Channel SecretChannel Access Token
  3. 设置 Webhook URL 为 https://your-domain/line/webhook
  4. 在 Console 中启用 Use webhooks 并关闭 Auto-reply messages

最小配置

# zhin.config.yml
adapters:
  - context: line
    name: my-line-bot
    channelSecret: ${LINE_CHANNEL_SECRET}
    channelAccessToken: ${LINE_CHANNEL_ACCESS_TOKEN}
    webhookPath: /line/webhook       # 可选,默认 /line/webhook
    apiBaseUrl: https://api.line.me   # 可选,调试时可改为 LINE API 沙盒地址

环境变量

| 变量 | 说明 | |------|------| | LINE_CHANNEL_SECRET | Channel Secret(签名验证用) | | LINE_CHANNEL_ACCESS_TOKEN | Long-lived Channel Access Token(API 调用用) |

Webhook URL 配置

LINE 要求 Webhook URL 以 HTTPS 开头。常见方案:

  • 反向代理:Nginx/Caddy 将 https://your-domain/line/webhook 转发到本地 zhIn 端口
  • Cloudflare Tunnelcloudflared tunnel --url http://localhost:端口
  • ngrok:调试用 ngrok http 端口

设置完成后在 LINE Developers Console 点击 Verify 验证连通性。

消息类型映射

| LINE 类型 | Zhin.js Segment | 说明 | |-----------|----------------|------| | text | text | 纯文本 | | image | image | 图片(暂不支持二次获取) | | video | video | 视频 | | audio | audio | 音频 | | file | file | 文件 | | location | location | 位置信息 | | sticker | sticker | 贴纸 |

已知限制

  • 不支持消息撤回:LINE Messaging API 不提供撤回已发送消息的接口
  • 图片/视频/音频:收到的媒体消息仅包含 message_id,需通过 Content API 下载(未实装)
  • 单次最多 5 条消息:LINE 限制单次 Reply/Push 最多 5 条
  • 文本长度限制:单条文本消息最多 5000 字符

故障排查

| 问题 | 排查方法 | |------|---------| | Webhook Verify 失败 | 检查 HTTPS 证书、域名解析、端口是否可达 | | 签名验证 403 | 确认 Channel Secret 与 Console 一致 | | 发送 401 | 确认 Channel Access Token 未过期 | | 发送 400 | 检查消息格式是否符合 LINE API 规范 | | 事件未到达 | Console 中 Webhook 是否已启用、是否关闭 Auto-reply |