1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

add ReplaceWith to old functions and replace built-in usages of deprecations

This commit is contained in:
InsanusMokrassar 2019-02-10 13:46:23 +08:00
parent 1dc80f6929
commit d67d16c72d
7 changed files with 23 additions and 15 deletions

View File

@ -23,7 +23,7 @@ data class TextContent(
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendMessage( ): Request<RawMessage> = SendMessage(
chatId, chatId,
toMarkdownText(), toMarkdownTexts().first(),
MarkdownParseMode, MarkdownParseMode,
false, false,
disableNotification, disableNotification,

View File

@ -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.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent 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.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
data class AudioContent( data class AudioContent(
override val media: AudioFile, override val media: AudioFile,
@ -27,7 +27,7 @@ data class AudioContent(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,
toMarkdownCaption(), toMarkdownCaptions().firstOrNull(),
MarkdownParseMode, MarkdownParseMode,
media.duration, media.duration,
media.performer, media.performer,

View File

@ -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.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent 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.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
data class DocumentContent( data class DocumentContent(
override val media: DocumentFile, override val media: DocumentFile,
@ -27,7 +27,7 @@ data class DocumentContent(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,
toMarkdownCaption(), toMarkdownCaptions().firstOrNull(),
MarkdownParseMode, MarkdownParseMode,
disableNotification, disableNotification,
replyToMessageId, replyToMessageId,

View File

@ -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.files.biggest
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.* 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( data class PhotoContent(
override val media: List<PhotoSize>, override val media: List<PhotoSize>,
@ -28,7 +28,7 @@ data class PhotoContent(
): Request<RawMessage> = SendPhoto( ): Request<RawMessage> = SendPhoto(
chatId, chatId,
media.biggest() ?.fileId ?: throw IllegalStateException("Empty list of media"), media.biggest() ?.fileId ?: throw IllegalStateException("Empty list of media"),
toMarkdownCaption(), toMarkdownCaptions().firstOrNull(),
MarkdownParseMode, MarkdownParseMode,
disableNotification, disableNotification,
replyToMessageId, replyToMessageId,
@ -37,7 +37,7 @@ data class PhotoContent(
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto( override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto(
media.biggest() ?.fileId ?: throw IllegalStateException("Can't locate any photo size for this content"), media.biggest() ?.fileId ?: throw IllegalStateException("Can't locate any photo size for this content"),
toMarkdownCaption(), toMarkdownCaptions().firstOrNull(),
MarkdownParseMode MarkdownParseMode
) )
} }

View File

@ -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.files.VideoFile
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.* 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( data class VideoContent(
override val media: VideoFile, override val media: VideoFile,
@ -28,7 +28,7 @@ data class VideoContent(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,
toMarkdownCaption(), toMarkdownCaptions().firstOrNull(),
MarkdownParseMode, MarkdownParseMode,
media.duration, media.duration,
media.width, media.width,
@ -41,7 +41,7 @@ data class VideoContent(
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo( override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo(
media.fileId, media.fileId,
toMarkdownCaption(), toMarkdownCaptions().firstOrNull(),
MarkdownParseMode, MarkdownParseMode,
media.width, media.width,
media.height, media.height,

View File

@ -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.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent 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.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
data class VoiceContent( data class VoiceContent(
override val media: VoiceFile, override val media: VoiceFile,
@ -27,7 +27,7 @@ data class VoiceContent(
chatId, chatId,
media.fileId, media.fileId,
null, null,
toMarkdownCaption(), toMarkdownCaptions().firstOrNull(),
MarkdownParseMode, MarkdownParseMode,
media.duration, media.duration,
disableNotification, disableNotification,

View File

@ -55,7 +55,11 @@ fun createMarkdownText(
} }
@Deprecated( @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() fun CaptionedMediaContent.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull()
@ -69,7 +73,11 @@ fun CaptionedMediaContent.fullEntitiesList(): List<MessageEntity> = caption ?.le
} ?: emptyList() } ?: emptyList()
@Deprecated( @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() fun TextContent.toMarkdownText(): String = toMarkdownTexts().first()