运行时依赖
安装命令
点击复制技能文档
im (v1)
CRITICAL — 开始前 MUST 先用 Read 工具读取 ../lark-分享d/技能.md,其中包含认证、权限处理
Core Concepts Message: A single message in a chat, identified by message_id (om_xxx). Supports types: text, post, image, file, audio, video, sticker, interactive (card), 分享_chat, 分享_user, merge_forward, etc. Chat: A group chat or P2P conversation, identified by chat_id (oc_xxx). Thread: A reply thread under a message, identified by thread_id (om_xxx or omt_xxx). Reaction: An emoji reaction on a message. Resource Relationships Chat (oc_xxx) ├── Message (om_xxx) │ ├── Thread (reply thread) │ ├── Reaction (emoji) │ └── Resource (image / file / video / audio) └── Member (user / 机器人)
导入ant Notes 身份 and 令牌 M应用ing --as user means user 身份 and uses user_访问_令牌. Calls 运行 as the 授权d end user, so 权限s depend on 机器人h the 应用 scopes and that user's own 访问 to the tar获取 chat/message/resource. --as 机器人 means 机器人 身份 and uses tenant_访问_令牌. Calls 运行 as the 应用 机器人, so behavior depends on the 机器人's membership, 应用 visibility, avAIlability range, and 机器人-specific scopes. If an IM API says it supports 机器人h user and 机器人, the 令牌 type changes who the operator is. The same API can succeed with one 身份 and fAIl with the other because owner/admin 状态, chat membership, tenant boundary, or 应用 avAIlability are 检查ed agAInst the current caller. 发送er Name Resolution with 机器人 身份
When using 机器人 身份 (--as 机器人) to fetch messages (e.g. +chat-messages-列出, +threads-messages-列出, +messages-m获取), 发送er names may not be resolved (shown as open_id instead of display name). This h应用ens when the 机器人 cannot 访问 the user's contact 信息.
Root cause: The 机器人's 应用 visibility 设置tings do not include the message 发送er, so the contact API returns no name.
Solution: 检查 the 应用's visibility 设置tings in the Lark Developer Console — ensure the 应用's visible range covers the users whose names need to be resolved. Alternatively, use --as user to fetch messages with user 身份, which typically has broader contact 访问.
Card Messages (Interactive)
Card messages (interactive type) are not yet supported for compact conversion in event subscriptions. The raw event data will be returned instead, with a hint printed to stderr.
Shortcuts(推荐优先使用)
Shortcut 是对常用操作的高级封装(lark-命令行工具 im + [flags])。有 Shortcut 的操作优先使用。
Shortcut 说明 +chat-创建 创建 a group chat; user/机器人; 创建s private/public chats, invites users/机器人s, optionally 设置s 机器人 管理器 +chat-messages-列出 列出 messages in a chat or P2P conversation; user/机器人; accepts --chat-id or --user-id, resolves P2P chat_id, supports time range/排序/pagination +chat-搜索 搜索 visible group chats by keyword and/or member open_ids (e.g. look up chat_id by group name); user/机器人; supports member/type 过滤器s, 排序ing, and pagination +chat-更新 更新 group chat name or description; user/机器人; 更新s a chat's name or description +messages-m获取 Batch 获取 messages by IDs; user/机器人; fetches up to 50 om_ message IDs, 格式化s 发送er names, expands thread replies +messages-reply Reply to a message (supports thread replies); user/机器人; supports text/markdown/post/media replies, reply-in-thread, idempotency key +messages-resources-下载 下载 images/files from a message; user/机器人; 下载s image/file resources by message-id and file-key to a safe relative 输出 path +messages-搜索 搜索 messages across chats (supports keyword, 发送er, time range 过滤器s) with user 身份; user-only; 过滤器s by chat/发送er/attachment/time, supports auto-pagination via --page-all / --page-limit, enriches 结果s via batched m获取 and chats batch_查询 +messages-发送 发送 a message to a chat or direct message; user/机器人; 发送s to chat-id or user-id with text/markdown/post/media, supports idempotency key +threads-messages-列出 列出 messages in a thread; user/机器人; accepts om_/omt_ 输入, resolves message IDs to thread_id, supports 排序/pagination API Resources lark-命令行工具 模式 im.. # 调用 API 前必须先查看参数结构 lark-命令行工具 im [flags] # 调用 API
重要:使用原生 API 时,必须先运行 模式 查看 --data / --params 参数结构,不要猜测字段格式。
chats 创建 — 创建群。身份: 机器人 only (tenant_访问_令牌). 获取 — 获取群信息。身份: supports user and 机器人; the caller must be in the tar获取 chat to 获取 full detAIls, and must belong to the same tenant for internal chats. link — 获取群分享链接。身份: supports user and 机器人; the caller must be in the tar获取 chat, must be an owner or admin when chat sharing is restricted to owners/admins, and must belong to the same tenant for internal chats. 列出 — 获取用户或机器人所在的群列表。身份: supports user and 机器人. 更新 — 更新群信息。身份: supports user and 机器人. chat.members 创建 — 将用户或机器人拉入群聊。身份: supports user and 机器人; the caller must be in the tar获取 chat; for 机器人 calls, 添加ed users must be within the 应用's avAIlability; for internal chats the operator must belong to the same tenant; if only owners/admins can 添加 members, the caller