feishu-group-msg-sync.xiaokui/references/lark-cli-cheatsheet.md
2026-04-10 19:57:15 +08:00

77 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# lark-cli 消息和表格操作速查
## 拉取群消息
```bash
lark-cli im +chat-messages-list \
--chat-id "oc_xxx" \
--start "2026-04-10T00:00:00+08:00" \
--end "2026-04-10T23:59:59+08:00" \
--sort asc \
--page-size 50 \
--as bot
```
注意:
- `--start`/`--end` 使用 ISO 8601 格式(含时区)
- `--sort` 值为 `asc``desc`(不是 `create_time_asc`
- `--page-size` 范围 1-50
## 下载消息资源
```bash
# 图片(--type image
lark-cli im +messages-resources-download \
--message-id "om_xxx" \
--file-key "img_xxx" \
--type image \
--output "filename.png" \
--as bot
# 文件/视频/音频(--type file
lark-cli im +messages-resources-download \
--message-id "om_xxx" \
--file-key "file_xxx" \
--type file \
--output "filename.mp4" \
--as bot
```
注意:
- `--output` 不支持绝对路径,必须使用相对路径
- 需要先 `cd` 到目标目录再执行
## 电子表格操作
### 查看表格信息
```bash
lark-cli sheets +info --spreadsheet-token "xxx" --as bot
```
### 读取数据
```bash
lark-cli sheets +read \
--spreadsheet-token "xxx" \
--range "{sheet_id}!A1:D10" \
--as bot
```
### 追加行
```bash
lark-cli sheets +append \
--spreadsheet-token "xxx" \
--sheet-id "{sheet_id}" \
--range "{sheet_id}!A:D" \
--values '[["val1","val2","val3","val4"]]' \
--as bot
```
### 覆盖写入
```bash
lark-cli sheets +write \
--spreadsheet-token "xxx" \
--range "{sheet_id}!A2:D10" \
--values '[["a","b","c","d"]]' \
--as bot
```