From 9737371a7e334b26e225834cda1b8d6afed335f5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 1 Jul 2026 15:10:41 +0600 Subject: [PATCH] add medialess variant of markdown text --- .../src/main/kotlin/RichMessagesBot.kt | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/RichMessagesBot/src/main/kotlin/RichMessagesBot.kt b/RichMessagesBot/src/main/kotlin/RichMessagesBot.kt index 9b641ef..ae11e7d 100644 --- a/RichMessagesBot/src/main/kotlin/RichMessagesBot.kt +++ b/RichMessagesBot/src/main/kotlin/RichMessagesBot.kt @@ -190,6 +190,102 @@ suspend fun main(vararg args: String) { """.trimIndent() + val testMarkdownMediaLessText = """ + **bold text** + __bold text__ + *italic text* + _italic text_ + ~~strikethrough text~~ + `inline fixed-width code` + ==marked text== + ||spoiler|| + + [inline URL](https://t.me/) + [inline e-mail](mailto:user@example.com) + [inline phone number](tel:+123456789) + [inline mention of a user](tg://user?id=123456789) + ![👍](tg://emoji?id=5368324170671202286) + ![22:45 tomorrow](tg://time?unix=1647531900&format=wDT) + ${'$'}x^2 + y^2$ + \#hashtag ${'$'}USD +12345678901, card: 4242 4242 4242 4242, https://t.me t.me a@t.me /command @username + all the text above was on the same line + + # Heading 1 + ## Heading 2 + ### Heading 3 + #### Heading 4 + ##### Heading 5 + ###### Heading 6 + + Paragraph text + + ```python + print('pre-formatted fixed-width code block written in the Python programming language') + ``` + + --- + + - unordered list item + * unordered list item + + unordered list item + + 1. ordered list item + 2. ordered list item + + - [ ] task list item + - [x] completed task list item + + >Block quotation started + > + >Block quotation continued on the next line + >Block quotation continued on the same line + > + >The last line of the block quotation + + | Header 1 | Header 2 | + |:---------|:--------:| + | left | center | + + Text with a reference[^id1] and another one[^id2]. + + [^id1]: Definition of the first footnote. + [^id2]: Definition of the second footnote. + + $${'$'}E = mc^2$$ + + ```math + E = mc^2 + ``` + + ## Example Nested Syntax Report for _Q1_ + Intro with underlined text, ==marked text==, and ${'$'}x^2 + y^2$. + **Bold _italic underlined italic bold italic_ bold** + In inline tags, nested **markdown** is parsed + >Quote with **bold text, ~~strikethrough, and spoiler~~**, plus [a link](https://t.me/). + + - List item with `code`, superscript, subscript, and a footnote[^note] + - Another item with **bold spoiler code** + - Another item with ~~strikethrough and inserted text~~ + + | Metric | Value | + |:-------|------:| + | Speed | **42** ms | + | Status | ready | + + [^note]: Footnote with _italic text_ and HTML underline. + + --- + + # Details blocks can contain Markdown content: + +
Summary with **bold text** + + ### Details heading + - List item with _italic text_ + - List item with spoiler + +
+ """.trimIndent() telegramBotWithBehaviourAndLongPolling( botToken, @@ -304,6 +400,18 @@ suspend fun main(vararg args: String) { println(sent) } + // sendRichMessage with Markdown-formatted content + onCommand("rich_markdown_medialess") { + val sent = sendRichMessage( + it.chat.id, + // InputRichMessageMarkdown factory — content described using Markdown formatting + InputRichMessageMarkdown( + testMarkdownMediaLessText + ) + ) + println(sent) + } + // sendRichMessageDraft: stream partial rich messages sharing one draftId, then finalize // with a full sendRichMessage. Emulates streaming of an AI-generated reply. onCommand("rich_draft") {