1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00
This commit is contained in:
InsanusMokrassar 2020-01-20 22:10:46 +06:00
parent d330cd2bfc
commit f99873dd70

View File

@ -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,
""