mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-04 23:59:55 +00:00
fixes in PollContent#createResend, added Poll#createRequest
This commit is contained in:
@@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.PollContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
@@ -48,6 +49,47 @@ fun SendPoll(
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
fun Poll.createRequest(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = when (this) {
|
||||
is RegularPoll -> SendRegularPoll(
|
||||
chatId,
|
||||
question,
|
||||
options.map { it.text },
|
||||
isAnonymous,
|
||||
isClosed,
|
||||
allowMultipleAnswers,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
is QuizPoll -> SendQuizPoll(
|
||||
chatId,
|
||||
question,
|
||||
options.map { it.text },
|
||||
correctOptionId,
|
||||
isAnonymous,
|
||||
isClosed,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
is UnknownPollType -> SendRegularPoll(
|
||||
chatId,
|
||||
question,
|
||||
options.map { it.text },
|
||||
isAnonymous,
|
||||
isClosed,
|
||||
false,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
}
|
||||
|
||||
sealed class SendPoll : SendMessageRequest<ContentMessage<PollContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<PollContent>> {
|
||||
abstract val question: String
|
||||
|
Reference in New Issue
Block a user