1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00

added BehaviourContext.waitCommandMessage supporting BotCommand

This commit is contained in:
d1snin 2022-10-19 22:15:15 +03:00
parent 4f75bc792d
commit 81fbff0bf5
No known key found for this signature in database
GPG Key ID: 2B2D54531207CA16

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration
import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
@ -39,6 +40,12 @@ suspend fun BehaviourContext.waitCommandMessage(
errorFactory: NullableRequestBuilder<*> = { null }
) = waitCommandMessage(Regex(command), initRequest, errorFactory)
suspend fun BehaviourContext.waitCommandMessage(
botCommand: BotCommand,
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitCommandMessage(botCommand.command, initRequest, errorFactory)
fun Flow<CommonMessage<TextContent>>.requireCommandAtStart() = filter {
it.content.textSources.firstOrNull() is BotCommandTextSource
}