From b9e674821bc4fd4e60ba5a8b0dfdb31f69c8891e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 23 Jan 2020 20:42:54 +0600 Subject: [PATCH] fix in createRequest for Poll --- .../requests/send/polls/SendPoll.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt index b4b390f6e2..831d874ec7 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt @@ -49,6 +49,10 @@ fun SendPoll( replyMarkup = replyMarkup ) +/** + * @return [SendPoll] in case when all is right. It can return [SendRegularPoll] for [QuizPoll] in case if + * [QuizPoll.correctOptionId] equal to null + */ fun Poll.createRequest( chatId: ChatIdentifier, disableNotification: Boolean = false, @@ -66,13 +70,25 @@ fun Poll.createRequest( replyToMessageId, replyMarkup ) - is QuizPoll -> SendQuizPoll( + is QuizPoll -> correctOptionId ?.let { correctOptionId -> + SendQuizPoll( + chatId, + question, + options.map { it.text }, + correctOptionId, + isAnonymous, + isClosed, + disableNotification, + replyToMessageId, + replyMarkup + ) + } ?: SendRegularPoll( chatId, question, options.map { it.text }, - correctOptionId, isAnonymous, isClosed, + false, disableNotification, replyToMessageId, replyMarkup