mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
add setStickerEmojiList
This commit is contained in:
parent
1633b9baaf
commit
5533303d86
@ -0,0 +1,25 @@
|
||||
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.SetStickerPositionInSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
|
||||
suspend fun TelegramBot.setStickerEmojiList(
|
||||
sticker: FileId,
|
||||
emojis: List<String>
|
||||
) = execute(
|
||||
SetStickerEmojiList(
|
||||
sticker,
|
||||
emojis
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerEmojiList(
|
||||
sticker: Sticker,
|
||||
vararg emojis: String
|
||||
) = setStickerEmojiList(
|
||||
sticker.fileId,
|
||||
emojis.toList()
|
||||
)
|
@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.types.stickerField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
@ -9,8 +10,8 @@ import kotlinx.serialization.builtins.serializer
|
||||
@Serializable
|
||||
data class DeleteStickerFromSet(
|
||||
@SerialName(stickerField)
|
||||
val sticker: FileId
|
||||
) : SimpleRequest<Boolean> {
|
||||
override val sticker: FileId
|
||||
) : StickerAction<Boolean> {
|
||||
override fun method(): String = "deleteStickerFromSet"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
|
@ -0,0 +1,33 @@
|
||||
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 SetStickerEmojiList (
|
||||
@SerialName(stickerField)
|
||||
override val sticker: FileId,
|
||||
@SerialName(emojiListField)
|
||||
val emojis: List<String>
|
||||
) : StickerAction<Boolean> {
|
||||
constructor(sticker: FileId, vararg emojis: String) : this(sticker, emojis.toList())
|
||||
|
||||
init {
|
||||
require(emojis.size !in emojisInStickerLimit) {
|
||||
"Emojis size should be in range $emojisInStickerLimit, but was ${emojis.size}"
|
||||
}
|
||||
}
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "setStickerEmojiList"
|
||||
}
|
@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerAction
|
||||
import dev.inmo.tgbotapi.types.positionField
|
||||
import dev.inmo.tgbotapi.types.stickerField
|
||||
import kotlinx.serialization.*
|
||||
@ -10,10 +11,10 @@ import kotlinx.serialization.builtins.serializer
|
||||
@Serializable
|
||||
data class SetStickerPositionInSet(
|
||||
@SerialName(stickerField)
|
||||
val sticker: FileId,
|
||||
override val sticker: FileId,
|
||||
@SerialName(positionField)
|
||||
val position: Int
|
||||
) : SimpleRequest<Boolean> {
|
||||
) : StickerAction<Boolean> {
|
||||
init {
|
||||
if (position < 0) {
|
||||
throw IllegalArgumentException("Position must be positive or 0")
|
||||
|
@ -0,0 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.stickers.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
|
||||
interface StickerAction<T : Any> : SimpleRequest<T> {
|
||||
val sticker: FileId
|
||||
}
|
@ -134,6 +134,8 @@ val suggestedTipAmountsLimit = 1 .. 4
|
||||
|
||||
val inputFieldPlaceholderLimit = 1 .. 64
|
||||
|
||||
val emojisInStickerLimit = 1 .. 20
|
||||
|
||||
const val botActionActualityTime: Seconds = 5
|
||||
|
||||
// Made as lazy for correct work in K/JS
|
||||
@ -257,6 +259,7 @@ const val createsJoinRequestField = "creates_join_request"
|
||||
const val pendingJoinRequestCountField = "pending_join_request_count"
|
||||
const val memberLimitField = "member_limit"
|
||||
const val iconColorField = "icon_color"
|
||||
const val emojiListField = "emoji_list"
|
||||
|
||||
const val requestContactField = "request_contact"
|
||||
const val requestLocationField = "request_location"
|
||||
|
Loading…
Reference in New Issue
Block a user