When buttons are attached, Slack renders the blocks instead of the text field, and the only section block carried text[:3000]. Anything past 3000 characters of the final chunk (up to 39000) was silently dropped. Split the chunk across multiple section blocks that each respect the Block Kit limit.
Bold, italic and strikethrough passes ran over generated href attributes, so URLs such as .../__init__.py became .../<b>init</b>.py and Telegram rejected or mis-linked the message. Protect URLs with placeholders until inline formatting is done and escape double quotes inside href.