1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-16 13:49:26 +00:00

add waitCommands* expectations

This commit is contained in:
2022-08-24 15:03:54 +06:00
parent fff05a40d9
commit 9ea06de27c
5 changed files with 142 additions and 2 deletions

View File

@@ -81,6 +81,8 @@ sealed interface StickerType {
}
}
val usernameRegex = Regex("@[\\w\\d_]+")
val degreesLimit = 1 .. 360
val horizontalAccuracyLimit = 0F .. 1500F

View File

@@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.message.textsources
import dev.inmo.tgbotapi.types.usernameRegex
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable
@@ -16,6 +17,9 @@ 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 "@"
}
override val markdown: String by lazy { source.commandMarkdown() }
override val markdownV2: String by lazy { source.commandMarkdownV2() }