mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-02 22:59:48 +00:00
@@ -1,5 +1,11 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 27.1.2
|
||||
|
||||
* `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
|
||||
|
||||
* `Version`:
|
||||
|
@@ -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
|
||||
|
@@ -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 <T> Flow<T>.subscribeWithBotLogger(
|
||||
scope: CoroutineScope,
|
||||
errorMessageBuilder: T.(Throwable) -> Any = { "Something web wrong" },
|
||||
errorMessageBuilder: T.(Throwable) -> Any = { "Something went wrong" },
|
||||
block: suspend (T) -> Unit
|
||||
) = subscribeLoggingDropExceptions (
|
||||
scope,
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user