1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

fixes in create sticker set methods

This commit is contained in:
InsanusMokrassar 2022-02-01 17:59:23 +06:00
parent 0c2fe6bce7
commit fba6707f44
7 changed files with 50 additions and 20 deletions

View File

@ -11,44 +11,48 @@ import dev.inmo.tgbotapi.types.stickers.MaskPosition
suspend fun TelegramBot.createNewAnimatedStickerSet( suspend fun TelegramBot.createNewAnimatedStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: FileId, sticker: FileId,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = execute( ) = execute(
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
) )
suspend fun TelegramBot.createNewAnimatedStickerSet( suspend fun TelegramBot.createNewAnimatedStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: MultipartFile, sticker: MultipartFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = execute( ) = execute(
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
) )
suspend fun TelegramBot.createNewAnimatedStickerSet( suspend fun TelegramBot.createNewAnimatedStickerSet(
user: CommonUser, user: CommonUser,
name: String, name: String,
title: String,
sticker: FileId, sticker: FileId,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = createNewAnimatedStickerSet( ) = createNewAnimatedStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition user.id, name, title, sticker, emojis, containsMasks, maskPosition
) )
suspend fun TelegramBot.createNewAnimatedStickerSet( suspend fun TelegramBot.createNewAnimatedStickerSet(
user: CommonUser, user: CommonUser,
name: String, name: String,
title: String,
sticker: MultipartFile, sticker: MultipartFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = createNewAnimatedStickerSet( ) = createNewAnimatedStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition user.id, name, title, sticker, emojis, containsMasks, maskPosition
) )

View File

@ -11,44 +11,48 @@ import dev.inmo.tgbotapi.types.stickers.MaskPosition
suspend fun TelegramBot.createNewStaticStickerSet( suspend fun TelegramBot.createNewStaticStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: FileId, sticker: FileId,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = execute( ) = execute(
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
) )
suspend fun TelegramBot.createNewStaticStickerSet( suspend fun TelegramBot.createNewStaticStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: MultipartFile, sticker: MultipartFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = execute( ) = execute(
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
) )
suspend fun TelegramBot.createNewStaticStickerSet( suspend fun TelegramBot.createNewStaticStickerSet(
user: CommonUser, user: CommonUser,
name: String, name: String,
title: String,
sticker: FileId, sticker: FileId,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = createNewStaticStickerSet( ) = createNewStaticStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition user.id, name, title, sticker, emojis, containsMasks, maskPosition
) )
suspend fun TelegramBot.createNewStaticStickerSet( suspend fun TelegramBot.createNewStaticStickerSet(
user: CommonUser, user: CommonUser,
name: String, name: String,
title: String,
sticker: MultipartFile, sticker: MultipartFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = createNewStaticStickerSet( ) = createNewStaticStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition user.id, name, title, sticker, emojis, containsMasks, maskPosition
) )

View File

