mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-10-31 21:43:48 +00:00
add setStickerKeywords
This commit is contained in:
parent
5533303d86
commit
d8c659f866
@ -0,0 +1,26 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerEmojiList
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerKeywords
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
|
||||
suspend fun TelegramBot.setStickerKeywords(
|
||||
sticker: FileId,
|
||||
keywords: List<String>
|
||||
) = execute(
|
||||
SetStickerKeywords(
|
||||
sticker,
|
||||
keywords
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerKeywords(
|
||||
sticker: Sticker,
|
||||
vararg keywords: String
|
||||
) = setStickerKeywords(
|
||||
sticker.fileId,
|
||||
keywords.toList()
|
||||
)
|
@ -0,0 +1,38 @@
|
||||
package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.OwnerStickerSetAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetStickerKeywords (
|
||||
@SerialName(stickerField)
|
||||
override val sticker: FileId,
|
||||
@SerialName(keywordsField)
|
||||
val keywords: List<String>
|
||||
) : StickerAction<Boolean> {
|
||||
constructor(sticker: FileId, vararg keywords: String) : this(sticker, keywords.toList())
|
||||
|
||||
init {
|
||||
require(keywords.size !in keywordsInStickerLimit) {
|
||||
"Keywords list size should be in range $keywordsInStickerLimit, but was ${keywords.size}"
|
||||
}
|
||||
keywords.forEach {
|
||||
require(it.length in stickerKeywordLengthLimit) {
|
||||
"Keyword length should be in range $stickerKeywordLengthLimit, but was ${it.length} (word \"$it\")"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "setStickerKeywords"
|
||||
}
|
@ -136,6 +136,10 @@ val inputFieldPlaceholderLimit = 1 .. 64
|
||||
|
||||
val emojisInStickerLimit = 1 .. 20
|
||||
|
||||
val keywordsInStickerLimit = 0 .. 20
|
||||
|
||||
val stickerKeywordLengthLimit = 0 .. 64
|
||||
|
||||
const val botActionActualityTime: Seconds = 5
|
||||
|
||||
// Made as lazy for correct work in K/JS
|
||||
@ -412,6 +416,7 @@ const val offsetField = "offset"
|
||||
const val limitField = "limit"
|
||||
const val stickersField = "stickers"
|
||||
const val stickerField = "sticker"
|
||||
const val keywordsField = "keywords"
|
||||
const val urlField = "url"
|
||||
const val addressField = "address"
|
||||
const val actionField = "action"
|
||||
|
Loading…
Reference in New Issue
Block a user