mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
replace warning about two bots from LongPolling to DefaultKtorRequestsExecutor
This commit is contained in:
parent
74f625a53a
commit
ca7314923e
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## 9.4.1
|
## 9.4.1
|
||||||
|
|
||||||
|
* Replace warning about two bots from `LongPolling` to `DefaultKtorRequestsExecutor`
|
||||||
|
|
||||||
## 9.4.0
|
## 9.4.0
|
||||||
|
|
||||||
* `Version`:
|
* `Version`:
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
import dev.inmo.kslog.common.KSLog
|
import dev.inmo.kslog.common.*
|
||||||
import dev.inmo.kslog.common.e
|
import dev.inmo.micro_utils.coroutines.defaultSafelyExceptionHandler
|
||||||
import dev.inmo.kslog.common.i
|
|
||||||
import dev.inmo.kslog.common.v
|
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.BotException
|
import dev.inmo.tgbotapi.bot.exceptions.BotException
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
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.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||||
@ -102,8 +101,13 @@ class DefaultKtorRequestsExecutor internal constructor(
|
|||||||
}
|
}
|
||||||
is BotException -> e
|
is BotException -> e
|
||||||
else -> CommonBotException(cause = e)
|
else -> CommonBotException(cause = e)
|
||||||
}.also {
|
}.also { newException ->
|
||||||
logger.v(e) { "Result exception on handling of $request: $it" }
|
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
|
} ?.let { Result.failure(it) } ?: it
|
||||||
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories).also {
|
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories).also {
|
||||||
|
@ -114,9 +114,6 @@ fun TelegramBot.longPollingFlow(
|
|||||||
if (e is RequestException) {
|
if (e is RequestException) {
|
||||||
delay(1000L)
|
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(
|
execute(
|
||||||
|
Loading…
Reference in New Issue
Block a user