From 29e155261829517df2efab4d220010cb1c159d47 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 14:37:01 +0600 Subject: [PATCH] migration --- FSMBot/src/main/kotlin/SimpleFSMBot.kt | 1 + .../src/main/kotlin/ForwardInfoSenderBot.kt | 5 ++++- .../src/commonMain/kotlin/KeyboardsBot.kt | 22 +++++++++---------- .../src/commonMain/kotlin/StickerInfoBot.kt | 3 ++- WebApp/src/jvmMain/kotlin/WebAppServer.kt | 5 +---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/FSMBot/src/main/kotlin/SimpleFSMBot.kt b/FSMBot/src/main/kotlin/SimpleFSMBot.kt index ca3f0b2..5c569f5 100644 --- a/FSMBot/src/main/kotlin/SimpleFSMBot.kt +++ b/FSMBot/src/main/kotlin/SimpleFSMBot.kt @@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.extensions.utils.formatting.* import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.TextContent +import dev.inmo.tgbotapi.utils.botCommand import kotlinx.coroutines.* import kotlinx.coroutines.flow.first diff --git a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt index c1e657d..5723b0f 100644 --- a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt +++ b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt @@ -6,6 +6,8 @@ import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.ExtendedBot import dev.inmo.tgbotapi.types.message.* +import dev.inmo.tgbotapi.utils.code +import dev.inmo.tgbotapi.utils.regular import kotlinx.coroutines.* /** @@ -33,9 +35,10 @@ suspend fun main(vararg args: String) { regular("User ") } } + is CommonBot, is ExtendedBot -> regular("Bot ") - } + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})" + } + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username?.username ?: "Without username"})" } is ForwardInfo.PublicChat.FromChannel -> regular("Channel (") + code(forwardInfo.channelChat.title) + ")" is ForwardInfo.PublicChat.FromSupergroup -> regular("Supergroup (") + code(forwardInfo.group.title) + ")" diff --git a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt index d87f757..3f69b47 100644 --- a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt +++ b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt @@ -7,12 +7,11 @@ import dev.inmo.tgbotapi.extensions.api.edit.edit import dev.inmo.tgbotapi.extensions.api.send.* import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* -import dev.inmo.tgbotapi.extensions.utils.formatting.botCommand -import dev.inmo.tgbotapi.extensions.utils.formatting.buildEntities import dev.inmo.tgbotapi.extensions.utils.types.buttons.* import dev.inmo.tgbotapi.extensions.utils.withContent import dev.inmo.tgbotapi.types.BotCommand import dev.inmo.tgbotapi.types.message.content.TextContent +import dev.inmo.tgbotapi.utils.* import kotlinx.coroutines.* private const val nextPageData = "next" @@ -71,13 +70,14 @@ suspend fun activateKeyboardsBot( val numberOfPages = args.firstOrNull() ?.toIntOrNull() ?: 10 reply( message, - "Your inline keyboard with $numberOfPages pages", replyMarkup = inlineKeyboard { row { includePageButtons(1, numberOfPages) } } - ) + ) { + regular("Your inline keyboard with $numberOfPages pages") + } } onMessageDataCallbackQuery { @@ -86,35 +86,33 @@ suspend fun activateKeyboardsBot( return@onMessageDataCallbackQuery } - val text = "This is $page of $count" - edit( it.message.withContent() ?: it.let { answer(it, "Unsupported message type :(") return@onMessageDataCallbackQuery }, - text, replyMarkup = inlineKeyboard { row { includePageButtons(page, count) } } - ) + ) { + regular("This is $page of $count") + } answer(it) } onUnhandledCommand { reply( it, - buildEntities { - +"Use " + botCommand("inline") + " to get pagination inline keyboard" - }, replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) { row { simpleButton("/inline") } } - ) + ) { + +"Use " + botCommand("inline") + " to get pagination inline keyboard" + } } setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard")) diff --git a/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt b/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt index c6f4e08..399cc6e 100644 --- a/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt +++ b/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt @@ -7,10 +7,11 @@ import dev.inmo.tgbotapi.extensions.api.get.getStickerSet import dev.inmo.tgbotapi.extensions.api.send.* import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* -import dev.inmo.tgbotapi.extensions.utils.formatting.* import dev.inmo.tgbotapi.types.StickerType import dev.inmo.tgbotapi.types.message.textsources.* import dev.inmo.tgbotapi.types.stickers.StickerSet +import dev.inmo.tgbotapi.utils.bold +import dev.inmo.tgbotapi.utils.buildEntities import kotlinx.coroutines.* fun StickerSet.buildInfo() = buildEntities { diff --git a/WebApp/src/jvmMain/kotlin/WebAppServer.kt b/WebApp/src/jvmMain/kotlin/WebAppServer.kt index fed639e..37acaef 100644 --- a/WebApp/src/jvmMain/kotlin/WebAppServer.kt +++ b/WebApp/src/jvmMain/kotlin/WebAppServer.kt @@ -7,16 +7,13 @@ import dev.inmo.tgbotapi.extensions.api.send.* import dev.inmo.tgbotapi.extensions.api.telegramBot import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* -import dev.inmo.tgbotapi.extensions.utils.formatting.botCommand -import dev.inmo.tgbotapi.extensions.utils.formatting.buildEntities import dev.inmo.tgbotapi.extensions.utils.types.buttons.* import dev.inmo.tgbotapi.types.BotCommand import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent import dev.inmo.tgbotapi.types.webAppQueryIdField import dev.inmo.tgbotapi.types.webapps.WebAppInfo -import dev.inmo.tgbotapi.utils.PreviewFeature -import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper +import dev.inmo.tgbotapi.utils.* import io.ktor.http.* import io.ktor.server.application.call import io.ktor.server.http.content.*