feat: 飞书知识库读写工具:增删查改节点、写入页面、创建早报、记录踩坑,支持 Markdown 表格原生渲染。

This commit is contained in:
NightStar
2026-07-30 15:50:17 +08:00
commit ceb3b6c9a8
13 changed files with 1029 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env python3
"""获取 tenant_access_token,同时暴露 app_id 和 bot_open_id。
用法:
python3 init_token.py → {"token": "..."}
python3 init_token.py --full → {"token": "...", "app_id": "...", "bot_open_id": "..."}
"""
import json, sys, os
from pathlib import Path
CONFIG = Path.home() / '.openclaw' / 'openclaw.json'
def read_config():
cfg = json.loads(CONFIG.read_text())
fs = cfg['channels']['feishu']
return fs['appId'], fs['appSecret'], fs.get('botOpenId', '')
def get_token():
aid, asc, _ = read_config()
import requests
r = requests.post(
'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal',
json={'app_id': aid, 'app_secret': asc}
)
td = r.json()
if 'tenant_access_token' not in td:
print(json.dumps({'error': td}), file=sys.stderr)
sys.exit(1)
return td['tenant_access_token']
if __name__ == '__main__':
try:
token = get_token()
result = {'token': token}
if '--full' in sys.argv:
aid, asc, bot_id = read_config()
result['app_id'] = aid
result['bot_open_id'] = bot_id
print(json.dumps(result))
except Exception as e:
print(json.dumps({'error': str(e)}), file=sys.stderr)
sys.exit(1)