added `BehaviourContext.waitCommandMessage` supporting `BotCommand`
This commit is contained in:
parent
4f75bc792d
commit
81fbff0bf5
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue