mirror of
https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git
synced 2025-10-26 17:50:20 +00:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82d859272f | |||
| 64952fb054 | |||
| bd4e3d2380 | |||
| d77e08631c | |||
| 90e063a47a | |||
| a988117037 | |||
| 50d8511db5 | |||
| cf5b02057d | |||
| 64305c9393 | |||
| b4107cff26 | |||
| 23d68c9aa5 | |||
| 735e23cadb | |||
| 59b32f9b9a | |||
| b8601d4c90 | |||
| 240ee3de6f | |||
| 300ff6514b | |||
| ce85622876 | |||
| bd9e6045a3 | |||
| e8a41d97e8 | |||
| e2e329a757 | |||
| c69dd61eb9 | |||
| cf13bfadde | |||
| 6e33649e6c | |||
| 40dd4b166f | |||
| 95adaef36f | |||
| 8386690090 |
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.libraries.cache.admins
|
||||
|
||||
import com.soywiz.klock.minutes
|
||||
import korlibs.time.minutes
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.libraries.cache.admins
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||
import dev.inmo.tgbotapi.extensions.api.chat.members.getChatMember
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.libraries.cache.admins.micro_utils
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.tgbotapi.libraries.cache.admins.DefaultAdminsCacheAPIRepo
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.libraries.cache.media.common
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.milliseconds
|
||||
import korlibs.time.DateTime
|
||||
import korlibs.time.milliseconds
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.DeleteMessage
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
|
||||
@@ -6,21 +6,21 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
|
||||
kotlin_version=1.8.10
|
||||
kotlin_serialisation_core_version=1.5.0
|
||||
kotlin_version=1.8.21
|
||||
kotlin_serialisation_core_version=1.5.1
|
||||
|
||||
github_release_plugin_version=2.4.1
|
||||
|
||||
tgbotapi_version=6.0.2
|
||||
micro_utils_version=0.17.1
|
||||
tgbotapi_version=8.0.1
|
||||
micro_utils_version=0.19.2
|
||||
exposed_version=0.41.1
|
||||
plagubot_version=4.0.2
|
||||
plagubot_version=6.0.1
|
||||
|
||||
# Dokka
|
||||
|
||||
dokka_version=1.7.20
|
||||
dokka_version=1.8.10
|
||||
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.9.2
|
||||
version=0.12.1
|
||||
|
||||
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) { _, _ -> }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user