mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-14 11:00:20 +00:00
add overloads for containsCommand
This commit is contained in:
@@ -31,24 +31,28 @@ suspend fun BehaviourContext.botInfo(): ExtendedBot? {
|
||||
}
|
||||
}
|
||||
|
||||
context(textSources: TextSourcesList, bc: BehaviourContext)
|
||||
suspend fun containsCommand(commandRegex: Regex) = textSources.any {
|
||||
suspend fun BehaviourContext.containsCommand(commandRegex: Regex, textSources: TextSourcesList) = textSources.any {
|
||||
val command = it.botCommandTextSourceOrNull() ?.takeIf {
|
||||
commandRegex.matches(it.command)
|
||||
} ?: return@any false
|
||||
if (command.username == null) {
|
||||
return@any true
|
||||
}
|
||||
val botInfo = bc.botInfo()
|
||||
val botInfo = botInfo()
|
||||
if (botInfo == null || command.username == botInfo.username) {
|
||||
return@any true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
context(textSources: TextSourcesList, bc: BehaviourContext)
|
||||
suspend fun containsCommand(commandRegex: Regex) = bc.containsCommand(commandRegex, textSources)
|
||||
|
||||
context(textSources: TextSourcesList, bc: BehaviourContext)
|
||||
suspend fun containsCommand(command: String) = containsCommand(Regex(command))
|
||||
|
||||
suspend fun BehaviourContext.containsCommand(command: String, textSources: TextSourcesList) = containsCommand(Regex(command), textSources)
|
||||
|
||||
@Warning("It is internal API and can be changed without notes")
|
||||
fun <BC : BehaviourContext, R, U : Update> CustomBehaviourContextAndTypeReceiver<BC, R, U>.withDefaultReceiver(
|
||||
data: BehaviourContextData
|
||||
|
||||
Reference in New Issue
Block a user