1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-26 11:38:09 +00:00

fix in createRequest for Poll

This commit is contained in:
InsanusMokrassar 2020-01-23 20:42:54 +06:00
parent f4a731940e
commit b9e674821b

View File

@ -49,6 +49,10 @@ fun SendPoll(
replyMarkup = replyMarkup 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( fun Poll.createRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -66,13 +70,25 @@ fun Poll.createRequest(
replyToMessageId, replyToMessageId,
replyMarkup replyMarkup
) )
is QuizPoll -> SendQuizPoll( is QuizPoll -> correctOptionId ?.let { correctOptionId ->
SendQuizPoll(
chatId,
question,
options.map { it.text },
correctOptionId,
isAnonymous,
isClosed,
disableNotification,
replyToMessageId,
replyMarkup
)
} ?: SendRegularPoll(
chatId, chatId,
question, question,
options.map { it.text }, options.map { it.text },
correctOptionId,
isAnonymous, isAnonymous,
isClosed, isClosed,
false,
disableNotification, disableNotification,
replyToMessageId, replyToMessageId,
replyMarkup replyMarkup