diff --git a/CHANGELOG.md b/CHANGELOG.md index 599c7d0ffc..5c9e146bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,8 @@ * `TelegramBotAPI`: * `UnknownUpdateType` was renamed to `UnknownUpdate` * Refactoring and optimization of `FlowsUpdatesFilter` +* `TelegramBotAPI-extensions-utils`: + * Several new functions `makeLinkToMessage` was added ### 0.27.7 diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt index 1bd86d26d5..3959d7a9b2 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt @@ -1,8 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting -import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.* -import com.github.insanusmokrassar.TelegramBotAPI.types.StickerSetName import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UsernameChat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat @@ -14,6 +13,14 @@ fun makeLinkToMessage( username: String, messageId: MessageIdentifier ): String = "$internalLinkBeginning/$username/$messageId" +fun makeLinkToMessage( + username: Username, + messageId: MessageIdentifier +): String = makeLinkToMessage(username.username, messageId) +fun makeLinkToMessage( + chat: UsernameChat, + messageId: MessageIdentifier +): String? = chat.username ?.let { makeLinkToMessage(it, messageId) } private val linkIdRedundantPartRegex = Regex("^-100") private val usernameBeginSymbolRegex = Regex("^@")