diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 721f40c97d..7707bfe43e 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -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 diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt index a09a6871a8..4e7bc59404 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt @@ -858,9 +858,31 @@ suspend fun TelegramBot.send( */ suspend fun TelegramBot.send( chatId: ChatIdentifier, - poll: RegularPoll, + questionTextSources: List, + options: List, + 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 = 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 = poll.questionTextSources, + isClosed: Boolean = false, + options: List = 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, + options: List, + 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 = poll.options.map { it.text }, + options: List = 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 = poll.questionTextSources, + isClosed: Boolean = false, + options: List = 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, + options: List, 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, + options: List, 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 = quizPoll.options.map { it.text }, + question: String, + questionParseMode: ParseMode? = null, + options: List = 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 = quizPoll.options.map { it.text }, + question: String, + questionParseMode: ParseMode? = null, + options: List = 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, + questionTextSources: List, + options: List, 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, + questionTextSources: List, + options: List, 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 = quizPoll.options.map { it.text }, + questionTextSources: List, + options: List = 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 = quizPoll.options.map { it.text }, + questionTextSources: List, + options: List = 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, + correctOptionId: Int, + explanationTextSources: List? = 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, + correctOptionId: Int, + explanationTextSources: List? = 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? = null, + questionParseMode: ParseMode? = null, + options: List = 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? = null, + options: List = 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, + options: List, + correctOptionId: Int, + explanationTextSources: List? = 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, + options: List, + correctOptionId: Int, + explanationTextSources: List? = 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 = quizPoll.questionTextSources, + explanationTextSources: List? = quizPoll.explanationTextSources.takeIf { it.isNotEmpty() }, + options: List = 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 = quizPoll.questionTextSources, + explanationTextSources: List? = quizPoll.explanationTextSources.takeIf { it.isNotEmpty() }, + options: List = 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 diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendQuizPoll.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendQuizPoll.kt index db3e8dbf39..5cd169e9fd 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendQuizPoll.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendQuizPoll.kt @@ -16,8 +16,8 @@ suspend fun TelegramBot.sendQuizPoll( question: String, options: List, 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, options: List, 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, correctOptionId: Int, - explanationTextSources: List, + explanationTextSources: List? = 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, options: List, correctOptionId: Int, - explanationTextSources: List, + explanationTextSources: List? = 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, 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, correctOptionId: Int, - explanationTextSources: List, closeInfo: ScheduledCloseInfo?, questionParseMode: ParseMode? = null, + explanationTextSources: List? = 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, options: List, correctOptionId: Int, - explanationTextSources: List, closeInfo: ScheduledCloseInfo?, + explanationTextSources: List? = 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, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt index 7ab37723d4..c72323558d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt @@ -129,8 +129,8 @@ fun Poll.createRequest( textSources, options.map { it.asInput() }, correctOptionId, - explanationTextSources, scheduledCloseInfo, + explanationTextSources, isAnonymous, isClosed, threadId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt index 32d927784f..e38df7dedc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt @@ -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, 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, options: List, 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, correctOptionId: Int, - explanationTextSources: List, questionParseMode: ParseMode? = null, + explanationTextSources: List? = 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, options: List, correctOptionId: Int, - explanationTextSources: List, + explanationTextSources: List? = 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, 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, 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, correctOptionId: Int, - explanationTextSources: List, closeInfo: ScheduledCloseInfo?, questionParseMode: ParseMode? = null, + explanationTextSources: List? = 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, options: List, correctOptionId: Int, - explanationTextSources: List, closeInfo: ScheduledCloseInfo?, + explanationTextSources: List? = null, isAnonymous: Boolean = true, isClosed: Boolean = false, threadId: MessageThreadId? = chatId.threadId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt index 793df0595f..a3ea25780f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt @@ -54,6 +54,8 @@ sealed interface Poll : ReplyInfo.External.ContentVariant, TextedInput { val question: String override val text: String get() = question + val questionTextSources: List + get() = textSources val options: List val votesCount: Int val isClosed: Boolean