1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-18 15:55:26 +00:00
tgbotapi/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt

230 lines
9.4 KiB
Kotlin
Raw Normal View History

package dev.inmo.tgbotapi.extensions.api.send.polls
2020-02-15 09:33:04 +00:00
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.bot.TelegramBot
2021-06-24 06:49:47 +00:00
import dev.inmo.tgbotapi.extensions.api.send.reply
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll
import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
import dev.inmo.tgbotapi.types.ChatIdentifier
2021-05-29 09:34:14 +00:00
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.polls.*
2020-02-15 09:33:04 +00:00
suspend fun TelegramBot.sendRegularPoll(
2020-02-15 09:33:04 +00:00
chatId: ChatIdentifier,
question: String,
options: List<String>,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
) = execute(
SendRegularPoll(
2020-11-05 17:48:23 +00:00
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
2020-02-15 09:33:04 +00:00
)
)
suspend fun TelegramBot.sendRegularPoll(
2020-02-15 09:33:04 +00:00
chatId: ChatIdentifier,
poll: RegularPoll,
isClosed: Boolean = false,
question: String = poll.question,
options: List<String> = poll.options.map { it.text },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
2020-11-05 17:48:23 +00:00
) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup)
2020-02-15 09:33:04 +00:00
suspend fun TelegramBot.sendRegularPoll(
2020-02-15 09:33:04 +00:00
chat: Chat,
question: String,
options: List<String>,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(
2020-11-05 17:48:23 +00:00
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
2020-02-15 09:33:04 +00:00
)
suspend fun TelegramBot.sendRegularPoll(
2020-02-15 09:33:04 +00:00
chat: Chat,
poll: RegularPoll,
isClosed: Boolean = false,
question: String = poll.question,
options: List<String> = poll.options.map { it.text },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(
2020-11-05 17:48:23 +00:00
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
2020-02-15 09:33:04 +00:00
)
suspend fun TelegramBot.sendQuizPoll(
2020-02-15 09:33:04 +00:00
chatId: ChatIdentifier,
question: String,
options: List<String>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
) = execute(
SendQuizPoll(
2020-11-05 17:48:23 +00:00
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
2020-02-15 09:33:04 +00:00
)
)
suspend fun TelegramBot.sendQuizPoll(
2020-02-15 09:33:04 +00:00
chat: Chat,
question: String,
options: List<String>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
2020-11-05 17:48:23 +00:00
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
2020-02-15 09:33:04 +00:00
)
suspend fun TelegramBot.sendQuizPoll(
2020-02-15 09:33:04 +00:00
chatId: ChatIdentifier,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
2020-10-04 10:47:30 +00:00
) = sendQuizPoll(
2020-11-05 17:48:23 +00:00
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
2020-02-15 09:33:04 +00:00
)
suspend fun TelegramBot.sendQuizPoll(
2020-02-15 09:33:04 +00:00
chat: Chat,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
2020-02-15 09:33:04 +00:00
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
2020-11-05 17:48:23 +00:00
allowSendingWithoutReply: Boolean? = null,
2020-02-15 09:33:04 +00:00
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
2020-11-05 17:48:23 +00:00
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
suspend inline fun TelegramBot.sendQuizPoll(
chatId: ChatIdentifier,
question: String,
options: List<String>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
2021-05-29 09:34:14 +00:00
entities: TextSourcesList,
2020-11-05 17:48:23 +00:00
closeInfo: ScheduledCloseInfo? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
)
suspend inline fun TelegramBot.sendQuizPoll(
chat: Chat,
question: String,
options: List<String>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
2021-05-29 09:34:14 +00:00
entities: TextSourcesList,
2020-11-05 17:48:23 +00:00
closeInfo: ScheduledCloseInfo? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
suspend inline fun TelegramBot.sendQuizPoll(
chatId: ChatIdentifier,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
2021-05-29 09:34:14 +00:00
entities: TextSourcesList,
2020-11-05 17:48:23 +00:00
closeInfo: ScheduledCloseInfo? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
suspend inline fun TelegramBot.sendQuizPoll(
chat: Chat,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
2021-05-29 09:34:14 +00:00
entities: TextSourcesList,
2020-11-05 17:48:23 +00:00
closeInfo: ScheduledCloseInfo? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
2020-02-15 09:33:04 +00:00
)