mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-30 09:59:18 +00:00
Compare commits
3 Commits
05112afe0c
...
b1931900e7
| Author | SHA1 | Date | |
|---|---|---|---|
| b1931900e7 | |||
| fab3af48d6 | |||
| 8d7563b6e4 |
@@ -40,7 +40,7 @@ suspend fun BehaviourContext.waitCommandMessage(
|
||||
) = waitCommandMessage(Regex(command), initRequest, errorFactory)
|
||||
|
||||
fun Flow<CommonMessage<TextContent>>.requireCommandAtStart() = filter {
|
||||
(it.content.textSources.firstOrNull() as? BotCommandTextSource) != null
|
||||
it.content.textSources.firstOrNull() is BotCommandTextSource
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ fun Flow<CommonMessage<TextContent>>.requireSingleCommand() = filter {
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
count == 1
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.message.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.types.usernameRegex
|
||||
import dev.inmo.tgbotapi.types.Username
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -17,8 +18,8 @@ data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
|
||||
val command: String by lazy {
|
||||
commandRegex.find(source) ?.value ?.substring(1) ?: source.substring(1)// skip first symbol like "/" or "!"
|
||||
}
|
||||
val username: String? by lazy {
|
||||
usernameRegex.find(source) ?.value ?.substring(1) ?: source.substring(1)// skip first symbol "@"
|
||||
val username: Username? by lazy {
|
||||
Username(usernameRegex.find(source) ?.value ?: return@lazy null)
|
||||
}
|
||||
|
||||
override val markdown: String by lazy { source.commandMarkdown() }
|
||||
|
||||
Reference in New Issue
Block a user