mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-09 01:59:47 +00:00
more improvements :)
This commit is contained in:
@@ -56,7 +56,7 @@ val horizontalAccuracyLimit = 0F .. 1500F
|
||||
val getUpdatesLimit = 1 .. 100
|
||||
val callbackQueryAnswerLength = 0 until 200
|
||||
val captionLength = 0 .. 1024
|
||||
val postCaptionLength = 0 .. 2048
|
||||
val storyCaptionLength = 0 .. 2048
|
||||
val textLength = 1 .. 4096
|
||||
val userProfilePhotosRequestLimit = 0 .. 100
|
||||
val chatTitleLength = 1 until 255
|
||||
|
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.message.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.captionLength
|
||||
import dev.inmo.tgbotapi.types.storyCaptionLength
|
||||
import dev.inmo.tgbotapi.types.textLength
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -90,7 +91,7 @@ fun List<TextSource>.splitForMessage(limit: IntRange, numberOfParts: Int? = null
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will prepare [TextSource]s list for messages. Remember, that first part will be separated with
|
||||
* This method will prepare [TextSource]s list for captions. Remember, that first part will be separated with
|
||||
* [captionLength] and all others with
|
||||
*/
|
||||
fun List<TextSource>.splitForCaption(): List<List<TextSource>> {
|
||||
@@ -98,6 +99,13 @@ fun List<TextSource>.splitForCaption(): List<List<TextSource>> {
|
||||
return listOf(captionPart) + minus(captionPart).splitForMessage(textLength)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will prepare [TextSource]s list for stories
|
||||
*/
|
||||
fun List<TextSource>.splitForStoryCaption(): List<List<TextSource>> {
|
||||
return splitForMessage(storyCaptionLength)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will prepare [TextSource]s list for messages with [textLength]
|
||||
*/
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.utils.extensions
|
||||
|
||||
import dev.inmo.tgbotapi.types.captionLength
|
||||
import dev.inmo.tgbotapi.types.storyCaptionLength
|
||||
import dev.inmo.tgbotapi.types.textLength
|
||||
|
||||
fun String.toMarkdown(): String {
|
||||
@@ -59,3 +60,4 @@ fun String.toHtml(): String = replace(
|
||||
|
||||
fun String.splitForText() = chunked(textLength.last)
|
||||
fun String.splitForCaption() = chunked(captionLength.last)
|
||||
fun String.splitForStoryCaption() = chunked(storyCaptionLength.last)
|
||||
|
Reference in New Issue
Block a user