From b1931900e798332023dcded748d24aa1e5c702ee Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 25 Aug 2022 02:11:04 +0600 Subject: [PATCH] Update BotCommandTextSource.kt --- .../types/message/textsources/BotCommandTextSource.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BotCommandTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BotCommandTextSource.kt index e2d711ea66..bb143c5fe0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BotCommandTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BotCommandTextSource.kt @@ -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() }