mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 23:29:33 +00:00
add support of custom emojis
This commit is contained in:
@@ -295,6 +295,7 @@ import dev.inmo.tgbotapi.types.message.textsources.BoldTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.CodeTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.EMailTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.HashTagTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.ItalicTextSource
|
||||
@@ -3427,6 +3428,15 @@ public inline fun TextSource.codeTextSourceOrThrow(): CodeTextSource = this as
|
||||
public inline fun <T> TextSource.ifCodeTextSource(block: (CodeTextSource) -> T): T? =
|
||||
codeTextSourceOrNull() ?.let(block)
|
||||
|
||||
public inline fun TextSource.customEmojiTextSourceOrNull(): CustomEmojiTextSource? = this as?
|
||||
dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
||||
|
||||
public inline fun TextSource.customEmojiTextSourceOrThrow(): CustomEmojiTextSource = this as
|
||||
dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
||||
|
||||
public inline fun <T> TextSource.ifCustomEmojiTextSource(block: (CustomEmojiTextSource) -> T): T? =
|
||||
customEmojiTextSourceOrNull() ?.let(block)
|
||||
|
||||
public inline fun TextSource.eMailTextSourceOrNull(): EMailTextSource? = this as?
|
||||
dev.inmo.tgbotapi.types.message.textsources.EMailTextSource
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils.formatting
|
||||
|
||||
import dev.inmo.micro_utils.common.joinTo
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
@@ -510,3 +511,39 @@ inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types
|
||||
* Version of [EntitiesBuilder.underline] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine
|
||||
|
||||
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji].
|
||||
* Will reuse separator config from [buildEntities]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init)))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end.
|
||||
* Will reuse separator config from [buildEntities]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine
|
||||
|
Reference in New Issue
Block a user