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

refactoring and fixes

This commit is contained in:
InsanusMokrassar 2019-01-24 11:49:27 +08:00
parent 5692bb321c
commit c2cb57635c
4 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,6 @@ kotlin_version=1.3.11
kotlin_coroutines_version=1.1.0 kotlin_coroutines_version=1.1.0
kotlin_serialisation_runtime_version=0.9.1 kotlin_serialisation_runtime_version=0.9.1
joda_time_version=2.10.1 joda_time_version=2.10.1
ktor_version=1.0.1 ktor_version=1.1.1
gradle_bintray_plugin_version=1.8.4 gradle_bintray_plugin_version=1.8.4

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor 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.Credentials
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import java.net.InetSocketAddress import java.net.InetSocketAddress
@ -22,7 +23,7 @@ fun OkHttpClient.Builder.useWith(proxySettings: ProxySettings) {
_, response -> _, response ->
response.request().newBuilder().apply { response.request().newBuilder().apply {
addHeader( addHeader(
"Proxy-Authorization", HttpHeaders.ProxyAuthorization,
Credentials.basic(proxySettings.username ?: "", password) Credentials.basic(proxySettings.username ?: "", password)
) )
}.build() }.build()

View File

@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.bot package com.github.insanusmokrassar.TelegramBotAPI.bot
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.useWith import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.useWith
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.ProxySettings
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
@Deprecated( @Deprecated(

View File

@ -4,6 +4,7 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.serialization.Optional import kotlinx.serialization.Optional
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.coroutines.* import kotlin.coroutines.*
@ -24,10 +25,13 @@ data class PowLimiter(
@Optional @Optional
private val powK: Double = 0.0016 private val powK: Double = 0.0016
) : RequestLimiter { ) : RequestLimiter {
@Transient
private val scope = CoroutineScope( private val scope = CoroutineScope(
Executors.newFixedThreadPool(3).asCoroutineDispatcher() Executors.newFixedThreadPool(3).asCoroutineDispatcher()
) )
@Transient
private val eventsChannel = Channel<RequestEvent>(Channel.UNLIMITED) private val eventsChannel = Channel<RequestEvent>(Channel.UNLIMITED)
@Transient
private val awaitTimeRange = minAwaitTime .. maxAwaitTime private val awaitTimeRange = minAwaitTime .. maxAwaitTime
init { init {