Skip to content

Commit 90d7bdf

Browse files
Merge pull request #1020 from InsanusMokrassar/30.0.2
30.0.2
2 parents f27caae + 374f6a9 commit 90d7bdf

File tree

10 files changed

+1844
-1759
lines changed

10 files changed

+1844
-1759
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# TelegramBotAPI changelog
22

3+
## 30.0.2
4+
5+
* `Version`:
6+
* `Kotlin`: `2.2.20` -> `2.2.21`
7+
* `Ktor`: `3.3.1` -> `3.3.2`
8+
* `KSP`: `2.2.20-2.0.4` -> `2.3.2`
9+
* `MicroUtils`: `0.26.6` -> `0.26.8`
10+
* `KSLog`: `1.5.1` -> `1.5.2`
11+
* `Core`:
12+
* Allow to use `SetWebhook` with `maxAllowedConnections` up to `100000` (fix of [#1019](https://github.com/InsanusMokrassar/ktgbotapi/issues/1019))
13+
* `KSP`:
14+
* Fixed annotation property access for KSP2 compatibility using `withNoSuchElementWorkaround`
15+
* Removed `ksp.useKSP2=false` workaround from `gradle.properties` (KSP2 is now properly supported)
16+
* `Utils`:
17+
* Regenerated class casts extensions
18+
* Allow to use custom `GetUpdates` in `longPollingFlow`
19+
320
## 30.0.1
421

522
* `Core`:

gradle.properties

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ kotlin.js.generate.externals=true
55
kotlin.incremental=true
66
kotlin.incremental.js=true
77

8-
# https://github.com/google/ksp/issues/2491
9-
ksp.useKSP2=false
10-
118
library_group=dev.inmo
12-
library_version=30.0.1
9+
library_version=30.0.2

gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[versions]
22

3-
kotlin = "2.2.20"
3+
kotlin = "2.2.21"
44
kotlin-serialization = "1.9.0"
55
kotlin-coroutines = "1.10.2"
66

77
javax-activation = "1.1.1"
88

99
korlibs = "5.4.0"
1010
uuid = "0.8.4"
11-
ktor = "3.3.1"
11+
ktor = "3.3.2"
1212

13-
ksp = "2.2.20-2.0.4"
13+
ksp = "2.3.2"
1414
kotlin-poet = "2.2.0"
1515

16-
microutils = "0.26.6"
17-
kslog = "1.5.1"
16+
microutils = "0.26.8"
17+
kslog = "1.5.2"
1818

1919
versions = "0.53.0"
2020

tgbotapi.core/api/tgbotapi.core.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10654,6 +10654,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt {
1065410654
public static final field yShiftField Ljava/lang/String;
1065510655
public static final field yearField Ljava/lang/String;
1065610656
public static final fun getAllowedConnectionsLength ()Lkotlin/ranges/IntRange;
10657+
public static final fun getAllowedConnectionsWithLocalServerLength ()Lkotlin/ranges/IntRange;
1065710658
public static final fun getBasketballAndFootballDiceResultLimit ()Lkotlin/ranges/IntRange;
1065810659
public static final fun getBotCommandDescriptionLimit ()Lkotlin/ranges/IntRange;
1065910660
public static final fun getBotCommandLengthLimit ()Lkotlin/ranges/IntRange;

tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/webhook/SetWebhook.kt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package dev.inmo.tgbotapi.requests.webhook
22

3+
import dev.inmo.kslog.common.w
34
import dev.inmo.tgbotapi.requests.abstracts.*
45
import dev.inmo.tgbotapi.requests.send.media.base.DataRequest
56
import dev.inmo.tgbotapi.requests.send.media.base.MultipartRequestImpl
67
import dev.inmo.tgbotapi.types.*
8+
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
79
import kotlinx.serialization.*
810
import kotlinx.serialization.builtins.serializer
911

@@ -118,11 +120,22 @@ fun SetWebhook(
118120
)
119121

120122
/**
121-
* Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update
122-
* for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update.
123+
* Represents a request for setting a webhook in Telegram's Bot API. A webhook allows Telegram to send updates directly
124+
* to the bot via an HTTPS POST request to the provided URL, enabling real-time interaction.
123125
*
124-
* If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the [url],
125-
* e.g. https://www.example.com/<token>. Since nobody else knows your bot's token, you can be pretty sure it's us.
126+
* @constructor Creates a data class holding configuration options for the webhook.
127+
*
128+
* @property url The HTTPS URL to which updates will be posted. Must be valid and accessible.
129+
* @property certificateFile An optional path to a public certificate file for webhook verification. Use only if a self-signed certificate is applied.
130+
* @property ipAddress The fixed IP address for incoming webhook connections.
131+
* @property maxAllowedConnections The maximum number of simultaneous HTTPS connections allowed to the webhook for
132+
* delivering updates. You may use value outside of [allowedConnectionsLength], but be sure that it is in
133+
* [allowedConnectionsWithLocalServerLength] and you are using local bot api url
134+
* @property allowedUpdates A list of update types the bot will receive. Defaults to all update types.
135+
* @property dropPendingUpdates If true, all pending updates will be dropped when the webhook is changed.
136+
* @property secretToken An optional arbitrary secret key to ensure the webhook updates are coming from Telegram.
137+
*
138+
* @throws IllegalArgumentException if the provided maxAllowedConnections value is outside the permitted range (both [allowedConnectionsLength] and [allowedConnectionsWithLocalServerLength])
126139
*/
127140
@ConsistentCopyVisibility
128141
@Serializable
@@ -150,8 +163,19 @@ data class SetWebhook internal constructor(
150163

151164
init {
152165
maxAllowedConnections ?.let {
153-
if (it !in allowedConnectionsLength) {
154-
throw IllegalArgumentException("Allowed connection for webhook must be in $allowedConnectionsLength range (but passed $it)")
166+
when {
167+
it !in allowedConnectionsLength && it in allowedConnectionsWithLocalServerLength -> {
168+
DefaultKTgBotAPIKSLog.w {
169+
"""
170+
Passed amount of allowed connections to server is $it and it exceeds default amount of
171+
connections $allowedConnectionsLength, but can be used with local bot api server. Make sure
172+
you are using local bot api url in your bot.
173+
""".trimIndent()
174+
}
175+
}
176+
it !in allowedConnectionsLength -> {
177+
throw IllegalArgumentException("Allowed connection for webhook must be in $allowedConnectionsLength range (but passed $it)")
178+
}
155179
}
156180
}
157181
}

tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ val threadNameLength = 1 until 128
6464
val chatDescriptionLength = 0 until 256
6565
val inlineResultQueryIdLingth = 1 until 64
6666
val allowedConnectionsLength = 1 .. 100
67+
val allowedConnectionsWithLocalServerLength = 1 .. 100000
6768

6869
val invoiceTitleLimit = 1 until 32
6970
val invoiceDescriptionLimit = 1 until 256

tgbotapi.ksp/src/main/kotlin/TelegramBotAPISymbolProcessor.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.squareup.kotlinpoet.FileSpec
88
import com.squareup.kotlinpoet.asClassName
99
import com.squareup.kotlinpoet.ksp.writeTo
1010
import dev.inmo.micro_ksp.generator.resolveSubclasses
11+
import dev.inmo.micro_ksp.generator.withNoSuchElementWorkaround
1112
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
1213
import dev.inmo.tgbotapi.utils.RiskFeature
1314
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
@@ -30,7 +31,9 @@ class TelegramBotAPISymbolProcessor(
3031
val classes = resolver.getSymbolsWithAnnotation(classCastsIncludedClassName.canonicalName).filterIsInstance<KSClassDeclaration>()
3132
val classesRegexes: Map<KSClassDeclaration, Pair<Regex?, Regex?>> = classes.mapNotNull {
3233
it to (it.getAnnotationsByType(ClassCastsIncluded::class).firstNotNullOfOrNull {
33-
it.typesRegex.takeIf { it.isNotEmpty() } ?.let(::Regex) to it.excludeRegex.takeIf { it.isNotEmpty() } ?.let(::Regex)
34+
val typesRegex = withNoSuchElementWorkaround("") { it.typesRegex }
35+
val excludeRegex = withNoSuchElementWorkaround("") { it.excludeRegex }
36+
typesRegex.takeIf { it.isNotEmpty() } ?.let(::Regex) to excludeRegex.takeIf { it.isNotEmpty() } ?.let(::Regex)
3437
} ?: return@mapNotNull null)
3538
}.toMap()
3639
val classesSubtypes = mutableMapOf<KSClassDeclaration, MutableSet<KSClassDeclaration>>()

tgbotapi.utils/api/tgbotapi.utils.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3705,7 +3705,9 @@ public final class dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPol
37053705
public static synthetic fun longPolling$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ILkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;IZZLjava/lang/Long;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/coroutines/Job;
37063706
public static synthetic fun longPolling$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/updateshandlers/UpdatesFilter;ILkotlinx/coroutines/CoroutineScope;ZZLjava/lang/Long;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/Job;
37073707
public static final fun longPollingFlow (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ILkotlin/jvm/functions/Function2;Ljava/util/List;ZZLjava/lang/Long;)Lkotlinx/coroutines/flow/Flow;
3708+
public static final fun longPollingFlow (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/jvm/functions/Function2;ZZLjava/lang/Long;Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/flow/Flow;
37083709
public static synthetic fun longPollingFlow$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ILkotlin/jvm/functions/Function2;Ljava/util/List;ZZLjava/lang/Long;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
3710+
public static synthetic fun longPollingFlow$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/jvm/functions/Function2;ZZLjava/lang/Long;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
37093711
public static final fun retrieveAccumulatedUpdates (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;ZZLkotlinx/coroutines/CoroutineScope;ZLjava/lang/Long;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job;
37103712
public static final fun retrieveAccumulatedUpdates (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ZZLkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;Ljava/util/List;ZLjava/lang/Long;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job;
37113713
public static synthetic fun retrieveAccumulatedUpdates$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter;ZZLkotlinx/coroutines/CoroutineScope;ZLjava/lang/Long;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/Job;

0 commit comments

Comments
 (0)