mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 03:28:44 +00:00
Implemented paid media reply extension
This commit is contained in:
parent
a0fdebd13e
commit
05341be534
@ -26,6 +26,9 @@ import dev.inmo.tgbotapi.types.games.Game
|
||||
import dev.inmo.tgbotapi.types.location.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.payments.PaidMedia
|
||||
import dev.inmo.tgbotapi.types.message.payments.toTelegramMediaPhoto
|
||||
import dev.inmo.tgbotapi.types.message.payments.toTelegramPaidMediaVideo
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
@ -2045,3 +2048,43 @@ suspend fun TelegramBot.reply(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
content: PaidMediaInfoContent,
|
||||
replyInChatId: IdChatIdentifier = toChatId,
|
||||
replyInThreadId: MessageThreadId? = replyInChatId.threadId,
|
||||
replyInBusinessConnectionId: BusinessConnectionId? = replyInChatId.businessConnectionId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) {
|
||||
val media = content.paidMediaInfo.media.mapNotNull {
|
||||
when (it) {
|
||||
is PaidMedia.Video -> it.toTelegramPaidMediaVideo()
|
||||
is PaidMedia.Photo -> it.toTelegramMediaPhoto()
|
||||
is PaidMedia.Preview, is PaidMedia.Unknown -> null
|
||||
}
|
||||
}
|
||||
sendPaidMedia(
|
||||
chatId = replyInChatId,
|
||||
starCount = content.paidMediaInfo.stars,
|
||||
media = media,
|
||||
text = content.text,
|
||||
parseMode = parseMode,
|
||||
showCaptionAboveMedia = content.showCaptionAboveMedia,
|
||||
threadId = replyInThreadId,
|
||||
businessConnectionId = replyInBusinessConnectionId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
replyMarkup = replyMarkup,
|
||||
replyParameters = ReplyParameters(
|
||||
messageId = toMessageId,
|
||||
chatIdentifier = toChatId,
|
||||
allowSendingWithoutReply = allowSendingWithoutReply
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package dev.inmo.tgbotapi.types.message.payments
|
||||
|
||||
import dev.inmo.tgbotapi.types.media.TelegramMediaPhoto
|
||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMedia
|
||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMediaPhoto
|
||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMediaVideo
|
||||
|
||||
fun PaidMedia.toTelegramPaidMedia(): TelegramPaidMedia? = when (this) {
|
||||
is PaidMedia.Photo -> TelegramPaidMediaPhoto(
|
||||
file = this.photo.biggest.fileId
|
||||
)
|
||||
is PaidMedia.Video -> TelegramPaidMediaPhoto(
|
||||
file = this.video.fileId
|
||||
)
|
||||
is PaidMedia.Preview, is PaidMedia.Unknown -> null
|
||||
}
|
||||
|
||||
fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = TelegramPaidMediaVideo(
|
||||
file = this.video.fileId,
|
||||
duration = this.video.duration
|
||||
)
|
||||
|
||||
fun PaidMedia.Photo.toTelegramMediaPhoto(): TelegramPaidMediaPhoto = TelegramPaidMediaPhoto(
|
||||
file = this.photo.fileId
|
||||
)
|
Loading…
Reference in New Issue
Block a user