From 2a89c41a58d614cad3814b7353180bcd525465f3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Feb 2021 17:15:28 +0600 Subject: [PATCH] fix of #292 --- CHANGELOG.md | 1 + .../dev/inmo/tgbotapi/types/ChatIdentifier.kt | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e828c00e..01bcbea7dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Now `AbstractRequestCallFactory` will set up one-second delay for zero timeouts in `GetUpdate` requests * Several extensions for `TelegramBotAPI` like `retrieveAccumulatedUpdates` have been added as a solution for [#293](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/293) + * Links for `tg://user?id=` have been updated ([#292](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/292)) ## 0.32.4 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt index 813ac70c44..bdd251b7ed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt @@ -1,5 +1,7 @@ package dev.inmo.tgbotapi.types +import dev.inmo.micro_utils.common.Warning +import dev.inmo.tgbotapi.types.chat.abstracts.Chat import kotlinx.serialization.* import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -17,9 +19,20 @@ data class ChatId( val chatId: Identifier ) : ChatIdentifier() - -val ChatId.link: String - get() = "tg://user?id=$chatId" +/** + * https://core.telegram.org/bots/api#formatting-options + */ +@Warning("This API have restrictions in Telegram System") +val Identifier.link: String + get() = "tg://user?id=$this" +/** + * https://core.telegram.org/bots/api#formatting-options + */ +@Warning("This API have restrictions in Telegram System") +val UserId.link: String + get() = chatId.link +val User.link: String + get() = id.link typealias UserId = ChatId