mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-10-25 17:20:07 +00:00
@@ -1,5 +1,10 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 28.0.3
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Add passing of default engines in `HttpClient` constructors
|
||||||
|
|
||||||
## 28.0.2
|
## 28.0.2
|
||||||
|
|
||||||
* `Core`:
|
* `Core`:
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != n
|
|||||||
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||||
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
validationTimeout = Duration.ofSeconds(0)
|
validationTimeout = Duration.ofSeconds(0)
|
||||||
publishingType = "USER_MANAGED"
|
publishingType = System.getenv('PUBLISHING_TYPE') != "" ? System.getenv('PUBLISHING_TYPE') : "USER_MANAGED"
|
||||||
}
|
}
|
||||||
|
|
||||||
publishAllProjectsProbablyBreakingProjectIsolation()
|
publishAllProjectsProbablyBreakingProjectIsolation()
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ kotlin.incremental.js=true
|
|||||||
ksp.useKSP2=false
|
ksp.useKSP2=false
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=28.0.2
|
library_version=28.0.3
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref =
|
|||||||
|
|
||||||
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
||||||
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
|
||||||
|
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
|
||||||
|
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
|
||||||
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
|
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
|
||||||
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
|
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
|
||||||
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
|
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api
|
|||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import dev.inmo.tgbotapi.utils.defaultKtorEngine
|
||||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.HttpClientConfig
|
import io.ktor.client.HttpClientConfig
|
||||||
@@ -13,7 +14,7 @@ import io.ktor.client.engine.*
|
|||||||
*/
|
*/
|
||||||
public fun telegramBot(
|
public fun telegramBot(
|
||||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient()
|
client: HttpClient = HttpClient(defaultKtorEngine)
|
||||||
): TelegramBot = telegramBot(urlsKeeper) {
|
): TelegramBot = telegramBot(urlsKeeper) {
|
||||||
this.client = client
|
this.client = client
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,7 @@ public fun telegramBot(
|
|||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
testServer: Boolean = false,
|
testServer: Boolean = false,
|
||||||
fileLinkUrlMapper: TelegramAPIUrlsKeeper.(String) -> String = { "${fileBaseUrl}/$it" },
|
fileLinkUrlMapper: TelegramAPIUrlsKeeper.(String) -> String = { "${fileBaseUrl}/$it" },
|
||||||
client: HttpClient = HttpClient()
|
client: HttpClient = HttpClient(defaultKtorEngine)
|
||||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl, fileLinkUrlMapper), client)
|
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl, fileLinkUrlMapper), client)
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
|||||||
@@ -30506,6 +30506,10 @@ public final class dev/inmo/tgbotapi/utils/DefaultKSLogKt {
|
|||||||
public static final fun setDefaultKTgBotAPIKSLogSystemTag (Ljava/lang/String;)V
|
public static final fun setDefaultKTgBotAPIKSLogSystemTag (Ljava/lang/String;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class dev/inmo/tgbotapi/utils/DefaultKtorEngine_jvmKt {
|
||||||
|
public static final fun getDefaultKtorEngine ()Lio/ktor/client/engine/HttpClientEngineFactory;
|
||||||
|
}
|
||||||
|
|
||||||
public final class dev/inmo/tgbotapi/utils/DeserializeWithUnknownKt {
|
public final class dev/inmo/tgbotapi/utils/DeserializeWithUnknownKt {
|
||||||
public static final fun deserializeEitherWithRaw (Lkotlinx/serialization/encoding/Decoder;Lkotlinx/serialization/KSerializer;)Ldev/inmo/micro_utils/common/Either;
|
public static final fun deserializeEitherWithRaw (Lkotlinx/serialization/encoding/Decoder;Lkotlinx/serialization/KSerializer;)Ldev/inmo/micro_utils/common/Either;
|
||||||
public static final fun deserializeWithRaw (Lkotlinx/serialization/encoding/Decoder;Lkotlinx/serialization/KSerializer;)Lkotlin/Pair;
|
public static final fun deserializeWithRaw (Lkotlinx/serialization/encoding/Decoder;Lkotlinx/serialization/KSerializer;)Lkotlin/Pair;
|
||||||
|
|||||||
@@ -47,12 +47,19 @@ kotlin {
|
|||||||
api libs.ktor.server.host.common
|
api libs.ktor.server.host.common
|
||||||
|
|
||||||
api libs.ktor.client.cio
|
api libs.ktor.client.cio
|
||||||
|
api libs.ktor.client.java
|
||||||
|
|
||||||
api libs.javax.activation
|
api libs.javax.activation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linuxX64Main {
|
jsMain {
|
||||||
|
dependencies {
|
||||||
|
api libs.ktor.client.js
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
linuxMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api libs.ktor.client.curl
|
api libs.ktor.client.curl
|
||||||
}
|
}
|
||||||
@@ -64,7 +71,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mingwX64Main {
|
mingwMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api libs.ktor.client.winhttp
|
api libs.ktor.client.winhttp
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import dev.inmo.tgbotapi.utils.defaultKtorEngine
|
||||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
@@ -37,7 +38,7 @@ expect class KtorRequestsExecutor internal constructor(
|
|||||||
|
|
||||||
fun KtorRequestsExecutor(
|
fun KtorRequestsExecutor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient(),
|
client: HttpClient = HttpClient(defaultKtorEngine),
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean = false,
|
||||||
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ fun createTelegramBotDefaultKtorCallRequestsFactories(logger: KSLog? = null) = l
|
|||||||
class KtorRequestsExecutorBuilder(
|
class KtorRequestsExecutorBuilder(
|
||||||
var telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
var telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
||||||
) {
|
) {
|
||||||
var client: HttpClient = HttpClient()
|
var client: HttpClient = HttpClient(defaultKtorEngine)
|
||||||
var callsFactories: List<KtorCallFactory> = emptyList()
|
var callsFactories: List<KtorCallFactory> = emptyList()
|
||||||
var excludeDefaultFactories: Boolean = false
|
var excludeDefaultFactories: Boolean = false
|
||||||
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter
|
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package dev.inmo.tgbotapi.utils
|
||||||
|
|
||||||
|
import io.ktor.client.engine.HttpClientEngineFactory
|
||||||
|
|
||||||
|
expect val defaultKtorEngine: HttpClientEngineFactory<*>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package dev.inmo.tgbotapi.utils
|
||||||
|
|
||||||
|
import io.ktor.client.engine.HttpClientEngineFactory
|
||||||
|
import io.ktor.client.engine.js.Js
|
||||||
|
|
||||||
|
actual val defaultKtorEngine: HttpClientEngineFactory<*> by lazy {
|
||||||
|
Js
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package dev.inmo.tgbotapi.utils
|
||||||
|
|
||||||
|
import io.ktor.client.engine.HttpClientEngineFactory
|
||||||
|
import io.ktor.client.engine.java.Java
|
||||||
|
|
||||||
|
actual val defaultKtorEngine: HttpClientEngineFactory<*> by lazy {
|
||||||
|
Java
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.utils.defaultKtorEngine
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.engine.cio.*
|
import io.ktor.client.engine.cio.*
|
||||||
|
|
||||||
@@ -21,4 +22,8 @@ internal actual inline fun platformClientCopy(client: HttpClient): HttpClient =
|
|||||||
HttpClient(CIO) {
|
HttpClient(CIO) {
|
||||||
this.plusAssign(config)
|
this.plusAssign(config)
|
||||||
}
|
}
|
||||||
} ?: throw IllegalArgumentException("On LinuxX64 TelegramBotAPI currently support only Curl Ktor HttpClient engine")
|
} ?: HttpClient(
|
||||||
|
defaultKtorEngine
|
||||||
|
) {
|
||||||
|
install(client)
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package dev.inmo.tgbotapi.utils
|
||||||
|
|
||||||
|
import io.ktor.client.engine.HttpClientEngineFactory
|
||||||
|
import io.ktor.client.engine.curl.Curl
|
||||||
|
|
||||||
|
actual val defaultKtorEngine: HttpClientEngineFactory<*> by lazy {
|
||||||
|
Curl
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.bot.ktor.base
|
package dev.inmo.tgbotapi.bot.ktor.base
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.utils.defaultKtorEngine
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.engine.curl.*
|
import io.ktor.client.engine.curl.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,4 +23,8 @@ internal actual inline fun platformClientCopy(client: HttpClient): HttpClient =
|
|||||||
HttpClient(Curl) {
|
HttpClient(Curl) {
|
||||||
this.plusAssign(config)
|
this.plusAssign(config)
|
||||||
}
|
}
|
||||||
} ?: throw IllegalArgumentException("On LinuxX64 TelegramBotAPI currently support only Curl Ktor HttpClient engine")
|
} ?: HttpClient(
|
||||||
|
defaultKtorEngine
|
||||||
|
) {
|
||||||
|
install(client)
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package dev.inmo.tgbotapi.utils
|
||||||
|
|
||||||
|
import io.ktor.client.engine.HttpClientEngineFactory
|
||||||
|
import io.ktor.client.engine.winhttp.WinHttp
|
||||||
|
|
||||||
|
actual val defaultKtorEngine: HttpClientEngineFactory<*> by lazy {
|
||||||
|
WinHttp
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.extensions
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import dev.inmo.tgbotapi.utils.defaultKtorEngine
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.statement.readBytes
|
import io.ktor.client.statement.readBytes
|
||||||
@@ -19,5 +20,5 @@ suspend fun HttpClient.loadFile(
|
|||||||
|
|
||||||
suspend fun PathedFile.download(
|
suspend fun PathedFile.download(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient()
|
client: HttpClient = HttpClient(defaultKtorEngine)
|
||||||
) = client.loadFile(telegramAPIUrlsKeeper, this)
|
) = client.loadFile(telegramAPIUrlsKeeper, this)
|
||||||
|
|||||||
Reference in New Issue
Block a user