Skip to content

企业微信机器人插件

Maven 模块:mms-plugin-wechat-bot。向企业微信群机器人 Webhook 扇出 text / markdown / image / news / template_card 等消息;支持插件生命周期 Markdown 通知。

白话理解

在插件市场里配好 Webhook 列表(JSON 数组字符串),管理端带令牌调 /plugin/.../wechat/send/* 即发群消息;也可用 invoke / tryInvokePeerPluginWechatBotPlugin 上的公有方法(如 sendText)。

标识与运行模式

插件 IDmms.plugin.wechat-bot
runtimeModeHOST_MVC
hostServicesContractVersion3(使用 插件参数 pluginSysConfig
入口类com.sxpcwlkj.plugin.wechatbot.WechatBotPlugin

插件参数(sys_config 后缀)

配置可在 插件市场详情 → 插件参数 维护;完整键为 mms.plugin.{pluginId}.{suffix}

后缀含义
webhook.urlsJSON 数组字符串;一条或多条企业微信机器人 Webhook URL(仅一条时也写 ["https://..."]
lifecycle.notify.enabledtrue / false,是否响应插件生命周期 Markdown 通知

默认模板见 JAR 内 META-INF/mms/wechat-bot-default.json

权限

  • HOST_MVC 接口校验 plugin:wechatbot:send
  • 主仓提供示例 SQL:mms-plugins/mms-plugin-wechat-bot/script/install.sql(导入前请核对 id 不与现网冲突)。

Demo:引入插件

  1. 构建瘦包即可(依赖由宿主提供,以当前 pom 为准):
bash
cd mms-plugins/mms-plugin-wechat-bot
mvn -DskipTests package
# 产物:target/mms-plugin-wechat-bot-*.jar
  1. 插件市场 上传并激活;在 详情 → 插件参数 配置 webhook.urls(及可选 lifecycle.notify.enabled),或依赖 JAR 内默认 wechat-bot-default.json
  2. 执行权限 SQL 并为角色分配 plugin:wechatbot:send

Demo:调用能力

为管理端接口根(同 DeepL 分册 说明)。

HTTP

http
GET {{apiBase}}/plugin/mms.plugin.wechat-bot/wechat/formats
Authorization: <token>
http
POST {{apiBase}}/plugin/mms.plugin.wechat-bot/wechat/send/text
Content-Type: application/json
Authorization: <token>

{"content":"告警:来自 wechat-bot 插件"}

对等插件(Java)

java
ctx.tryInvokePeerPlugin(
    "mms.plugin.wechat-bot",
    "sendText",
    "hello from peer plugin");

其它公有方法见 WechatBotPlugin(如 sendMarkdownsendPluginLifecycleMarkdown)。

运维 invoke

bash
curl -sS -X POST "{{apiBase}}/system/pluginHost/invoke" \
  -H "Content-Type: application/json" \
  -H "Authorization: <token>" \
  -d '{
    "pluginId": "mms.plugin.wechat-bot",
    "methodName": "sendText",
    "args": ["hello"]
  }'

路由提示

相对前缀 /plugin/mms.plugin.wechat-bot/wechat/:除 /formats/send/text 外,尚有 /send/markdown/send/image/send/news 等(见 WechatBotMvcController)。

参见

Released under the MIT License.