mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
add setStickerSetThumb
This commit is contained in:
parent
033ec8f2da
commit
9cd2a6220c
@ -16,6 +16,7 @@
|
|||||||
* `StickerSet#thumb` was added
|
* `StickerSet#thumb` was added
|
||||||
* `AddStickerToSet` renamed to `AddStaticStickerToSet`
|
* `AddStickerToSet` renamed to `AddStaticStickerToSet`
|
||||||
* `AddAnimatedStickerToSet` request was added
|
* `AddAnimatedStickerToSet` request was added
|
||||||
|
* `SetStickerSetThumb` request was added
|
||||||
* `TelegramBotAPI-extensions-api`:
|
* `TelegramBotAPI-extensions-api`:
|
||||||
* Extensions `sendDice` was added
|
* Extensions `sendDice` was added
|
||||||
* Extension `getMyCommands` request was added
|
* Extension `getMyCommands` request was added
|
||||||
@ -25,6 +26,7 @@
|
|||||||
* Extensions `createNewAnimatedStickerSet` was added
|
* Extensions `createNewAnimatedStickerSet` was added
|
||||||
* **All extensions `addStickerToSet` was renamed to `addStaticStickerToSet`**
|
* **All extensions `addStickerToSet` was renamed to `addStaticStickerToSet`**
|
||||||
* Extensions `addAnimatedStickerToSet` was added
|
* Extensions `addAnimatedStickerToSet` was added
|
||||||
|
* Extensions `setStickerSetThumb` was added
|
||||||
|
|
||||||
## 0.25.0
|
## 0.25.0
|
||||||
|
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.SetStickerSetThumb
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId
|
||||||
|
) = execute(
|
||||||
|
SetStickerSetThumb(userId, stickerSetName, sticker)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = execute(
|
||||||
|
SetStickerSetThumb(userId, stickerSetName, sticker)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, stickerSetName, sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, stickerSetName, sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
userId, stickerSet.name, sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
userId, stickerSet.name, sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, stickerSet.name, sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, stickerSet.name, sticker
|
||||||
|
)
|
||||||
|
|
@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
@ -35,7 +36,7 @@ data class AddAnimatedStickerToSet internal constructor(
|
|||||||
val sticker: FileId? = null,
|
val sticker: FileId? = null,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
override val maskPosition: MaskPosition? = null
|
override val maskPosition: MaskPosition? = null
|
||||||
) : StickerSetAction {
|
) : StandardStickerSetAction {
|
||||||
init {
|
init {
|
||||||
if(emojis.isEmpty()) {
|
if(emojis.isEmpty()) {
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
throw IllegalArgumentException("Emojis must not be empty")
|
||||||
|
@ -2,10 +2,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun AddStaticStickerToSet(
|
fun AddStaticStickerToSet(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSetName: String,
|
stickerSetName: String,
|
||||||
@ -53,7 +55,7 @@ data class AddStaticStickerToSet internal constructor(
|
|||||||
val sticker: FileId? = null,
|
val sticker: FileId? = null,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
override val maskPosition: MaskPosition? = null
|
override val maskPosition: MaskPosition? = null
|
||||||
) : StickerSetAction {
|
) : StandardStickerSetAction {
|
||||||
init {
|
init {
|
||||||
if(emojis.isEmpty()) {
|
if(emojis.isEmpty()) {
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
throw IllegalArgumentException("Emojis must not be empty")
|
||||||
|
@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
@ -39,7 +40,7 @@ data class CreateNewAnimatedStickerSet internal constructor(
|
|||||||
val containsMasks: Boolean? = null,
|
val containsMasks: Boolean? = null,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
override val maskPosition: MaskPosition? = null
|
override val maskPosition: MaskPosition? = null
|
||||||
) : StickerSetAction {
|
) : StandardStickerSetAction {
|
||||||
init {
|
init {
|
||||||
if(emojis.isEmpty()) {
|
if(emojis.isEmpty()) {
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
throw IllegalArgumentException("Emojis must not be empty")
|
||||||
|
@ -2,6 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StandardStickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
@ -54,7 +55,7 @@ data class CreateNewStaticStickerSet internal constructor(
|
|||||||
val containsMasks: Boolean? = null,
|
val containsMasks: Boolean? = null,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
override val maskPosition: MaskPosition? = null
|
override val maskPosition: MaskPosition? = null
|
||||||
) : StickerSetAction {
|
) : StandardStickerSetAction {
|
||||||
init {
|
init {
|
||||||
if(emojis.isEmpty()) {
|
if(emojis.isEmpty()) {
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
throw IllegalArgumentException("Emojis must not be empty")
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipartFileRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
fun SetStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: InputFile
|
||||||
|
): Request<Boolean> {
|
||||||
|
val data = SetStickerSetThumb(userId, stickerSetName, sticker as? FileId)
|
||||||
|
return when (sticker) {
|
||||||
|
is MultipartFile -> CommonMultipartFileRequest(
|
||||||
|
data,
|
||||||
|
mapOf(thumbField to sticker)
|
||||||
|
)
|
||||||
|
is FileId -> data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetStickerSetThumb internal constructor(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: StickerSetName,
|
||||||
|
@SerialName(thumbField)
|
||||||
|
val thumb: FileId? = null
|
||||||
|
) : StickerSetAction {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "setStickerSetThumb"
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
|
|
||||||
|
interface StandardStickerSetAction : StickerSetAction {
|
||||||
|
val emojis: String // must be more than one
|
||||||
|
val maskPosition: MaskPosition?
|
||||||
|
}
|
@ -9,8 +9,6 @@ import kotlinx.serialization.builtins.serializer
|
|||||||
interface StickerSetAction : SimpleRequest<Boolean> {
|
interface StickerSetAction : SimpleRequest<Boolean> {
|
||||||
val userId: UserId
|
val userId: UserId
|
||||||
val name: String
|
val name: String
|
||||||
val emojis: String // must be more than one
|
|
||||||
val maskPosition: MaskPosition?
|
|
||||||
|
|
||||||
override val resultDeserializer: KSerializer<Boolean>
|
override val resultDeserializer: KSerializer<Boolean>
|
||||||
get() = Boolean.serializer()
|
get() = Boolean.serializer()
|
||||||
|
Loading…
Reference in New Issue
Block a user