mirror of
				https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git
				synced 2025-11-04 06:00:24 +00:00 
			
		
		
		
	Compare commits
	
		
			9 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| b4107cff26 | |||
| 23d68c9aa5 | |||
| 735e23cadb | |||
| 59b32f9b9a | |||
| b8601d4c90 | |||
| 240ee3de6f | |||
| 300ff6514b | |||
| ce85622876 | |||
| bd9e6045a3 | 
@@ -6,15 +6,15 @@ kotlin.incremental=true
 | 
				
			|||||||
kotlin.incremental.js=true
 | 
					kotlin.incremental.js=true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
kotlin_version=1.8.10
 | 
					kotlin_version=1.8.21
 | 
				
			||||||
kotlin_serialisation_core_version=1.5.0
 | 
					kotlin_serialisation_core_version=1.5.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
github_release_plugin_version=2.4.1
 | 
					github_release_plugin_version=2.4.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
tgbotapi_version=7.0.1
 | 
					tgbotapi_version=7.1.2
 | 
				
			||||||
micro_utils_version=0.17.5
 | 
					micro_utils_version=0.18.1
 | 
				
			||||||
exposed_version=0.41.1
 | 
					exposed_version=0.41.1
 | 
				
			||||||
plagubot_version=5.0.1
 | 
					plagubot_version=5.1.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Dokka
 | 
					# Dokka
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,4 +23,4 @@ dokka_version=1.8.10
 | 
				
			|||||||
# Project data
 | 
					# Project data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
group=dev.inmo
 | 
					group=dev.inmo
 | 
				
			||||||
version=0.10.1
 | 
					version=0.11.2
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
distributionBase=GRADLE_USER_HOME
 | 
					distributionBase=GRADLE_USER_HOME
 | 
				
			||||||
distributionPath=wrapper/dists
 | 
					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
 | 
					zipStoreBase=GRADLE_USER_HOME
 | 
				
			||||||
zipStorePath=wrapper/dists
 | 
					zipStorePath=wrapper/dists
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,8 @@ class MessagesResender(
 | 
				
			|||||||
) {
 | 
					) {
 | 
				
			||||||
    suspend fun resend(
 | 
					    suspend fun resend(
 | 
				
			||||||
        targetChatId: IdChatIdentifier,
 | 
					        targetChatId: IdChatIdentifier,
 | 
				
			||||||
        messagesInfo: List<MessageMetaInfo>
 | 
					        messagesInfo: List<MessageMetaInfo>,
 | 
				
			||||||
 | 
					        onBetweenMessages: suspend (sent: List<MessageMetaInfo>, toBeSent: List<MessageMetaInfo>) -> Unit
 | 
				
			||||||
    ): List<Pair<MessageMetaInfo, MessageMetaInfo>> {
 | 
					    ): List<Pair<MessageMetaInfo, MessageMetaInfo>> {
 | 
				
			||||||
        val messagesWithOrders = messagesInfo.mapIndexed { i, messageInfo -> messageInfo to i }.toMap()
 | 
					        val messagesWithOrders = messagesInfo.mapIndexed { i, messageInfo -> messageInfo to i }.toMap()
 | 
				
			||||||
        val ordersWithMessagesGroups = messagesInfo.groupBy { it.group }.flatMap { (group, list) ->
 | 
					        val ordersWithMessagesGroups = messagesInfo.groupBy { it.group }.flatMap { (group, list) ->
 | 
				
			||||||
@@ -29,9 +30,14 @@ class MessagesResender(
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }.sortedBy { it.first }
 | 
					        }.sortedBy { it.first }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        val sent = mutableListOf<MessageMetaInfo>()
 | 
				
			||||||
 | 
					        val leftToSend = ordersWithMessagesGroups.map { it.second }.toMutableList()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return ordersWithMessagesGroups.flatMap { (_, contents) ->
 | 
					        return ordersWithMessagesGroups.flatMap { (_, contents) ->
 | 
				
			||||||
            val sourceMessagesToSentMessages = mutableListOf<Pair<MessageMetaInfo, MessageMetaInfo>>()
 | 
					            val sourceMessagesToSentMessages = mutableListOf<Pair<MessageMetaInfo, MessageMetaInfo>>()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            onBetweenMessages(sent.toList(), leftToSend.flatten())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            when {
 | 
					            when {
 | 
				
			||||||
                contents.size == 1 -> {
 | 
					                contents.size == 1 -> {
 | 
				
			||||||
                    val messageInfo = contents.first()
 | 
					                    val messageInfo = contents.first()
 | 
				
			||||||
@@ -137,8 +143,15 @@ class MessagesResender(
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            leftToSend.takeIf { it.isNotEmpty() } ?.removeAt(0) ?.also {
 | 
				
			||||||
 | 
					                sent.addAll(it)
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            sourceMessagesToSentMessages.toList()
 | 
					            sourceMessagesToSentMessages.toList()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    suspend fun resend(
 | 
				
			||||||
 | 
					        targetChatId: IdChatIdentifier,
 | 
				
			||||||
 | 
					        messagesInfo: List<MessageMetaInfo>
 | 
				
			||||||
 | 
					    ): List<Pair<MessageMetaInfo, MessageMetaInfo>> = resend(targetChatId, messagesInfo) { _, _ -> }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user