fix(telegram): hard-cut when fence body cut lands on the prefix

A leading space in the fenced body made the soft cut land at min_code_pos
and re-emit the same fence forever. Require progress past the fence line.
This commit is contained in:
santhreal authored and chengyongru committed 2026-07-23 23:56:18 +08:00
1 parent 98d661775e
commit 7e9426d9bd
2 files changed
+19 -2

No files matched your search

@@ -293,6 +293,19 @@ def test_split_telegram_markdown_tiny_limit_with_early_body_newline() -> None:
assert plain.count("a") >= 100
def test_split_telegram_markdown_leading_space_in_fence_body() -> None:
body = "a" * 4500
content = f"```\n {body}"
chunks = _split_telegram_markdown(content, TELEGRAM_MAX_MESSAGE_LEN)
assert chunks
assert all(len(chunk) <= TELEGRAM_MAX_MESSAGE_LEN for chunk in chunks)
plain = "".join(chunks).replace("```", "").replace("\n", "")
assert plain.count("a") == 4500
@pytest.mark.asyncio
async def test_start_creates_separate_pools_with_proxy(monkeypatch) -> None: