You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -18,10 +18,88 @@ Replies sent by this tool are visible to other people. Before calling it, you **
18
18
19
19
When using `--as bot`, the reply is sent in the app's name, so make sure the app has already been added to the target chat.
20
20
21
+
## Choose The Right Content Flag
22
+
23
+
| Need | Recommended flag | Why |
24
+
|------|------|------|
25
+
| Reply with plain text exactly as written |`--text`| Wrapped directly to `{"text":"..."}`|
26
+
| Reply with simple Markdown and accept conversion |`--markdown`| Automatically converted to `post` JSON |
27
+
| Precisely control the reply payload |`--content`| You provide the exact JSON |
28
+
| Reply with media |`--image` / `--file` / `--video` / `--audio`| Shortcut uploads local files automatically |
29
+
30
+
### `--text` vs `--markdown`
31
+
32
+
- Use `--text` when the reply should remain plain text and you want exact control over line breaks, spacing, indentation, code samples, or literal Markdown characters.
33
+
- Use `--markdown` when you want a lightweight formatted reply and you accept that the shortcut will normalize and rewrite parts of the content before sending.
34
+
- Use `--content` when you need exact `post` JSON, a card, a title, multiple locales, or any structure that `--markdown` cannot express reliably.
35
+
36
+
## What `--markdown` Really Does
37
+
38
+
`--markdown` does **not** send arbitrary raw Markdown to the API.
39
+
40
+
The shortcut:
41
+
42
+
1. Forces `msg_type=post`
43
+
2. Resolves remote Markdown images like ``
44
+
3. Normalizes the Markdown for Feishu post rendering
So `--markdown` is a convenience mode, not a full Markdown compatibility layer.
52
+
53
+
### Current Markdown Caveats
54
+
55
+
- It does **not** promise full CommonMark / GitHub Flavored Markdown support.
56
+
- It always becomes a `post` payload with a single `zh_cn` locale.
57
+
- It does **not** let you set a `post` title.
58
+
- Headings are rewritten:
59
+
-`# Title` becomes `#### Title`
60
+
-`##` to `######` are normalized to `#####` when the content contains H1-H3
61
+
- Consecutive headings are separated with blank lines after heading normalization.
62
+
- Block spacing and line breaks may be normalized during conversion.
63
+
- Code blocks are preserved as code blocks.
64
+
- Excess blank lines are compressed.
65
+
- Only remote `http://...`, `https://...`, or already-uploaded `img_xxx` Markdown images are kept reliably.
66
+
- Local paths in Markdown image syntax like `` are **not** auto-uploaded by `--markdown`.
67
+
- If remote Markdown image handling fails, that image is removed with a warning.
68
+
69
+
If you need exact output, use `--msg-type post --content ...` instead of `--markdown`.
70
+
71
+
## Preserving Formatting
72
+
73
+
If the reply contains multiple lines, code blocks, indentation, tabs, or a lot of escaping, prefer `$'...'`.
74
+
75
+
### When formatting must be preserved
76
+
77
+
Use `--text` plus `$'...'`:
78
+
79
+
```bash
80
+
lark-cli im +messages-reply --message-id om_xxx --text $'Received\nI will check this today.\nOwner: alice'
81
+
```
82
+
83
+
```bash
84
+
lark-cli im +messages-reply --message-id om_xxx --text $'```sql\nselect * from jobs;\n```'
85
+
```
86
+
87
+
This keeps the reply as plain text instead of converting it to a `post`.
88
+
89
+
### When formatting does not need exact preservation
90
+
91
+
Use `--markdown`:
92
+
93
+
```bash
94
+
lark-cli im +messages-reply --message-id om_xxx --markdown $'## Follow-up\n\n- I reproduced it\n- I am fixing it'
95
+
```
96
+
97
+
This is better for quick readable formatting, but the final payload may still differ from the source text because headings and spacing are normalized before sending.
98
+
21
99
## Commands
22
100
23
101
```bash
24
-
# Reply to a message (plain text, bot identity, --text is recommended)
102
+
# Reply to a message (plain text, --text is recommended for normal replies)
25
103
lark-cli im +messages-reply --message-id om_xxx --text "Received"
#If you need exact post structure, send JSON directly
40
121
lark-cli im +messages-reply --message-id om_xxx --msg-type post --content '{"zh_cn":{"title":"Reply","content":[[{"tag":"text","text":"Detailed content"}]]}}'
41
122
42
123
# Reply with a local image (uploaded automatically before sending)
lark-cli im +messages-reply --message-id om_xxx --text "Received" --idempotency-key my-unique-id
53
134
54
135
# Preview the request without executing it
55
-
lark-cli im +messages-reply --message-id om_xxx --text "Test" --dry-run
136
+
lark-cli im +messages-reply --message-id om_xxx --markdown $'## Test\n\nhello' --dry-run
56
137
```
57
138
58
139
## Parameters
59
140
60
141
| Parameter | Required | Description |
61
142
|------|------|------|
62
143
|`--message-id <id>`| Yes | ID of the message being replied to (`om_xxx`) |
63
-
|`--msg-type <type>`| No | Message type (default `text`): `text`, `post`, `image`, `file`, `audio`, `media`, `interactive`, `share_chat`, `share_user`|
64
-
|`--content <json>`| One of content options|Reply content as a JSON string; format depends on `msg_type`|
65
-
|`--text <string>`| One of content options| Plain text message (automatically wrapped as `{"text":"..."}` JSON)|
66
-
|`--markdown <string>`| One of content options| Markdown text (auto-wrapped as post format with style optimization; image URLs auto-resolved)|
67
-
|`--image <path\|key>`| One of content options| Local image path, `image_key` (`img_xxx`)|
68
-
|`--file <path\|key>`| One of content options| Local file path, `file_key` (`file_xxx`)|
69
-
|`--video <path\|key>`| One of content options| Local video path,`file_key`; **must be used together with `--video-cover`**|
70
-
|`--video-cover <path\|key>`|**Required with `--video`**| Video cover image path,`image_key` (`img_xxx`) |
71
-
|`--audio <path\|key>`| One of content options| Local audio path,`file_key`|
144
+
|`--msg-type <type>`| No | Message type (default `text`). If you use `--text` / `--markdown` / media flags, the effective type is inferred automatically. Explicitly setting a conflicting `--msg-type` fails validation|
145
+
|`--content <json>`| One content option|Exact reply content as JSON. The JSON must match the effective `--msg-type`|
146
+
|`--text <string>`| One content option| Plain text reply. Best default when you need exact text and formatting preservation|
147
+
|`--markdown <string>`| One content option|Convenience Markdown input. Internally converted to `post` JSON with Feishu-specific normalization|
148
+
|`--image <path\|key>`| One content option| Local image path or `image_key` (`img_xxx`)|
149
+
|`--file <path\|key>`| One content option| Local file path or `file_key` (`file_xxx`)|
150
+
|`--video <path\|key>`| One content option| Local video path or`file_key`; **must be used together with `--video-cover`**|
151
+
|`--video-cover <path\|key>`|**Required with `--video`**| Video cover image path or`image_key` (`img_xxx`) |
152
+
|`--audio <path\|key>`| One content option| Local audio path or`file_key`|
72
153
|`--reply-in-thread`| No | Reply inside the thread. The reply appears in the target message's thread instead of the main chat stream |
73
154
|`--idempotency-key <key>`| No | Idempotency key; the same key sends only one reply within 1 hour |
74
155
|`--as <identity>`| No | Identity type: `bot` only |
> **Video cover rule:**`--video`**must** be accompanied by `--video-cover`. Omitting `--video-cover` when using `--video` will fail validation. `--video-cover` cannot be used without `--video`.
80
161
162
+
## Common Mistakes
163
+
164
+
- Choosing `--markdown` when you actually need exact plain text. If exact line breaks and spacing matter, use `--text`, usually with `$'...'`.
165
+
- Assuming `--markdown` supports all Markdown features. It does not; it is converted into a Feishu `post` payload and rewritten first.
166
+
- Putting local image paths inside Markdown like ``. `--markdown` does not auto-upload those paths.
167
+
- Using `--content` without making the JSON match the effective `--msg-type`.
168
+
- Explicitly setting `--msg-type` to something that conflicts with `--text`, `--markdown`, or media flags.
169
+
- Mixing `--text`, `--markdown`, or `--content` with media flags in one command.
170
+
81
171
## Return Value
82
172
83
173
```json
@@ -108,16 +198,22 @@ The reply appears in the target message's thread and does not show up in the mai
- The shortcut normalizes common variants like `<at id=...>` and `<at open_id=...>` into `user_id`, but `user_id` remains the recommended documented form
113
204
114
205
## Notes
115
206
116
207
-`--message-id` must be a valid message ID in `om_xxx` format
117
-
-`--content` must be a valid JSON string
118
-
-`--reply-in-thread` is only meaningful in group chats
119
-
-`--image`/`--file`/`--video`/`--audio`/`--video-cover` support local file paths; use relative paths within the current working directory. The shortcut automatically uploads the file first and then sends the reply
120
-
- If the provided value starts with `img_` or `file_`, it is treated as an existing key and used directly
121
-
- When using `--video`, `--video-cover` is **required** as the video cover. Omitting `--video-cover` with `--video` will produce a validation error. `--video-cover` cannot be used without `--video`
208
+
-`--content` must be valid JSON
209
+
- When using `--content`, you are responsible for making the JSON structure match the effective `msg_type`
210
+
-`--reply-in-thread` adds `reply_in_thread=true` to the API request
211
+
-`--reply-in-thread` is mainly meaningful in chats that support thread replies
212
+
-`--image`/`--file`/`--video`/`--audio`/`--video-cover` support local file paths; the shortcut uploads first and then sends the reply
213
+
- If the provided media value starts with `img_` or `file_`, it is treated as an existing key and used directly
214
+
-`--markdown` always sends `msg_type=post`
215
+
- If you explicitly set `--msg-type` and it conflicts with the chosen content flag, validation fails
216
+
- When using `--video`, `--video-cover` is required as the video cover
217
+
-`--dry-run` uses placeholder image keys for remote Markdown images and placeholder media keys for local uploads
122
218
- Failures return error codes and messages
123
-
-`--as bot` uses a tenant access token (TAT), and requires the `im:message:send_as_bot` scope
219
+
-`--as bot` uses a tenant access token (TAT), and requires the `im:message:send_as_bot` scope
0 commit comments