mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
BotBuilder fixes
This commit is contained in:
parent
7ede53fdbb
commit
22e8b06fda
@ -68,6 +68,8 @@
|
||||
* `TelegramBotAPI-extensions-api`:
|
||||
* A lot of `RequesstExecutor#getChat` extensions was added for more explicit types showing
|
||||
* New `RequesstExecutor#setMyCommands` extension was added
|
||||
* New field `BotBuilder#ktorClientEngineFactory` introduced
|
||||
* Field `BotBuilder#ktorClientEngine` now is deprecated
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* `safely` function was introduced. It is in `PreviewFeature` state currently
|
||||
* `makeLinkToMessage` extensions has been added
|
||||
|
@ -4,8 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.HttpClientConfig
|
||||
import io.ktor.client.engine.HttpClientEngine
|
||||
import io.ktor.client.engine.ProxyConfig
|
||||
import io.ktor.client.engine.*
|
||||
|
||||
/**
|
||||
* @param proxy Standard ktor [ProxyConfig]
|
||||
@ -14,20 +13,30 @@ import io.ktor.client.engine.ProxyConfig
|
||||
*/
|
||||
data class BotBuilder internal constructor(
|
||||
var proxy: ProxyConfig? = null,
|
||||
@Deprecated("ktorClientEngineFactory parameter will be used preferable. In future this parameter will be removed")
|
||||
var ktorClientEngine: HttpClientEngine? = null,
|
||||
var ktorClientEngineFactory: HttpClientEngineFactory<out HttpClientEngineConfig>? = null,
|
||||
var ktorClientConfig: (HttpClientConfig<*>.() -> Unit) ? = null
|
||||
) {
|
||||
internal fun createHttpClient(): HttpClient = ktorClientEngine ?.let { engine ->
|
||||
internal fun createHttpClient(): HttpClient = ktorClientEngineFactory ?.let {
|
||||
HttpClient(
|
||||
it.create {
|
||||
this@create.proxy = this@BotBuilder.proxy ?: this@create.proxy
|
||||
}
|
||||
) {
|
||||
ktorClientConfig ?.let { it() }
|
||||
}
|
||||
} ?: ktorClientEngine ?.let { engine ->
|
||||
HttpClient(engine) {
|
||||
ktorClientConfig ?.let { it() }
|
||||
engine {
|
||||
proxy = this@BotBuilder.proxy ?: proxy
|
||||
this@engine.proxy = this@BotBuilder.proxy ?: this@engine.proxy
|
||||
}
|
||||
}
|
||||
} ?: HttpClient {
|
||||
ktorClientConfig ?.let { it() }
|
||||
engine {
|
||||
proxy = this@BotBuilder.proxy ?: proxy
|
||||
this@engine.proxy = this@BotBuilder.proxy ?: this@engine.proxy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user