1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

*.link renames

This commit is contained in:
InsanusMokrassar 2023-02-27 22:32:08 +06:00
parent c30ce5c803
commit 9ef1b54ada
3 changed files with 34 additions and 6 deletions

View File

@ -2,10 +2,14 @@
## 6.0.0 ## 6.0.0
* `Core`:
* `*.link` extensions have been deprecated with renaming to avoid collisions with `link` methods
* `API`: * `API`:
* Add `TelegramBot.resend` methods * Add `TelegramBot.resend` methods
* `BehaviourBuilder`: * `BehaviourBuilder`:
* Add triggers and waiters for `VisualMediaGroupPartContent` * Add triggers and waiters for `VisualMediaGroupPartContent`
* `Utils`:
* `*.link` extensions have been deprecated with renaming to avoid collisions with `link` methods
## 5.2.1 ## 5.2.1

View File

@ -74,8 +74,11 @@ val Identifier.userLink: String
@Warning("This API have restrictions in Telegram System") @Warning("This API have restrictions in Telegram System")
val UserId.userLink: String val UserId.userLink: String
get() = chatId.userLink get() = chatId.userLink
val User.link: String val User.userLink: String
get() = id.userLink get() = id.userLink
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.userLink", "dev.inmo.tgbotapi.types.userLink"))
val User.link: String
get() = userLink
typealias UserId = ChatId typealias UserId = ChatId

View File

@ -18,10 +18,16 @@ fun makeChatLink(identifier: Identifier, threadId: MessageThreadId? = null) = id
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start=" fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$username?startattach" fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$username?startattach"
fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}" fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}"
inline val Username.link inline val Username.usernameLink
get() = makeUsernameLink(usernameWithoutAt) get() = makeUsernameLink(usernameWithoutAt)
val IdChatIdentifier.link: String @Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.usernameLink", "dev.inmo.tgbotapi.extensions.utils.formatting.usernameLink"))
inline val Username.link
get() = usernameLink
val IdChatIdentifier.chatLink: String
get() = makeChatLink(chatId, threadId) get() = makeChatLink(chatId, threadId)
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.chatLink", "dev.inmo.tgbotapi.extensions.utils.formatting.chatLink"))
val IdChatIdentifier.link: String
get() = chatLink
fun ChatId.link(threadId: MessageThreadId?) = makeChatLink(chatId, threadId) fun ChatId.link(threadId: MessageThreadId?) = makeChatLink(chatId, threadId)
inline fun Username.link(threadId: MessageThreadId?) = makeUsernameLink(usernameWithoutAt, threadId) inline fun Username.link(threadId: MessageThreadId?) = makeUsernameLink(usernameWithoutAt, threadId)
inline val Username.deepLinkPrefix inline val Username.deepLinkPrefix
@ -83,20 +89,27 @@ fun makeLinkToMessage(
/** /**
* @see makeLinkToMessage * @see makeLinkToMessage
*/ */
val Message.link: String? val Message.messageLink: String?
get() = makeLinkToMessage( get() = makeLinkToMessage(
chat, chat,
messageId messageId
) )
/**
* @see makeLinkToMessage
*/
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.messageLink", "dev.inmo.tgbotapi.extensions.utils.formatting.messageLink"))
val Message.link: String?
get() = messageLink
/** /**
* Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no * Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no
* known way to build link * known way to build link
*/ */
val Chat.link: String? val Chat.chatLink: String?
get() { get() {
if (this is UsernameChat) { if (this is UsernameChat) {
username ?.link ?: id.link username ?.usernameLink ?: id.chatLink
} }
if (this is ExtendedPublicChat) { if (this is ExtendedPublicChat) {
inviteLink ?.let { return it } inviteLink ?.let { return it }
@ -107,6 +120,14 @@ val Chat.link: String?
return null return null
} }
/**
* Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no
* known way to build link
*/
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.chatLink", "dev.inmo.tgbotapi.extensions.utils.formatting.chatLink"))
val Chat.link: String?
get() = chatLink
private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addstickers" private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addstickers"
val StickerSetName.stickerSetLink val StickerSetName.stickerSetLink