From f99873dd70f6f0c9e0ba3042179a490dc3c59bdc Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 20 Jan 2020 22:10:46 +0600 Subject: [PATCH] hotfix --- .../insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt index 9b8825ca0e..d031cc25f4 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/LinksFormatting.kt @@ -15,6 +15,7 @@ fun makeLinkToMessage( ): String = "$internalLinkBeginning/$username/$messageId" private val linkIdRedundantPartRegex = Regex("^-100") +private val usernameBeginSymbolRegex = Regex("^@") @PreviewFeature fun makeLinkToMessage( @@ -22,7 +23,9 @@ fun makeLinkToMessage( messageId: MessageIdentifier ): String? { return when { - chat is UsernameChat && chat.username != null -> "$internalLinkBeginning/${chat.username ?.username}/$messageId" + chat is UsernameChat && chat.username != null -> { + "$internalLinkBeginning/${chat.username ?.username ?.replace(usernameBeginSymbolRegex, "")}/$messageId" + } chat !is PrivateChat -> chat.id.chatId.toString().replace( linkIdRedundantPartRegex, ""