diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b841162b0..ec139c5ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # TelegramBotAPI changelog +## 9.4.1 + +* Replace warning about two bots from `LongPolling` to `DefaultKtorRequestsExecutor` + ## 9.4.0 * `Version`: diff --git a/gradle.properties b/gradle.properties index 1a95c1f955..99c4d6ad57 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=9.4.0 +library_version=9.4.1 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt index fd7a0bf237..220539e6f5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt @@ -1,13 +1,12 @@ package dev.inmo.tgbotapi.bot.ktor.base -import dev.inmo.kslog.common.KSLog -import dev.inmo.kslog.common.e -import dev.inmo.kslog.common.i -import dev.inmo.kslog.common.v +import dev.inmo.kslog.common.* +import dev.inmo.micro_utils.coroutines.defaultSafelyExceptionHandler import dev.inmo.micro_utils.coroutines.runCatchingSafely import dev.inmo.tgbotapi.bot.BaseRequestsExecutor import dev.inmo.tgbotapi.bot.exceptions.BotException import dev.inmo.tgbotapi.bot.exceptions.CommonBotException +import dev.inmo.tgbotapi.bot.exceptions.GetUpdatesConflict import dev.inmo.tgbotapi.bot.exceptions.newRequestException import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder @@ -102,8 +101,13 @@ class DefaultKtorRequestsExecutor internal constructor( } is BotException -> e else -> CommonBotException(cause = e) - }.also { - logger.v(e) { "Result exception on handling of $request: $it" } + }.also { newException -> + logger.v(newException) { "Result exception on handling of $request is an exception" } + if (newException is GetUpdatesConflict) { + logger.w(newException) { + "Warning!!! Other bot with the same bot token requests updates with getUpdate in parallel" + } + } } } ?.let { Result.failure(it) } ?: it pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories).also { diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt index 8f83d31002..9c56622c85 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt @@ -114,9 +114,6 @@ fun TelegramBot.longPollingFlow( if (e is RequestException) { delay(1000L) } - if (e is GetUpdatesConflict && (exceptionsHandler == null || exceptionsHandler == defaultSafelyExceptionHandler)) { - println("Warning!!! Other bot with the same bot token requests updates with getUpdate in parallel") - } } ) { execute(