mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-10-20 06:40:08 +00:00
try to fix cancelling on timeout for long polling
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
## 27.1.2
|
||||
|
||||
* `Core`:
|
||||
* Try to fix cancelling on timeout for long polling
|
||||
|
||||
## 27.1.1
|
||||
|
||||
* `Version`:
|
||||
|
@@ -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,6 +125,7 @@ fun TelegramBot.longPollingFlow(
|
||||
updatesHandler(originalUpdates)
|
||||
}
|
||||
}.onFailure { e ->
|
||||
runCatchingLogging(logger = Log) {
|
||||
val isHttpRequestTimeoutException =
|
||||
e is HttpRequestTimeoutException || (e is CommonBotException && e.cause is HttpRequestTimeoutException)
|
||||
if (isHttpRequestTimeoutException && autoSkipTimeoutExceptions) {
|
||||
@@ -141,6 +139,7 @@ fun TelegramBot.longPollingFlow(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mediaGroupsDebounceTimeMillis Will be used for calling of [updateHandlerWithMediaGroupsAdaptation]. Pass null
|
||||
|
Reference in New Issue
Block a user