tgfancy icon indicating copy to clipboard operation
tgfancy copied to clipboard

Text paging cutting markdown tags

Open dustyhorizon opened this issue 7 years ago • 2 comments

Hello,

I have a specific use case where I will send text reports as messages over telegram and would contain several markdown tags. However, there are cases where text paging cuts in between these tags, causing telegram to error with Can't find end of the entity starting at byte offset xxxx.

Any advice?

dustyhorizon avatar Oct 12 '17 17:10 dustyhorizon

The library currently paginates the first 4088 characters if the entire text > 4096 characters. The main issue is that if the markdown closing tag ends up somewhere > 4096'th character, it will definitely break the markdown with or without the library. The only solution seems to allow users to pass in their own reserve space value. A higher reserve space value means a lower probability of the markdown breaking, however it still does not guarantee there will be no breakage since its entirely dependent on the position of the tags. So its all about where the tag will fall.

kamikazechaser avatar Oct 12 '17 18:10 kamikazechaser

Do you think it is possible to parse the response after text paging for any broken markdown if parsed by Telegram and to 'append/prepend' the necessary tags to both pages so that the message gets through instead of being rejected by the server?

An alternative would be to push the last markdown tagged text to from the first message to the second message so that it doesn't get 'cut'.

Both way seems pretty complicated to implement though, not very sure.

dustyhorizon avatar Oct 13 '17 00:10 dustyhorizon