mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-25 18:17:13 +00:00
add several makeLinkToMessage
This commit is contained in:
parent
147889a66a
commit
cfb7f35d20
@ -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
|
||||
|
||||
|
@ -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("^@")
|
||||
|
Loading…
Reference in New Issue
Block a user