Repository navigation
feat(send): format a caption with --html - #239
Open
ertembiyik wants to merge 1 commit into
Open
ertembiyik wants to merge 1 commit into
ertembiyik wants to merge 1 commit into
Conversation
--html and --markdown refused a file: a caption was plain text, so it could not carry a link. messages.sendMedia takes no rich message, only entities, so --html with --file now parses the caption on this machine with Telegram's HTML style (bold, italic, links, code, quotes, spoilers) and sends its text and entities. --markdown keeps formatting --message only: a rich message's Markdown and the entity dialect differ. A link to a user by ID needs an access hash the caption has no way to give, so it is INVALID_ARGS before anything connects. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 25, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
A caption is plain text, so it can't carry a link:
--htmland--markdownrefuse--file.--htmlwith--filenow formats--caption.Before (0.16.0)
After (trimmed)
The chat shows
Q3: the numbers, withthe numbersas a link.How it works
messages.sendMediatakes no rich message, onlyentities. So the caption is parsed on this machine with the HTML parser@mtcute/bunalready ships (no new dependency) and sent as text plus entities. It follows Telegram's HTML style:<b>,<i>,<u>,<s>,<a href>,<code>,<pre>,<blockquote>,<tg-spoiler>. Line breaks stay as written.--markdownstill formats--messageonly (INVALID_ARGSwith a file, with a message that names--html). The entity Markdown is a different dialect from a rich message's:__x__is italic and*x*is literal, so one flag would mean two syntaxes.tg://user?id=…) needs an access hash, so it isINVALID_ARGSbefore anything connects.--html --filewithout--captionisINVALID_ARGS.formatishtmlfor a formatted caption andnullfor a plain one, as before. The cached text is the caption without tags.Independent of #238 (an MP4 or MOV file sent as a video). Both edit the same paragraphs of
docs/media.mdanddocs/cli-commands.md; I will mergemaininto whichever is left after the first one lands.How I checked it
Unit test: a caption with bold, a link, an escaped
&and blank lines becomes the expected text and entities, andsendFileputs them intomessages.sendMedia; a plain caption sends no entities.E2E through the real CLI:
--markdown --file,--html --filewithout a caption and a mention by ID are refused before credentials are read;--html --captionpasses the argument checks.Live, one send to Saved Messages (a file with a two-line caption holding bold text and a link): the stored message has the text without tags, the line break,
messageEntityBoldandmessageEntityTextUrlat the right offsets.bun run check,bun run test(1339 pass),bun run test:e2e(439 pass).Tests pass locally and use made-up data only
README, docs and affected demos follow the product content standard
Title follows the repo's commit style: Conventional Commits (
feat: …,fix: …) unlessAGENTS.mdsays otherwise🤖 Generated with Claude Code