1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-02 07:55:25 +00:00
tgbotapi/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/GetUpdates.kt

41 lines
1.7 KiB
Kotlin
Raw Normal View History

2020-10-04 11:06:30 +00:00
package dev.inmo.tgbotapi.requests
2018-12-26 08:07:24 +00:00
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.types.update.abstracts.UpdateSerializerWithoutSerialization
2019-12-02 08:35:37 +00:00
import kotlinx.serialization.*
2020-03-22 07:37:01 +00:00
import kotlinx.serialization.builtins.ListSerializer
2018-12-26 08:07:24 +00:00
2020-03-22 07:37:01 +00:00
private val updatesListSerializer = ListSerializer(
UpdateSerializerWithoutSerialization
2019-12-02 08:35:37 +00:00
)
2020-05-14 07:26:56 +00:00
/**
* Request updates from Telegram Bot API system. It is important, that the result updates WILL NOT include
2020-10-04 11:06:30 +00:00
* [dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate] objects due to the fact,
* that it is internal abstraction and in fact any [dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage]
2024-01-07 09:52:49 +00:00
* is just a common [dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage]
2020-05-14 07:26:56 +00:00
*
2020-10-04 11:06:30 +00:00
* @see dev.inmo.tgbotapi.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation
* @see dev.inmo.tgbotapi.utils.convertWithMediaGroupUpdates
2020-05-14 07:26:56 +00:00
*/
2018-12-26 08:07:24 +00:00
@Serializable
data class GetUpdates(
override val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
override val limit: Int = getUpdatesLimit.last,
override val timeout: Seconds? = null,
override val allowed_updates: List<String>? = ALL_UPDATES_LIST
): GetUpdatesRequest<List<Update>> {
2019-12-02 08:35:37 +00:00
override val resultDeserializer: DeserializationStrategy<List<Update>>
get() = updatesListSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
2020-03-31 05:28:48 +00:00
init {
if (limit !in getUpdatesLimit) {
error("GetUpdates request can be called only with limit in range $getUpdatesLimit (actual value is $limit)")
}
}
2018-12-26 08:07:24 +00:00
}