mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
addopportunity to copy messages using just content
This commit is contained in:
parent
a615d1c4fd
commit
24bffbbd97
@ -22,7 +22,7 @@ import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
||||
messages: List<MediaGroupContent>,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
@ -30,7 +30,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
): List<MediaGroupMessage<MediaGroupContent>> {
|
||||
val first = messages.first().content.toMediaGroupMemberInputMedia().let {
|
||||
val first = messages.first().toMediaGroupMemberInputMedia().let {
|
||||
if (text != null) {
|
||||
when (it) {
|
||||
is InputMediaAudio -> it.copy(text = text, parseMode = parseMode)
|
||||
@ -46,7 +46,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
return sendMediaGroup(
|
||||
toChatId,
|
||||
listOf(first) + messages.drop(1).map {
|
||||
it.content.toMediaGroupMemberInputMedia()
|
||||
it.toMediaGroupMemberInputMedia()
|
||||
},
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@ -55,6 +55,21 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
||||
* will be copied as they are
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChatId, messages.map { it.content }, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
/**
|
||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
||||
* will be copied as they are
|
||||
@ -106,14 +121,14 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
||||
messages: List<MediaGroupContent>,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
): List<MediaGroupMessage<MediaGroupContent>> {
|
||||
val first = messages.first().content.toMediaGroupMemberInputMedia().let {
|
||||
val first = messages.first().toMediaGroupMemberInputMedia().let {
|
||||
when (it) {
|
||||
is InputMediaAudio -> InputMediaAudio(it.file, entities, it.duration, it.performer, it.title, it.thumb)
|
||||
is InputMediaDocument -> InputMediaDocument(it.file, entities, it.thumb, it.disableContentTypeDetection)
|
||||
@ -125,7 +140,7 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
return sendMediaGroup(
|
||||
toChatId,
|
||||
listOf(first) + messages.drop(1).map {
|
||||
it.content.toMediaGroupMemberInputMedia()
|
||||
it.toMediaGroupMemberInputMedia()
|
||||
},
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@ -134,6 +149,20 @@ suspend inline fun TelegramBot.copyMessages(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
||||
* will be copied as they are
|
||||
*/
|
||||
suspend inline fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
messages: List<MediaGroupMessage<MediaGroupContent>>,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null
|
||||
) = copyMessages(toChatId, messages.map { it.content }, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
|
||||
|
||||
/**
|
||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
||||
* will be copied as they are
|
||||
|
Loading…
Reference in New Issue
Block a user