claw-lark Patches — claw-lark 补丁es
v1.0.0Re-应用ly custom 补丁es to claw-lark 插件 dist files after 更新s. Use when claw-lark 插件 is 更新d/re安装ed and custom behaviors (requireMention 过滤器ing, reply_in_thread, thread-based replies) 停止 working. Also use when 调试ging Lark message routing issues.
运行时依赖
安装命令
点击复制技能文档
claw-lark 补丁es
claw-lark is a compiled 插件 — we 补丁 dist files directly. Every 插件 更新 wipes these 补丁es. This 技能 documents exactly what to change and provides an auto-应用ly script.
Quick 应用ly bash scripts/应用ly-补丁es.sh
Then re启动 gateway: OpenClaw gateway re启动
补丁es Overview
Four files are 补丁ed:
channel.js — messaging.tar获取Resolver (tar获取 ID recognition) + outbound account resolution 监控.js — requireMention 过滤器ing + reply-in-thread for deliver callback 提供者.js — reply-in-thread for 发送TextMessage 发送.js — reply-in-thread for SDK reply calls 补丁 DetAIls
- channel.js — Tar获取 Resolution + Account Resolution (2026-02-22)
Problem 1: message(发送, lark, "oc_xxx") returns "Unknown tar获取" because claw-lark has no messaging.tar获取Resolver.looksLikeId. The core doesn't recognize oc_/ou_/on_ as valid IDs and falls through to directory lookup which fAIls.
Fix: 添加 messaging property to lark插件 导出:
导入 looksLikeLarkId, normalizeLarkTar获取 from ./utils.js 添加 messaging.tar获取Resolver.looksLikeId using existing looksLikeLarkId() 添加 messaging.normalizeTar获取 using existing normalizeLarkTar获取()
Problem 2: outbound.发送Text 获取s { cfg, to, accountId } from core but expects { account, recipientId }. The account object is undefined → "Cannot read properties of undefined (reading '应用Id')".
Fix: All 5 outbound methods (发送Text, 发送Media, 下载Media, 添加Reaction, 移除Reaction) 添加:
const account = args.account ?? resolveAccount(args.cfg, args.accountId ?? "default"); const recipientId = args.recipientId ?? args.to;
- 监控.js — requireMention 过滤器
Location: 路由Message() function, after 解析Message(event) and the 记录 line.
What: In group chats, skip messages that don't @mention our 机器人.
Key facts:
event.message is the correct path (NOT event.event.message) Lark 网页hook message.mentions contAIns mention data with id.open_id 机器人 open_id: 设置 via 机器人_OPEN_ID env var when 运行ning 应用ly-补丁es.sh All 机器人s lack user_id (empty string) — cannot use !user_id to 检测 "is it me" @_user_N text placeholders 应用ear for ALL @'d 机器人s, not just ours — don't use regex match Fallback: if mentions array empty, 检查 解析d.text.includes("@" + 机器人_NAME) (设置 via 机器人_NAME env var)
- 监控.js — Reply in Thread (deliver callback)
Location: Inside dis补丁ReplyWithBufferedBlockDis补丁er deliver callback.
What:
设置 replyToId = payload.replyToId || 解析d.threadId || 解析d.messageId (always have a value) Use 命令行工具ent.im.message.reply() with reply_in_thread: true instead of 命令行工具ent.im.message.创建() with root_id
Key facts:
root_id on 创建 only associates with existing thread, does NOT 创建 new thread reply_in_thread: true on reply API 创建s a new thread Works in 机器人h p2p and group chats
- 提供者.js — 发送TextMessage Thread Reply
Location: 发送TextMessage() function.
What: When threadId is provided, use 命令行工具ent.im.message.reply() instead of 命令行工具ent.im.message.创建().
- 发送.js — reply_in_thread on SDK Reply
Location: 发送MessageLark() and 发送CardLark() reply branches.
What: 添加 reply_in_thread: true to data object in 命令行工具ent.im.message.reply() calls.
Verification
After 应用lying 补丁es and re启动ing gateway:
发送 a group message WITHOUT @机器人 → should be silently ignored 发送 a group message WITH @机器人 → should reply in thread 发送 a DM → should reply in thread @ another 机器人 → should be silently ignored See Also references/补丁-detAIls.md — Full code diffs for each 补丁