This commit is contained in:
InsanusMokrassar committed 2019-01-23 12:15:57 +08:00
1 parent c6e7111ff5
commit a0a93646e4
5 files changed
+28 -8

No files matched your search

@@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toMarkdown
fun createMarkdownText(
text: String,
@@ -12,7 +13,7 @@ fun createMarkdownText(
var offset = 0
for (entity in messageEntities) {
builder.append(
text.substring(offset until entity.offset)
text.substring(offset until entity.offset).toMarkdown()
)
builder.append(
entity.asMarkdownSource
@@ -20,7 +21,7 @@ fun createMarkdownText(
offset += entity.length
}
builder.append(
text.substring(offset)
text.substring(offset).toMarkdown()
)
return builder.toString()
}
@@ -0,0 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
fun String.toMarkdown(): String {
return replace(
"*",
"\\*"
).replace(
"_",
"\\_"
)
}