diff --git a/CHANGELOG.md b/CHANGELOG.md index 901f5a5984..4b4e02139f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,13 +27,19 @@ * Sealed class `DiceAnimationType` was added * Field `Dice#animationType` was added as `emoji` API representation * `SendDice` now receive `animationType` as second parameter - * For `List` and `List` was added several extensions: + * For `List` was added several extensions: * `toMarkdownCaptions` * `toMarkdownTexts` * `toMarkdownV2Captions` * `toMarkdownV2Texts` * `toHtmlCaptions` * `toHtmlTexts` +* `TelegramBotAPI-extensions-api`: + * All `RequestsExecutor#sendDice` extensions now accept `DiceAnimationType?` as second parameter + * All `RequestsExecutor#sendRegularPoll` extensions now accept `ScheduledCloseInfo` fourth parameter + * All `RequestsExecutor#sendQuizPoll` extensions now accept additional parameters `caption: String` and + `parseMode: ParseMode` for `explanation` functionality and `closeInfo: ScheduledCloseInfo?` for autoclose poll + functionality ## 0.26.0 diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt index c0e7f89442..d82e1c6293 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt @@ -6,19 +6,22 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.dice.DiceAnimationType suspend fun RequestsExecutor.sendDice( chatId: ChatIdentifier, + animationType: DiceAnimationType? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendDice(chatId, disableNotification, replyToMessageId, replyMarkup) + SendDice(chatId, animationType, disableNotification, replyToMessageId, replyMarkup) ) suspend fun RequestsExecutor.sendDice( chat: Chat, + animationType: DiceAnimationType? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(chat.id, disableNotification, replyToMessageId, replyMarkup) +) = sendDice(chat.id, animationType, disableNotification, replyToMessageId, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt index 813b91fa0b..a4cb7298c6 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt @@ -3,12 +3,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.polls import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendQuizPoll import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendRegularPoll -import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier -import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.polls.QuizPoll -import com.github.insanusmokrassar.TelegramBotAPI.types.polls.RegularPoll +import com.github.insanusmokrassar.TelegramBotAPI.types.polls.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Transient suspend fun RequestsExecutor.sendRegularPoll( chatId: ChatIdentifier, @@ -17,12 +18,13 @@ suspend fun RequestsExecutor.sendRegularPoll( isAnonymous: Boolean = true, isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendRegularPoll( - chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup + chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup ) ) suspend fun RequestsExecutor.sendRegularPoll( @@ -33,12 +35,13 @@ suspend fun RequestsExecutor.sendRegularPoll( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendRegularPoll( - chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup + chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup ) ) @@ -49,11 +52,12 @@ suspend fun RequestsExecutor.sendRegularPoll( isAnonymous: Boolean = true, isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup + chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup ) suspend fun RequestsExecutor.sendRegularPoll( @@ -64,11 +68,12 @@ suspend fun RequestsExecutor.sendRegularPoll( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup + chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup ) @@ -79,12 +84,15 @@ suspend fun RequestsExecutor.sendQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, + caption: String? = null, + parseMode: ParseMode? = null, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, caption, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup ) ) @@ -95,11 +103,14 @@ suspend fun RequestsExecutor.sendQuizPoll( correctOptionId: Int, isAnonymous: Boolean = true, isClosed: Boolean = false, + caption: String? = null, + parseMode: ParseMode? = null, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, caption, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup ) suspend fun RequestsExecutor.sendQuizPoll( @@ -110,12 +121,15 @@ suspend fun RequestsExecutor.sendQuizPoll( options: List = 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, + caption: String? = null, + parseMode: ParseMode? = null, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, caption, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup ) ) @@ -127,9 +141,12 @@ suspend fun RequestsExecutor.sendQuizPoll( options: List = 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, + caption: String? = null, + parseMode: ParseMode? = null, + closeInfo: ScheduledCloseInfo? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, caption, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup ) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt index 38a19c90d4..1c09393282 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/polls/SendPoll.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.justTextSources import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* @@ -84,7 +85,7 @@ fun Poll.createRequest( correctOptionId, isAnonymous, isClosed, - caption ?.fullListOfSubSource(captionEntities) ?.toMarkdownV2Captions() ?.firstOrNull(), + caption ?.fullListOfSubSource(captionEntities) ?.justTextSources() ?.toMarkdownV2Captions() ?.firstOrNull(), MarkdownV2, scheduledCloseInfo, disableNotification, diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt index 73b722fc62..2e89721bed 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/CaptionAndTextSourcesToText.kt @@ -57,14 +57,12 @@ fun List.toMarkdownCaptions(): List = createMarkdownText( this, captionLength.last + 1 ) -fun List.toMarkdownCaptions(): List = justTextSources().toMarkdownCaptions() fun CaptionedInput.toMarkdownCaptions(): List = fullEntitiesList().toMarkdownCaptions() fun List.toMarkdownTexts(): List = createMarkdownText( this, textLength.last + 1 ) -fun List.toMarkdownTexts(): List = justTextSources().toMarkdownTexts() fun TextContent.toMarkdownTexts(): List = fullEntitiesList().toMarkdownTexts() @@ -77,14 +75,12 @@ fun List.toMarkdownV2Captions(): List = createMarkdownV2Text this, captionLength.last + 1 ) -fun List.toMarkdownV2Captions(): List = justTextSources().toMarkdownV2Captions() fun CaptionedInput.toMarkdownV2Captions(): List = fullEntitiesList().toMarkdownV2Captions() fun List.toMarkdownV2Texts(): List = createMarkdownV2Text( this, textLength.last + 1 ) -fun List.toMarkdownV2Texts(): List = justTextSources().toMarkdownV2Texts() fun TextContent.toMarkdownV2Texts(): List = fullEntitiesList().toMarkdownV2Texts() @@ -97,14 +93,12 @@ fun List.toHtmlCaptions(): List = createHtmlText( this, captionLength.last + 1 ) -fun List.toHtmlCaptions(): List = justTextSources().toHtmlCaptions() fun CaptionedInput.toHtmlCaptions(): List = fullEntitiesList().toHtmlCaptions() fun List.toHtmlTexts(): List = createHtmlText( this, textLength.last + 1 ) -fun List.toHtmlTexts(): List = justTextSources().toHtmlTexts() fun TextContent.toHtmlTexts(): List = fullEntitiesList().toHtmlTexts()