mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-07-03 08:35:02 +00:00
add medialess variant of markdown text
This commit is contained in:
@@ -190,6 +190,102 @@ suspend fun main(vararg args: String) {
|
|||||||
|
|
||||||
</tg-slideshow>
|
</tg-slideshow>
|
||||||
""".trimIndent()
|
""".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)
|
||||||
|

|
||||||
|

|
||||||
|
${'$'}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 <u>underlined text</u>, ==marked text==, and ${'$'}x^2 + y^2$.
|
||||||
|
**Bold _italic <u>underlined italic bold</u> italic_ bold**
|
||||||
|
<u>In inline tags, nested **markdown** is parsed</u>
|
||||||
|
>Quote with **bold text, ~~strikethrough, and <tg-spoiler>spoiler</tg-spoiler>~~**, plus [a link](https://t.me/).
|
||||||
|
|
||||||
|
- List item with `code`, <sup>superscript</sup>, <sub>subscript</sub>, and a footnote[^note]
|
||||||
|
- Another item with **bold <tg-spoiler><code>spoiler code</code></tg-spoiler>**
|
||||||
|
- Another item with ~~strikethrough and <ins>inserted text</ins>~~
|
||||||
|
|
||||||
|
| Metric | Value |
|
||||||
|
|:-------|------:|
|
||||||
|
| Speed | **42** <sup>ms</sup> |
|
||||||
|
| Status | <tg-spoiler>ready</tg-spoiler> |
|
||||||
|
|
||||||
|
[^note]: Footnote with _italic text_ and <u>HTML underline</u>.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Details blocks can contain Markdown content:
|
||||||
|
|
||||||
|
<details open><summary>Summary with **bold text**</summary>
|
||||||
|
|
||||||
|
### Details heading
|
||||||
|
- List item with _italic text_
|
||||||
|
- List item with <tg-spoiler>spoiler</tg-spoiler>
|
||||||
|
|
||||||
|
</details>
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
telegramBotWithBehaviourAndLongPolling(
|
telegramBotWithBehaviourAndLongPolling(
|
||||||
botToken,
|
botToken,
|
||||||
@@ -304,6 +400,18 @@ suspend fun main(vararg args: String) {
|
|||||||
println(sent)
|
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
|
// sendRichMessageDraft: stream partial rich messages sharing one draftId, then finalize
|
||||||
// with a full sendRichMessage. Emulates streaming of an AI-generated reply.
|
// with a full sendRichMessage. Emulates streaming of an AI-generated reply.
|
||||||
onCommand("rich_draft") {
|
onCommand("rich_draft") {
|
||||||
|
|||||||
Reference in New Issue
Block a user