mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
create new animated sticker set
This commit is contained in:
parent
53257ff131
commit
f6692a22d1
@ -36,11 +36,15 @@
|
|||||||
* `SetMyCommands` request was added
|
* `SetMyCommands` request was added
|
||||||
* `GetMe` now is object instead of class
|
* `GetMe` now is object instead of class
|
||||||
* `GetMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.requests.bot.GetMe`
|
* `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`:
|
* `TelegramBotAPI-extensions-api`:
|
||||||
* Extensions `sendDice` was added
|
* Extensions `sendDice` was added
|
||||||
* Extension `getMyCommands` request was added
|
* Extension `getMyCommands` request was added
|
||||||
* Extension `setMyCommands` request was added
|
* Extension `setMyCommands` request was added
|
||||||
* Extension `getMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.GetMeKt.getMe`
|
* 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.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.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
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.CommonUser
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
|
|
||||||
suspend fun RequestsExecutor.createNewStickerSet(
|
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
name: String,
|
name: String,
|
||||||
sticker: FileId,
|
sticker: FileId,
|
||||||
@ -16,10 +16,10 @@ suspend fun RequestsExecutor.createNewStickerSet(
|
|||||||
containsMasks: Boolean? = null,
|
containsMasks: Boolean? = null,
|
||||||
maskPosition: MaskPosition? = null
|
maskPosition: MaskPosition? = null
|
||||||
) = execute(
|
) = 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,
|
userId: UserId,
|
||||||
name: String,
|
name: String,
|
||||||
sticker: MultipartFile,
|
sticker: MultipartFile,
|
||||||
@ -27,28 +27,28 @@ suspend fun RequestsExecutor.createNewStickerSet(
|
|||||||
containsMasks: Boolean? = null,
|
containsMasks: Boolean? = null,
|
||||||
maskPosition: MaskPosition? = null
|
maskPosition: MaskPosition? = null
|
||||||
) = execute(
|
) = 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,
|
user: CommonUser,
|
||||||
name: String,
|
name: String,
|
||||||
sticker: FileId,
|
sticker: FileId,
|
||||||
emojis: String,
|
emojis: String,
|
||||||
containsMasks: Boolean? = null,
|
containsMasks: Boolean? = null,
|
||||||
maskPosition: MaskPosition? = null
|
maskPosition: MaskPosition? = null
|
||||||
) = createNewStickerSet(
|
) = createNewStaticStickerSet(
|
||||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun RequestsExecutor.createNewStickerSet(
|
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
name: String,
|
name: String,
|
||||||
sticker: MultipartFile,
|
sticker: MultipartFile,
|
||||||
emojis: String,
|
emojis: String,
|
||||||
containsMasks: Boolean? = null,
|
containsMasks: Boolean? = null,
|
||||||
maskPosition: MaskPosition? = null
|
maskPosition: MaskPosition? = null
|
||||||
) = createNewStickerSet(
|
) = createNewStaticStickerSet(
|
||||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
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 com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun CreateNewStickerSet(
|
fun CreateNewAnimatedStickerSet(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
name: String,
|
name: String,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
@ -15,7 +15,7 @@ fun CreateNewStickerSet(
|
|||||||
containsMasks: Boolean? = null,
|
containsMasks: Boolean? = null,
|
||||||
maskPosition: MaskPosition? = null
|
maskPosition: MaskPosition? = null
|
||||||
): Request<Boolean> {
|
): 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) {
|
return when (sticker) {
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
is MultipartFile -> CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
@ -26,14 +26,14 @@ fun CreateNewStickerSet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CreateNewStickerSet internal constructor(
|
data class CreateNewAnimatedStickerSet internal constructor(
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
override val name: String,
|
override val name: String,
|
||||||
@SerialName(emojisField)
|
@SerialName(emojisField)
|
||||||
override val emojis: String,
|
override val emojis: String,
|
||||||
@SerialName(pngStickerField)
|
@SerialName(tgsStickerField)
|
||||||
val sticker: FileId? = null,
|
val sticker: FileId? = null,
|
||||||
@SerialName(containsMasksField)
|
@SerialName(containsMasksField)
|
||||||
val containsMasks: Boolean? = null,
|
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 canPinMessagesField = "can_pin_messages"
|
||||||
const val canPromoteMembersField = "can_promote_members"
|
const val canPromoteMembersField = "can_promote_members"
|
||||||
const val pngStickerField = "png_sticker"
|
const val pngStickerField = "png_sticker"
|
||||||
|
const val tgsStickerField = "tgs_sticker"
|
||||||
|
|
||||||
const val okField = "ok"
|
const val okField = "ok"
|
||||||
const val captionField = "caption"
|
const val captionField = "caption"
|
||||||
|
Loading…
Reference in New Issue
Block a user