[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77YX0V9J85MBT313H8HXK4N":3,"skill-same:01M77YX0V9J85MBT313H8HXK4N":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M77YX0V9J85MBT313H8HXK4N","lark-bot",null,"飞书\u002FLark Bot 完整对接方案 - 所有敏感配置从环境变量读取，支持消息收发、知识库操作、Bitable 任务管理","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fx\u002Fxiaoman-lark-bot\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: lark-bot\ndescription: \"飞书\u002FLark Bot 完整对接方案 - 所有敏感配置从环境变量读取，支持消息收发、知识库操作、Bitable 任务管理\"\nmetadata: { \n  \"openclaw\": { \n    \"emoji\": \"🦉\", \n    \"requires\": { \n      \"bins\": [\"python3\"], \n      \"env\": [\"LARK_APP_ID\", \"LARK_APP_SECRET\"] \n    } \n  } \n}\n---\n\n# Lark Bot 完整对接方案\n\n本 skill 提供飞书 Bot 完整对接方案，包含消息收发、知识库操作、Bitable 任务管理。所有配置均从环境变量读取，确保安全。\n\n## 环境变量配置\n\n在使用本 skill 前，需配置以下环境变量：\n\n| 变量名 | 说明 | 示例 |\n|--------|------|------|\n| `LARK_APP_ID` | 飞书应用 ID | cli_xxxxxxxx |\n| `LARK_APP_SECRET` | 飞书应用密钥 | xxxxxxxxxxxxxx |\n| `LARK_APP_TOKEN` | Bitable App Token（可选） | ${LARK_APP_TOKEN} |\n| `LARK_TABLE_ID` | Bitable Table ID（可选） | ${LARK_TABLE_ID} |\n| `LARK_SPACE_ID` | Wiki 知识库 ID（可选） | 76036636xxxxx |\n| `LARK_CHAT_ID` | 群聊 ID（可选） | ${LARK_CHAT_ID} |\n\n## 核心功能\n\n### 1. 获取 Access Token\n\n```python\nimport os\nimport json\nimport urllib.request\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\n\ndef get_tenant_access_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\n        \"app_id\": APP_ID,\n        \"app_secret\": APP_SECRET\n    }).encode()\n    \n    req = urllib.request.Request(\n        url, \n        data=data, \n        headers={'Content-Type': 'application\u002Fjson'}\n    )\n    \n    with urllib.request.urlopen(req, timeout=10) as resp:\n        result = json.loads(resp.read())\n        return result.get(\"tenant_access_token\")\n\ntoken = get_tenant_access_token()\nprint(f\"Token: {token}\")\n```\n\n### 2. 发送消息到群聊\n\n```python\nimport os\nimport json\nimport urllib.request\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nCHAT_ID = os.environ.get(\"LARK_CHAT_ID\", \"\")\n\ndef get_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    return json.loads(urllib.request.urlopen(req).read())['tenant_access_token']\n\ndef send_message(text):\n    token = get_token()\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fim\u002Fv1\u002Fmessages\"\n    params = f\"?receive_id_type=chat_id\"\n    data = {\n        \"receive_id\": CHAT_ID,\n        \"msg_type\": \"text\",\n        \"content\": json.dumps({\"text\": text})\n    }\n    \n    req = urllib.request.Request(\n        url + params,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {token}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 发送消息\nresult = send_message(\"Hello from Lark Bot!\")\nprint(result)\n```\n\n### 3. 发送富文本卡片消息\n\n```python\nimport os\nimport json\nimport urllib.request\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nCHAT_ID = os.environ.get(\"LARK_CHAT_ID\", \"\")\n\ndef get_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    return json.loads(urllib.request.urlopen(req).read())['tenant_access_token']\n\ndef send_interactive_card(text, button_text, button_url):\n    token = get_token()\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fim\u002Fv1\u002Fmessages\"\n    params = \"?receive_id_type=chat_id\"\n    \n    card = {\n        \"config\": {\"wide_screen_mode\": True},\n        \"header\": {\n            \"title\": {\"tag\": \"plain_text\", \"content\": \"📢 通知\"},\n            \"template\": \"blue\"\n        },\n        \"elements\": [\n            {\n                \"tag\": \"div\",\n                \"text\": {\"tag\": \"plain_text\", \"content\": text}\n            },\n            {\n                \"tag\": \"action\",\n                \"actions\": [\n                    {\n                        \"tag\": \"button\",\n                        \"text\": {\"tag\": \"plain_text\", \"content\": button_text},\n                        \"type\": \"primary\",\n                        \"url\": button_url\n                    }\n                ]\n            }\n        ]\n    }\n    \n    data = {\n        \"receive_id\": CHAT_ID,\n        \"msg_type\": \"interactive\",\n        \"content\": json.dumps(card)\n    }\n    \n    req = urllib.request.Request(\n        url + params,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {token}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req).read())\n\nresult = send_interactive_card(\"报告已生成\", \"查看详情\", \"https:\u002F\u002Fexample.com\")\nprint(result)\n```\n\n### 4. 操作 Bitable（任务管理）\n\n```python\nimport os\nimport json\nimport urllib.request\nimport time\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nAPP_TOKEN = os.environ.get(\"LARK_APP_TOKEN\", \"\")\nTABLE_ID = os.environ.get(\"LARK_TABLE_ID\", \"\")\n\n_cache = {'token': None, 'exp': 0}\n\ndef get_token():\n    if _cache['token'] and time.time() \u003C _cache['exp']:\n        return _cache['token']\n    \n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    \n    with urllib.request.urlopen(req, timeout=10) as resp:\n        result = json.loads(resp.read())\n        _cache['token'] = result['tenant_access_token']\n        _cache['exp'] = time.time() + result.get('expire', 7200) - 300\n        return _cache['token']\n\ndef api(method, path, body=None):\n    base_url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fbitable\u002Fv1\u002Fapps\u002F{APP_TOKEN}\u002Ftables\u002F{TABLE_ID}\"\n    url = base_url + path\n    data = json.dumps(body).encode() if body else None\n    \n    req = urllib.request.Request(\n        url,\n        data=data,\n        method=method,\n        headers={\n            'Authorization': f'Bearer {get_token()}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req, timeout=15).read())\n\n# 列出所有记录\ndef list_records():\n    return api(\"GET\", \"\u002Frecords?page_size=100\")\n\n# 创建记录\ndef create_record(name, status=\"待办\", priority=\"中\"):\n    fields = {\n        \"任务名称\": name,\n        \"状态\": status,\n        \"优先级\": priority\n    }\n    return api(\"POST\", \"\u002Frecords\", {\"fields\": fields})\n\n# 更新记录\ndef update_record(record_id, fields):\n    return api(\"PUT\", f\"\u002Frecords\u002F{record_id}\", {\"fields\": fields})\n\n# 删除记录\ndef delete_record(record_id):\n    return api(\"DELETE\", f\"\u002Frecords\u002F{record_id}\")\n\n# 使用示例\nrecords = list_records()\nprint(f\"当前有 {len(records.get('data', {}).get('items', []))} 条任务\")\n```\n\n### 5. 操作 Wiki 知识库\n\n```python\nimport os\nimport json\nimport urllib.request\nimport time\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nSPACE_ID = os.environ.get(\"LARK_SPACE_ID\", \"\")\n\n_cache = {'token': None, 'exp': 0}\n\ndef get_token():\n    if _cache['token'] and time.time() \u003C _cache['exp']:\n        return _cache['token']\n    \n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    \n    with urllib.request.urlopen(req, timeout=10) as resp:\n        result = json.loads(resp.read())\n        _cache['token'] = result['tenant_access_token']\n        _cache['exp'] = time.time() + result.get('expire', 7200) - 300\n        return _cache['token']\n\n# 获取知识库列表\ndef list_spaces():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fwiki\u002Fv2\u002Fspaces\"\n    req = urllib.request.Request(url, headers={'Authorization': f'Bearer {get_token()}'})\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 获取节点列表\ndef list_nodes(space_id):\n    url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fwiki\u002Fv2\u002Fspaces\u002F{space_id}\u002Fnodes\"\n    req = urllib.request.Request(url, headers={'Authorization': f'Bearer {get_token()}'})\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 创建文档\ndef create_doc(space_id, parent_node_id, title, content):\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fdocx\u002Fv1\u002Fdocuments\"\n    data = {\n        \"document_request\": {\n            \"node_type\": \"docx\",\n            \"parent_node_id\": parent_node_id,\n            \"space_id\": space_id,\n            \"title\": title\n        }\n    }\n    \n    req = urllib.request.Request(\n        url,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {get_token()}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    result = json.loads(urllib.request.urlopen(req).read())\n    \n    # 写入内容\n    doc_token = result['data']['document']['token']\n    return write_doc_content(doc_token, content)\n\n# 写入文档内容\ndef write_doc_content(doc_token, content):\n    url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fdocx\u002Fv1\u002Fdocuments\u002F{doc_token}\u002Fblocks\"\n    \n    # 构建文本块\n    blocks = []\n    for line in content.split('\\n'):\n        if line.strip():\n            blocks.append({\n                \"block_type\": \"paragraph\",\n                \"paragraph\": {\n                    \"elements\": [\n                        {\n                            \"text_element\": {\n                                \"content\": line,\n                                \"type\": \"text\"\n                            }\n                        }\n                    ]\n                }\n            })\n    \n    data = {\"blocks\": blocks}\n    \n    req = urllib.request.Request(\n        url,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {get_token()}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 使用示例\nspaces = list_spaces()\nprint(f\"知识库列表: {spaces}\")\n```\n\n## 消息接收（Webhook）\n\n如需接收群消息，需配置 Webhook 回调：\n\n1. 在飞书开放平台配置事件回调 URL\n2. 使用内网穿透工具（如 cloudflared）暴露本地服务\n3. 处理飞书推送的事件消息\n\n示例 Webhook 服务：\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"\nLark Webhook 消息接收服务\n\"\"\"\nimport os\nimport json\nimport hmac\nimport hashlib\nimport time\nfrom http.server import HTTPServer, BaseHTTPRequestHandler\nfrom urllib.parse import parse_qs\n\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nPORT = int(os.environ.get(\"LARK_WEBHOOK_PORT\", \"19800\"))\n\ndef verify_signature(timestamp, nonce, signature):\n    \"\"\"验证飞书签名\"\"\"\n    string = f\"{timestamp}{nonce}{APP_SECRET}\"\n    h = hashlib.sha1(string.encode()).hexdigest()\n    return h == signature\n\nclass Handler(BaseHTTPRequestHandler):\n    def do_POST(self):\n        content_length = int(self.headers['Content-Length'])\n        body = self.rfile.read(content_length).decode()\n        \n        # 解析请求体\n        data = json.loads(body)\n        \n        # 处理消息事件\n        if data.get(\"type\") == \"url_verification\":\n            # 验证 URL\n            self.send_response(200)\n            self.send_header('Content-Type', 'application\u002Fjson')\n            self.end_headers()\n            self.wfile.write(json.dumps({\n                \"challenge\": data.get(\"challenge\")\n            }).encode())\n            return\n        \n        if data.get(\"type\") == \"event_callback\":\n            event = data.get(\"event\", {})\n            msg_type = event.get(\"msg_type\")\n            \n            if msg_type == \"text\":\n                text = event.get(\"message\", {}).get(\"text\", \"\")\n                print(f\"收到消息: {text}\")\n                \n                # TODO: 处理消息逻辑\n        \n        self.send_response(200)\n        self.end_headers()\n    \n    def log_message(self, format, *args):\n        print(f\"[{self.log_date_time_string()}] {format % args}\")\n\nif __name__ == '__main__':\n    server = HTTPServer(('', PORT), Handler)\n    print(f\"Lark Webhook 服务启动于端口 {PORT}\")\n    server.serve_forever()\n```\n\n## 完整工作流示例\n\n### 场景：定时发送报告到群聊\n\n```python\nimport os\nimport json\nimport urllib.request\nimport time\n\n# 配置\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nCHAT_ID = os.environ.get(\"LARK_CHAT_ID\", \"\")\nAPP_TOKEN = os.environ.get(\"LARK_APP_TOKEN\", \"\")\nTABLE_ID = os.environ.get(\"LARK_TABLE_ID\", \"\")\n\n# 获取 token\ndef get_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    return json.loads(urllib.request.urlopen(req).read())['tenant_access_token']\n\n# 发送消息\ndef send_message(text):\n    token = get_token()\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fim\u002Fv1\u002Fmessages?receive_id_type=chat_id\"\n    data = {\n        \"receive_id\": CHAT_ID,\n        \"msg_type\": \"text\",\n        \"content\": json.dumps({\"text\": text})\n    }\n    \n    req = urllib.request.Request(\n        url,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {token}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return urllib.request.urlopen(req).read()\n\n# 读取 Bitable 任务\ndef get_tasks():\n    url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fbitable\u002Fv1\u002Fapps\u002F{APP_TOKEN}\u002Ftables\u002F{TABLE_ID}\u002Frecords?page_size=10\"\n    req = urllib.request.Request(url, headers={'Authorization': f'Bearer {get_token()}'})\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 定时执行\ndef main():\n    tasks_data = get_tasks()\n    items = tasks_data.get('data', {}).get('items', [])\n    \n    task_list = \"\\n\".join([\n        f\"- {item['fields'].get('任务名称', '未命名')}\" \n        for item in items[:5]\n    ])\n    \n    message = f\"📋 今日任务概览\\n\\n{task_list}\\n\\n更多任务请查看 Bitable\"\n    send_message(message)\n    print(\"报告已发送\")\n\nif __name__ == '__main__':\n    main()\n```\n\n## API 文档\n\n- [飞书开放平台](https:\u002F\u002Fopen.larksuite.com\u002F)\n- [应用权限配置](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fgetting-started\u002Foverview)\n- [IM 消息 API](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fim-v1\u002Fmessage-content-description)\n- [Bitable API](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fbitable-v1)\n- [Wiki API](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fwiki-v2)\n- [Webhooks](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fgetting-started\u002Fusing-webhooks)\n\n## 注意事项\n\n1. **Token 有效期**：tenant_access_token 有效期 2 小时，需缓存复用\n2. **频率限制**：API 有调用频率限制，批量操作需加延时\n3. **权限配置**：需在飞书开放平台给应用开通相应权限\n4. **签名验证**：接收消息时需验证签名确保安全\n","# Lark Bot 完整对接方案\n\n本 skill 提供飞书 Bot 完整对接方案，包含消息收发、知识库操作、Bitable 任务管理。所有配置均从环境变量读取，确保安全。\n\n## 环境变量配置\n\n在使用本 skill 前，需配置以下环境变量：\n\n| 变量名 | 说明 | 示例 |\n|--------|------|------|\n| `LARK_APP_ID` | 飞书应用 ID | cli_xxxxxxxx |\n| `LARK_APP_SECRET` | 飞书应用密钥 | xxxxxxxxxxxxxx |\n| `LARK_APP_TOKEN` | Bitable App Token（可选） | ${LARK_APP_TOKEN} |\n| `LARK_TABLE_ID` | Bitable Table ID（可选） | ${LARK_TABLE_ID} |\n| `LARK_SPACE_ID` | Wiki 知识库 ID（可选） | 76036636xxxxx |\n| `LARK_CHAT_ID` | 群聊 ID（可选） | ${LARK_CHAT_ID} |\n\n## 核心功能\n\n### 1. 获取 Access Token\n\n```python\nimport os\nimport json\nimport urllib.request\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\n\ndef get_tenant_access_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\n        \"app_id\": APP_ID,\n        \"app_secret\": APP_SECRET\n    }).encode()\n    \n    req = urllib.request.Request(\n        url, \n        data=data, \n        headers={'Content-Type': 'application\u002Fjson'}\n    )\n    \n    with urllib.request.urlopen(req, timeout=10) as resp:\n        result = json.loads(resp.read())\n        return result.get(\"tenant_access_token\")\n\ntoken = get_tenant_access_token()\nprint(f\"Token: {token}\")\n```\n\n### 2. 发送消息到群聊\n\n```python\nimport os\nimport json\nimport urllib.request\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nCHAT_ID = os.environ.get(\"LARK_CHAT_ID\", \"\")\n\ndef get_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    return json.loads(urllib.request.urlopen(req).read())['tenant_access_token']\n\ndef send_message(text):\n    token = get_token()\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fim\u002Fv1\u002Fmessages\"\n    params = f\"?receive_id_type=chat_id\"\n    data = {\n        \"receive_id\": CHAT_ID,\n        \"msg_type\": \"text\",\n        \"content\": json.dumps({\"text\": text})\n    }\n    \n    req = urllib.request.Request(\n        url + params,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {token}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 发送消息\nresult = send_message(\"Hello from Lark Bot!\")\nprint(result)\n```\n\n### 3. 发送富文本卡片消息\n\n```python\nimport os\nimport json\nimport urllib.request\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nCHAT_ID = os.environ.get(\"LARK_CHAT_ID\", \"\")\n\ndef get_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    return json.loads(urllib.request.urlopen(req).read())['tenant_access_token']\n\ndef send_interactive_card(text, button_text, button_url):\n    token = get_token()\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fim\u002Fv1\u002Fmessages\"\n    params = \"?receive_id_type=chat_id\"\n    \n    card = {\n        \"config\": {\"wide_screen_mode\": True},\n        \"header\": {\n            \"title\": {\"tag\": \"plain_text\", \"content\": \"📢 通知\"},\n            \"template\": \"blue\"\n        },\n        \"elements\": [\n            {\n                \"tag\": \"div\",\n                \"text\": {\"tag\": \"plain_text\", \"content\": text}\n            },\n            {\n                \"tag\": \"action\",\n                \"actions\": [\n                    {\n                        \"tag\": \"button\",\n                        \"text\": {\"tag\": \"plain_text\", \"content\": button_text},\n                        \"type\": \"primary\",\n                        \"url\": button_url\n                    }\n                ]\n            }\n        ]\n    }\n    \n    data = {\n        \"receive_id\": CHAT_ID,\n        \"msg_type\": \"interactive\",\n        \"content\": json.dumps(card)\n    }\n    \n    req = urllib.request.Request(\n        url + params,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {token}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req).read())\n\nresult = send_interactive_card(\"报告已生成\", \"查看详情\", \"https:\u002F\u002Fexample.com\")\nprint(result)\n```\n\n### 4. 操作 Bitable（任务管理）\n\n```python\nimport os\nimport json\nimport urllib.request\nimport time\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nAPP_TOKEN = os.environ.get(\"LARK_APP_TOKEN\", \"\")\nTABLE_ID = os.environ.get(\"LARK_TABLE_ID\", \"\")\n\n_cache = {'token': None, 'exp': 0}\n\ndef get_token():\n    if _cache['token'] and time.time() \u003C _cache['exp']:\n        return _cache['token']\n    \n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    \n    with urllib.request.urlopen(req, timeout=10) as resp:\n        result = json.loads(resp.read())\n        _cache['token'] = result['tenant_access_token']\n        _cache['exp'] = time.time() + result.get('expire', 7200) - 300\n        return _cache['token']\n\ndef api(method, path, body=None):\n    base_url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fbitable\u002Fv1\u002Fapps\u002F{APP_TOKEN}\u002Ftables\u002F{TABLE_ID}\"\n    url = base_url + path\n    data = json.dumps(body).encode() if body else None\n    \n    req = urllib.request.Request(\n        url,\n        data=data,\n        method=method,\n        headers={\n            'Authorization': f'Bearer {get_token()}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req, timeout=15).read())\n\n# 列出所有记录\ndef list_records():\n    return api(\"GET\", \"\u002Frecords?page_size=100\")\n\n# 创建记录\ndef create_record(name, status=\"待办\", priority=\"中\"):\n    fields = {\n        \"任务名称\": name,\n        \"状态\": status,\n        \"优先级\": priority\n    }\n    return api(\"POST\", \"\u002Frecords\", {\"fields\": fields})\n\n# 更新记录\ndef update_record(record_id, fields):\n    return api(\"PUT\", f\"\u002Frecords\u002F{record_id}\", {\"fields\": fields})\n\n# 删除记录\ndef delete_record(record_id):\n    return api(\"DELETE\", f\"\u002Frecords\u002F{record_id}\")\n\n# 使用示例\nrecords = list_records()\nprint(f\"当前有 {len(records.get('data', {}).get('items', []))} 条任务\")\n```\n\n### 5. 操作 Wiki 知识库\n\n```python\nimport os\nimport json\nimport urllib.request\nimport time\n\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nSPACE_ID = os.environ.get(\"LARK_SPACE_ID\", \"\")\n\n_cache = {'token': None, 'exp': 0}\n\ndef get_token():\n    if _cache['token'] and time.time() \u003C _cache['exp']:\n        return _cache['token']\n    \n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    \n    with urllib.request.urlopen(req, timeout=10) as resp:\n        result = json.loads(resp.read())\n        _cache['token'] = result['tenant_access_token']\n        _cache['exp'] = time.time() + result.get('expire', 7200) - 300\n        return _cache['token']\n\n# 获取知识库列表\ndef list_spaces():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fwiki\u002Fv2\u002Fspaces\"\n    req = urllib.request.Request(url, headers={'Authorization': f'Bearer {get_token()}'})\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 获取节点列表\ndef list_nodes(space_id):\n    url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fwiki\u002Fv2\u002Fspaces\u002F{space_id}\u002Fnodes\"\n    req = urllib.request.Request(url, headers={'Authorization': f'Bearer {get_token()}'})\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 创建文档\ndef create_doc(space_id, parent_node_id, title, content):\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fdocx\u002Fv1\u002Fdocuments\"\n    data = {\n        \"document_request\": {\n            \"node_type\": \"docx\",\n            \"parent_node_id\": parent_node_id,\n            \"space_id\": space_id,\n            \"title\": title\n        }\n    }\n    \n    req = urllib.request.Request(\n        url,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {get_token()}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    result = json.loads(urllib.request.urlopen(req).read())\n    \n    # 写入内容\n    doc_token = result['data']['document']['token']\n    return write_doc_content(doc_token, content)\n\n# 写入文档内容\ndef write_doc_content(doc_token, content):\n    url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fdocx\u002Fv1\u002Fdocuments\u002F{doc_token}\u002Fblocks\"\n    \n    # 构建文本块\n    blocks = []\n    for line in content.split('\\n'):\n        if line.strip():\n            blocks.append({\n                \"block_type\": \"paragraph\",\n                \"paragraph\": {\n                    \"elements\": [\n                        {\n                            \"text_element\": {\n                                \"content\": line,\n                                \"type\": \"text\"\n                            }\n                        }\n                    ]\n                }\n            })\n    \n    data = {\"blocks\": blocks}\n    \n    req = urllib.request.Request(\n        url,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {get_token()}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 使用示例\nspaces = list_spaces()\nprint(f\"知识库列表: {spaces}\")\n```\n\n## 消息接收（Webhook）\n\n如需接收群消息，需配置 Webhook 回调：\n\n1. 在飞书开放平台配置事件回调 URL\n2. 使用内网穿透工具（如 cloudflared）暴露本地服务\n3. 处理飞书推送的事件消息\n\n示例 Webhook 服务：\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"\nLark Webhook 消息接收服务\n\"\"\"\nimport os\nimport json\nimport hmac\nimport hashlib\nimport time\nfrom http.server import HTTPServer, BaseHTTPRequestHandler\nfrom urllib.parse import parse_qs\n\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nPORT = int(os.environ.get(\"LARK_WEBHOOK_PORT\", \"19800\"))\n\ndef verify_signature(timestamp, nonce, signature):\n    \"\"\"验证飞书签名\"\"\"\n    string = f\"{timestamp}{nonce}{APP_SECRET}\"\n    h = hashlib.sha1(string.encode()).hexdigest()\n    return h == signature\n\nclass Handler(BaseHTTPRequestHandler):\n    def do_POST(self):\n        content_length = int(self.headers['Content-Length'])\n        body = self.rfile.read(content_length).decode()\n        \n        # 解析请求体\n        data = json.loads(body)\n        \n        # 处理消息事件\n        if data.get(\"type\") == \"url_verification\":\n            # 验证 URL\n            self.send_response(200)\n            self.send_header('Content-Type', 'application\u002Fjson')\n            self.end_headers()\n            self.wfile.write(json.dumps({\n                \"challenge\": data.get(\"challenge\")\n            }).encode())\n            return\n        \n        if data.get(\"type\") == \"event_callback\":\n            event = data.get(\"event\", {})\n            msg_type = event.get(\"msg_type\")\n            \n            if msg_type == \"text\":\n                text = event.get(\"message\", {}).get(\"text\", \"\")\n                print(f\"收到消息: {text}\")\n                \n                # TODO: 处理消息逻辑\n        \n        self.send_response(200)\n        self.end_headers()\n    \n    def log_message(self, format, *args):\n        print(f\"[{self.log_date_time_string()}] {format % args}\")\n\nif __name__ == '__main__':\n    server = HTTPServer(('', PORT), Handler)\n    print(f\"Lark Webhook 服务启动于端口 {PORT}\")\n    server.serve_forever()\n```\n\n## 完整工作流示例\n\n### 场景：定时发送报告到群聊\n\n```python\nimport os\nimport json\nimport urllib.request\nimport time\n\n# 配置\nAPP_ID = os.environ.get(\"LARK_APP_ID\", \"\")\nAPP_SECRET = os.environ.get(\"LARK_APP_SECRET\", \"\")\nCHAT_ID = os.environ.get(\"LARK_CHAT_ID\", \"\")\nAPP_TOKEN = os.environ.get(\"LARK_APP_TOKEN\", \"\")\nTABLE_ID = os.environ.get(\"LARK_TABLE_ID\", \"\")\n\n# 获取 token\ndef get_token():\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fauth\u002Fv3\u002Ftenant_access_token\u002Finternal\"\n    data = json.dumps({\"app_id\": APP_ID, \"app_secret\": APP_SECRET}).encode()\n    req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application\u002Fjson'})\n    return json.loads(urllib.request.urlopen(req).read())['tenant_access_token']\n\n# 发送消息\ndef send_message(text):\n    token = get_token()\n    url = \"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fim\u002Fv1\u002Fmessages?receive_id_type=chat_id\"\n    data = {\n        \"receive_id\": CHAT_ID,\n        \"msg_type\": \"text\",\n        \"content\": json.dumps({\"text\": text})\n    }\n    \n    req = urllib.request.Request(\n        url,\n        data=json.dumps(data).encode(),\n        method=\"POST\",\n        headers={\n            'Authorization': f'Bearer {token}',\n            'Content-Type': 'application\u002Fjson'\n        }\n    )\n    return urllib.request.urlopen(req).read()\n\n# 读取 Bitable 任务\ndef get_tasks():\n    url = f\"https:\u002F\u002Fopen.larksuite.com\u002Fopen-apis\u002Fbitable\u002Fv1\u002Fapps\u002F{APP_TOKEN}\u002Ftables\u002F{TABLE_ID}\u002Frecords?page_size=10\"\n    req = urllib.request.Request(url, headers={'Authorization': f'Bearer {get_token()}'})\n    return json.loads(urllib.request.urlopen(req).read())\n\n# 定时执行\ndef main():\n    tasks_data = get_tasks()\n    items = tasks_data.get('data', {}).get('items', [])\n    \n    task_list = \"\\n\".join([\n        f\"- {item['fields'].get('任务名称', '未命名')}\" \n        for item in items[:5]\n    ])\n    \n    message = f\"📋 今日任务概览\\n\\n{task_list}\\n\\n更多任务请查看 Bitable\"\n    send_message(message)\n    print(\"报告已发送\")\n\nif __name__ == '__main__':\n    main()\n```\n\n## API 文档\n\n- [飞书开放平台](https:\u002F\u002Fopen.larksuite.com\u002F)\n- [应用权限配置](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fgetting-started\u002Foverview)\n- [IM 消息 API](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fim-v1\u002Fmessage-content-description)\n- [Bitable API](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fbitable-v1)\n- [Wiki API](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fwiki-v2)\n- [Webhooks](https:\u002F\u002Fopen.larksuite.com\u002Fdocument\u002Fserver-docs\u002Fgetting-started\u002Fusing-webhooks)\n\n## 注意事项\n\n1. **Token 有效期**：tenant_access_token 有效期 2 小时，需缓存复用\n2. **频率限制**：API 有调用频率限制，批量操作需加延时\n3. **权限配置**：需在飞书开放平台给应用开通相应权限\n4. **签名验证**：接收消息时需验证签名确保安全\n",{"name":5,"metadata":24,"description":7},{"openclaw":25},{"emoji":26,"requires":27},"🦉",{"env":28,"bins":31},[29,30],"LARK_APP_ID","LARK_APP_SECRET",[32],"python3","master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Fx\u002Fxiaoman-lark-bot",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill lark-bot",{"tool":48,"command":49},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill lark-bot",{"tool":51,"command":52},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill lark-bot","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fx\u002Fxiaoman-lark-bot\u002FSKILL.md",true,[],[57,64,71,78,85,92],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]