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-wechat-mp

v0.1.71

Published

Zhin.js adapter for WeChat Official Account (微信公众号)

Readme

@zhin.js/adapter-wechat-mp

Zhin.js 微信公众号适配器,支持微信公众号的消息收发。

功能特性

  • Webhook 事件接收(HTTP 回调)
  • 签名验证
  • Access Token 自动刷新
  • XML 消息解析
  • 可选消息加密(AES)

安装

pnpm add @zhin.js/adapter-wechat-mp

依赖

  • @zhin.js/http — HTTP 服务(提供 Webhook 路由)

配置

# zhin.config.yml
bots:
  - context: wechat-mp
    name: my-wechat-bot
    appId: ${WECHAT_APP_ID}
    appSecret: ${WECHAT_APP_SECRET}
    token: ${WECHAT_TOKEN}
    path: /wechat/webhook
    # 可选配置
    # encodingAESKey: your-aes-key
    # encrypt: false

plugins:
  - adapter-wechat-mp
  - http

TypeScript 配置

import { defineConfig } from 'zhin.js'

export default defineConfig({
  bots: [
    {
      context: 'wechat-mp',
      name: 'my-wechat-bot',
      appId: process.env.WECHAT_APP_ID!,
      appSecret: process.env.WECHAT_APP_SECRET!,
      token: process.env.WECHAT_TOKEN!,
      path: '/wechat/webhook',
    }
  ],
  plugins: ['adapter-wechat-mp', 'http']
})

使用示例

注册命令

import { usePlugin, MessageCommand } from 'zhin.js'

const { addCommand } = usePlugin()

addCommand(
  new MessageCommand('hello')
    .desc('微信问候')
    .action((message) => `你好,${message.$sender.name}!`)
)

消息中间件

import { usePlugin } from 'zhin.js'

const { addMiddleware } = usePlugin()

addMiddleware(async (message, next) => {
  if (message.$adapter === 'wechat-mp') {
    console.log('收到微信消息:', message.$content)
  }
  await next()
})

微信公众号配置

  1. 登录 微信公众平台
  2. 在「开发 → 基本配置」中获取 AppIDAppSecret
  3. 配置服务器地址(URL):http://your-server:8086/api/wechat/webhook
  4. 设置 Token(与配置文件中的 token 一致)
  5. 如需消息加解密,设置 EncodingAESKey

注意事项

  • 微信公众号要求服务器必须在 5 秒内响应
  • 服务器地址必须是公网可访问的 HTTP/HTTPS URL
  • 建议使用已备案的域名

许可证

MIT License