mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
add opportunity to send emoji with sticker
This commit is contained in:
parent
79c9e6258f
commit
b0e32e8ad9
@ -8,14 +8,19 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
|||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
import dev.inmo.tgbotapi.types.message.content.StickerContent
|
||||||
|
import dev.inmo.tgbotapi.utils.mapOfNotNull
|
||||||
import dev.inmo.tgbotapi.utils.toJsonWithoutNulls
|
import dev.inmo.tgbotapi.utils.toJsonWithoutNulls
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
import kotlinx.serialization.json.JsonPrimitive
|
||||||
|
import kotlinx.serialization.json.buildJsonObject
|
||||||
|
import kotlinx.serialization.json.put
|
||||||
|
|
||||||
fun SendSticker(
|
fun SendSticker(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
@ -32,7 +37,7 @@ fun SendSticker(
|
|||||||
replyMarkup
|
replyMarkup
|
||||||
).let {
|
).let {
|
||||||
when (sticker) {
|
when (sticker) {
|
||||||
is MultipartFile -> SendStickerByFile(it, sticker)
|
is MultipartFile -> SendStickerByFile(it, sticker, emoji)
|
||||||
is FileId -> it
|
is FileId -> it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,8 +74,16 @@ data class SendStickerByFileId internal constructor(
|
|||||||
data class SendStickerByFile internal constructor(
|
data class SendStickerByFile internal constructor(
|
||||||
@Transient
|
@Transient
|
||||||
private val sendStickerByFileId: SendStickerByFileId,
|
private val sendStickerByFileId: SendStickerByFileId,
|
||||||
val sticker: MultipartFile
|
val sticker: MultipartFile,
|
||||||
|
val emoji: String?
|
||||||
) : MultipartRequest<ContentMessage<StickerContent>>, Request<ContentMessage<StickerContent>> by sendStickerByFileId {
|
) : MultipartRequest<ContentMessage<StickerContent>>, Request<ContentMessage<StickerContent>> by sendStickerByFileId {
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
||||||
override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
override val paramsJson: JsonObject
|
||||||
|
get() {
|
||||||
|
return JsonObject(
|
||||||
|
mapOfNotNull(
|
||||||
|
emojiField to emoji ?.let { JsonPrimitive(it) }
|
||||||
|
) + sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user