1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-03 07:09:23 +00:00

getting updates refactoring

This commit is contained in:
2020-03-17 20:24:31 +06:00
parent be64287c42
commit d61aa8b50e
9 changed files with 67 additions and 29 deletions

View File

@@ -4,6 +4,7 @@ import io.ktor.utils.io.core.Closeable
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
interface UpdatesPoller : Closeable {
fun start(scope: CoroutineScope = CoroutineScope(Dispatchers.Default))
}

View File

@@ -1,9 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
import kotlinx.serialization.*
@@ -17,7 +15,7 @@ private val updatesListSerializer = ArrayListSerializer(
data class GetUpdates(
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
val limit: Int? = null,
val timeout: Int? = null,
val timeout: Seconds? = null,
val allowed_updates: List<String>? = ALL_UPDATES_LIST
): SimpleRequest<List<Update>> {
override fun method(): String = "getUpdates"

View File

@@ -20,6 +20,8 @@ typealias PollIdentifier = String
typealias StickerSetName = String
typealias FileUniqueId = String
typealias Seconds = Int
val callbackQueryAnswerLength = 0 until 200
val captionLength = 0 until 1024
val textLength = 0 until 4096

View File

@@ -17,6 +17,7 @@ import io.ktor.client.engine.HttpClientEngine
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
fun KtorUpdatesPoller(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
engine: HttpClientEngine,
@@ -41,6 +42,7 @@ fun KtorUpdatesPoller(
)
}
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
class KtorUpdatesPoller(
private val executor: RequestsExecutor,
private val timeoutSeconds: Int? = null,

View File

@@ -10,6 +10,7 @@ import io.ktor.client.engine.cio.CIO
import io.ktor.client.engine.cio.endpoint
import io.ktor.util.KtorExperimentalAPI
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
@KtorExperimentalAPI
fun KtorUpdatesPoller(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
@@ -43,6 +44,7 @@ fun KtorUpdatesPoller(
)
}
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
@KtorExperimentalAPI
fun KtorUpdatesPoller(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,