1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

add TextSource

This commit is contained in:
InsanusMokrassar 2019-12-11 13:49:17 +06:00
parent dd0e3c04bc
commit 6f1f5e640a
6 changed files with 20 additions and 7 deletions

View File

@ -14,6 +14,11 @@
* `TextMentionMessageEntity` now accept `PrivateChat` instead of `User` in main constructor
* `TextMentionMessageEntity` now contains not user, but contains `PrivateChat`
* Fixeed: `TextMentionMessageEntity#asHtmlSource` previously worked incorrect
* Abstraction `TextSource`
* `MessageEntity` now extends `TextSource`
* `createFormattedText` method now accept `List<TextSource>`
* `createHtmlText` method now accept `List<TextSource>`
* `createMarkdownText` method now accept `List<TextSource>`
## 0.19.0 ImplicitReflection removing

View File

@ -0,0 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
interface TextSource {
val asMarkdownSource: String
val asHtmlSource: String
}

View File

@ -1,10 +1,9 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
interface MessageEntity {
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
interface MessageEntity : TextSource {
val offset: Int
val length: Int
val sourceString: String
val asMarkdownSource: String
val asHtmlSource: String
}

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RegularTextMessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
@ -37,7 +38,7 @@ fun convertToFullMessageEntityList(
}
fun createFormattedText(
entities: List<MessageEntity>,
entities: List<TextSource>,
partLength: Int = 4096,
mode: ParseMode = MarkdownParseMode
): List<String> {

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
@ -8,7 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextCont
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
fun createHtmlText(
entities: List<MessageEntity>,
entities: List<TextSource>,
partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, HTMLParseMode)

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
@ -8,7 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextCont
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
fun createMarkdownText(
entities: List<MessageEntity>,
entities: List<TextSource>,
partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, MarkdownParseMode)