1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 19:48:43 +00:00

remove List<TextPart> extensions for texts due to JVM signature conflict and actualize TelegramBotAPI-extensions-api

This commit is contained in:
InsanusMokrassar 2020-04-24 19:24:49 +06:00
parent c6fb50c4a6
commit a5c3e06f1c
5 changed files with 43 additions and 22 deletions

View File

@ -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<TextPart>` and `List<TextSource>` was added several extensions:
* For `List<TextSource>` 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

View File

@ -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)

View File

@ -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<String> = 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<String> = 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<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,
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<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,
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
)

View File

@ -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,

View File

@ -57,14 +57,12 @@ fun List<TextSource>.toMarkdownCaptions(): List<String> = createMarkdownText(
this,
captionLength.last + 1
)
fun List<TextPart>.toMarkdownCaptions(): List<String> = justTextSources().toMarkdownCaptions()
fun CaptionedInput.toMarkdownCaptions(): List<String> = fullEntitiesList().toMarkdownCaptions()
fun List<TextSource>.toMarkdownTexts(): List<String> = createMarkdownText(
this,
textLength.last + 1
)
fun List<TextPart>.toMarkdownTexts(): List<String> = justTextSources().toMarkdownTexts()
fun TextContent.toMarkdownTexts(): List<String> = fullEntitiesList().toMarkdownTexts()
@ -77,14 +75,12 @@ fun List<TextSource>.toMarkdownV2Captions(): List<String> = createMarkdownV2Text
this,
captionLength.last + 1
)
fun List<TextPart>.toMarkdownV2Captions(): List<String> = justTextSources().toMarkdownV2Captions()
fun CaptionedInput.toMarkdownV2Captions(): List<String> = fullEntitiesList().toMarkdownV2Captions()
fun List<TextSource>.toMarkdownV2Texts(): List<String> = createMarkdownV2Text(
this,
textLength.last + 1
)
fun List<TextPart>.toMarkdownV2Texts(): List<String> = justTextSources().toMarkdownV2Texts()
fun TextContent.toMarkdownV2Texts(): List<String> = fullEntitiesList().toMarkdownV2Texts()
@ -97,14 +93,12 @@ fun List<TextSource>.toHtmlCaptions(): List<String> = createHtmlText(
this,
captionLength.last + 1
)
fun List<TextPart>.toHtmlCaptions(): List<String> = justTextSources().toHtmlCaptions()
fun CaptionedInput.toHtmlCaptions(): List<String> = fullEntitiesList().toHtmlCaptions()
fun List<TextSource>.toHtmlTexts(): List<String> = createHtmlText(
this,
textLength.last + 1
)
fun List<TextPart>.toHtmlTexts(): List<String> = justTextSources().toHtmlTexts()
fun TextContent.toHtmlTexts(): List<String> = fullEntitiesList().toHtmlTexts()