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

add PollUpdate

This commit is contained in:
InsanusMokrassar 2019-04-16 15:56:04 +08:00
parent b7d214d145
commit 457cadf265
3 changed files with 15 additions and 1 deletions

View File

@ -4,6 +4,7 @@
* Type `PollOption` and `AnonymousPollOption` added * Type `PollOption` and `AnonymousPollOption` added
* Type `Poll` added * Type `Poll` added
* Type `PollUpdate` added and implemented in `RawUpdate`. Now `PollUpdate` can be retrieved from `RawUpdate`
## 0.12.0 Webhooks ## 0.12.0 Webhooks

View File

@ -0,0 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.update
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
data class PollUpdate(
override val updateId: UpdateIdentifier,
override val data: Poll
) : Update

View File

@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField
import kotlinx.serialization.* import kotlinx.serialization.*
@ -25,7 +26,8 @@ data class RawUpdate constructor(
private val chosen_inline_result: RawChosenInlineResult? = null, private val chosen_inline_result: RawChosenInlineResult? = null,
private val callback_query: RawCallbackQuery? = null, private val callback_query: RawCallbackQuery? = null,
private val shipping_query: ShippingQuery? = null, private val shipping_query: ShippingQuery? = null,
private val pre_checkout_query: PreCheckoutQuery? = null private val pre_checkout_query: PreCheckoutQuery? = null,
private val poll: Poll? = null
) { ) {
@Transient @Transient
val asUpdate: Update by lazy { val asUpdate: Update by lazy {
@ -40,6 +42,7 @@ data class RawUpdate constructor(
callback_query != null -> CallbackQueryUpdate(updateId, callback_query.asCallbackQuery) callback_query != null -> CallbackQueryUpdate(updateId, callback_query.asCallbackQuery)
shipping_query != null -> ShippingQueryUpdate(updateId, shipping_query) shipping_query != null -> ShippingQueryUpdate(updateId, shipping_query)
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query) pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
poll != null -> PollUpdate(updateId, poll)
else -> throw IllegalArgumentException("Unsupported type of update") else -> throw IllegalArgumentException("Unsupported type of update")
} }
} }