1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

base ktor request call factories became classes to avoid sharing of their cache between bots

This commit is contained in:
InsanusMokrassar 2021-08-08 16:14:43 +06:00
parent 96d980cb8a
commit 75f4226772
4 changed files with 7 additions and 5 deletions

View File

@ -8,6 +8,8 @@
* `Ktor`: `1.6.1` -> `1.6.2` * `Ktor`: `1.6.1` -> `1.6.2`
* `MicroUtils`: `0.5.16` -> `0.5.18` * `MicroUtils`: `0.5.16` -> `0.5.18`
* `Core`: * `Core`:
* **`SimpleRequestCallFactory` and `MultipartRequestCallFactory` became a classes instead of objects to avoid
collisions in different bots**
* Support of strongly-typed ietf language codes has been added * Support of strongly-typed ietf language codes has been added
* `API`: * `API`:
* New extension `TelegramBot#downloadFile` for any `MediaContent` * New extension `TelegramBot#downloadFile` for any `MediaContent`

View File

@ -52,7 +52,7 @@ class KtorRequestsExecutor(
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) { ) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
private val callsFactories: List<KtorCallFactory> = callsFactories.run { private val callsFactories: List<KtorCallFactory> = callsFactories.run {
if (!excludeDefaultFactories) { if (!excludeDefaultFactories) {
this + listOf(SimpleRequestCallFactory, MultipartRequestCallFactory, DownloadFileRequestCallFactory) this + listOf(SimpleRequestCallFactory(), MultipartRequestCallFactory(), DownloadFileRequestCallFactory)
} else { } else {
this this
} }

View File

@ -9,7 +9,7 @@ import io.ktor.client.request.forms.formData
import io.ktor.http.Headers import io.ktor.http.Headers
import io.ktor.http.HttpHeaders import io.ktor.http.HttpHeaders
object MultipartRequestCallFactory : AbstractRequestCallFactory() { class MultipartRequestCallFactory : AbstractRequestCallFactory() {
override fun <T : Any> prepareCallBody( override fun <T : Any> prepareCallBody(
client: HttpClient, client: HttpClient,
urlsKeeper: TelegramAPIUrlsKeeper, urlsKeeper: TelegramAPIUrlsKeeper,

View File

@ -6,7 +6,7 @@ import io.ktor.client.HttpClient
import io.ktor.http.ContentType import io.ktor.http.ContentType
import io.ktor.http.content.TextContent import io.ktor.http.content.TextContent
object SimpleRequestCallFactory : AbstractRequestCallFactory() { class SimpleRequestCallFactory : AbstractRequestCallFactory() {
override fun <T : Any> prepareCallBody( override fun <T : Any> prepareCallBody(
client: HttpClient, client: HttpClient,
urlsKeeper: TelegramAPIUrlsKeeper, urlsKeeper: TelegramAPIUrlsKeeper,