From a788ea76f17287efe36f3a22e2aefdccd1e01359 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 08:20:13 +0800 Subject: [PATCH 1/9] start work with 0.9.0 --- CHANGELOG | 2 ++ build.gradle | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 58d0d932f2..811a0aea26 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,3 +42,5 @@ * Add extension `String#toMarkdown` * Fix of inserting of text when create Markdown-adapted text from text and text entities * Fix default realisation of MessageEntity#asMarkdownSource + +### 0.9.0 diff --git a/build.gradle b/build.gradle index 679e579617..4b60baaa21 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -project.version = "0.8.5" +project.version = "0.9.0" project.group = "com.github.insanusmokrassar" buildscript { From 82420165d0a24bd16ef38ee3d53fcd6dd2fafc59 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 08:37:39 +0800 Subject: [PATCH 2/9] replace "useWith" and rename file of BaseRequestsExecutor --- CHANGELOG | 3 ++ ...stsExecutor.kt => BaseRequestsExecutor.kt} | 0 .../TelegramBotAPI/bot/Ktor/ProxySettings.kt | 31 +++++++++++++++++ .../TelegramBotAPI/bot/ProxySettings.kt | 33 ++++--------------- 4 files changed, 41 insertions(+), 26 deletions(-) rename src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/{DefaultRequestsExecutor.kt => BaseRequestsExecutor.kt} (100%) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt diff --git a/CHANGELOG b/CHANGELOG index 811a0aea26..96762ecf16 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -44,3 +44,6 @@ * Fix default realisation of MessageEntity#asMarkdownSource ### 0.9.0 + +* Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in +`com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor` package diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/DefaultRequestsExecutor.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/BaseRequestsExecutor.kt similarity index 100% rename from src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/DefaultRequestsExecutor.kt rename to src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/BaseRequestsExecutor.kt diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt new file mode 100644 index 0000000000..9316112d72 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt @@ -0,0 +1,31 @@ +package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor + +import com.github.insanusmokrassar.TelegramBotAPI.bot.ProxySettings +import okhttp3.Credentials +import okhttp3.OkHttpClient +import java.net.InetSocketAddress +import java.net.Proxy + +fun OkHttpClient.Builder.useWith(proxySettings: ProxySettings) { + proxy( + Proxy( + Proxy.Type.SOCKS, + InetSocketAddress( + proxySettings.host, + proxySettings.port + ) + ) + ) + proxySettings.password ?.let { + password -> + proxyAuthenticator { + _, response -> + response.request().newBuilder().apply { + addHeader( + "Proxy-Authorization", + Credentials.basic(proxySettings.username ?: "", password) + ) + }.build() + } + } +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt index 1023292e76..a137983f62 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt @@ -1,9 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot -import okhttp3.Credentials +import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.useWith import okhttp3.OkHttpClient -import java.net.InetSocketAddress -import java.net.Proxy data class ProxySettings( val host: String = "localhost", @@ -12,26 +10,9 @@ data class ProxySettings( val password: String? = null ) -fun OkHttpClient.Builder.useWith(proxySettings: ProxySettings) { - proxy( - Proxy( - Proxy.Type.SOCKS, - InetSocketAddress( - proxySettings.host, - proxySettings.port - ) - ) - ) - proxySettings.password ?.let { - password -> - proxyAuthenticator { - _, response -> - response.request().newBuilder().apply { - addHeader( - "Proxy-Authorization", - Credentials.basic(proxySettings.username ?: "", password) - ) - }.build() - } - } -} + +@Deprecated( + "Replaced in Ktor package", + ReplaceWith("useWith", "com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.useWith") +) +fun OkHttpClient.Builder.useWith(proxySettings: ProxySettings) = useWith(proxySettings) From 58684ee57ee2affa485c62d1f128cf65561aeed9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 09:00:29 +0800 Subject: [PATCH 3/9] replace ProxySettings --- CHANGELOG | 1 + .../TelegramBotAPI/bot/ProxySettings.kt | 9 ++++----- .../TelegramBotAPI/bot/settings/ProxySettings.kt | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/ProxySettings.kt diff --git a/CHANGELOG b/CHANGELOG index 96762ecf16..442914cbae 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -47,3 +47,4 @@ * Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in `com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor` package +* Replace `ProxySettings` data class in `settings` package, deprecate old link diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt index a137983f62..afbe01c957 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt @@ -3,12 +3,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.useWith import okhttp3.OkHttpClient -data class ProxySettings( - val host: String = "localhost", - val port: Int = 1080, - val username: String? = null, - val password: String? = null +@Deprecated( + "Replaced in settings package", + ReplaceWith("ProxySettings", "com.github.insanusmokrassar.TelegramBotAPI.bot.settings.ProxySettings") ) +typealias ProxySettings = com.github.insanusmokrassar.TelegramBotAPI.bot.settings.ProxySettings @Deprecated( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/ProxySettings.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/ProxySettings.kt new file mode 100644 index 0000000000..19dfdec44d --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/ProxySettings.kt @@ -0,0 +1,16 @@ +package com.github.insanusmokrassar.TelegramBotAPI.bot.settings + +import kotlinx.serialization.Optional +import kotlinx.serialization.Serializable + +@Serializable +data class ProxySettings( + @Optional + val host: String = "localhost", + @Optional + val port: Int = 1080, + @Optional + val username: String? = null, + @Optional + val password: String? = null +) From d7a77085b51ff32ac59df5ec3e4e18fd0b4a400a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 10:34:31 +0800 Subject: [PATCH 4/9] remove BaseRequestsExecutor scope --- CHANGELOG | 1 + .../TelegramBotAPI/bot/BaseRequestsExecutor.kt | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 442914cbae..0e9898854b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -48,3 +48,4 @@ * Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in `com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor` package * Replace `ProxySettings` data class in `settings` package, deprecate old link +* `BaseRequestsExecutor` now have no it's own scope diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/BaseRequestsExecutor.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/BaseRequestsExecutor.kt index dd1ac11d42..abaf662aa4 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/BaseRequestsExecutor.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/BaseRequestsExecutor.kt @@ -1,16 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.asCoroutineDispatcher -import java.util.concurrent.Executors - abstract class BaseRequestsExecutor( token: String, hostUrl: String = "https://api.telegram.org" ) : RequestsExecutor { protected val baseUrl: String = "$hostUrl/bot$token" - - protected val scope: CoroutineScope = CoroutineScope( - Executors.newSingleThreadExecutor().asCoroutineDispatcher() - ) } \ No newline at end of file From e77478b13e819b2af2579d4b85a0bb168bb0c56d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 10:35:38 +0800 Subject: [PATCH 5/9] RequestLimiter --- CHANGELOG | 1 + .../bot/settings/limiters/EmptyLimiter.kt | 5 ++ .../bot/settings/limiters/PowLimiter.kt | 73 +++++++++++++++++++ .../bot/settings/limiters/RequestLimiter.kt | 8 ++ 4 files changed, 87 insertions(+) create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/EmptyLimiter.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt create mode 100644 src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/RequestLimiter.kt diff --git a/CHANGELOG b/CHANGELOG index 0e9898854b..c8b8b4c1ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -49,3 +49,4 @@ `com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor` package * Replace `ProxySettings` data class in `settings` package, deprecate old link * `BaseRequestsExecutor` now have no it's own scope +* Add `RequestLimiter` and base realisations diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/EmptyLimiter.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/EmptyLimiter.kt new file mode 100644 index 0000000000..c0a24f1885 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/EmptyLimiter.kt @@ -0,0 +1,5 @@ +package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters + +object EmptyLimiter : RequestLimiter { + override suspend fun limit(block: suspend () -> T): T = block() +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt new file mode 100644 index 0000000000..d20bbc194d --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt @@ -0,0 +1,73 @@ +package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters + +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.Channel +import kotlinx.serialization.Optional +import kotlinx.serialization.Serializable +import java.util.concurrent.Executors +import kotlin.coroutines.* + +private sealed class RequestEvent +private class AddRequest( + val continuation: Continuation +) : RequestEvent() +private object CompleteRequest : RequestEvent() + +@Serializable +data class PowLimiter( + @Optional + private val minAwaitTime: Long = 0L, + @Optional + private val maxAwaitTime: Long = 10000L, + @Optional + private val powValue: Double = 4.0, + @Optional + private val powK: Double = 0.0016 +) : RequestLimiter { + private val scope = CoroutineScope( + Executors.newFixedThreadPool(3).asCoroutineDispatcher() + ) + private val eventsChannel = Channel(Channel.UNLIMITED) + private val awaitTimeRange = minAwaitTime .. maxAwaitTime + + init { + scope.launch { + var requestsInWork: Double = 0.0 + for (event in eventsChannel) { + when (event) { + is AddRequest -> { + val awaitTime = ((Math.pow(requestsInWork, powValue) * powK) * 1000L).toLong() + requestsInWork++ + + event.continuation.resume( + if (awaitTime in awaitTimeRange) { + awaitTime + } else { + if (awaitTime < minAwaitTime) { + minAwaitTime + } else { + maxAwaitTime + } + } + ) + } + is CompleteRequest -> requestsInWork-- + } + } + } + } + + override suspend fun limit( + block: suspend () -> T + ): T { + val delayMillis = suspendCoroutine { + scope.launch { eventsChannel.send(AddRequest(it)) } + } + delay(delayMillis) + return try { + block() + } finally { + eventsChannel.send(CompleteRequest) + } + } +} diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/RequestLimiter.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/RequestLimiter.kt new file mode 100644 index 0000000000..8abc707151 --- /dev/null +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/RequestLimiter.kt @@ -0,0 +1,8 @@ +package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters + +interface RequestLimiter { + /** + * Use limit for working of block (like delay between or after, for example) + */ + suspend fun limit(block: suspend () -> T): T +} From 5692bb321cfbb3911d6d2d2b0159f8bcc9872174 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 10:36:44 +0800 Subject: [PATCH 6/9] Ktor realisation use RequestLimiter --- CHANGELOG | 1 + .../bot/Ktor/KtorRequestsExecutor.kt | 51 ++++++++++--------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c8b8b4c1ab..39438fbf05 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -50,3 +50,4 @@ * Replace `ProxySettings` data class in `settings` package, deprecate old link * `BaseRequestsExecutor` now have no it's own scope * Add `RequestLimiter` and base realisations +* Now `KtorRequestsExecutor` can receive as one of parameters `RequestLimiter` (by default - `EmptyLimiter`) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt index 5b3ec01f38..7660088d98 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/KtorRequestsExecutor.kt @@ -4,6 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.MultipartRequestCallFactory import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.SimpleRequestCallFactory import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException +import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter +import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.types.ResponseParameters import io.ktor.client.HttpClient @@ -19,7 +21,8 @@ class KtorRequestsExecutor( private val client: HttpClient = HttpClient(OkHttp), hostUrl: String = "https://api.telegram.org", callsFactories: List = emptyList(), - excludeDefaultFactories: Boolean = false + excludeDefaultFactories: Boolean = false, + private val requestsLimiter: RequestLimiter = EmptyLimiter ) : BaseRequestsExecutor(token, hostUrl) { constructor( token: String, @@ -40,30 +43,32 @@ class KtorRequestsExecutor( } override suspend fun execute(request: Request): T { - var call: HttpClientCall? = null - for (factory in callsFactories) { - call = factory.prepareCall( - client, - baseUrl, - request - ) - if (call != null) { - break + return requestsLimiter.limit { + var call: HttpClientCall? = null + for (factory in callsFactories) { + call = factory.prepareCall( + client, + baseUrl, + request + ) + if (call != null) { + break + } } - } - if (call == null) { - throw IllegalArgumentException("Can't execute request: $request") - } - val content = call.response.content.toByteArray().toString(Charset.defaultCharset()) - val responseObject = JSON.parse( - ResponseParameters.serializer(request.resultSerializer()), - content - ) - return responseObject.result ?: call.let { - throw RequestException( - responseObject, - "Can't get result object" + if (call == null) { + throw IllegalArgumentException("Can't execute request: $request") + } + val content = call.response.content.toByteArray().toString(Charset.defaultCharset()) + val responseObject = JSON.parse( + ResponseParameters.serializer(request.resultSerializer()), + content ) + responseObject.result ?: call.let { + throw RequestException( + responseObject, + "Can't get result object" + ) + } } } } From c2cb57635c4ead763635473c825f7559c1f5bd48 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 11:49:27 +0800 Subject: [PATCH 7/9] refactoring and fixes --- gradle.properties | 2 +- .../TelegramBotAPI/bot/Ktor/ProxySettings.kt | 5 +++-- .../insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt | 1 + .../TelegramBotAPI/bot/settings/limiters/PowLimiter.kt | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index dc6da056e3..209f0390f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,6 @@ kotlin_version=1.3.11 kotlin_coroutines_version=1.1.0 kotlin_serialisation_runtime_version=0.9.1 joda_time_version=2.10.1 -ktor_version=1.0.1 +ktor_version=1.1.1 gradle_bintray_plugin_version=1.8.4 diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt index 9316112d72..745c4ecdf8 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/Ktor/ProxySettings.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor -import com.github.insanusmokrassar.TelegramBotAPI.bot.ProxySettings +import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.ProxySettings +import io.ktor.http.HttpHeaders import okhttp3.Credentials import okhttp3.OkHttpClient import java.net.InetSocketAddress @@ -22,7 +23,7 @@ fun OkHttpClient.Builder.useWith(proxySettings: ProxySettings) { _, response -> response.request().newBuilder().apply { addHeader( - "Proxy-Authorization", + HttpHeaders.ProxyAuthorization, Credentials.basic(proxySettings.username ?: "", password) ) }.build() diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt index afbe01c957..12e3ab9e71 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/ProxySettings.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.useWith +import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.ProxySettings import okhttp3.OkHttpClient @Deprecated( diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt index d20bbc194d..d18c600e9c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt @@ -4,6 +4,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import kotlinx.serialization.Optional import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient import java.util.concurrent.Executors import kotlin.coroutines.* @@ -24,10 +25,13 @@ data class PowLimiter( @Optional private val powK: Double = 0.0016 ) : RequestLimiter { + @Transient private val scope = CoroutineScope( Executors.newFixedThreadPool(3).asCoroutineDispatcher() ) + @Transient private val eventsChannel = Channel(Channel.UNLIMITED) + @Transient private val awaitTimeRange = minAwaitTime .. maxAwaitTime init { From 8318f708fddc5c2d5f09568a5f71b95a6bbeed0b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 24 Jan 2019 11:50:25 +0800 Subject: [PATCH 8/9] optimise imports --- .../TelegramBotAPI/bot/settings/limiters/PowLimiter.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt index d18c600e9c..da2acc46bf 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/settings/limiters/PowLimiter.kt @@ -2,9 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel -import kotlinx.serialization.Optional -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient +import kotlinx.serialization.* import java.util.concurrent.Executors import kotlin.coroutines.* From fcb760eb984bd0bf6535539582d0c5c0ef386daa Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 25 Jan 2019 09:59:52 +0800 Subject: [PATCH 9/9] fix in GetMe --- .../github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt index d32001e0dd..ae0b4eb48d 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt +++ b/src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt @@ -3,7 +3,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.User import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +@Serializable class GetMe : SimpleRequest { override fun method(): String = "getMe" override fun resultSerializer(): KSerializer = User.serializer()