@ -11,44 +11,48 @@ import dev.inmo.tgbotapi.types.stickers.MaskPosition
suspend fun TelegramBot.createNewVideoStickerSet( suspend fun TelegramBot.createNewVideoStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: FileId, sticker: FileId,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = execute( ) = execute(
CreateNewVideoStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
) )
suspend fun TelegramBot.createNewVideoStickerSet( suspend fun TelegramBot.createNewVideoStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: MultipartFile, sticker: MultipartFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = execute( ) = execute(
CreateNewVideoStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
) )
suspend fun TelegramBot.createNewVideoStickerSet( suspend fun TelegramBot.createNewVideoStickerSet(
user: CommonUser, user: CommonUser,
name: String, name: String,
title: String,
sticker: FileId, sticker: FileId,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = createNewVideoStickerSet( ) = createNewVideoStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition user.id, name, title, sticker, emojis, containsMasks, maskPosition
) )
suspend fun TelegramBot.createNewVideoStickerSet( suspend fun TelegramBot.createNewVideoStickerSet(
user: CommonUser, user: CommonUser,
name: String, name: String,
title: String,
sticker: MultipartFile, sticker: MultipartFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
) = createNewVideoStickerSet( ) = createNewVideoStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition user.id, name, title, sticker, emojis, containsMasks, maskPosition
) )

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition import dev.inmo.tgbotapi.types.stickers.MaskPosition
@ -10,12 +11,13 @@ import kotlinx.serialization.*
fun CreateNewAnimatedStickerSet( fun CreateNewAnimatedStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: InputFile, sticker: InputFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
): Request<Boolean> { ): Request<Boolean> {
val data = CreateNewAnimatedStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition) val data = CreateNewAnimatedStickerSet(userId, name, title, emojis, sticker as? FileId, containsMasks, maskPosition)
return when (sticker) { return when (sticker) {
is MultipartFile -> CommonMultipartFileRequest( is MultipartFile -> CommonMultipartFileRequest(
data, data,
@ -31,6 +33,8 @@ data class CreateNewAnimatedStickerSet internal constructor(
override val userId: UserId, override val userId: UserId,
@SerialName(nameField) @SerialName(nameField)
override val name: String, override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(emojisField) @SerialName(emojisField)
override val emojis: String, override val emojis: String,
@SerialName(tgsStickerField) @SerialName(tgsStickerField)
@ -39,7 +43,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
) : StandardStickerSetAction { ) : CreateStickerSetAction {
init { init {
if(emojis.isEmpty()) { if(emojis.isEmpty()) {
throw IllegalArgumentException("Emojis must not be empty") throw IllegalArgumentException("Emojis must not be empty")

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition import dev.inmo.tgbotapi.types.stickers.MaskPosition
@ -10,12 +11,13 @@ import kotlinx.serialization.*
fun CreateNewStaticStickerSet( fun CreateNewStaticStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: InputFile, sticker: InputFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
): Request<Boolean> { ): Request<Boolean> {
val data = CreateNewStaticStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition) val data = CreateNewStaticStickerSet(userId, name, title, emojis, sticker as? FileId, containsMasks, maskPosition)
return when (sticker) { return when (sticker) {
is MultipartFile -> CommonMultipartFileRequest( is MultipartFile -> CommonMultipartFileRequest(
data, data,
@ -28,11 +30,12 @@ fun CreateNewStaticStickerSet(
fun CreateNewStickerSet( fun CreateNewStickerSet(
userId: UserId, userId: UserId,
name: String, name: String,
title: String,
sticker: InputFile, sticker: InputFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
): Request<Boolean> = CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition) ): Request<Boolean> = CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
@Serializable @Serializable
data class CreateNewStaticStickerSet internal constructor( data class CreateNewStaticStickerSet internal constructor(
@ -40,6 +43,8 @@ data class CreateNewStaticStickerSet internal constructor(
override val userId: UserId, override val userId: UserId,
@SerialName(nameField) @SerialName(nameField)
override val name: String, override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(emojisField) @SerialName(emojisField)
override val emojis: String, override val emojis: String,
@SerialName(pngStickerField) @SerialName(pngStickerField)
@ -48,7 +53,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
) : StandardStickerSetAction { ) : CreateStickerSetAction {
init { init {
if(emojis.isEmpty()) { if(emojis.isEmpty()) {
throw IllegalArgumentException("Emojis must not be empty") throw IllegalArgumentException("Emojis must not be empty")

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.stickers
import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.stickers.MaskPosition import dev.inmo.tgbotapi.types.stickers.MaskPosition
@ -9,13 +10,14 @@ import kotlinx.serialization.*
fun CreateNewVideoStickerSet( fun CreateNewVideoStickerSet(
userId: UserId, userId: UserId,
name: String, linkName: String,
title: String,
sticker: InputFile, sticker: InputFile,
emojis: String, emojis: String,
containsMasks: Boolean? = null, containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null maskPosition: MaskPosition? = null
): Request<Boolean> { ): Request<Boolean> {
val data = CreateNewVideoStickerSet(userId, name, emojis, sticker as? FileId, containsMasks, maskPosition) val data = CreateNewVideoStickerSet(userId, linkName, title, emojis, sticker as? FileId, containsMasks, maskPosition)
return when (sticker) { return when (sticker) {
is MultipartFile -> CommonMultipartFileRequest( is MultipartFile -> CommonMultipartFileRequest(
data, data,
@ -31,6 +33,8 @@ data class CreateNewVideoStickerSet internal constructor(
override val userId: UserId, override val userId: UserId,
@SerialName(nameField) @SerialName(nameField)
override val name: String, override val name: String,
@SerialName(titleField)
override val title: String,
@SerialName(emojisField) @SerialName(emojisField)
override val emojis: String, override val emojis: String,
@SerialName(webmStickerField) @SerialName(webmStickerField)
@ -39,7 +43,7 @@ data class CreateNewVideoStickerSet internal constructor(
val containsMasks: Boolean? = null, val containsMasks: Boolean? = null,
@SerialName(maskPositionField) @SerialName(maskPositionField)
override val maskPosition: MaskPosition? = null override val maskPosition: MaskPosition? = null
) : StandardStickerSetAction { ) : CreateStickerSetAction {
init { init {
if(emojis.isEmpty()) { if(emojis.isEmpty()) {
throw IllegalArgumentException("Emojis must not be empty") throw IllegalArgumentException("Emojis must not be empty")

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.requests.stickers.abstracts
interface CreateStickerSetAction : StandardStickerSetAction {
val title: String
}