commonMain.dev.inmo.tgbotapi.extensions.api.ForwardMessages.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tgbotapi.api-jvm Show documentation
Show all versions of tgbotapi.api-jvm Show documentation
API extensions with "Telegram Bot API"-like extensions for TelegramBot and RequestsExecutor
The newest version!
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.send.copyMessages
import dev.inmo.tgbotapi.requests.ForwardMessages
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlin.jvm.JvmName
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = messageIds.chunked(forwardMessagesLimit.last).flatMap {
execute(
ForwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = it,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
)
}
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds.toList(),
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messagesMetas: List,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) ->
forwardMessages(
toChatId = toChatId,
fromChatId = chatId,
messageIds = messages.map { it.messageId },
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
}
@JvmName("forwardMessagesWithMessages")
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messages: List,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = forwardMessages(
toChatId = toChatId,
messagesMetas = messages.map { it.metaInfo },
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messagesMetas: List,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = forwardMessages(
toChatId = toChatId,
messagesMetas = messagesMetas,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
@JvmName("forwardWithMessages")
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messages: List,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List = forwardMessages(
toChatId = toChatId,
messages = messages,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)