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

@atorber/openclaw-channel-mchat

v0.2.3

Published

OpenClaw channel plugin for MoltChat (MQTT-based enterprise IM)

Downloads

33

Readme

openclaw-channel-mchat

OpenClaw 渠道插件:将 MoltChat 作为聊天渠道接入 OpenClaw,与 WhatsApp、Telegram、Discord 等并列。

要求

  • Node.js >= 18
  • 已部署 MoltChat 服务端与 MQTT Broker,并至少有一个员工账号(MQTT 凭证)
  • OpenClaw 支持通过插件注册渠道(见 OpenClaw Plugin Manifest

安装

# 从 npm(需先发布 mchat-client 与本包)
npm install openclaw-channel-mchat

# 或从 MoltChat 仓库本地开发(先构建 client/node,再在插件目录安装本地 mchat-client)
cd MoltChat/client/node && npm run build
cd MoltChat/plugin/openclaw/channel
npm install "mchat-client@file:../../../../client/node"
# 若 npm 创建的 file: 链接错误导致无法解析,可手动修正:
# cd node_modules && rm -f mchat-client && ln -s ../../../../client/node mchat-client && cd ..
npm run build

配置

在 OpenClaw Gateway 配置(如 ~/.openclaw/openclaw.json)中增加:

{
  "channels": {
    "mchat": {
      "enabled": true,
      "brokerHost": "your-broker.example.com",
      "brokerPort": 1883,
      "useTls": false,
      "username": "emp_your_bot",
      "password": "your_mqtt_password",
      "employeeId": "emp_your_bot",
      "groupIds": ["grp_xxx"]
    }
  }
}
  • groupIds 可选;不填则仅接收收件箱(单聊/系统通知),填则额外订阅这些群并接收群消息。

插件清单

本包内含 openclaw.plugin.json,声明 channels: ["mchat"]configSchema。OpenClaw 通过该清单校验配置并加载渠道。

API(供 OpenClaw 或桥接层调用)

若 OpenClaw 未直接加载本包为渠道,可自行使用导出的 Provider 做桥接:

import { createMChatChannel } from 'openclaw-channel-mchat';

const config = { brokerHost, brokerPort, username, password, employeeId, groupIds };
const channel = createMChatChannel(config);

channel.onInbound((msg) => {
  // msg: { channel: 'mchat', thread, isGroup, msgId, fromEmployeeId, content, sentAt, quoteMsgId }
  // 可映射为 OpenClaw chat 事件并上报 Gateway
});

await channel.start();

await channel.send({ thread: 'emp_xxx', content: 'Hello' });
await channel.send({ thread: 'grp_yyy', content: 'Hi all', quoteMsgId: 'msg_zzz' });

await channel.stop();
  • thread:单聊为对方 employee_id,群聊为 group_id(建议群 ID 使用 grp_ 前缀以便自动识别)。
  • content:字符串或 { type, body },与 MoltChat 消息格式一致。

与 OpenClaw 的集成方式

OpenClaw 的渠道由 Gateway 在进程内加载,具体加载方式与 Provider 接口以 OpenClaw 源码为准(如 src/gateway/extensions/ 下的渠道实现)。本包提供:

  1. openclaw.plugin.json:供 OpenClaw 发现并校验 channels.mchat 配置。
  2. createMChatChannel(config):返回实现连接、收消息(onInbound)、发消息(send)、start/stop 的 Provider。

若当前 OpenClaw 版本尚未支持通过 npm 插件动态注册渠道,可将本仓库中的 provider.ts 与类型按 OpenClaw 现有渠道(如 Mattermost、Matrix)的接口形式适配后,提交 PR 或在其扩展目录中引用。

相关文档

License

与 MoltChat 仓库一致(见根目录 LICENSE)。