@@ -134,7 +134,8 @@ export class WeChatChannel {
134134 * The plugin should be installed and configured in OpenClaw
135135 *
136136 * @param markdownContent Markdown content to send
137- * @param openclawApi OpenClaw API instance for invoking tools
137+ * @param openclawApi OpenClaw API instance for invoking channels
138+ * @param config WeChat configuration
138139 * @returns Push result
139140 */
140141 static async send (
@@ -158,38 +159,37 @@ export class WeChatChannel {
158159 botAccountId : wechatBotAccountId
159160 } ) ;
160161
161- // 使用 OpenClaw system-event 发送微信消息
162- // 格式参考: {
163- // "action": "send",
164- // "channel": "openclaw-weixin",
165- // "to": "微信 ID(接收者)",
166- // "accountId": "机器人账号 ID",
167- // "message": "推送内容"
168- // }
169-
170- const systemEventParams = {
171- action : 'send' ,
172- channel : 'openclaw-weixin' ,
173- to : wechatReceiverId ,
174- accountId : wechatBotAccountId ,
175- message : markdownContent
176- } ;
162+ // 检查 openclawApi 是否包含 channels
163+ if ( ! openclawApi || ! openclawApi . channels ) {
164+ logger . error ( 'openclawApi.channels not available' ) ;
165+ return {
166+ success : false ,
167+ error : 'openclawApi.channels not available - WeChat plugin may not be installed'
168+ } ;
169+ }
177170
178- logger . debug ( 'Invoking OpenClaw system-event for WeChat...' , {
179- params : {
180- action : systemEventParams . action ,
181- channel : systemEventParams . channel ,
182- to : systemEventParams . to ,
183- accountId : systemEventParams . accountId ,
184- message : `${ markdownContent . length } chars`
185- }
171+ // 获取微信 channel 实例
172+ const wechatChannel = openclawApi . channels [ 'openclaw-weixin' ] ;
173+ if ( ! wechatChannel ) {
174+ logger . error ( 'WeChat channel "openclaw-weixin" not found' ) ;
175+ return {
176+ success : false ,
177+ error : 'WeChat channel "openclaw-weixin" not found - please install and configure the plugin'
178+ } ;
179+ }
180+
181+ // 直接调用微信 channel 的 send 方法
182+ // OpenClaw 的 channel API 通常有 send 方法
183+ logger . debug ( 'Invoking WeChat channel send...' , {
184+ receiverId : wechatReceiverId ,
185+ botAccountId : wechatBotAccountId ,
186+ messageLength : markdownContent . length
186187 } ) ;
187188
188- // 通过 executeTool 调用 system-event 工具
189- // OpenClaw 的 system-event 工具用于发送系统级消息到指定通道
190- const sendResult = await openclawApi . executeTool ( {
191- tool_name : 'system-event' ,
192- params : systemEventParams
189+ const sendResult = await wechatChannel . send ( {
190+ to : wechatReceiverId ,
191+ accountId : wechatBotAccountId ,
192+ message : markdownContent
193193 } ) ;
194194
195195 const duration = Date . now ( ) - startTime ;
0 commit comments