From 02b5d282d3d751fa6909c0e7fe5cf1aa656b86ad Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 17 Feb 2023 15:31:40 +0600 Subject: [PATCH] now it is possible to handle send content message in handleLiveLocation --- .../extensions/api/LiveFlowLocation.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt index aa168e30d1..cc4c1e14bf 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt @@ -45,7 +45,8 @@ suspend fun TelegramBot.handleLiveLocation( disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + allowSendingWithoutReply: Boolean? = null, + sentMessageDeferred: CompletableDeferred>? = null ) { var currentLiveLocationMessage: ContentMessage? = null val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) { @@ -73,7 +74,9 @@ suspend fun TelegramBot.handleLiveLocation( replyToMessageId, allowSendingWithoutReply, it.replyMarkup - ) + ).also { + sentMessageDeferred ?.complete(it) + } } else { edit( capturedLiveLocationMessage, @@ -102,7 +105,8 @@ suspend fun TelegramBot.handleLiveLocation( disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + allowSendingWithoutReply: Boolean? = null, + sentMessageDeferred: CompletableDeferred>? = null ) { handleLiveLocation( chatId, @@ -121,7 +125,8 @@ suspend fun TelegramBot.handleLiveLocation( disableNotification, protectContent, replyToMessageId, - allowSendingWithoutReply + allowSendingWithoutReply, + sentMessageDeferred ) } @@ -139,7 +144,8 @@ suspend fun TelegramBot.handleLiveLocation( disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + allowSendingWithoutReply: Boolean? = null, + sentMessageDeferred: CompletableDeferred>? = null ) { handleLiveLocation( chatId, @@ -154,6 +160,7 @@ suspend fun TelegramBot.handleLiveLocation( disableNotification, protectContent, replyToMessageId, - allowSendingWithoutReply + allowSendingWithoutReply, + sentMessageDeferred ) }