mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
explanation small utils and explanationLimit
This commit is contained in:
parent
a4d077dd17
commit
76b25d719a
@ -57,6 +57,9 @@
|
|||||||
* In `QuizPoll#caption` and `QuizPoll#captionEntities` are deprecated now
|
* In `QuizPoll#caption` and `QuizPoll#captionEntities` are deprecated now
|
||||||
* Class `SendQuizPoll` now implement `ExplainedOutput`
|
* Class `SendQuizPoll` now implement `ExplainedOutput`
|
||||||
* In `SendQuizPoll#caption` is deprecated now
|
* In `SendQuizPoll#caption` is deprecated now
|
||||||
|
* `explanationLimit` range was added as future replacement of `quizPollExplanationLimit`
|
||||||
|
* `quizPollExplanationLimit` now is deprecated
|
||||||
|
* Extensions `toMarkdownExplanations`, `toMarkdownV2Explanations` and `toHtmlExplanations` was added
|
||||||
* `TelegramBotAPI-extensions-api`:
|
* `TelegramBotAPI-extensions-api`:
|
||||||
* `sendQuizPoll` now is using `explanation` parameter instead of `caption`
|
* `sendQuizPoll` now is using `explanation` parameter instead of `caption`
|
||||||
|
|
||||||
|
@ -237,8 +237,8 @@ data class SendQuizPoll(
|
|||||||
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
throw IllegalArgumentException("Correct option id must be in range of $correctOptionIdRange, but actual " +
|
||||||
"value is $correctOptionId")
|
"value is $correctOptionId")
|
||||||
}
|
}
|
||||||
if (explanation != null && explanation.length !in quizPollExplanationLimit) {
|
if (explanation != null && explanation.length !in explanationLimit) {
|
||||||
error("Quiz poll explanation size must be in range $quizPollExplanationLimit," +
|
error("Quiz poll explanation size must be in range $explanationLimit," +
|
||||||
"but actual explanation contains ${explanation.length} symbols")
|
"but actual explanation contains ${explanation.length} symbols")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,9 @@ val botCommandLimit = botCommandLengthLimit
|
|||||||
val botCommandDescriptionLimit = 3 .. 256
|
val botCommandDescriptionLimit = 3 .. 256
|
||||||
val botCommandsLimit = 0 .. 100
|
val botCommandsLimit = 0 .. 100
|
||||||
|
|
||||||
val quizPollExplanationLimit = 0 .. 200
|
val explanationLimit = 0 .. 200
|
||||||
|
@Deprecated("Will be removed in near updates", ReplaceWith("explanationLimit"))
|
||||||
|
val quizPollExplanationLimit = explanationLimit
|
||||||
|
|
||||||
val openPeriodPollSecondsLimit = 5 .. 600
|
val openPeriodPollSecondsLimit = 5 .. 600
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.fullEntitiesList
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.fullEntitiesList
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
|
|
||||||
|
|
||||||
fun createFormattedText(
|
fun createFormattedText(
|
||||||
entities: List<TextSource>,
|
entities: List<TextSource>,
|
||||||
@ -65,6 +64,12 @@ fun List<TextSource>.toMarkdownTexts(): List<String> = createMarkdownText(
|
|||||||
)
|
)
|
||||||
fun TextContent.toMarkdownTexts(): List<String> = fullEntitiesList().toMarkdownTexts()
|
fun TextContent.toMarkdownTexts(): List<String> = fullEntitiesList().toMarkdownTexts()
|
||||||
|
|
||||||
|
fun List<TextSource>.toMarkdownExplanations(): List<String> = createMarkdownText(
|
||||||
|
this,
|
||||||
|
explanationLimit.last + 1
|
||||||
|
)
|
||||||
|
fun ExplainedInput.toMarkdownExplanations(): List<String> = fullEntitiesList().toMarkdownTexts()
|
||||||
|
|
||||||
|
|
||||||
fun createMarkdownV2Text(
|
fun createMarkdownV2Text(
|
||||||
entities: List<TextSource>,
|
entities: List<TextSource>,
|
||||||
@ -83,6 +88,12 @@ fun List<TextSource>.toMarkdownV2Texts(): List<String> = createMarkdownV2Text(
|
|||||||
)
|
)
|
||||||
fun TextContent.toMarkdownV2Texts(): List<String> = fullEntitiesList().toMarkdownV2Texts()
|
fun TextContent.toMarkdownV2Texts(): List<String> = fullEntitiesList().toMarkdownV2Texts()
|
||||||
|
|
||||||
|
fun List<TextSource>.toMarkdownV2Explanations(): List<String> = createMarkdownV2Text(
|
||||||
|
this,
|
||||||
|
explanationLimit.last + 1
|
||||||
|
)
|
||||||
|
fun ExplainedInput.toMarkdownV2Explanations(): List<String> = fullEntitiesList().toMarkdownV2Texts()
|
||||||
|
|
||||||
|
|
||||||
fun createHtmlText(
|
fun createHtmlText(
|
||||||
entities: List<TextSource>,
|
entities: List<TextSource>,
|
||||||
@ -101,4 +112,10 @@ fun List<TextSource>.toHtmlTexts(): List<String> = createHtmlText(
|
|||||||
)
|
)
|
||||||
fun TextContent.toHtmlTexts(): List<String> = fullEntitiesList().toHtmlTexts()
|
fun TextContent.toHtmlTexts(): List<String> = fullEntitiesList().toHtmlTexts()
|
||||||
|
|
||||||
|
fun List<TextSource>.toHtmlExplanations(): List<String> = createHtmlText(
|
||||||
|
this,
|
||||||
|
explanationLimit.last + 1
|
||||||
|
)
|
||||||
|
fun ExplainedInput.toHtmlExplanations(): List<String> = fullEntitiesList().toHtmlTexts()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user