mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
remove List<TextPart> extensions for texts due to JVM signature conflict and actualize TelegramBotAPI-extensions-api
This commit is contained in:
parent
c6fb50c4a6
commit
a5c3e06f1c
@ -27,13 +27,19 @@
|
|||||||
* Sealed class `DiceAnimationType` was added
|
* Sealed class `DiceAnimationType` was added
|
||||||
* Field `Dice#animationType` was added as `emoji` API representation
|
* Field `Dice#animationType` was added as `emoji` API representation
|
||||||
* `SendDice` now receive `animationType` as second parameter
|
* `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`
|
* `toMarkdownCaptions`
|
||||||
* `toMarkdownTexts`
|
* `toMarkdownTexts`
|
||||||
* `toMarkdownV2Captions`
|
* `toMarkdownV2Captions`
|
||||||
* `toMarkdownV2Texts`
|
* `toMarkdownV2Texts`
|
||||||
* `toHtmlCaptions`
|
* `toHtmlCaptions`
|
||||||
* `toHtmlTexts`
|
* `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
|
## 0.26.0
|
||||||
|
|
||||||
|
@ -6,19 +6,22 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.dice.DiceAnimationType
|
||||||
|
|
||||||
suspend fun RequestsExecutor.sendDice(
|
suspend fun RequestsExecutor.sendDice(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
|
animationType: DiceAnimationType? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendDice(chatId, disableNotification, replyToMessageId, replyMarkup)
|
SendDice(chatId, animationType, disableNotification, replyToMessageId, replyMarkup)
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun RequestsExecutor.sendDice(
|
suspend fun RequestsExecutor.sendDice(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
|
animationType: DiceAnimationType? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendDice(chat.id, disableNotification, replyToMessageId, replyMarkup)
|
) = sendDice(chat.id, animationType, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
@ -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.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendQuizPoll
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendQuizPoll
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendRegularPoll
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendRegularPoll
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.QuizPoll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.RegularPoll
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Transient
|
||||||
|
|
||||||
suspend fun RequestsExecutor.sendRegularPoll(
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@ -17,12 +18,13 @@ suspend fun RequestsExecutor.sendRegularPoll(
|
|||||||
isAnonymous: Boolean = true,
|
isAnonymous: Boolean = true,
|
||||||
isClosed: Boolean = false,
|
isClosed: Boolean = false,
|
||||||
allowMultipleAnswers: Boolean = false,
|
allowMultipleAnswers: Boolean = false,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendRegularPoll(
|
SendRegularPoll(
|
||||||
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
suspend fun RequestsExecutor.sendRegularPoll(
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
@ -33,12 +35,13 @@ suspend fun RequestsExecutor.sendRegularPoll(
|
|||||||
options: List<String> = poll.options.map { it.text },
|
options: List<String> = poll.options.map { it.text },
|
||||||
isAnonymous: Boolean = poll.isAnonymous,
|
isAnonymous: Boolean = poll.isAnonymous,
|
||||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendRegularPoll(
|
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,
|
isAnonymous: Boolean = true,
|
||||||
isClosed: Boolean = false,
|
isClosed: Boolean = false,
|
||||||
allowMultipleAnswers: Boolean = false,
|
allowMultipleAnswers: Boolean = false,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendRegularPoll(
|
) = 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(
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
@ -64,11 +68,12 @@ suspend fun RequestsExecutor.sendRegularPoll(
|
|||||||
options: List<String> = poll.options.map { it.text },
|
options: List<String> = poll.options.map { it.text },
|
||||||
isAnonymous: Boolean = poll.isAnonymous,
|
isAnonymous: Boolean = poll.isAnonymous,
|
||||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendRegularPoll(
|
) = 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,
|
correctOptionId: Int,
|
||||||
isAnonymous: Boolean = true,
|
isAnonymous: Boolean = true,
|
||||||
isClosed: Boolean = false,
|
isClosed: Boolean = false,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendQuizPoll(
|
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,
|
correctOptionId: Int,
|
||||||
isAnonymous: Boolean = true,
|
isAnonymous: Boolean = true,
|
||||||
isClosed: Boolean = false,
|
isClosed: Boolean = false,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendQuizPoll(
|
) = 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(
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
@ -110,12 +121,15 @@ suspend fun RequestsExecutor.sendQuizPoll(
|
|||||||
options: List<String> = quizPoll.options.map { it.text },
|
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"),
|
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendQuizPoll(
|
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 },
|
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"),
|
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
closeInfo: ScheduledCloseInfo? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendQuizPoll(
|
) = sendQuizPoll(
|
||||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
chat.id, question, options, correctOptionId, isAnonymous, isClosed, caption, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
|
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.ReplyingMarkupSendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
@ -84,7 +85,7 @@ fun Poll.createRequest(
|
|||||||
correctOptionId,
|
correctOptionId,
|
||||||
isAnonymous,
|
isAnonymous,
|
||||||
isClosed,
|
isClosed,
|
||||||
caption ?.fullListOfSubSource(captionEntities) ?.toMarkdownV2Captions() ?.firstOrNull(),
|
caption ?.fullListOfSubSource(captionEntities) ?.justTextSources() ?.toMarkdownV2Captions() ?.firstOrNull(),
|
||||||
MarkdownV2,
|
MarkdownV2,
|
||||||
scheduledCloseInfo,
|
scheduledCloseInfo,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
|
@ -57,14 +57,12 @@ fun List<TextSource>.toMarkdownCaptions(): List<String> = createMarkdownText(
|
|||||||
this,
|
this,
|
||||||
captionLength.last + 1
|
captionLength.last + 1
|
||||||
)
|
)
|
||||||
fun List<TextPart>.toMarkdownCaptions(): List<String> = justTextSources().toMarkdownCaptions()
|
|
||||||
fun CaptionedInput.toMarkdownCaptions(): List<String> = fullEntitiesList().toMarkdownCaptions()
|
fun CaptionedInput.toMarkdownCaptions(): List<String> = fullEntitiesList().toMarkdownCaptions()
|
||||||
|
|
||||||
fun List<TextSource>.toMarkdownTexts(): List<String> = createMarkdownText(
|
fun List<TextSource>.toMarkdownTexts(): List<String> = createMarkdownText(
|
||||||
this,
|
this,
|
||||||
textLength.last + 1
|
textLength.last + 1
|
||||||
)
|
)
|
||||||
fun List<TextPart>.toMarkdownTexts(): List<String> = justTextSources().toMarkdownTexts()
|
|
||||||
fun TextContent.toMarkdownTexts(): List<String> = fullEntitiesList().toMarkdownTexts()
|
fun TextContent.toMarkdownTexts(): List<String> = fullEntitiesList().toMarkdownTexts()
|
||||||
|
|
||||||
|
|
||||||
@ -77,14 +75,12 @@ fun List<TextSource>.toMarkdownV2Captions(): List<String> = createMarkdownV2Text
|
|||||||
this,
|
this,
|
||||||
captionLength.last + 1
|
captionLength.last + 1
|
||||||
)
|
)
|
||||||
fun List<TextPart>.toMarkdownV2Captions(): List<String> = justTextSources().toMarkdownV2Captions()
|
|
||||||
fun CaptionedInput.toMarkdownV2Captions(): List<String> = fullEntitiesList().toMarkdownV2Captions()
|
fun CaptionedInput.toMarkdownV2Captions(): List<String> = fullEntitiesList().toMarkdownV2Captions()
|
||||||
|
|
||||||
fun List<TextSource>.toMarkdownV2Texts(): List<String> = createMarkdownV2Text(
|
fun List<TextSource>.toMarkdownV2Texts(): List<String> = createMarkdownV2Text(
|
||||||
this,
|
this,
|
||||||
textLength.last + 1
|
textLength.last + 1
|
||||||
)
|
)
|
||||||
fun List<TextPart>.toMarkdownV2Texts(): List<String> = justTextSources().toMarkdownV2Texts()
|
|
||||||
fun TextContent.toMarkdownV2Texts(): List<String> = fullEntitiesList().toMarkdownV2Texts()
|
fun TextContent.toMarkdownV2Texts(): List<String> = fullEntitiesList().toMarkdownV2Texts()
|
||||||
|
|
||||||
|
|
||||||
@ -97,14 +93,12 @@ fun List<TextSource>.toHtmlCaptions(): List<String> = createHtmlText(
|
|||||||
this,
|
this,
|
||||||
captionLength.last + 1
|
captionLength.last + 1
|
||||||
)
|
)
|
||||||
fun List<TextPart>.toHtmlCaptions(): List<String> = justTextSources().toHtmlCaptions()
|
|
||||||
fun CaptionedInput.toHtmlCaptions(): List<String> = fullEntitiesList().toHtmlCaptions()
|
fun CaptionedInput.toHtmlCaptions(): List<String> = fullEntitiesList().toHtmlCaptions()
|
||||||
|
|
||||||
fun List<TextSource>.toHtmlTexts(): List<String> = createHtmlText(
|
fun List<TextSource>.toHtmlTexts(): List<String> = createHtmlText(
|
||||||
this,
|
this,
|
||||||
textLength.last + 1
|
textLength.last + 1
|
||||||
)
|
)
|
||||||
fun List<TextPart>.toHtmlTexts(): List<String> = justTextSources().toHtmlTexts()
|
|
||||||
fun TextContent.toHtmlTexts(): List<String> = fullEntitiesList().toHtmlTexts()
|
fun TextContent.toHtmlTexts(): List<String> = fullEntitiesList().toHtmlTexts()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user