From 0650fc594f07261a7e4e3599ddd46ae724d5426c Mon Sep 17 00:00:00 2001 From: BlackBaroness <57033600+BlackBaroness@users.noreply.github.com> Date: Sun, 27 Jul 2025 07:34:56 +0300 Subject: [PATCH 1/4] fix: typo in default error messages --- .../kotlin/dev/inmo/tgbotapi/utils/LaunchWithBotLogger.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/LaunchWithBotLogger.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/LaunchWithBotLogger.kt index 4b5125e8f0..328030bbac 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/LaunchWithBotLogger.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/LaunchWithBotLogger.kt @@ -13,7 +13,7 @@ import kotlin.coroutines.EmptyCoroutineContext context(bot: TelegramBot) fun CoroutineScope.launchWithBotLogger( - errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something web wrong" }, + errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something went wrong" }, context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit @@ -28,7 +28,7 @@ fun CoroutineScope.launchWithBotLogger( context(bot: TelegramBot) fun Flow.subscribeWithBotLogger( scope: CoroutineScope, - errorMessageBuilder: T.(Throwable) -> Any = { "Something web wrong" }, + errorMessageBuilder: T.(Throwable) -> Any = { "Something went wrong" }, block: suspend (T) -> Unit ) = subscribeLoggingDropExceptions ( scope, From 0f7536a21c67020dd534e0efd85fbef8d7257972 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 6 Aug 2025 13:10:42 +0600 Subject: [PATCH 2/4] start 27.1.2 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a23f137160..6ace938af0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 27.1.2 + ## 27.1.1 * `Version`: diff --git a/gradle.properties b/gradle.properties index c1612639f1..bb1e962b3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ kotlin.incremental.js=true ksp.useKSP2=false library_group=dev.inmo -library_version=27.1.1 +library_version=27.1.2 From f97575405881a992d9978d8bced5f5c5e3ea156e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 6 Aug 2025 13:14:22 +0600 Subject: [PATCH 3/4] try to fix cancelling on timeout for long polling --- CHANGELOG.md | 3 +++ .../utils/updates/retrieving/LongPolling.kt | 25 +++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ace938af0..d2b9bfd9bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 27.1.2 +* `Core`: + * Try to fix cancelling on timeout for long polling + ## 27.1.1 * `Version`: 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 da18e877a6..b59dc5a4c0 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 @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.extensions.utils.updates.retrieving +import dev.inmo.kslog.common.logger import dev.inmo.micro_utils.coroutines.* import dev.inmo.tgbotapi.bot.RequestsExecutor import dev.inmo.tgbotapi.bot.TelegramBot @@ -107,17 +108,13 @@ fun TelegramBot.longPollingFlow( lastUpdateIdentifier = update.updateId } } - }.onFailure { - it.causedCancellationException() ?.let { - cancel(it) - } } } } withContext(contextToWork) { while (isActive) { - runCatching { + runCatchingLogging(logger = Log) { execute( GetUpdates( offset = lastUpdateIdentifier?.plus(1), @@ -128,14 +125,16 @@ fun TelegramBot.longPollingFlow( updatesHandler(originalUpdates) } }.onFailure { e -> - val isHttpRequestTimeoutException = - e is HttpRequestTimeoutException || (e is CommonBotException && e.cause is HttpRequestTimeoutException) - if (isHttpRequestTimeoutException && autoSkipTimeoutExceptions) { - return@onFailure - } - exceptionsHandler?.invoke(e) - if (e is RequestException) { - delay(1000L) + runCatchingLogging(logger = Log) { + val isHttpRequestTimeoutException = + e is HttpRequestTimeoutException || (e is CommonBotException && e.cause is HttpRequestTimeoutException) + if (isHttpRequestTimeoutException && autoSkipTimeoutExceptions) { + return@onFailure + } + exceptionsHandler?.invoke(e) + if (e is RequestException) { + delay(1000L) + } } } } From 72781487f0510f75f1d168a0fec8dc6179775fd9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 6 Aug 2025 14:00:29 +0600 Subject: [PATCH 4/4] add note about Something web wrong --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2b9bfd9bf..006c660ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * `Core`: * Try to fix cancelling on timeout for long polling + * Since this update phrase `Something web wrong` will not happen from this library 😭 ## 27.1.1