mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
additional KtorUpdatesPoller method
This commit is contained in:
parent
f2701b920f
commit
ab6688bbaa
@ -37,6 +37,11 @@
|
|||||||
|
|
||||||
### 0.23.1
|
### 0.23.1
|
||||||
|
|
||||||
|
* Versions updates:
|
||||||
|
* Klock `1.8.6` -> `1.8.7`
|
||||||
|
* Ktor `1.3.0` -> `1.3.1`
|
||||||
|
* Now it is possible to get updates by polling with custom executor engine
|
||||||
|
|
||||||
## 0.22.0
|
## 0.22.0
|
||||||
|
|
||||||
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
|
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
|
||||||
|
@ -2,8 +2,8 @@ kotlin.code.style=official
|
|||||||
kotlin_version=1.3.61
|
kotlin_version=1.3.61
|
||||||
kotlin_coroutines_version=1.3.3
|
kotlin_coroutines_version=1.3.3
|
||||||
kotlin_serialisation_runtime_version=0.14.0
|
kotlin_serialisation_runtime_version=0.14.0
|
||||||
klock_version=1.8.6
|
klock_version=1.8.7
|
||||||
uuid_version=0.0.7
|
uuid_version=0.0.7
|
||||||
ktor_version=1.3.0
|
ktor_version=1.3.1
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
|
import io.ktor.client.engine.HttpClientEngine
|
||||||
import io.ktor.client.engine.cio.CIO
|
import io.ktor.client.engine.cio.CIO
|
||||||
import io.ktor.client.engine.cio.endpoint
|
import io.ktor.client.engine.cio.endpoint
|
||||||
import io.ktor.util.KtorExperimentalAPI
|
import io.ktor.util.KtorExperimentalAPI
|
||||||
@ -42,3 +43,35 @@ fun KtorUpdatesPoller(
|
|||||||
updatesReceiver
|
updatesReceiver
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@KtorExperimentalAPI
|
||||||
|
fun KtorUpdatesPoller(
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
timeoutSeconds: Int? = null,
|
||||||
|
oneTimeUpdatesLimit: Int? = null,
|
||||||
|
allowedUpdates: List<String> = ALL_UPDATES_LIST,
|
||||||
|
exceptionsHandler: (Exception) -> Boolean = { true },
|
||||||
|
clientEngine: HttpClientEngine = CIO.create {
|
||||||
|
endpoint {
|
||||||
|
timeoutSeconds ?.times(1000) ?.also { timeOutMillis ->
|
||||||
|
keepAliveTime = timeOutMillis.toLong()
|
||||||
|
}
|
||||||
|
connectTimeout = 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updatesReceiver: UpdateReceiver<Update>
|
||||||
|
): KtorUpdatesPoller {
|
||||||
|
val executor = KtorRequestsExecutor(
|
||||||
|
telegramAPIUrlsKeeper,
|
||||||
|
HttpClient(clientEngine)
|
||||||
|
)
|
||||||
|
|
||||||
|
return KtorUpdatesPoller(
|
||||||
|
executor,
|
||||||
|
timeoutSeconds,
|
||||||
|
oneTimeUpdatesLimit,
|
||||||
|
allowedUpdates,
|
||||||
|
exceptionsHandler,
|
||||||
|
updatesReceiver
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user