1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +00:00

fixes in sends and poll.kt

This commit is contained in:
InsanusMokrassar 2024-05-07 16:15:40 +06:00
parent 905486fff9
commit cfc2fd1b47
6 changed files with 338 additions and 72 deletions

View File

@ -31,7 +31,6 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
import kotlinx.coroutines.flow.Flow
import kotlin.js.JsName
import kotlin.jvm.JvmName

View File

@ -858,9 +858,31 @@ suspend fun TelegramBot.send(
*/
suspend fun TelegramBot.send(
chatId: ChatIdentifier,
poll: RegularPoll,
questionTextSources: List<TextSource>,
options: List<InputPollOption>,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(chatId, questionTextSources, options, closeInfo, isAnonymous, isClosed, allowMultipleAnswers, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendRegularPoll] request
* @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.send(
chatId: ChatIdentifier,
poll: RegularPoll,
question: String,
questionParseMode: ParseMode? = null,
isClosed: Boolean = false,
question: String = poll.question,
options: List<InputPollOption> = poll.options.map { it.asInput() },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
@ -871,7 +893,29 @@ suspend fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(chatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendRegularPoll(chatId, question, options, closeInfo, questionParseMode, isAnonymous, isClosed, allowMultipleAnswers, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendRegularPoll] request
* @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.send(
chatId: ChatIdentifier,
poll: RegularPoll,
questionTextSources: List<TextSource> = poll.questionTextSources,
isClosed: Boolean = false,
options: List<InputPollOption> = poll.options.map { it.asInput() },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(chatId, questionTextSources, options, closeInfo, isAnonymous, isClosed, allowMultipleAnswers, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendRegularPoll] request
@ -881,7 +925,8 @@ suspend fun TelegramBot.send(
suspend fun TelegramBot.send(
chat: Chat,
question: String,
options: List<String>,
options: List<InputPollOption>,
questionParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
@ -892,7 +937,7 @@ suspend fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendRegularPoll(chat.id, question, options, closeInfo, questionParseMode, isAnonymous, isClosed, allowMultipleAnswers, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendRegularPoll] request
@ -902,9 +947,10 @@ suspend fun TelegramBot.send(
suspend fun TelegramBot.send(
chat: Chat,
poll: RegularPoll,
question: String,
questionParseMode: ParseMode? = null,
isClosed: Boolean = false,
question: String = poll.question,
options: List<String> = poll.options.map { it.text },
options: List<InputPollOption> = poll.options.map { it.asInput() },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null,
@ -914,7 +960,29 @@ suspend fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendRegularPoll(chat.id, question, options, closeInfo, questionParseMode, isAnonymous, isClosed, allowMultipleAnswers, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendRegularPoll] request
* @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.send(
chat: Chat,
poll: RegularPoll,
questionTextSources: List<TextSource> = poll.questionTextSources,
isClosed: Boolean = false,
options: List<InputPollOption> = poll.options.map { it.asInput() },
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(chat.id, questionTextSources, options, closeInfo, isAnonymous, isClosed, allowMultipleAnswers, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
@ -924,12 +992,13 @@ suspend fun TelegramBot.send(
suspend fun TelegramBot.send(
chatId: ChatIdentifier,
question: String,
options: List<String>,
options: List<InputPollOption>,
correctOptionId: Int,
questionParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
explanation: String? = null,
parseMode: ParseMode? = null,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@ -937,7 +1006,7 @@ suspend fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendQuizPoll(chatId, question, options, correctOptionId, closeInfo, questionParseMode, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
@ -947,12 +1016,13 @@ suspend fun TelegramBot.send(
suspend fun TelegramBot.send(
chat: Chat,
question: String,
options: List<String>,
options: List<InputPollOption>,
correctOptionId: Int,
questionParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
explanation: String? = null,
parseMode: ParseMode? = null,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
@ -960,7 +1030,7 @@ suspend fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendQuizPoll(chat.id, question, options, correctOptionId, closeInfo, questionParseMode, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
@ -971,12 +1041,13 @@ suspend fun TelegramBot.send(
chatId: ChatIdentifier,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
question: String,
questionParseMode: ParseMode? = null,
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
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,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@ -985,7 +1056,7 @@ suspend fun TelegramBot.send(
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup
chatId, question, options, correctOptionId, closeInfo, questionParseMode, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup
)
/**
@ -997,12 +1068,13 @@ suspend fun TelegramBot.send(
chat: Chat,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
question: String,
questionParseMode: ParseMode? = null,
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
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,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
@ -1010,21 +1082,22 @@ suspend fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendQuizPoll(chat.id, question, options, correctOptionId, closeInfo, questionParseMode, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
suspend fun TelegramBot.send(
chatId: ChatIdentifier,
question: String,
options: List<String>,
questionTextSources: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
entities: TextSourcesList,
explanation: String? = null,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@ -1032,21 +1105,22 @@ suspend inline fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendQuizPoll(chatId, questionTextSources, options, correctOptionId, closeInfo, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
suspend fun TelegramBot.send(
chat: Chat,
question: String,
options: List<String>,
questionTextSources: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
entities: TextSourcesList,
explanation: String? = null,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
@ -1054,22 +1128,23 @@ suspend inline fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendQuizPoll(chat.id, questionTextSources, options, correctOptionId, closeInfo, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
suspend fun TelegramBot.send(
chatId: ChatIdentifier,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
questionTextSources: List<TextSource>,
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
entities: TextSourcesList,
explanation: String? = null,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@ -1077,22 +1152,25 @@ suspend inline fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendQuizPoll(
chatId, questionTextSources, options, correctOptionId, closeInfo, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup
)
/**
* Will execute [sendQuizPoll] request
* @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.send(
suspend fun TelegramBot.send(
chat: Chat,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String = quizPoll.question,
options: List<String> = quizPoll.options.map { it.text },
questionTextSources: List<TextSource>,
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
entities: TextSourcesList,
explanation: String? = null,
explanationParseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
@ -1100,7 +1178,195 @@ suspend inline fun TelegramBot.send(
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
) = sendQuizPoll(chat.id, questionTextSources, options, correctOptionId, closeInfo, explanation, explanationParseMode, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chatId: ChatIdentifier,
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>? = null,
questionParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chatId, question, options, correctOptionId, closeInfo, questionParseMode, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chat: Chat,
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>? = null,
questionParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat.id, question, options, correctOptionId, closeInfo, questionParseMode, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chatId: ChatIdentifier,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String,
explanationTextSources: List<TextSource>? = null,
questionParseMode: ParseMode? = null,
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chatId, question, options, correctOptionId, closeInfo, questionParseMode, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup
)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chat: Chat,
isClosed: Boolean = false,
quizPoll: QuizPoll,
question: String,
questionParseMode: ParseMode? = null,
explanationTextSources: List<TextSource>? = null,
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat.id, question, options, correctOptionId, closeInfo, questionParseMode, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chatId: ChatIdentifier,
questionTextSources: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chatId, questionTextSources, options, correctOptionId, closeInfo, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chat: Chat,
questionTextSources: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat.id, questionTextSources, options, correctOptionId, closeInfo, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chatId: ChatIdentifier,
isClosed: Boolean = false,
quizPoll: QuizPoll,
questionTextSources: List<TextSource> = quizPoll.questionTextSources,
explanationTextSources: List<TextSource>? = quizPoll.explanationTextSources.takeIf { it.isNotEmpty() },
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chatId, questionTextSources, options, correctOptionId, closeInfo, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup
)
/**
* Will execute [sendQuizPoll] request
* @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.send(
chat: Chat,
isClosed: Boolean = false,
quizPoll: QuizPoll,
questionTextSources: List<TextSource> = quizPoll.questionTextSources,
explanationTextSources: List<TextSource>? = quizPoll.explanationTextSources.takeIf { it.isNotEmpty() },
options: List<InputPollOption> = quizPoll.options.map { it.asInput() },
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
isAnonymous: Boolean = quizPoll.isAnonymous,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(chat.id, questionTextSources, options, correctOptionId, closeInfo, explanationTextSources, isAnonymous, isClosed, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup)
/**
* Will execute [sendSticker] request

View File

@ -16,8 +16,8 @@ suspend fun TelegramBot.sendQuizPoll(
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanation: String?,
questionParseMode: ParseMode? = null,
explanation: String? = null,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -35,8 +35,8 @@ suspend fun TelegramBot.sendQuizPoll(
question,
options,
correctOptionId,
questionParseMode,
explanation,
questionParseMode,
explanationParseMode,
isAnonymous,
isClosed,
@ -56,7 +56,7 @@ suspend fun TelegramBot.sendQuizPoll(
questionEntities: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanation: String? = null,
explanation: String?,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -94,7 +94,7 @@ suspend fun TelegramBot.sendQuizPoll(
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
explanationTextSources: List<TextSource>? = null,
questionParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -112,8 +112,8 @@ suspend fun TelegramBot.sendQuizPoll(
question,
options,
correctOptionId,
explanationTextSources,
questionParseMode,
explanationTextSources,
isAnonymous,
isClosed,
openPeriod,
@ -133,7 +133,7 @@ suspend fun TelegramBot.sendQuizPoll(
questionEntities: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
openPeriod: LongSeconds? = null,
@ -171,7 +171,7 @@ suspend fun TelegramBot.sendQuizPoll(
correctOptionId: Int,
closeInfo: ScheduledCloseInfo?,
questionParseMode: ParseMode? = null,
explanation: String? = null,
explanation: String?,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -188,8 +188,8 @@ suspend fun TelegramBot.sendQuizPoll(
options,
correctOptionId,
closeInfo,
questionParseMode,
explanation,
questionParseMode,
explanationParseMode,
isAnonymous,
isClosed,
@ -208,7 +208,7 @@ suspend fun TelegramBot.sendQuizPoll(
options: List<InputPollOption>,
correctOptionId: Int,
closeInfo: ScheduledCloseInfo?,
explanation: String? = null,
explanation: String?,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -243,9 +243,9 @@ suspend fun TelegramBot.sendQuizPoll(
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
closeInfo: ScheduledCloseInfo?,
questionParseMode: ParseMode? = null,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
@ -260,9 +260,9 @@ suspend fun TelegramBot.sendQuizPoll(
question,
options,
correctOptionId,
explanationTextSources,
closeInfo,
questionParseMode,
explanationTextSources,
isAnonymous,
isClosed,
threadId,
@ -279,8 +279,8 @@ suspend fun TelegramBot.sendQuizPoll(
questionEntities: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
closeInfo: ScheduledCloseInfo?,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
@ -295,8 +295,8 @@ suspend fun TelegramBot.sendQuizPoll(
questionEntities,
options,
correctOptionId,
explanationTextSources,
closeInfo,
explanationTextSources,
isAnonymous,
isClosed,
threadId,

View File

@ -129,8 +129,8 @@ fun Poll.createRequest(
textSources,
options.map { it.asInput() },
correctOptionId,
explanationTextSources,
scheduledCloseInfo,
explanationTextSources,
isAnonymous,
isClosed,
threadId,

View File

@ -13,7 +13,6 @@ import dev.inmo.tgbotapi.types.polls.ExactScheduledCloseInfo
import dev.inmo.tgbotapi.types.polls.InputPollOption
import dev.inmo.tgbotapi.types.polls.ScheduledCloseInfo
import dev.inmo.tgbotapi.utils.extensions.makeSourceString
import dev.inmo.tgbotapi.utils.extensions.makeString
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
@ -74,8 +73,8 @@ class SendQuizPoll internal constructor(
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanation: String?,
questionParseMode: ParseMode? = null,
explanation: String? = null,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -114,7 +113,7 @@ class SendQuizPoll internal constructor(
questionEntities: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanation: String? = null,
explanation: String?,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -153,8 +152,8 @@ class SendQuizPoll internal constructor(
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
questionParseMode: ParseMode? = null,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
openPeriod: LongSeconds? = null,
@ -174,9 +173,9 @@ class SendQuizPoll internal constructor(
rawQuestionEntities = emptyList(),
isAnonymous = isAnonymous,
isClosed = isClosed,
explanation = explanationTextSources.makeSourceString(),
explanation = explanationTextSources ?.makeSourceString(),
explanationParseMode = null,
rawExplanationEntities = explanationTextSources.toRawMessageEntities(),
rawExplanationEntities = explanationTextSources ?.toRawMessageEntities(),
openPeriod = openPeriod,
closeDate = closeDate,
threadId = threadId,
@ -192,7 +191,7 @@ class SendQuizPoll internal constructor(
questionEntities: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
openPeriod: LongSeconds? = null,
@ -212,9 +211,9 @@ class SendQuizPoll internal constructor(
rawQuestionEntities = questionEntities.toRawMessageEntities(),
isAnonymous = isAnonymous,
isClosed = isClosed,
explanation = explanationTextSources.makeSourceString(),
explanation = explanationTextSources ?.makeSourceString(),
explanationParseMode = null,
rawExplanationEntities = explanationTextSources.toRawMessageEntities(),
rawExplanationEntities = explanationTextSources ?.toRawMessageEntities(),
openPeriod = openPeriod,
closeDate = closeDate,
threadId = threadId,
@ -246,8 +245,8 @@ fun SendQuizPoll(
options: List<InputPollOption>,
correctOptionId: Int,
closeInfo: ScheduledCloseInfo?,
explanation: String?,
questionParseMode: ParseMode? = null,
explanation: String? = null,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -262,8 +261,8 @@ fun SendQuizPoll(
question = question,
options = options,
correctOptionId = correctOptionId,
questionParseMode = questionParseMode,
explanation = explanation,
questionParseMode = questionParseMode,
explanationParseMode = explanationParseMode,
isAnonymous = isAnonymous,
isClosed = isClosed,
@ -283,7 +282,7 @@ fun SendQuizPoll(
options: List<InputPollOption>,
correctOptionId: Int,
closeInfo: ScheduledCloseInfo?,
explanation: String? = null,
explanation: String?,
explanationParseMode: ParseMode? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
@ -317,9 +316,9 @@ fun SendQuizPoll(
question: String,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
closeInfo: ScheduledCloseInfo?,
questionParseMode: ParseMode? = null,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
@ -333,8 +332,8 @@ fun SendQuizPoll(
question = question,
options = options,
correctOptionId = correctOptionId,
explanationTextSources = explanationTextSources,
questionParseMode = questionParseMode,
explanationTextSources = explanationTextSources,
isAnonymous = isAnonymous,
isClosed = isClosed,
openPeriod = (closeInfo as? ApproximateScheduledCloseInfo)?.openPeriod,
@ -352,8 +351,8 @@ fun SendQuizPoll(
questionEntities: List<TextSource>,
options: List<InputPollOption>,
correctOptionId: Int,
explanationTextSources: List<TextSource>,
closeInfo: ScheduledCloseInfo?,
explanationTextSources: List<TextSource>? = null,
isAnonymous: Boolean = true,
isClosed: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,

View File

@ -54,6 +54,8 @@ sealed interface Poll : ReplyInfo.External.ContentVariant, TextedInput {
val question: String
override val text: String
get() = question
val questionTextSources: List<TextSource>
get() = textSources
val options: List<PollOption>
val votesCount: Int
val isClosed: Boolean