commonMain.dev.inmo.tgbotapi.extensions.api.DeleteMessages.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tgbotapi.api Show documentation
Show all versions of tgbotapi.api Show documentation
API extensions with "Telegram Bot API"-like extensions for TelegramBot and RequestsExecutor
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.DeleteMessages
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.deleteMessages(
chatId: ChatIdentifier,
messageIds: List
): Boolean = messageIds.chunked(deleteMessagesLimit.last).map {
execute(
DeleteMessages(
chatId = chatId,
messageIds = it
)
)
}.all { it }
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: Array
): Boolean = deleteMessages(
chatId = chatId,
messageIds = messageIds.toList()
)
public suspend fun TelegramBot.deleteMessages(
messagesMetas: List
): Boolean = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) ->
deleteMessages(
chatId = chatId,
messageIds = messages.map { it.messageId }
)
}.all { it }
@JvmName("deleteMessagesWithMessages")
public suspend fun TelegramBot.deleteMessages(
messages: List
): Boolean = deleteMessages(messages.map { it.metaInfo })
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: List
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: Array
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
messagesMetas: List
): Boolean = deleteMessages(messagesMetas)
@JvmName("deleteWithMessages")
public suspend fun TelegramBot.delete(
messages: List
): Boolean = deleteMessages(messages)