1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-03 23:29:33 +00:00

potentially cover new update of Bot API

This commit is contained in:
2025-02-14 21:01:47 +06:00
parent 7d3e9325f1
commit d4490dec75
21 changed files with 199 additions and 16 deletions

View File

@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.ForwardMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.Seconds
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
@@ -15,10 +16,11 @@ public suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = execute(
ForwardMessage(fromChatId, toChatId, messageId, threadId, disableNotification, protectContent)
ForwardMessage(fromChatId, toChatId, messageId, threadId, startTimestamp, disableNotification, protectContent)
)
public suspend fun TelegramBot.forwardMessage(
@@ -26,40 +28,45 @@ public suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChatId, messageId, threadId, startTimestamp, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(fromChatId, toChat.id, messageId, threadId, startTimestamp, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChat.id, messageId, threadId, startTimestamp, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
message: AccessibleMessage,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(message.chat, toChatId, message.messageId, threadId, startTimestamp, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
toChat: Chat,
message: AccessibleMessage,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(message.chat, toChat, message.messageId, threadId, startTimestamp, disableNotification, protectContent)

View File

@@ -21,6 +21,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -35,6 +36,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -55,6 +57,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -68,6 +71,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -87,6 +91,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -100,6 +105,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -119,6 +125,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -132,6 +139,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -151,6 +159,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -164,6 +173,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -183,6 +193,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -195,6 +206,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -213,6 +225,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -225,6 +238,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -243,6 +257,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -255,6 +270,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -273,6 +289,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -286,6 +303,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -304,6 +322,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -317,6 +336,7 @@ public suspend inline fun TelegramBot.copyMessage(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -334,6 +354,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -346,6 +367,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -363,6 +385,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChat.id.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -375,6 +398,7 @@ public suspend inline fun TelegramBot.copyMessage(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,

View File

@@ -25,6 +25,8 @@ public suspend fun TelegramBot.sendVideo(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false,
cover: InputFile? = null,
startTimestamp: Seconds? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -45,6 +47,8 @@ public suspend fun TelegramBot.sendVideo(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
spoilered = spoilered,
cover = cover,
startTimestamp = startTimestamp,
duration = duration,
width = width,
height = height,
@@ -87,6 +91,8 @@ public suspend fun TelegramBot.sendVideo(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
spoilered = spoilered,
cover = video.cover ?.fileId,
startTimestamp = video.startTimestamp,
duration = video.duration,
width = video.width,
height = video.height,
@@ -112,6 +118,8 @@ public suspend fun TelegramBot.sendVideo(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false,
cover: InputFile? = null,
startTimestamp: Seconds? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -131,6 +139,8 @@ public suspend fun TelegramBot.sendVideo(
parseMode = parseMode,
showCaptionAboveMedia = showCaptionAboveMedia,
spoilered = spoilered,
cover = cover,
startTimestamp = startTimestamp,
duration = duration,
width = width,
height = height,
@@ -192,6 +202,8 @@ public suspend inline fun TelegramBot.sendVideo(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false,
cover: InputFile? = null,
startTimestamp: Seconds? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -211,6 +223,8 @@ public suspend inline fun TelegramBot.sendVideo(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
spoilered = spoilered,
cover = cover,
startTimestamp = startTimestamp,
duration = duration,
width = width,
height = height,
@@ -251,6 +265,8 @@ public suspend inline fun TelegramBot.sendVideo(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
spoilered = spoilered,
cover = video.cover ?.fileId,
startTimestamp = video.startTimestamp,
duration = video.duration,
width = video.width,
height = video.height,
@@ -275,6 +291,8 @@ public suspend inline fun TelegramBot.sendVideo(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false,
cover: InputFile? = null,
startTimestamp: Seconds? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -293,6 +311,8 @@ public suspend inline fun TelegramBot.sendVideo(
entities = entities,
showCaptionAboveMedia = showCaptionAboveMedia,
spoilered = spoilered,
cover = cover,
startTimestamp = startTimestamp,
duration = duration,
width = width,
height = height,

View File

@@ -0,0 +1,8 @@
package dev.inmo.tgbotapi.abstracts
import dev.inmo.tgbotapi.types.files.Photo
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
interface CoverableData {
val cover: Photo?
}

View File

@@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.abstracts
import dev.inmo.tgbotapi.types.Seconds
interface WithCustomStartMediaData {
val startTimestamp: Seconds?
}

View File

@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.requests
import dev.inmo.tgbotapi.abstracts.WithCustomStartMediaData
import dev.inmo.tgbotapi.abstracts.types.MessageAction
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
@@ -21,11 +22,13 @@ data class ForwardMessage(
override val messageId: MessageId,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = toChatId.threadId,
@SerialName(videoStartTimestampField)
override val startTimestamp: Seconds? = null,
@SerialName(disableNotificationField)
val disableNotification: Boolean = false,
@SerialName(protectContentField)
override val protectContent: Boolean = false
): SimpleRequest<PossiblyForwardedMessage>, MessageAction, ProtectContent, OptionallyMessageThreadRequest {
): SimpleRequest<PossiblyForwardedMessage>, MessageAction, ProtectContent, OptionallyMessageThreadRequest, WithCustomStartMediaData {
override val chatId: ChatIdentifier
get() = fromChatId

View File

@@ -5,4 +5,11 @@ import kotlinx.serialization.json.JsonObject
interface MultipartRequest<T: Any> : Request<T> {
val paramsJson: JsonObject
val mediaMap: Map<String, MultipartFile>
interface Common<T : Any> : MultipartRequest<T>, SimpleRequest<T> {
val data: SimpleRequest<T>
override val paramsJson: JsonObject
get() = data.json()
}
}

View File

@@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.requests.send
import dev.inmo.tgbotapi.abstracts.TextedOutput
import dev.inmo.tgbotapi.abstracts.WithCustomStartMediaData
import dev.inmo.tgbotapi.abstracts.WithCustomizableCaption
import dev.inmo.tgbotapi.abstracts.types.MessageAction
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
@@ -89,6 +90,7 @@ fun CopyMessage(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -103,6 +105,7 @@ fun CopyMessage(
rawEntities = null,
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -117,6 +120,7 @@ fun CopyMessage(
entities: List<TextSource>,
showCaptionAboveMedia: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
startTimestamp: Seconds? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowPaidBroadcast: Boolean = false,
@@ -131,6 +135,7 @@ fun CopyMessage(
rawEntities = entities.toRawMessageEntities(),
showCaptionAboveMedia = showCaptionAboveMedia,
threadId = threadId,
startTimestamp = startTimestamp,
disableNotification = disableNotification,
protectContent = protectContent,
allowPaidBroadcast = allowPaidBroadcast,
@@ -156,6 +161,8 @@ data class CopyMessage internal constructor(
override val showCaptionAboveMedia: Boolean = false,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = toChatId.threadId,
@SerialName(videoStartTimestampField)
override val startTimestamp: Seconds? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)
@@ -172,7 +179,8 @@ data class CopyMessage internal constructor(
MessageAction,
TextedOutput,
ProtectContent,
OptionallyMessageThreadRequest {
OptionallyMessageThreadRequest,
WithCustomStartMediaData {
override val chatId: ChatIdentifier
get() = fromChatId
override val textSources: List<TextSource>? by lazy {

View File

@@ -0,0 +1,10 @@
package dev.inmo.tgbotapi.requests.send.abstracts
import dev.inmo.tgbotapi.requests.abstracts.FileId
interface CoveredSendMessageRequest<T: Any>: SendMessageRequest<T> {
/**
* Duration of media, usually in seconds
*/
val cover: String?
}

View File

@@ -51,6 +51,11 @@ fun <T : MediaGroupPartContent> SendMediaGroup(
it.thumb as? MultipartFile
} else {
null
},
if (it is CoveredTelegramMedia) {
it.cover as? MultipartFile
} else {
null
}
)
}

View File

@@ -12,6 +12,7 @@ import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.parseModeField
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.media.CoveredTelegramMedia
import dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.RawMessageEntity
@@ -63,6 +64,11 @@ fun SendPaidMedia(
it.thumb as? MultipartFile
} else {
null
},
if (it is CoveredTelegramMedia) {
it.cover as? MultipartFile
} else {
null
}
)
}
@@ -117,6 +123,11 @@ fun SendPaidMedia(
it.thumb as? MultipartFile
} else {
null
},
if (it is CoveredTelegramMedia) {
it.cover as? MultipartFile
} else {
null
}
)
}

View File

@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.requests.send.media
import dev.inmo.tgbotapi.abstracts.WithCustomStartMediaData
import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.send.abstracts.*
@@ -29,6 +30,8 @@ fun SendVideo(
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false,
cover: InputFile? = null,
startTimestamp: Seconds? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -44,11 +47,14 @@ fun SendVideo(
): Request<ContentMessage<VideoContent>> {
val videoAsFile = video as? MultipartFile
val thumbAsFile = thumbnail as? MultipartFile
val coverAsFile = cover as? MultipartFile
val data = SendVideoData(
chatId = chatId,
video = video,
thumbnail = thumbnail ?.fileId,
cover = cover ?.fileId,
startTimestamp = startTimestamp,
text = text,
parseMode = parseMode,
rawEntities = null,
@@ -68,12 +74,12 @@ fun SendVideo(
replyMarkup = replyMarkup
)
return if (videoAsFile == null && thumbAsFile == null) {
return if (videoAsFile == null && thumbAsFile == null && coverAsFile == null) {
data
} else {
CommonMultipartFileRequest(
data,
listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId }
listOfNotNull(videoAsFile, thumbAsFile, coverAsFile).associateBy { it.fileId }
)
}
}
@@ -85,6 +91,8 @@ fun SendVideo(
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false,
cover: InputFile? = null,
startTimestamp: Seconds? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -100,11 +108,14 @@ fun SendVideo(
): Request<ContentMessage<VideoContent>> {
val videoAsFile = video as? MultipartFile
val thumbAsFile = thumbnail as? MultipartFile
val coverAsFile = cover as? MultipartFile
val data = SendVideoData(
chatId = chatId,
video = video,
thumbnail = thumbnail ?.fileId,
cover = cover ?.fileId,
startTimestamp = startTimestamp,
text = entities.makeString(),
parseMode = null,
rawEntities = entities.toRawMessageEntities(),
@@ -124,12 +135,12 @@ fun SendVideo(
replyMarkup = replyMarkup
)
return if (videoAsFile == null && thumbAsFile == null) {
return if (videoAsFile == null && thumbAsFile == null && coverAsFile == null) {
data
} else {
CommonMultipartFileRequest(
data,
listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId }
listOfNotNull(videoAsFile, thumbAsFile, coverAsFile).associateBy { it.fileId }
)
}
}
@@ -145,6 +156,10 @@ data class SendVideoData internal constructor(
val video: InputFile,
@SerialName(thumbnailField)
override val thumbnail: String? = null,
@SerialName(coverField)
override val cover: String? = null,
@SerialName(startTimestampField)
override val startTimestamp: Seconds? = null,
@SerialName(captionField)
override val text: String? = null,
@SerialName(parseModeField)
@@ -187,6 +202,8 @@ data class SendVideoData internal constructor(
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
SizedSendMessageRequest<ContentMessage<VideoContent>>,
WithCustomizableCaptionRequest<ContentMessage<VideoContent>>,
CoveredSendMessageRequest<ContentMessage<VideoContent>>,
WithCustomStartMediaData,
OptionallyWithSpoilerRequest
{
override val textSources: TextSourcesList? by lazy {

View File

@@ -315,6 +315,9 @@ const val userAdministratorRightsField = "user_administrator_rights"
const val botAdministratorRightsField = "bot_administrator_rights"
const val botIsMemberField = "bot_is_member"
const val startTimestampField = "start_timestamp"
const val videoStartTimestampField = "video_start_timestamp"
const val fileNameField = "file_name"
const val mimeTypeField = "mime_type"
const val fileIdField = "file_id"
@@ -424,6 +427,7 @@ const val idField = "id"
const val pollIdField = "poll_id"
const val textField = "text"
const val thumbnailField = "thumbnail"
const val coverField = "cover"
const val emojiField = "emoji"
const val emojisField = "emojis"
const val titleField = "title"

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.abstracts.CoverableData
sealed interface CoveredMediaFile : TelegramMediaFile, CoverableData

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.abstracts.WithCustomStartMediaData
sealed interface CustomStartMediaFile : WithCustomStartMediaData

View File

@@ -24,13 +24,17 @@ data class VideoFile(
override val duration: Long? = null,
@SerialName(thumbnailField)
override val thumbnail: PhotoSize? = null,
@SerialName(coverField)
override val cover: Photo? = null,
@SerialName(startTimestampField)
override val startTimestamp: Seconds? = null,
@SerialName(fileNameField)
override val fileName: String? = null,
@SerialName(mimeTypeField)
override val mimeType: MimeType? = null,
@SerialName(fileSizeField)
override val fileSize: Long? = null
) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile,
) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, CoveredMediaFile, CustomStartMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile,
MediaContentVariant, UsefulAsPaidMediaFile
@Suppress("NOTHING_TO_INLINE")

View File

@@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.requests.abstracts.InputFile
sealed interface CoveredTelegramMedia : TelegramMedia {
val cover: InputFile?
}

View File

@@ -1,6 +1,8 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.MultipartRequest
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
@@ -70,13 +72,23 @@ data class TelegramMediaVideo internal constructor (
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(hasSpoilerField)
override val spoilered: Boolean = false,
@SerialName(coverField)
override val cover: InputFile? = null,
@SerialName(startTimestampField)
override val startTimestamp: Seconds? = null,
@SerialName(showCaptionAboveMediaField)
override val showCaptionAboveMedia: Boolean = false,
override val width: Int? = null,
override val height: Int? = null,
override val duration: Long? = null,
override val thumb: InputFile? = null
) : TelegramFreeMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, VisualMediaGroupMemberTelegramMedia {
) : TelegramFreeMedia,
SizedTelegramMedia,
DuratedTelegramMedia,
ThumbedTelegramMedia,
CoveredTelegramMedia,
WithCustomStartTelegramMedia,
VisualMediaGroupMemberTelegramMedia {
override val type: String = videoTelegramMediaType
override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@@ -18,7 +18,16 @@ data class TelegramPaidMediaVideo (
override val duration: Long? = null,
@SerialName(supportsStreamingField)
val supportsStreaming: Boolean = false,
) : VisualTelegramPaidMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia {
@SerialName(coverField)
override val cover: InputFile? = null,
@SerialName(startTimestampField)
override val startTimestamp: Seconds? = null,
) : VisualTelegramPaidMedia,
SizedTelegramMedia,
DuratedTelegramMedia,
ThumbedTelegramMedia,
CoveredTelegramMedia,
WithCustomStartTelegramMedia {
override val type: String = videoTelegramPaidMediaType
@SerialName(mediaField)
@@ -31,7 +40,9 @@ fun VideoFile.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = TelegramPaidM
thumb = thumbnail ?.fileId,
width = width,
height = height,
duration = duration
duration = duration,
cover = cover ?.fileId,
startTimestamp = startTimestamp,
)
fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = video.toTelegramPaidMediaVideo()

View File

@@ -0,0 +1,6 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.abstracts.WithCustomStartMediaData
import dev.inmo.tgbotapi.requests.abstracts.FileId
sealed interface WithCustomStartTelegramMedia : TelegramMedia, WithCustomStartMediaData

View File

@@ -38,6 +38,8 @@ data class VideoContent(
entities = textSources,
showCaptionAboveMedia = showCaptionAboveMedia,
spoilered = spoilered,
cover = media.cover ?.fileId,
startTimestamp = media.startTimestamp,
duration = media.duration,
width = media.width,
height = media.height,