mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 23:29:33 +00:00
try to fix cancelling on timeout for long polling
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## 27.1.2
|
## 27.1.2
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Try to fix cancelling on timeout for long polling
|
||||||
|
|
||||||
## 27.1.1
|
## 27.1.1
|
||||||
|
|
||||||
* `Version`:
|
* `Version`:
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.utils.updates.retrieving
|
package dev.inmo.tgbotapi.extensions.utils.updates.retrieving
|
||||||
|
|
||||||
|
import dev.inmo.kslog.common.logger
|
||||||
import dev.inmo.micro_utils.coroutines.*
|
import dev.inmo.micro_utils.coroutines.*
|
||||||
import dev.inmo.tgbotapi.bot.RequestsExecutor
|
import dev.inmo.tgbotapi.bot.RequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
@@ -107,17 +108,13 @@ fun TelegramBot.longPollingFlow(
|
|||||||
lastUpdateIdentifier = update.updateId
|
lastUpdateIdentifier = update.updateId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.onFailure {
|
|
||||||
it.causedCancellationException() ?.let {
|
|
||||||
cancel(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
withContext(contextToWork) {
|
withContext(contextToWork) {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
runCatching {
|
runCatchingLogging(logger = Log) {
|
||||||
execute(
|
execute(
|
||||||
GetUpdates(
|
GetUpdates(
|
||||||
offset = lastUpdateIdentifier?.plus(1),
|
offset = lastUpdateIdentifier?.plus(1),
|
||||||
@@ -128,6 +125,7 @@ fun TelegramBot.longPollingFlow(
|
|||||||
updatesHandler(originalUpdates)
|
updatesHandler(originalUpdates)
|
||||||
}
|
}
|
||||||
}.onFailure { e ->
|
}.onFailure { e ->
|
||||||
|
runCatchingLogging(logger = Log) {
|
||||||
val isHttpRequestTimeoutException =
|
val isHttpRequestTimeoutException =
|
||||||
e is HttpRequestTimeoutException || (e is CommonBotException && e.cause is HttpRequestTimeoutException)
|
e is HttpRequestTimeoutException || (e is CommonBotException && e.cause is HttpRequestTimeoutException)
|
||||||
if (isHttpRequestTimeoutException && autoSkipTimeoutExceptions) {
|
if (isHttpRequestTimeoutException && autoSkipTimeoutExceptions) {
|
||||||
@@ -140,6 +138,7 @@ fun TelegramBot.longPollingFlow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user