1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-10-22 15:50:08 +00:00

TelegramAPIUrlsKeeper

This commit is contained in:
2019-07-25 16:25:18 +08:00
parent d8887bb7ff
commit 84ad751792
6 changed files with 69 additions and 12 deletions

View File

@@ -18,7 +18,7 @@ import io.ktor.client.engine.cio.CIO
import kotlinx.coroutines.*
fun KtorUpdatesPoller(
token: String,
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
timeoutSeconds: Int? = null,
oneTimeUpdatesLimit: Int? = null,
allowedUpdates: List<String> = ALL_UPDATES_LIST,
@@ -26,7 +26,7 @@ fun KtorUpdatesPoller(
updatesReceiver: UpdateReceiver<Update>
): KtorUpdatesPoller {
val executor = KtorRequestsExecutor(
token,
telegramAPIUrlsKeeper,
HttpClient(
CIO.create {
timeoutSeconds ?.let { _ ->
@@ -50,6 +50,25 @@ fun KtorUpdatesPoller(
)
}
@Deprecated("Deprecated due to new TelegramAPIUrlsKeeper")
fun KtorUpdatesPoller(
token: String,
timeoutSeconds: Int? = null,
oneTimeUpdatesLimit: Int? = null,
allowedUpdates: List<String> = ALL_UPDATES_LIST,
exceptionsHandler: (Exception) -> Boolean = { true },
updatesReceiver: UpdateReceiver<Update>
): KtorUpdatesPoller {
return KtorUpdatesPoller(
TelegramAPIUrlsKeeper(token),
timeoutSeconds,
oneTimeUpdatesLimit,
allowedUpdates,
exceptionsHandler,
updatesReceiver
)
}
class KtorUpdatesPoller(
private val executor: RequestsExecutor,
private val timeoutSeconds: Int? = null,