mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
update content resends and different other things
This commit is contained in:
parent
2a89c41a58
commit
8d27349868
@ -74,3 +74,15 @@ fun AudioFile.toInputMediaAudio(
|
||||
title,
|
||||
thumb ?.fileId
|
||||
)
|
||||
|
||||
fun AudioFile.toInputMediaAudio(
|
||||
textSources: TextSourcesList = emptyList(),
|
||||
title: String? = this.title
|
||||
): InputMediaAudio = InputMediaAudio(
|
||||
fileId,
|
||||
textSources,
|
||||
duration,
|
||||
performer,
|
||||
title,
|
||||
thumb ?.fileId
|
||||
)
|
||||
|
@ -70,3 +70,11 @@ fun DocumentFile.toInputMediaDocument(
|
||||
parseMode,
|
||||
thumb ?.fileId
|
||||
)
|
||||
|
||||
fun DocumentFile.toInputMediaDocument(
|
||||
textSources: TextSourcesList = emptyList()
|
||||
) = InputMediaDocument(
|
||||
fileId,
|
||||
textSources,
|
||||
thumb ?.fileId
|
||||
)
|
||||
|
@ -53,3 +53,10 @@ fun PhotoSize.toInputMediaPhoto(
|
||||
caption,
|
||||
parseMode
|
||||
)
|
||||
|
||||
fun PhotoSize.toInputMediaPhoto(
|
||||
textSources: TextSourcesList = emptyList()
|
||||
): InputMediaPhoto = InputMediaPhoto(
|
||||
fileId,
|
||||
textSources
|
||||
)
|
||||
|
@ -39,8 +39,9 @@ typealias HTML = HTMLParseMode
|
||||
internal object ParseModeSerializerObject : KSerializer<ParseMode> {
|
||||
override fun deserialize(decoder: Decoder): ParseMode {
|
||||
return when (decoder.decodeString()) {
|
||||
MarkdownParseMode.parseModeName -> MarkdownParseMode
|
||||
HTMLParseMode.parseModeName -> HTMLParseMode
|
||||
Markdown.parseModeName -> Markdown
|
||||
MarkdownV2.parseModeName -> MarkdownV2
|
||||
HTML.parseModeName -> HTML
|
||||
else -> throw IllegalArgumentException("Unknown parse mode")
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.files
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo
|
||||
@ -44,3 +45,15 @@ inline fun VideoFile.toInputMediaVideo(
|
||||
duration,
|
||||
thumb ?.fileId
|
||||
)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun VideoFile.toInputMediaVideo(
|
||||
textSources: TextSourcesList
|
||||
) = InputMediaVideo(
|
||||
fileId,
|
||||
textSources,
|
||||
width,
|
||||
height,
|
||||
duration,
|
||||
thumb ?.fileId
|
||||
)
|
||||
|
@ -1,16 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.*
|
||||
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
|
||||
data class TextContent(
|
||||
override val text: String,
|
||||
@ -24,8 +23,7 @@ data class TextContent(
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<ContentMessage<TextContent>> = SendTextMessage(
|
||||
chatId,
|
||||
toHtmlTexts().first(),
|
||||
HTMLParseMode,
|
||||
textSources,
|
||||
false,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
@ -48,6 +46,10 @@ data class TextContent(
|
||||
HTMLParseMode
|
||||
)
|
||||
|
||||
@Deprecated(
|
||||
"Useless due to fact that createResend currently use textSource and that will guarantee correct sending of message",
|
||||
ReplaceWith("createResend")
|
||||
)
|
||||
fun createResends(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean,
|
||||
@ -55,20 +57,7 @@ data class TextContent(
|
||||
allowSendingWithoutReply: Boolean?,
|
||||
replyMarkup: KeyboardMarkup?,
|
||||
parseMode: ParseMode = HTMLParseMode
|
||||
): List<Request<ContentMessage<TextContent>>> = when (parseMode) {
|
||||
is MarkdownParseMode -> toMarkdownTexts()
|
||||
is MarkdownV2ParseMode -> toMarkdownV2Texts()
|
||||
is HTMLParseMode -> toHtmlTexts()
|
||||
}.map {
|
||||
SendTextMessage(
|
||||
chatId,
|
||||
it,
|
||||
parseMode,
|
||||
false,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
replyMarkup
|
||||
)
|
||||
}
|
||||
): List<Request<ContentMessage<TextContent>>> = listOf(
|
||||
createResend(chatId, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
)
|
||||
}
|
||||
|
@ -1,21 +1,16 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendAnimation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaAnimation
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.AnimationFile
|
||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
import dev.inmo.tgbotapi.utils.internal.toHtmlCaptions
|
||||
import dev.inmo.tgbotapi.utils.internal.toMarkdownV2Captions
|
||||
|
||||
data class AnimationContent(
|
||||
override val media: AnimationFile,
|
||||
@ -33,8 +28,7 @@ data class AnimationContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
textSources,
|
||||
media.duration,
|
||||
media.width,
|
||||
media.height,
|
||||
@ -46,8 +40,7 @@ data class AnimationContent(
|
||||
|
||||
override fun asInputMedia(): InputMediaAnimation = InputMediaAnimation(
|
||||
media.fileId,
|
||||
toMarkdownV2Captions().firstOrNull(),
|
||||
MarkdownV2,
|
||||
textSources,
|
||||
media.width,
|
||||
media.height,
|
||||
media.duration,
|
||||
|
@ -1,18 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.textSources
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio
|
||||
import dev.inmo.tgbotapi.types.InputMedia.toInputMediaAudio
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent
|
||||
import dev.inmo.tgbotapi.utils.internal.toHtmlCaptions
|
||||
|
||||
data class AudioContent(
|
||||
override val media: AudioFile,
|
||||
@ -29,8 +28,7 @@ data class AudioContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
textSources,
|
||||
media.duration,
|
||||
media.performer,
|
||||
media.title,
|
||||
@ -42,8 +40,5 @@ data class AudioContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): InputMediaAudio = asInputMedia()
|
||||
|
||||
override fun asInputMedia(): InputMediaAudio = media.toInputMediaAudio(
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode
|
||||
)
|
||||
override fun asInputMedia(): InputMediaAudio = media.toInputMediaAudio(textSources)
|
||||
}
|
||||
|
@ -1,21 +1,18 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendDocument
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument
|
||||
import dev.inmo.tgbotapi.types.InputMedia.toInputMediaDocument
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
||||
import dev.inmo.tgbotapi.types.files.asDocumentFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.DocumentMediaGroupContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
import dev.inmo.tgbotapi.utils.internal.toHtmlCaptions
|
||||
|
||||
data class DocumentContent(
|
||||
override val media: DocumentFile,
|
||||
@ -32,8 +29,7 @@ data class DocumentContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
textSources,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
@ -42,10 +38,7 @@ data class DocumentContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): InputMediaDocument = asInputMedia()
|
||||
|
||||
override fun asInputMedia(): InputMediaDocument = media.toInputMediaDocument(
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode
|
||||
)
|
||||
override fun asInputMedia(): InputMediaDocument = media.toInputMediaDocument(textSources)
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -1,19 +1,18 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.textSources
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendPhoto
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaPhoto
|
||||
import dev.inmo.tgbotapi.types.InputMedia.toInputMediaPhoto
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaCollectionContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.utils.internal.toHtmlCaptions
|
||||
|
||||
data class PhotoContent(
|
||||
override val mediaCollection: Photo,
|
||||
@ -31,8 +30,7 @@ data class PhotoContent(
|
||||
): Request<ContentMessage<PhotoContent>> = SendPhoto(
|
||||
chatId,
|
||||
media.fileId,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
textSources,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
allowSendingWithoutReply,
|
||||
@ -41,8 +39,5 @@ data class PhotoContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): InputMediaPhoto = asInputMedia()
|
||||
|
||||
override fun asInputMedia(): InputMediaPhoto = media.toInputMediaPhoto(
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode
|
||||
)
|
||||
override fun asInputMedia(): InputMediaPhoto = media.toInputMediaPhoto(textSources)
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.textSources
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVideo
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.VideoFile
|
||||
import dev.inmo.tgbotapi.types.files.toInputMediaVideo
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
|
||||
import dev.inmo.tgbotapi.utils.internal.toHtmlCaptions
|
||||
|
||||
data class VideoContent(
|
||||
override val media: VideoFile,
|
||||
@ -29,8 +28,7 @@ data class VideoContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
textSources,
|
||||
media.duration,
|
||||
media.width,
|
||||
media.height,
|
||||
@ -43,8 +41,5 @@ data class VideoContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): InputMediaVideo = asInputMedia()
|
||||
|
||||
override fun asInputMedia(): InputMediaVideo = media.toInputMediaVideo(
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode
|
||||
)
|
||||
override fun asInputMedia(): InputMediaVideo = media.toInputMediaVideo(textSources)
|
||||
}
|
||||
|
@ -1,20 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.media
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextPart
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVoice
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.HTMLParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.VoiceFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
import dev.inmo.tgbotapi.utils.internal.toHtmlCaptions
|
||||
import dev.inmo.tgbotapi.utils.internal.toMarkdownV2Captions
|
||||
|
||||
data class VoiceContent(
|
||||
override val media: VoiceFile,
|
||||
@ -30,8 +25,7 @@ data class VoiceContent(
|
||||
): Request<ContentMessage<VoiceContent>> = SendVoice(
|
||||
chatId,
|
||||
media.fileId,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
textSources,
|
||||
media.duration,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
@ -41,8 +35,7 @@ data class VoiceContent(
|
||||
|
||||
override fun asInputMedia(): InputMediaAudio = InputMediaAudio(
|
||||
media.fileId,
|
||||
toMarkdownV2Captions().firstOrNull(),
|
||||
MarkdownV2,
|
||||
textSources,
|
||||
media.duration
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user