From 9d42385662f962019320f05bc05f07e1e429db23 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 11 May 2022 00:23:14 +0600 Subject: [PATCH 1/5] 1.0.0 migration preview --- .../src/main/kotlin/FilesLoaderBot.kt | 1 - .../src/main/kotlin/ForwardInfoSenderBot.kt | 8 +++-- GetMeBot/src/main/kotlin/GetMeBot.kt | 4 +-- HelloBot/src/main/kotlin/HelloBot.kt | 12 ++++--- .../src/commonMain/kotlin/KeyboardsBot.kt | 6 +--- .../src/main/kotlin/RandomFileSenderBot.kt | 13 +++---- .../src/commonMain/kotlin/ResenderBot.kt | 9 +++-- .../src/main/kotlin/SlotMachineDetectorBot.kt | 35 +++++++------------ WebApp/src/jsMain/kotlin/main.kt | 4 +-- WebApp/src/jvmMain/kotlin/WebAppServer.kt | 13 ++++--- gradle.properties | 8 ++--- 11 files changed, 51 insertions(+), 62 deletions(-) diff --git a/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt b/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt index ed2600d..b3a53c4 100644 --- a/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt +++ b/FilesLoaderBot/src/main/kotlin/FilesLoaderBot.kt @@ -1,7 +1,6 @@ import dev.inmo.tgbotapi.extensions.api.files.downloadFile import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviour import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onMedia diff --git a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt index d4e95e4..2feaddb 100644 --- a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt +++ b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt @@ -2,7 +2,9 @@ import dev.inmo.tgbotapi.extensions.api.send.reply import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage import dev.inmo.tgbotapi.extensions.utils.formatting.* -import dev.inmo.tgbotapi.types.* +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 kotlinx.coroutines.* @@ -34,8 +36,8 @@ suspend fun main(vararg args: String) { } } reply(it, toAnswer) - coroutineContext.job.invokeOnCompletion { println("completance of onContentMessage") } + currentCoroutineContext().job.invokeOnCompletion { println("completance of onContentMessage") } } - coroutineContext.job.invokeOnCompletion { println("Completed :)") } + currentCoroutineContext().job.invokeOnCompletion { println("Completed :)") } }.second.join() } diff --git a/GetMeBot/src/main/kotlin/GetMeBot.kt b/GetMeBot/src/main/kotlin/GetMeBot.kt index 3987703..aa883dd 100644 --- a/GetMeBot/src/main/kotlin/GetMeBot.kt +++ b/GetMeBot/src/main/kotlin/GetMeBot.kt @@ -1,4 +1,4 @@ -import dev.inmo.tgbotapi.bot.Ktor.telegramBot +import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.bot.getMe /** @@ -10,4 +10,4 @@ suspend fun main(vararg args: String) { val bot = telegramBot(botToken) println(bot.getMe()) -} \ No newline at end of file +} diff --git a/HelloBot/src/main/kotlin/HelloBot.kt b/HelloBot/src/main/kotlin/HelloBot.kt index 4e35c8a..f960424 100644 --- a/HelloBot/src/main/kotlin/HelloBot.kt +++ b/HelloBot/src/main/kotlin/HelloBot.kt @@ -6,15 +6,19 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAn import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2 import dev.inmo.tgbotapi.extensions.utils.formatting.textMentionMarkdownV2 -import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2 -import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.types.chat.abstracts.* +import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.chat.GroupChat +import dev.inmo.tgbotapi.types.chat.PrivateChat +import dev.inmo.tgbotapi.types.chat.SupergroupChat +import dev.inmo.tgbotapi.types.message.MarkdownV2 +import dev.inmo.tgbotapi.utils.PreviewFeature import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Common import kotlinx.coroutines.* /** * The main purpose of this bot is just to answer "Oh, hi, " and add user mention here */ +@OptIn(PreviewFeature::class) suspend fun main(vararg args: String) { val botToken = args.first() @@ -27,8 +31,8 @@ suspend fun main(vararg args: String) { return@onContentMessage } val answerText = "Oh, hi, " + when (chat) { - is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id) is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id) + is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id) is SupergroupChat -> (chat.username ?.username ?: getChat(chat).inviteLink) ?.let { chat.title.linkMarkdownV2(it) } ?: chat.title diff --git a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt index 448e607..da621f5 100644 --- a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt +++ b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt @@ -1,15 +1,11 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.tgbotapi.extensions.api.bot.getMe -import dev.inmo.tgbotapi.bot.Ktor.telegramBot +import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.answers.answer import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText import dev.inmo.tgbotapi.extensions.api.send.* -import dev.inmo.tgbotapi.extensions.api.send.media.* import dev.inmo.tgbotapi.extensions.behaviour_builder.* -import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups -import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* -import dev.inmo.tgbotapi.extensions.utils.shortcuts.* import dev.inmo.tgbotapi.extensions.utils.types.buttons.* import dev.inmo.tgbotapi.extensions.utils.withContent import dev.inmo.tgbotapi.types.message.content.TextContent diff --git a/RandomFileSenderBot/src/main/kotlin/RandomFileSenderBot.kt b/RandomFileSenderBot/src/main/kotlin/RandomFileSenderBot.kt index 29d0e42..87e8cbc 100644 --- a/RandomFileSenderBot/src/main/kotlin/RandomFileSenderBot.kt +++ b/RandomFileSenderBot/src/main/kotlin/RandomFileSenderBot.kt @@ -1,4 +1,4 @@ -import dev.inmo.tgbotapi.bot.Ktor.telegramBot +import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands @@ -6,18 +6,13 @@ import dev.inmo.tgbotapi.extensions.api.send.media.sendDocument import dev.inmo.tgbotapi.extensions.api.send.media.sendDocumentsGroup import dev.inmo.tgbotapi.extensions.api.send.reply import dev.inmo.tgbotapi.extensions.api.send.withUploadDocumentAction -import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviour import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling -import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommandWithArgs import dev.inmo.tgbotapi.requests.abstracts.asMultipartFile -import dev.inmo.tgbotapi.requests.abstracts.toInputFile import dev.inmo.tgbotapi.types.BotCommand -import dev.inmo.tgbotapi.types.InputMedia.DocumentMediaGroupMemberInputMedia -import dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument -import dev.inmo.tgbotapi.types.chat.abstracts.Chat +import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.media.TelegramMediaDocument import dev.inmo.tgbotapi.types.mediaCountInMediaGroup -import kotlinx.coroutines.* import java.io.File private const val command = "send_file" @@ -50,7 +45,7 @@ suspend fun main(args: Array) { ) else -> sendDocumentsGroup( chat, - files.map { InputMediaDocument(it.asMultipartFile()) }, + files.map { TelegramMediaDocument(it.asMultipartFile()) }, protectContent = true ) } diff --git a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt index 7cc6cec..eade287 100644 --- a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt +++ b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt @@ -1,6 +1,6 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.tgbotapi.extensions.api.bot.getMe -import dev.inmo.tgbotapi.bot.Ktor.telegramBot +import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.send.* import dev.inmo.tgbotapi.extensions.api.send.media.* import dev.inmo.tgbotapi.extensions.behaviour_builder.* @@ -8,7 +8,6 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilte import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* import dev.inmo.tgbotapi.extensions.utils.shortcuts.* -import dev.inmo.tgbotapi.types.message.abstracts.Message import kotlinx.coroutines.* suspend fun activateResenderBot( @@ -32,19 +31,19 @@ suspend fun activateResenderBot( onVisualGallery { val chat = it.chat ?: return@onVisualGallery withUploadPhotoAction(chat) { - sendVisualMediaGroup(chat, it.map { it.content.toMediaGroupMemberInputMedia() }) + sendVisualMediaGroup(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() }) } } onPlaylist { val chat = it.chat ?: return@onPlaylist withUploadDocumentAction(chat) { - sendPlaylist(chat, it.map { it.content.toMediaGroupMemberInputMedia() }) + sendPlaylist(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() }) } } onDocumentsGroup { val chat = it.chat ?: return@onDocumentsGroup withUploadDocumentAction(chat) { - sendDocumentsGroup(chat, it.map { it.content.toMediaGroupMemberInputMedia() }) + sendDocumentsGroup(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() }) } } diff --git a/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt b/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt index 4e7d425..2720ec1 100644 --- a/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt +++ b/SlotMachineDetectorBot/src/main/kotlin/SlotMachineDetectorBot.kt @@ -1,35 +1,26 @@ -import dev.inmo.micro_utils.coroutines.safely -import dev.inmo.tgbotapi.bot.Ktor.telegramBot +import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.send.reply +import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling +import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onDice import dev.inmo.tgbotapi.extensions.utils.* -import dev.inmo.tgbotapi.extensions.utils.shortcuts.filterContentMessages -import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType -import dev.inmo.tgbotapi.types.message.content.DiceContent import kotlinx.coroutines.* -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach suspend fun main(args: Array) { val bot = telegramBot(args.first()) - val scope = CoroutineScope(Dispatchers.Default) - bot.longPolling(scope = scope) { - filterContentMessages(scope).onEach { + bot.buildBehaviourWithLongPolling(scope = CoroutineScope(Dispatchers.IO)) { + onDice { val content = it.content val dice = content.dice val diceType = dice.animationType - safely ({ it.printStackTrace() }) { - if (diceType == SlotMachineDiceAnimationType) { - val result = dice.calculateSlotMachineResult() ?: return@safely - bot.reply(it, "${result.leftReel}|${result.centerReel}|${result.rightReel}") - } else { - bot.reply(it, "There is no slot machine dice in message") - } + if (diceType == SlotMachineDiceAnimationType) { + val result = dice.calculateSlotMachineResult() ?: return@onDice + bot.reply(it, "${result.leftReel}|${result.centerReel}|${result.rightReel}") + } else { + bot.reply(it, "There is no slot machine dice in message") } - }.launchIn(scope) - } - - scope.coroutineContext[Job]!!.join() -} \ No newline at end of file + } + }.join() +} diff --git a/WebApp/src/jsMain/kotlin/main.kt b/WebApp/src/jsMain/kotlin/main.kt index ec54816..3691e25 100644 --- a/WebApp/src/jsMain/kotlin/main.kt +++ b/WebApp/src/jsMain/kotlin/main.kt @@ -29,9 +29,9 @@ fun main() { addEventListener("click", { scope.launchSafelyWithoutExceptions { handleResult({ "Clicked" }) { - HttpClient().post("${window.location.origin.removeSuffix("/")}/inline") { + HttpClient().post("${window.location.origin.removeSuffix("/")}/inline") { parameter(webAppQueryIdField, it) - body = TextContent("Clicked", ContentType.Text.Plain) + setBody(TextContent("Clicked", ContentType.Text.Plain)) document.body ?.log(url.build().toString()) }.coroutineContext.job.join() } diff --git a/WebApp/src/jvmMain/kotlin/WebAppServer.kt b/WebApp/src/jvmMain/kotlin/WebAppServer.kt index 6f64c4c..6819687 100644 --- a/WebApp/src/jvmMain/kotlin/WebAppServer.kt +++ b/WebApp/src/jvmMain/kotlin/WebAppServer.kt @@ -13,12 +13,14 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent import dev.inmo.tgbotapi.types.webAppQueryIdField import dev.inmo.tgbotapi.types.webapps.WebAppInfo -import io.ktor.application.call +import dev.inmo.tgbotapi.utils.PreviewFeature import io.ktor.http.HttpStatusCode -import io.ktor.http.content.* -import io.ktor.request.receiveText -import io.ktor.response.respond -import io.ktor.routing.* +import io.ktor.server.application.call +import io.ktor.server.http.content.* +import io.ktor.server.request.receiveText +import io.ktor.server.response.respond +import io.ktor.server.routing.post +import io.ktor.server.routing.routing import kotlinx.coroutines.Dispatchers import java.io.File @@ -30,6 +32,7 @@ import java.io.File * * Will start the server to share the static (index.html and WebApp.js) on 0.0.0.0:8080 */ +@OptIn(PreviewFeature::class) suspend fun main(vararg args: String) { val bot = telegramBot(args.first(), testServer = args.any { it == "testServer" }) createKtorServer( diff --git a/gradle.properties b/gradle.properties index b677ec3..01422ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ kotlin.code.style=official org.gradle.parallel=true -kotlin_version=1.6.10 -telegram_bot_api_version=0.38.23 -micro_utils_version=0.9.24 -ktor_version=1.6.8 +kotlin_version=1.6.21 +telegram_bot_api_version=1.0.0 +micro_utils_version=0.10.2 +ktor_version=2.0.1 From e772cfda3b9b242b922c0b0a8f24a238a522f911 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 11 May 2022 02:47:37 +0600 Subject: [PATCH 2/5] start migration onto 1.0.0 --- FSMBot/src/main/kotlin/SimpleFSMBot.kt | 1 + ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt | 2 -- gradle.properties | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/FSMBot/src/main/kotlin/SimpleFSMBot.kt b/FSMBot/src/main/kotlin/SimpleFSMBot.kt index ed915f4..36dd2a0 100644 --- a/FSMBot/src/main/kotlin/SimpleFSMBot.kt +++ b/FSMBot/src/main/kotlin/SimpleFSMBot.kt @@ -1,3 +1,4 @@ +import dev.inmo.micro_utils.coroutines.AccumulatorFlow import dev.inmo.micro_utils.fsm.common.State import dev.inmo.tgbotapi.extensions.api.send.sendMessage import dev.inmo.tgbotapi.extensions.behaviour_builder.* diff --git a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt index 2feaddb..e8ddd0a 100644 --- a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt +++ b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt @@ -36,8 +36,6 @@ suspend fun main(vararg args: String) { } } reply(it, toAnswer) - currentCoroutineContext().job.invokeOnCompletion { println("completance of onContentMessage") } } - currentCoroutineContext().job.invokeOnCompletion { println("Completed :)") } }.second.join() } diff --git a/gradle.properties b/gradle.properties index 01422ea..72835e2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,5 +4,5 @@ org.gradle.parallel=true kotlin_version=1.6.21 telegram_bot_api_version=1.0.0 -micro_utils_version=0.10.2 +micro_utils_version=0.10.3 ktor_version=2.0.1 From 0489f217b323670241debe3d0c6fdf12969274fa Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 11 May 2022 12:15:18 +0600 Subject: [PATCH 3/5] update examples --- .../src/commonMain/kotlin/KeyboardsBot.kt | 24 ++++++++++++++++++- WebApp/src/jvmMain/kotlin/WebAppServer.kt | 10 +++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt index da621f5..a4a1115 100644 --- a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt +++ b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt @@ -2,12 +2,16 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.tgbotapi.extensions.api.bot.getMe import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.answers.answer +import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText 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 kotlinx.coroutines.* @@ -82,12 +86,14 @@ suspend fun activateKeyboardsBot( return@onMessageDataCallbackQuery } + val text = "This is $page of $count" + editMessageText( it.message.withContent() ?: it.let { answer(it, "Unsupported message type :(") return@onMessageDataCallbackQuery }, - "This is $page of $count", + text, replyMarkup = inlineKeyboard { row { includePageButtons(page, count) @@ -96,6 +102,22 @@ suspend fun activateKeyboardsBot( ) } + onUnhandledCommand { + reply( + it, + buildEntities { + +"Use " + botCommand("inline") + " to get pagination inline keyboard" + }, + replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) { + row { + simpleButton("/inline") + } + } + ) + } + + setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard")) + allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { println(it) } diff --git a/WebApp/src/jvmMain/kotlin/WebAppServer.kt b/WebApp/src/jvmMain/kotlin/WebAppServer.kt index 6819687..5deb2f8 100644 --- a/WebApp/src/jvmMain/kotlin/WebAppServer.kt +++ b/WebApp/src/jvmMain/kotlin/WebAppServer.kt @@ -7,6 +7,8 @@ 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 @@ -85,7 +87,13 @@ suspend fun main(vararg args: String) { ) } onUnhandledCommand { - println("Unhandled command: ${it.content}") + reply( + it, + buildEntities { + +"Use " + botCommand("inline") + " to get inline web app button\n" + +"Use " + botCommand("reply_markup") + " to get reply markup web app button\n" + } + ) } setMyCommands( BotCommand("reply_markup", "Use to get reply markup keyboard with web app trigger"), From a18f22fe8f5c857f84d0c566af58a705deb51b76 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 May 2022 16:47:46 +0600 Subject: [PATCH 4/5] update xmx for builds --- .github/workflows/build.yml | 4 ++-- gradle.properties | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ceab9f2..65f648c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,9 +8,9 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 11 - name: Build with Gradle run: ./gradlew build diff --git a/gradle.properties b/gradle.properties index 72835e2..0f1f9ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ kotlin.code.style=official org.gradle.parallel=true +org.gradle.jvmargs=-Xmx3g kotlin_version=1.6.21 From 16410debffd2d546f507a8dbbe2938619a03ebb3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 May 2022 17:00:22 +0600 Subject: [PATCH 5/5] decrease xmx --- gradle.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0f1f9ac..634dc79 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,7 @@ kotlin.code.style=official org.gradle.parallel=true -org.gradle.jvmargs=-Xmx3g +# Due to parallel compilation project require next amount of memory on full build +org.gradle.jvmargs=-Xmx768m kotlin_version=1.6.21