mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
create new animated sticker set
This commit is contained in:
parent
53257ff131
commit
f6692a22d1
@ -36,11 +36,15 @@
|
||||
* `SetMyCommands` request was added
|
||||
* `GetMe` now is object instead of class
|
||||
* `GetMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.requests.bot.GetMe`
|
||||
* `CreateNewStickerSet` renamed to `CreateStaticNewStickerSet`
|
||||
* `CreateNewAnimatedStickerSet` request was added (it handle work with `tgs_sticker`)
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* Extensions `sendDice` was added
|
||||
* Extension `getMyCommands` request was added
|
||||
* Extension `setMyCommands` request was added
|
||||
* Extension `getMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.GetMeKt.getMe`
|
||||
* **All extensions `createNewStickerSet` was renamed to `createNewStaticStickerSet`**
|
||||
* Extensions `createNewAnimatedStickerSet` was added
|
||||
|
||||
### 0.25.1
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
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.CreateNewAnimatedStickerSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
|
||||
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewAnimatedStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewAnimatedStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
@ -3,12 +3,12 @@ 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.CreateNewStickerSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.CreateNewStaticStickerSet
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
@ -16,10 +16,10 @@ suspend fun RequestsExecutor.createNewStickerSet(
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
@ -27,28 +27,28 @@ suspend fun RequestsExecutor.createNewStickerSet(
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStickerSet(
|
||||
) = createNewStaticStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun RequestsExecutor.createNewStickerSet(
|
||||
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStickerSet(
|
||||
) = createNewStaticStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun CreateNewStickerSet(
|
||||
fun CreateNewAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: InputFile,
|
||||
@ -15,7 +15,7 @@ fun CreateNewStickerSet(
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
): Request<Boolean> {
|
||||
val data = CreateNewStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition)
|
||||
val data = CreateNewAnimatedStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition)
|
||||
return when (sticker) {
|
||||
is MultipartFile -> CommonMultipartFileRequest(
|
||||
data,
|
||||
@ -26,14 +26,14 @@ fun CreateNewStickerSet(
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class CreateNewStickerSet internal constructor(
|
||||
data class CreateNewAnimatedStickerSet internal constructor(
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
override val name: String,
|
||||
@SerialName(emojisField)
|
||||
override val emojis: String,
|
||||
@SerialName(pngStickerField)
|
||||
@SerialName(tgsStickerField)
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(containsMasksField)
|
||||
val containsMasks: Boolean? = null,
|
@ -0,0 +1,68 @@
|
||||
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 com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun CreateNewStaticStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: InputFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
): Request<Boolean> {
|
||||
val data = CreateNewStaticStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition)
|
||||
return when (sticker) {
|
||||
is MultipartFile -> CommonMultipartFileRequest(
|
||||
data,
|
||||
mapOf(pngStickerField to sticker)
|
||||
)
|
||||
is FileId -> data
|
||||
}
|
||||
}
|
||||
|
||||
fun CreateNewStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: InputFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
): Request<Boolean> = CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith("CreateNewStaticStickerSet", "com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.CreateNewStaticStickerSet")
|
||||
)
|
||||
typealias CreateNewStickerSet = CreateNewStaticStickerSet
|
||||
|
||||
@Serializable
|
||||
data class CreateNewStaticStickerSet internal constructor(
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId,
|
||||
@SerialName(nameField)
|
||||
override val name: String,
|
||||
@SerialName(emojisField)
|
||||
override val emojis: String,
|
||||
@SerialName(pngStickerField)
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(containsMasksField)
|
||||
val containsMasks: Boolean? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
) : StickerSetAction {
|
||||
init {
|
||||
if(emojis.isEmpty()) {
|
||||
throw IllegalArgumentException("Emojis must not be empty")
|
||||
}
|
||||
}
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "createNewStickerSet"
|
||||
}
|
@ -192,6 +192,7 @@ const val canRestrictMembersField = "can_restrict_members"
|
||||
const val canPinMessagesField = "can_pin_messages"
|
||||
const val canPromoteMembersField = "can_promote_members"
|
||||
const val pngStickerField = "png_sticker"
|
||||
const val tgsStickerField = "tgs_sticker"
|
||||
|
||||
const val okField = "ok"
|
||||
const val captionField = "caption"
|
||||
|
Loading…
Reference in New Issue
Block a user