mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-02 06:39:41 +00:00
fixes
This commit is contained in:
@@ -19,5 +19,5 @@ suspend fun BehaviourContext.waitDeepLinks(
|
||||
.requireSingleCommand()
|
||||
.requireCommandAtStart()
|
||||
.flattenCommandsWithParams().mapNotNull {
|
||||
it.first to (it.second.second.singleOrNull() ?.regularTextSourceOrNull() ?.source ?: return@mapNotNull null)
|
||||
it.first to (it.second.second.singleOrNull() ?.regularTextSourceOrNull() ?.source ?.removePrefix(" ") ?: return@mapNotNull null)
|
||||
}
|
||||
|
@@ -17,9 +17,11 @@ import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.content.TextMessage
|
||||
import dev.inmo.tgbotapi.types.message.textsources.RegularTextSource
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import io.ktor.http.decodeURLQueryComponent
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.filter
|
||||
|
||||
private val startRegex = Regex("start")
|
||||
suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||
initialFilter: SimpleFilter<Pair<TextMessage, String>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, Pair<TextMessage, String>, Update> = { (message, _), update -> MessageFilterByChat(this, message, update) },
|
||||
@@ -36,6 +38,11 @@ suspend fun <BC : BehaviourContext> BC.onDeepLink(
|
||||
scenarioReceiver,
|
||||
) {
|
||||
(it.messageUpdateOrNull()) ?.data ?.commonMessageOrNull() ?.withContentOrNull<TextContent>() ?.let { message ->
|
||||
message to message.content.textSources[1].source
|
||||
message to message.content.textSources[1].source.removePrefix(" ").decodeURLQueryComponent()
|
||||
} ?.let(::listOfNotNull)
|
||||
}.also {
|
||||
triggersHolder.handleableCommandsHolder.registerHandleable(startRegex)
|
||||
it.invokeOnCompletion {
|
||||
this@onDeepLink.launchSafelyWithoutExceptions { triggersHolder.handleableCommandsHolder.unregisterHandleable(startRegex) }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user