The bot converts the Markdown of each model reply to text and message
entities, and sends them with the entities field of sendMessage, with no
parse mode. The phone then shows bold text, code and code blocks
formatted, not their marks. A reply longer than 4096 UTF-16 units is
split as before, and an entity that crosses a cut becomes one entity in
each part, with offsets from the start of its part.
When Telegram refuses a part with entities with HTTP 400, the bot sends
the same text again once with no entities and logs one line without the
text, so a bad entity does not lose a reply. Other failures wait and try
again as before.
Only the replies get entities. The notices of the bot get their own
event kind, so they stay plain text with the errors and the messages
typed in the terminal. A reply with no text left after the conversion
goes as its Markdown. The log and the terminal client do not change.
Issue:
3309f9b