mirror of
https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git
synced 2024-11-17 05:43:51 +00:00
commit
59b32f9b9a
@ -11,10 +11,10 @@ kotlin_serialisation_core_version=1.5.0
|
||||
|
||||
github_release_plugin_version=2.4.1
|
||||
|
||||
tgbotapi_version=7.0.2
|
||||
tgbotapi_version=7.1.0
|
||||
micro_utils_version=0.17.8
|
||||
exposed_version=0.41.1
|
||||
plagubot_version=5.0.2
|
||||
plagubot_version=5.1.0
|
||||
|
||||
# Dokka
|
||||
|
||||
@ -23,4 +23,4 @@ dokka_version=1.8.10
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.10.2
|
||||
version=0.11.0
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -16,7 +16,8 @@ class MessagesResender(
|
||||
) {
|
||||
suspend fun resend(
|
||||
targetChatId: IdChatIdentifier,
|
||||
messagesInfo: List<MessageMetaInfo>
|
||||
messagesInfo: List<MessageMetaInfo>,
|
||||
onBetweenMessages: suspend (sent: List<MessageMetaInfo>, toBeSent: List<MessageMetaInfo>) -> Unit
|
||||
): List<Pair<MessageMetaInfo, MessageMetaInfo>> {
|
||||
val messagesWithOrders = messagesInfo.mapIndexed { i, messageInfo -> messageInfo to i }.toMap()
|
||||
val ordersWithMessagesGroups = messagesInfo.groupBy { it.group }.flatMap { (group, list) ->
|
||||
@ -29,9 +30,14 @@ class MessagesResender(
|
||||
}
|
||||
}.sortedBy { it.first }
|
||||
|
||||
val sent = mutableListOf<MessageMetaInfo>()
|
||||
val leftToSend = ordersWithMessagesGroups.map { it.second }.toMutableList()
|
||||
|
||||
return ordersWithMessagesGroups.flatMap { (_, contents) ->
|
||||
val sourceMessagesToSentMessages = mutableListOf<Pair<MessageMetaInfo, MessageMetaInfo>>()
|
||||
|
||||
onBetweenMessages(sent.toList(), leftToSend.flatten())
|
||||
|
||||
when {
|
||||
contents.size == 1 -> {
|
||||
val messageInfo = contents.first()
|
||||
@ -137,8 +143,15 @@ class MessagesResender(
|
||||
}
|
||||
}
|
||||
|
||||
leftToSend.takeIf { it.isNotEmpty() } ?.removeAt(0) ?.also {
|
||||
sent.addAll(it)
|
||||
}
|
||||
sourceMessagesToSentMessages.toList()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
suspend fun resend(
|
||||
targetChatId: IdChatIdentifier,
|
||||
messagesInfo: List<MessageMetaInfo>
|
||||
): List<Pair<MessageMetaInfo, MessageMetaInfo>> = resend(targetChatId, messagesInfo) { _, _ -> }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user