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

inline buildEntities

This commit is contained in:
InsanusMokrassar 2022-07-31 18:26:07 +06:00
parent 0a0a7cea0e
commit c68b148d5e
2 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,8 @@
## 2.2.2
* `Utils`:
* `buildEntities` now is inline
* `Behaviour Builder`:
* Fixes in `CallbackQuery` triggers

View File

@ -5,19 +5,20 @@ package dev.inmo.tgbotapi.extensions.utils.formatting
import dev.inmo.micro_utils.common.joinTo
import dev.inmo.tgbotapi.types.message.textsources.*
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.utils.RiskFeature
typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit
val newLine = regular("\n")
fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build()
fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init)
inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build()
inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init)
/**
* This builder can be used to provide building of [TextSource]s [List]
*
* @see buildEntities
*/
class EntitiesBuilder internal constructor(
class EntitiesBuilder @RiskFeature constructor(
val separator: TextSource? = null
) {
private val entitiesList: MutableTextSourcesList = mutableListOf()