Skip to content

Commit

Permalink
3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vendelieu committed Nov 1, 2023
1 parent 1595214 commit e78f82d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Telegram-bot changelog

### 3.3.1
* Added ability to use proxy. See `httpClient{}` section in bot configuration.

## 3.3.0

* Fixed bug with missing media within input handling process.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build.gradle.kts example:

```gradle
dependencies {
implementation("eu.vendeli:telegram-bot:3.3.0")
implementation("eu.vendeli:telegram-bot:3.3.1")
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ logback = "1.4.11"
jackson = "2.15.3"
reflections = "0.10"

kotlin = "1.9.10"
kotlin = "1.9.20"
coroutines = "1.7.3"
dokka = "1.8.20"
kotlinter = "3.13.0"
Expand Down
2 changes: 1 addition & 1 deletion telegram-bot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
}

group = "eu.vendeli"
version = "3.3.0"
version = "3.3.1"

apply(from = "publishing.gradle.kts")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eu.vendeli.tgbot.types.internal.configuration

import java.net.Proxy

/**
* A class containing the configuration for the bot http client.
*
Expand All @@ -13,11 +15,13 @@ package eu.vendeli.tgbot.types.internal.configuration
* @property maxRequestRetry Specifies a http request maximum retry if had some exceptions
* @property retryDelay Multiplier for timeout at each retry, in milliseconds
* i.e. for the base value [maxRequestRetry] the attempts will be in 3, 6, 9 seconds
* @property proxy Specifies proxy that will be used for http calls.
*/
data class HttpConfiguration(
var requestTimeoutMillis: Long? = null,
var connectTimeoutMillis: Long? = null,
var socketTimeoutMillis: Long? = null,
var maxRequestRetry: Int = 3,
var retryDelay: Long = 3000L,
var proxy: Proxy? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import com.fasterxml.jackson.module.kotlin.KotlinModule
import eu.vendeli.tgbot.TelegramBot
import eu.vendeli.tgbot.TelegramBot.Companion.logger
import io.ktor.client.HttpClient
import io.ktor.client.engine.cio.CIO
import io.ktor.client.plugins.HttpRequestRetry
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.logging.Logging
import io.ktor.client.request.HttpSendPipeline
import io.ktor.http.isSuccess

internal fun TelegramBot.getConfiguredHttpClient() = HttpClient(CIO) {
internal fun TelegramBot.getConfiguredHttpClient() = HttpClient {
install("RequestLogging") {
sendPipeline.intercept(HttpSendPipeline.Monitoring) {
logger.trace { "TgApiRequest: ${context.method} ${context.url.buildString()}" }
Expand All @@ -44,6 +43,10 @@ internal fun TelegramBot.getConfiguredHttpClient() = HttpClient(CIO) {
retry * config.httpClient.retryDelay
}
}

engine {
proxy = config.httpClient.proxy
}
}

internal fun TelegramBot.Companion.getConfiguredMapper() = ObjectMapper().apply {
Expand Down

0 comments on commit e78f82d

Please sign in to comment.