mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-06-11 01:57:23 +00:00
Compare commits
9 Commits
27.1.1
...
16eaef0b9c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16eaef0b9c | ||
| ba647ee5ab | |||
| d2924ce1f2 | |||
| 72781487f0 | |||
| de435e5dbc | |||
| f975754058 | |||
| 0f7536a21c | |||
| d4c085c9b6 | |||
|
|
0650fc594f |
@@ -1,5 +1,11 @@
|
|||||||
# TelegramBotAPI changelog
|
# 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
|
## 27.1.1
|
||||||
|
|
||||||
* `Version`:
|
* `Version`:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#july-3-2025)
|
# TelegramBotAPI [](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#july-3-2025)
|
||||||
|
|
||||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
@@ -136,4 +136,4 @@ to proxy requests for files to the server where bot api server has been hosted
|
|||||||
(like `systemd-journal`) or be `101` UID user (like `systemd-resolve`)
|
(like `systemd-journal`) or be `101` UID user (like `systemd-resolve`)
|
||||||
* **OR** Use some reverse proxy (like nginx). It will allow you to broadcast your bots files without linux rights problems
|
* **OR** Use some reverse proxy (like nginx). It will allow you to broadcast your bots files without linux rights problems
|
||||||
* Set [TelegramAPIUrlsKeeper](tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper.kt)#fileLinkUrlMapper
|
* Set [TelegramAPIUrlsKeeper](tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper.kt)#fileLinkUrlMapper
|
||||||
to map urls to let bot execute requests to your nginx proxy
|
to map urls to let bot execute requests to your nginx proxy
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ kotlin.incremental.js=true
|
|||||||
ksp.useKSP2=false
|
ksp.useKSP2=false
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=27.1.1
|
library_version=27.1.2
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ javax-activation = "1.1.1"
|
|||||||
|
|
||||||
korlibs = "5.4.0"
|
korlibs = "5.4.0"
|
||||||
uuid = "0.8.4"
|
uuid = "0.8.4"
|
||||||
ktor = "3.2.2"
|
ktor = "3.2.3"
|
||||||
|
|
||||||
ksp = "2.2.0-2.0.2"
|
ksp = "2.2.0-2.0.2"
|
||||||
kotlin-poet = "2.2.0"
|
kotlin-poet = "2.2.0"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import kotlin.coroutines.EmptyCoroutineContext
|
|||||||
|
|
||||||
context(bot: TelegramBot)
|
context(bot: TelegramBot)
|
||||||
fun CoroutineScope.launchWithBotLogger(
|
fun CoroutineScope.launchWithBotLogger(
|
||||||
errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something web wrong" },
|
errorMessageBuilder: CoroutineScope.(Throwable) -> Any = { "Something went wrong" },
|
||||||
context: CoroutineContext = EmptyCoroutineContext,
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
block: suspend CoroutineScope.() -> Unit
|
block: suspend CoroutineScope.() -> Unit
|
||||||
@@ -28,7 +28,7 @@ fun CoroutineScope.launchWithBotLogger(
|
|||||||
context(bot: TelegramBot)
|
context(bot: TelegramBot)
|
||||||
fun <T> Flow<T>.subscribeWithBotLogger(
|
fun <T> Flow<T>.subscribeWithBotLogger(
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
errorMessageBuilder: T.(Throwable) -> Any = { "Something web wrong" },
|
errorMessageBuilder: T.(Throwable) -> Any = { "Something went wrong" },
|
||||||
block: suspend (T) -> Unit
|
block: suspend (T) -> Unit
|
||||||
) = subscribeLoggingDropExceptions (
|
) = subscribeLoggingDropExceptions (
|
||||||
scope,
|
scope,
|
||||||
|
|||||||
@@ -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,14 +125,16 @@ fun TelegramBot.longPollingFlow(
|
|||||||
updatesHandler(originalUpdates)
|
updatesHandler(originalUpdates)
|
||||||
}
|
}
|
||||||
}.onFailure { e ->
|
}.onFailure { e ->
|
||||||
val isHttpRequestTimeoutException =
|
runCatchingLogging(logger = Log) {
|
||||||
e is HttpRequestTimeoutException || (e is CommonBotException && e.cause is HttpRequestTimeoutException)
|
val isHttpRequestTimeoutException =
|
||||||
if (isHttpRequestTimeoutException && autoSkipTimeoutExceptions) {
|
e is HttpRequestTimeoutException || (e is CommonBotException && e.cause is HttpRequestTimeoutException)
|
||||||
return@onFailure
|
if (isHttpRequestTimeoutException && autoSkipTimeoutExceptions) {
|
||||||
}
|
return@onFailure
|
||||||
exceptionsHandler?.invoke(e)
|
}
|
||||||
if (e is RequestException) {
|
exceptionsHandler?.invoke(e)
|
||||||
delay(1000L)
|
if (e is RequestException) {
|
||||||
|
delay(1000L)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user