diff --git a/InlineQueriesBot/build.gradle b/InlineQueriesBot/build.gradle index 7131a21..49b7e81 100644 --- a/InlineQueriesBot/build.gradle +++ b/InlineQueriesBot/build.gradle @@ -12,14 +12,16 @@ plugins { id "org.jetbrains.kotlin.multiplatform" } -apply plugin: 'application' - -mainClassName="InlineQueriesBotKt" - apply from: "$nativePartTemplate" kotlin { - jvm() + jvm { + binaries { + executable { + mainClass.set("InlineQueriesBotKt") + } + } + } sourceSets { commonMain { @@ -27,12 +29,9 @@ kotlin { implementation kotlin('stdlib') api "dev.inmo:tgbotapi:$telegram_bot_api_version" + api "io.ktor:ktor-client-logging:$ktor_version" } } } } -dependencies { - implementation 'io.ktor:ktor-client-logging-jvm:3.1.0' -} - diff --git a/InlineQueriesBot/src/commonMain/kotlin/Bot.kt b/InlineQueriesBot/src/commonMain/kotlin/Bot.kt index 18019d8..c89df0f 100644 --- a/InlineQueriesBot/src/commonMain/kotlin/Bot.kt +++ b/InlineQueriesBot/src/commonMain/kotlin/Bot.kt @@ -1,4 +1,4 @@ -import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions +import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions import dev.inmo.tgbotapi.extensions.api.answers.answer import dev.inmo.tgbotapi.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.send.reply @@ -59,7 +59,7 @@ suspend fun doInlineQueriesBot(token: String) { reply(message, deepLink) } - allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { + allUpdatesFlow.subscribeLoggingDropExceptions(scope = this) { println(it) } diff --git a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt index 9781465..1be39cf 100644 --- a/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt +++ b/KeyboardsBot/KeyboardsBotLib/src/commonMain/kotlin/KeyboardsBot.kt @@ -1,4 +1,4 @@ -import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions +import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.answers.answer import dev.inmo.tgbotapi.extensions.api.bot.getMe @@ -89,7 +89,7 @@ suspend fun activateKeyboardsBot( onCommandWithArgs("inline") { message, args -> val numberArgs = args.mapNotNull { it.toIntOrNull() } val numberOfPages = numberArgs.getOrNull(1) ?: numberArgs.firstOrNull() ?: 10 - val page = numberArgs.firstOrNull() ?.takeIf { numberArgs.size > 1 } ?.coerceAtLeast(1) ?: 1 + val page = numberArgs.firstOrNull()?.takeIf { numberArgs.size > 1 }?.coerceAtLeast(1) ?: 1 reply( message, replyMarkup = inlineKeyboard { @@ -138,7 +138,8 @@ suspend fun activateKeyboardsBot( onBaseInlineQuery { val page = it.query.takeWhile { it.isDigit() }.toIntOrNull() ?: return@onBaseInlineQuery - val count = it.query.removePrefix(page.toString()).dropWhile { !it.isDigit() }.takeWhile { it.isDigit() }.toIntOrNull() ?: return@onBaseInlineQuery + val count = it.query.removePrefix(page.toString()).dropWhile { !it.isDigit() }.takeWhile { it.isDigit() } + .toIntOrNull() ?: return@onBaseInlineQuery answer( it, @@ -170,7 +171,7 @@ suspend fun activateKeyboardsBot( setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard")) - allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { + allUpdatesFlow.subscribeLoggingDropExceptions(scope = this) { println(it) } }.join() diff --git a/RandomFileSenderBot/build.gradle b/RandomFileSenderBot/build.gradle index d4e2f24..8626fe1 100644 --- a/RandomFileSenderBot/build.gradle +++ b/RandomFileSenderBot/build.gradle @@ -12,12 +12,14 @@ plugins { id "org.jetbrains.kotlin.multiplatform" } -apply plugin: 'application' - -mainClassName="RandomFileSenderBotKt" - kotlin { - jvm() + jvm { + binaries { + executable { + mainClass.set("RandomFileSenderBotKt") + } + } + } sourceSets { commonMain { diff --git a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt index 69fb356..094ff67 100644 --- a/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt +++ b/ResenderBot/ResenderBotLib/src/commonMain/kotlin/ResenderBot.kt @@ -1,4 +1,4 @@ -import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions +import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions import dev.inmo.tgbotapi.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.send.withTypingAction import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat @@ -31,15 +31,15 @@ suspend fun activateResenderBot( it.content.createResend( chat.id, messageThreadId = it.threadIdOrNull, - replyParameters = it.replyInfo ?.messageMeta ?.let { meta -> - val quote = it.withContentOrNull<TextContent>() ?.content ?.quote + replyParameters = it.replyInfo?.messageMeta?.let { meta -> + val quote = it.withContentOrNull<TextContent>()?.content?.quote ReplyParameters( meta, - entities = quote ?.textSources ?: emptyList(), - quotePosition = quote ?.position + entities = quote?.textSources ?: emptyList(), + quotePosition = quote?.position ) }, - effectId = it.possiblyWithEffectMessageOrNull() ?.effectId + effectId = it.possiblyWithEffectMessageOrNull()?.effectId ) ) { it.forEach(print) @@ -49,7 +49,7 @@ suspend fun activateResenderBot( println("Answer info: $answer") } - allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { + allUpdatesFlow.subscribeLoggingDropExceptions(scope = this) { println(it) } print(bot.getMe()) diff --git a/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt b/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt index da0db26..19aefe1 100644 --- a/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt +++ b/StickerInfoBot/StickerInfoBotLib/src/commonMain/kotlin/StickerInfoBot.kt @@ -1,5 +1,5 @@ import dev.inmo.micro_utils.coroutines.defaultSafelyWithoutExceptionHandler -import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions +import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.get.getCustomEmojiStickerOrNull @@ -55,7 +55,7 @@ suspend fun activateStickerInfoBot( withTypingAction(it.chat) { it.content.textSources.mapNotNull { if (it is CustomEmojiTextSource) { - getCustomEmojiStickerOrNull(it.customEmojiId) ?.stickerSetName + getCustomEmojiStickerOrNull(it.customEmojiId)?.stickerSetName } else { null } @@ -76,7 +76,7 @@ suspend fun activateStickerInfoBot( ) } - allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { + allUpdatesFlow.subscribeLoggingDropExceptions(scope = this) { println(it) } }.join() diff --git a/WebApp/build.gradle b/WebApp/build.gradle index 8e04927..22cad8d 100644 --- a/WebApp/build.gradle +++ b/WebApp/build.gradle @@ -16,10 +16,14 @@ plugins { id "org.jetbrains.compose" version "$compose_version" } -apply plugin: 'application' - kotlin { - jvm() + jvm { + binaries { + executable { + mainClass.set("WebAppServerKt") + } + } + } js(IR) { browser() binaries.executable() @@ -53,10 +57,6 @@ kotlin { } } -application { - mainClassName = "WebAppServerKt" -} - tasks.getByName("compileKotlinJvm") .dependsOn(jsBrowserDistribution) tasks.getByName("compileKotlinJvm").configure { diff --git a/WebApp/src/jsMain/kotlin/main.kt b/WebApp/src/jsMain/kotlin/main.kt index fa1c3d0..60a10f8 100644 --- a/WebApp/src/jsMain/kotlin/main.kt +++ b/WebApp/src/jsMain/kotlin/main.kt @@ -1,4 +1,5 @@ import androidx.compose.runtime.* +import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions import dev.inmo.tgbotapi.types.CustomEmojiId import dev.inmo.tgbotapi.types.userIdField @@ -110,7 +111,7 @@ fun main() { userId ?.let { userId -> Button({ onClick { - scope.launchSafelyWithoutExceptions { + scope.launchLoggingDropExceptions { client.post("$baseUrl/setCustomEmoji") { parameter(userIdField, userId.long) setBody( @@ -130,7 +131,7 @@ fun main() { Button({ onClick { - scope.launchSafelyWithoutExceptions { + scope.launchLoggingDropExceptions { handleResult({ "Clicked" }) { client.post("${window.location.origin.removeSuffix("/")}/inline") { parameter(webAppQueryIdField, it) diff --git a/WebApp/src/jvmMain/kotlin/WebAppServer.kt b/WebApp/src/jvmMain/kotlin/WebAppServer.kt index d6ed35f..11b1f8a 100644 --- a/WebApp/src/jvmMain/kotlin/WebAppServer.kt +++ b/WebApp/src/jvmMain/kotlin/WebAppServer.kt @@ -1,4 +1,5 @@ import dev.inmo.kslog.common.* +import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.micro_utils.ktor.server.createKtorServer import dev.inmo.tgbotapi.extensions.api.answers.answerInlineQuery @@ -195,7 +196,7 @@ suspend fun main(vararg args: String) { BotCommand("reply_markup", "Use to get reply markup keyboard with web app trigger"), BotCommand("inline", "Use to get inline keyboard with web app trigger"), ) - allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { + allUpdatesFlow.subscribeLoggingDropExceptions(this) { println(it) } println(getMe()) diff --git a/gradle.properties b/gradle.properties index dc5e890..cfda679 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,9 @@ org.gradle.jvmargs=-Xmx3148m kotlin.daemon.jvmargs=-Xmx3g -Xms500m -kotlin_version=2.1.10 -telegram_bot_api_version=23.2.0 -micro_utils_version=0.24.6 +kotlin_version=2.1.20 +telegram_bot_api_version=25.0.0-rc +micro_utils_version=0.25.3 serialization_version=1.8.0 -ktor_version=3.1.0 +ktor_version=3.1.1 compose_version=1.7.3