mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-22 14:15:45 +00:00
deprecations removing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.BroadcastChannel
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
/**
|
||||
* Shortcut for [dev.inmo.micro_utils.coroutines.safely]. It was created for more comfortable way of handling different things
|
||||
*/
|
||||
@Deprecated("In future will be used typealias from micro_utils", ReplaceWith("safely", "dev.inmo.micro_utils.coroutines.safely"))
|
||||
suspend inline fun <T> safely(
|
||||
noinline onException: ExceptionHandler<T> = { throw it },
|
||||
noinline block: suspend CoroutineScope.() -> T
|
||||
): T = dev.inmo.micro_utils.coroutines.safely(
|
||||
onException,
|
||||
block
|
||||
)
|
||||
@@ -1,24 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils.chat_events
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Deprecated("Refactored, replaced and renamed", ReplaceWith("filterByChatEvent", "dev.inmo.tgbotapi.extensions.utils.shortcuts.filterByChatEvent"))
|
||||
fun <T : ChatEventMessage<*>> Flow<ChatEventMessage<*>>.divideBySource(contentType: KClass<T>) = mapNotNull {
|
||||
if (contentType.isInstance(it)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
it as T
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Replaced and renamed", ReplaceWith("channelEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.channelEvents"))
|
||||
fun Flow<ChatEventMessage<*>>.onlyChannelEvents() = channelEvents()
|
||||
@Deprecated("Replaced and renamed", ReplaceWith("groupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.groupEvents"))
|
||||
fun Flow<ChatEventMessage<*>>.onlyGroupEvents() = groupEvents()
|
||||
@Deprecated("Replaced and renamed", ReplaceWith("supergroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.supergroupEvents"))
|
||||
fun Flow<ChatEventMessage<*>>.onlySupergroupEvents() = supergroupEvents()
|
||||
@@ -84,38 +84,3 @@ private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addsticke
|
||||
|
||||
val StickerSetName.stickerSetLink
|
||||
get() = link(this, "$stickerSetAddingLinkPrefix/$this")
|
||||
|
||||
/**
|
||||
* @return Link for adding of sticker set with name [stickerSetName] with formatting for [MarkdownV2]
|
||||
*/
|
||||
@Deprecated("Use extension `stickerSetLink` + getting of `asMarkdownV2Source` property")
|
||||
fun makeLinkToAddStickerSetInMarkdownV2(
|
||||
stickerSetName: StickerSetName
|
||||
) = stickerSetName.stickerSetLink.markdownV2
|
||||
/**
|
||||
* @return Link for adding of sticker set with name [stickerSetName] with formatting for [Markdown]
|
||||
*/
|
||||
@Deprecated("Use extension `stickerSetLink` + getting of `asMarkdownSource` property")
|
||||
fun makeLinkToAddStickerSetInMarkdown(stickerSetName: StickerSetName) = stickerSetName.stickerSetLink.markdown
|
||||
/**
|
||||
* @return Link for adding of sticker set with name [stickerSetName] with formatting for [HTML]
|
||||
*/
|
||||
@Deprecated("Use extension `stickerSetLink` + getting of `asHtmlSource` property")
|
||||
fun makeLinkToAddStickerSetInHtml(stickerSetName: StickerSetName) = stickerSetName.stickerSetLink.html
|
||||
/**
|
||||
* Create a link for adding of sticker set with name [stickerSetName]. Was added thanks to user Djaler and based on
|
||||
* https://github.com/Djaler/evil-bot/blob/master/src/main/kotlin/com/github/djaler/evilbot/utils/StickerUtils.kt#L6-L8
|
||||
*
|
||||
* @see [makeLinkToAddStickerSetInMarkdownV2]
|
||||
* @see [makeLinkToAddStickerSetInMarkdown]
|
||||
* @see [makeLinkToAddStickerSetInHtml]
|
||||
*/
|
||||
@Deprecated("Use extension `stickerSetLink` + getting of required property")
|
||||
fun makeLinkToAddStickerSet(
|
||||
stickerSetName: StickerSetName,
|
||||
parseMode: ParseMode
|
||||
) = when (parseMode) {
|
||||
MarkdownParseMode -> makeLinkToAddStickerSetInMarkdown(stickerSetName)
|
||||
MarkdownV2ParseMode -> makeLinkToAddStickerSetInMarkdownV2(stickerSetName)
|
||||
HTMLParseMode -> makeLinkToAddStickerSetInHtml(stickerSetName)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.ParseMode.*
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.content.fullEntitiesList
|
||||
|
||||
fun createFormattedText(
|
||||
entities: TextSourcesList,
|
||||
@@ -56,19 +55,19 @@ fun TextSourcesList.toMarkdownCaptions(): List<String> = createMarkdownText(
|
||||
this,
|
||||
captionLength.last
|
||||
)
|
||||
fun CaptionedInput.toMarkdownCaptions(): List<String> = fullEntitiesList().toMarkdownCaptions()
|
||||
fun CaptionedInput.toMarkdownCaptions(): List<String> = textSources.toMarkdownCaptions()
|
||||
|
||||
fun TextSourcesList.toMarkdownTexts(): List<String> = createMarkdownText(
|
||||
this,
|
||||
textLength.last
|
||||
)
|
||||
fun TextContent.toMarkdownTexts(): List<String> = fullEntitiesList().toMarkdownTexts()
|
||||
fun TextContent.toMarkdownTexts(): List<String> = textSources.toMarkdownTexts()
|
||||
|
||||
fun TextSourcesList.toMarkdownExplanations(): List<String> = createMarkdownText(
|
||||
this,
|
||||
explanationLimit.last
|
||||
)
|
||||
fun ExplainedInput.toMarkdownExplanations(): List<String> = fullEntitiesList().toMarkdownTexts()
|
||||
fun ExplainedInput.toMarkdownExplanations(): List<String> = textSources.toMarkdownTexts()
|
||||
|
||||
|
||||
fun createMarkdownV2Text(
|
||||
@@ -80,19 +79,19 @@ fun TextSourcesList.toMarkdownV2Captions(): List<String> = createMarkdownV2Text(
|
||||
this,
|
||||
captionLength.last
|
||||
)
|
||||
fun CaptionedInput.toMarkdownV2Captions(): List<String> = fullEntitiesList().toMarkdownV2Captions()
|
||||
fun CaptionedInput.toMarkdownV2Captions(): List<String> = textSources.toMarkdownV2Captions()
|
||||
|
||||
fun TextSourcesList.toMarkdownV2Texts(): List<String> = createMarkdownV2Text(
|
||||
this,
|
||||
textLength.last
|
||||
)
|
||||
fun TextContent.toMarkdownV2Texts(): List<String> = fullEntitiesList().toMarkdownV2Texts()
|
||||
fun TextContent.toMarkdownV2Texts(): List<String> = textSources.toMarkdownV2Texts()
|
||||
|
||||
fun TextSourcesList.toMarkdownV2Explanations(): List<String> = createMarkdownV2Text(
|
||||
this,
|
||||
explanationLimit.last
|
||||
)
|
||||
fun ExplainedInput.toMarkdownV2Explanations(): List<String> = fullEntitiesList().toMarkdownV2Texts()
|
||||
fun ExplainedInput.toMarkdownV2Explanations(): List<String> = textSources.toMarkdownV2Texts()
|
||||
|
||||
|
||||
fun createHtmlText(
|
||||
@@ -104,18 +103,18 @@ fun TextSourcesList.toHtmlCaptions(): List<String> = createHtmlText(
|
||||
this,
|
||||
captionLength.last
|
||||
)
|
||||
fun CaptionedInput.toHtmlCaptions(): List<String> = fullEntitiesList().toHtmlCaptions()
|
||||
fun CaptionedInput.toHtmlCaptions(): List<String> = textSources.toHtmlCaptions()
|
||||
|
||||
fun TextSourcesList.toHtmlTexts(): List<String> = createHtmlText(
|
||||
this,
|
||||
textLength.last
|
||||
)
|
||||
fun TextContent.toHtmlTexts(): List<String> = fullEntitiesList().toHtmlTexts()
|
||||
fun TextContent.toHtmlTexts(): List<String> = textSources.toHtmlTexts()
|
||||
|
||||
fun TextSourcesList.toHtmlExplanations(): List<String> = createHtmlText(
|
||||
this,
|
||||
explanationLimit.last
|
||||
)
|
||||
fun ExplainedInput.toHtmlExplanations(): List<String> = fullEntitiesList().toHtmlTexts()
|
||||
fun ExplainedInput.toHtmlExplanations(): List<String> = textSources.toHtmlTexts()
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.content.fullEntitiesList
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.content.fullEntitiesList
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.utils.updates
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
@@ -23,11 +25,6 @@ fun <T : BaseSentMessageUpdate> Flow<T>.asCommonMessagesFlow() = mapNotNull {
|
||||
inline fun <T : BaseSentMessageUpdate> Flow<T>.chatEvents() = mapNotNull {
|
||||
it.data as? ChatEventMessage<*>
|
||||
}
|
||||
/**
|
||||
* Will map incoming [BaseSentMessageUpdate]s to [ChatEventMessage] from [BaseSentMessageUpdate.data]
|
||||
*/
|
||||
@Deprecated("Renamed", ReplaceWith("chatEvents", "dev.inmo.tgbotapi.extensions.utils.updates.chatEvents"))
|
||||
fun <T : BaseSentMessageUpdate> Flow<T>.asChatEventsFlow() = chatEvents()
|
||||
|
||||
/**
|
||||
* Will map incoming [BaseSentMessageUpdate]s to [UnknownMessageType] from [BaseSentMessageUpdate.data]
|
||||
|
||||
Reference in New Issue
Block a user