mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
add ReplaceWith to old functions and replace built-in usages of deprecations
This commit is contained in:
parent
1dc80f6929
commit
d67d16c72d
@ -23,7 +23,7 @@ data class TextContent(
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendMessage(
|
||||
chatId,
|
||||
toMarkdownText(),
|
||||
toMarkdownTexts().first(),
|
||||
MarkdownParseMode,
|
||||
false,
|
||||
disableNotification,
|
||||
|
@ -11,7 +11,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class AudioContent(
|
||||
override val media: AudioFile,
|
||||
@ -27,7 +27,7 @@ data class AudioContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toMarkdownCaption(),
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
media.duration,
|
||||
media.performer,
|
||||
|
@ -11,7 +11,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class DocumentContent(
|
||||
override val media: DocumentFile,
|
||||
@ -27,7 +27,7 @@ data class DocumentContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toMarkdownCaption(),
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
|
@ -13,7 +13,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class PhotoContent(
|
||||
override val media: List<PhotoSize>,
|
||||
@ -28,7 +28,7 @@ data class PhotoContent(
|
||||
): Request<RawMessage> = SendPhoto(
|
||||
chatId,
|
||||
media.biggest() ?.fileId ?: throw IllegalStateException("Empty list of media"),
|
||||
toMarkdownCaption(),
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
@ -37,7 +37,7 @@ data class PhotoContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto(
|
||||
media.biggest() ?.fileId ?: throw IllegalStateException("Can't locate any photo size for this content"),
|
||||
toMarkdownCaption(),
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode
|
||||
)
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class VideoContent(
|
||||
override val media: VideoFile,
|
||||
@ -28,7 +28,7 @@ data class VideoContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toMarkdownCaption(),
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
media.duration,
|
||||
media.width,
|
||||
@ -41,7 +41,7 @@ data class VideoContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo(
|
||||
media.fileId,
|
||||
toMarkdownCaption(),
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
media.width,
|
||||
media.height,
|
||||
|
@ -11,7 +11,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class VoiceContent(
|
||||
override val media: VoiceFile,
|
||||
@ -27,7 +27,7 @@ data class VoiceContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
null,
|
||||
toMarkdownCaption(),
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
media.duration,
|
||||
disableNotification,
|
||||
|
@ -55,7 +55,11 @@ fun createMarkdownText(
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Deprecated because old version have problem with long texts, but new one must return list of strings"
|
||||
"Deprecated because old version have problem with long texts, but new one must return list of strings",
|
||||
ReplaceWith(
|
||||
"toMarkdownCaptions().firstOrNull()",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions"
|
||||
)
|
||||
)
|
||||
fun CaptionedMediaContent.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull()
|
||||
|
||||
@ -69,7 +73,11 @@ fun CaptionedMediaContent.fullEntitiesList(): List<MessageEntity> = caption ?.le
|
||||
} ?: emptyList()
|
||||
|
||||
@Deprecated(
|
||||
"Deprecated because old version have problem with long texts, but new one must return list of strings"
|
||||
"Deprecated because old version have problem with long texts, but new one must return list of strings",
|
||||
ReplaceWith(
|
||||
"toMarkdownTexts().first()",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts"
|
||||
)
|
||||
)
|
||||
fun TextContent.toMarkdownText(): String = toMarkdownTexts().first()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user