Repository navigation
Keep long linked definitions within Telegram's HTML byte limit - #135
Closed
cloudgpuapp wants to merge 1 commit into
Closed
cloudgpuapp wants to merge 1 commit into
cloudgpuapp wants to merge 1 commit into
Conversation
Owner
|
Hi, and thank you so much for looking into this and for the detailed explanation, especially the pointer to where the Bot API checks the byte size. That's really useful. I'm going to close this one, though, because I'd like to fix #134 myself. I'm in the middle of a bigger modernization of the bot and I'm keeping the commits and wording consistent with my own style. Unit tests are also planned for a later step (#142), so I'd rather not add a test setup in a separate PR yet. Your write-up will definitely help when I get to it. Thanks again! Generated by Claude Code |
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.
Fixes #134. Adding one link per word can make the rendered HTML larger than Telegram's parser accepts, even when the visible definition fits. The Bot API checks the UTF-8 byte size before parsing entities in Client.cpp.
Link mode now reserves room for the header, ellipsis, attribution and suffix, then stops at a complete word or punctuation fragment before crossing that byte limit. Plain mode and short linked definitions are unchanged.
Two offline regressions passed. The original produced 42,590 bytes on the synthetic long Romanian definition. The patched renderer keeps the payload below the parser limit, leaves valid links and keeps the footer. No live Telegram bot was contacted.
AI assistance: OpenAI Codex assisted with the patch and tests.