Skip to content

Commit

Permalink
replace warning about two bots from LongPolling to DefaultKtorRequest…
Browse files Browse the repository at this point in the history
…sExecutor
  • Loading branch information
InsanusMokrassar committed Nov 26, 2023
1 parent 74f625a commit ca73149
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 9.4.1

* Replace warning about two bots from `LongPolling` to `DefaultKtorRequestsExecutor`

## 9.4.0

* `Version`:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package dev.inmo.tgbotapi.bot.ktor.base

import dev.inmo.kslog.common.KSLog
import dev.inmo.kslog.common.e
import dev.inmo.kslog.common.i
import dev.inmo.kslog.common.v
import dev.inmo.kslog.common.*
import dev.inmo.micro_utils.coroutines.defaultSafelyExceptionHandler
import dev.inmo.micro_utils.coroutines.runCatchingSafely
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
import dev.inmo.tgbotapi.bot.exceptions.BotException
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.ktor.KtorCallFactory
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
Expand Down Expand Up @@ -102,8 +101,13 @@ class DefaultKtorRequestsExecutor internal constructor(
}
is BotException -> e
else -> CommonBotException(cause = e)
}.also {
logger.v(e) { "Result exception on handling of $request: $it" }
}.also { newException ->
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
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories).also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ fun TelegramBot.longPollingFlow(
if (e is RequestException) {
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(
Expand Down

0 comments on commit ca73149

Please sign in to comment.