From b660bf5f4200c926b8b512d70e70068a2817c178 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 18 Apr 2024 17:03:53 +0600 Subject: [PATCH] upgrade to support new ktgbotapi --- HelloBot/src/main/kotlin/HelloBot.kt | 4 ++++ .../src/commonMain/kotlin/StickerInfoBot.kt | 13 ------------- .../src/main/kotlin/StickerSetHandlerBot.kt | 4 +++- gradle.properties | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/HelloBot/src/main/kotlin/HelloBot.kt b/HelloBot/src/main/kotlin/HelloBot.kt index 71c5778..fb95839 100644 --- a/HelloBot/src/main/kotlin/HelloBot.kt +++ b/HelloBot/src/main/kotlin/HelloBot.kt @@ -56,6 +56,10 @@ suspend fun main(vararg args: String) { } ?: chat.title } } + is PreviewBusinessChat -> { + reply(message, "Hi, " + "${chat.original.firstName} ${chat.original.lastName} (as business chat :) )".textMentionMarkdownV2(chat.original.id), MarkdownV2) + return@onMentionWithAnyContent + } is UnknownChatType -> "Unknown :(".escapeMarkdownV2Common() } reply( diff --git a/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt b/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt index ddd9f00..9b1dc06 100644 --- a/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt +++ b/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt @@ -9,16 +9,9 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* import dev.inmo.tgbotapi.types.StickerFormat import dev.inmo.tgbotapi.types.StickerType import dev.inmo.tgbotapi.types.message.textsources.* -import dev.inmo.tgbotapi.types.stickers.AnimatedStickerSet -import dev.inmo.tgbotapi.types.stickers.CustomEmojiSimpleStickerSet import dev.inmo.tgbotapi.types.stickers.CustomEmojiStickerSet -import dev.inmo.tgbotapi.types.stickers.CustomEmojiVideoStickerSet -import dev.inmo.tgbotapi.types.stickers.MaskSimpleStickerSet import dev.inmo.tgbotapi.types.stickers.MaskStickerSet -import dev.inmo.tgbotapi.types.stickers.MaskVideoStickerSet -import dev.inmo.tgbotapi.types.stickers.RegularSimpleStickerSet import dev.inmo.tgbotapi.types.stickers.RegularStickerSet -import dev.inmo.tgbotapi.types.stickers.RegularVideoStickerSet import dev.inmo.tgbotapi.types.stickers.StickerSet import dev.inmo.tgbotapi.types.stickers.UnknownStickerSet import dev.inmo.tgbotapi.utils.bold @@ -31,12 +24,6 @@ fun StickerSet?.buildInfo() = buildEntities { } else { bold("StickerSet name: ") + "${name}\n" bold("StickerSet title: ") + "${title}\n" - bold("Sticker format: ") + when (stickerFormat) { - StickerFormat.Animated -> "Animated" - StickerFormat.Static -> "Static" - is StickerFormat.Unknown -> stickerFormat.type - StickerFormat.Video -> "Video" - } + "\n" bold( when (stickerType) { StickerType.CustomEmoji -> "Custom emoji" diff --git a/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt b/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt index 8a9cf65..9cefc7a 100644 --- a/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt +++ b/StickerSetHandler/src/main/kotlin/StickerSetHandlerBot.kt @@ -56,16 +56,19 @@ suspend fun main(args: Array) { val newSticker = when (sticker) { is CustomEmojiSticker -> InputSticker.WithKeywords.CustomEmoji( downloadFileToTemp(sticker.fileId).asMultipartFile(), + sticker.stickerFormat, listOf(sticker.emoji ?: "\uD83D\uDE0A"), emptyList() ) is MaskSticker -> InputSticker.Mask( downloadFileToTemp(sticker.fileId).asMultipartFile(), + sticker.stickerFormat, listOf(sticker.emoji ?: "\uD83D\uDE0A"), sticker.maskPosition ) is RegularSticker -> InputSticker.WithKeywords.Regular( downloadFileToTemp(sticker.fileId).asMultipartFile(), + sticker.stickerFormat, listOf(sticker.emoji ?: "\uD83D\uDE0A"), emptyList() ) @@ -85,7 +88,6 @@ suspend fun main(args: Array) { it.chat.id.toChatId(), stickerSetName.string, "Sticker set by ${me.firstName}", - it.content.media.stickerFormat, listOf( newSticker ), diff --git a/gradle.properties b/gradle.properties index da91621..f1971db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx2344m kotlin_version=1.9.23 -telegram_bot_api_version=11.0.0 +telegram_bot_api_version=12.0.0 micro_utils_version=0.20.39 serialization_version=1.6.3 ktor_version=2.3.9