276 lines
12 KiB
Kotlin
276 lines
12 KiB
Kotlin
package dev.inmo.tgbotapi.extensions.api.send.polls
|
|
|
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll
|
|
import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
|
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
|
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
|
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.polls.*
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend fun TelegramBot.sendRegularPoll(
|
|
chatId: ChatIdentifier,
|
|
question: String,
|
|
options: List<String>,
|
|
isAnonymous: Boolean = true,
|
|
isClosed: Boolean = false,
|
|
allowMultipleAnswers: Boolean = false,
|
|
closeInfo: ScheduledCloseInfo? = null,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = execute(
|
|
SendRegularPoll(
|
|
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
)
|
|
)
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend fun TelegramBot.sendRegularPoll(
|
|
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,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend fun TelegramBot.sendRegularPoll(
|
|
chat: Chat,
|
|
question: String,
|
|
options: List<String>,
|
|
isAnonymous: Boolean = true,
|
|
isClosed: Boolean = false,
|
|
allowMultipleAnswers: Boolean = false,
|
|
closeInfo: ScheduledCloseInfo? = null,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = sendRegularPoll(
|
|
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend fun TelegramBot.sendRegularPoll(
|
|
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,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = sendRegularPoll(
|
|
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
)
|
|
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend fun TelegramBot.sendQuizPoll(
|
|
chatId: ChatIdentifier,
|
|
question: String,
|
|
options: List<String>,
|
|
correctOptionId: Int,
|
|
isAnonymous: Boolean = true,
|
|
isClosed: Boolean = false,
|
|
explanation: String? = null,
|
|
parseMode: ParseMode? = null,
|
|
closeInfo: ScheduledCloseInfo? = null,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = execute(
|
|
SendQuizPoll(
|
|
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
)
|
|
)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend fun TelegramBot.sendQuizPoll(
|
|
chat: Chat,
|
|
question: String,
|
|
options: List<String>,
|
|
correctOptionId: Int,
|
|
isAnonymous: Boolean = true,
|
|
isClosed: Boolean = false,
|
|
explanation: String? = null,
|
|
parseMode: ParseMode? = null,
|
|
closeInfo: ScheduledCloseInfo? = null,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = sendQuizPoll(
|
|
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend 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,
|
|
explanation: String? = null,
|
|
parseMode: ParseMode? = null,
|
|
closeInfo: ScheduledCloseInfo? = null,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = sendQuizPoll(
|
|
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend 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,
|
|
explanation: String? = null,
|
|
parseMode: ParseMode? = null,
|
|
closeInfo: ScheduledCloseInfo? = null,
|
|
disableNotification: Boolean = false,
|
|
replyToMessageId: MessageIdentifier? = null,
|
|
allowSendingWithoutReply: Boolean? = null,
|
|
replyMarkup: KeyboardMarkup? = null
|
|
) = sendQuizPoll(
|
|
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
|
)
|
|
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend inline fun TelegramBot.sendQuizPoll(
|
|
chatId: ChatIdentifier,
|
|
question: String,
|
|
options: List<String>,
|
|
correctOptionId: Int,
|
|
isAnonymous: Boolean = true,
|
|
isClosed: Boolean = false,
|
|
entities: TextSourcesList,
|
|
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
|
|
)
|
|
)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
suspend inline fun TelegramBot.sendQuizPoll(
|
|
chat: Chat,
|
|
question: String,
|
|
options: List<String>,
|
|
correctOptionId: Int,
|
|
isAnonymous: Boolean = true,
|
|
isClosed: Boolean = false,
|
|
entities: TextSourcesList,
|
|
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
|
|
)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
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,
|
|
entities: TextSourcesList,
|
|
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
|
|
)
|
|
|
|
/**
|
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
|
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
|
|
*/
|
|
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,
|
|
entities: TextSourcesList,
|
|
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
|
|
)
|