mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 11:38:45 +00:00
commit
5752f7a4fb
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,11 +1,20 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 2.1.3
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `MicroUtils`: `0.11.9` -> `0.11.12`
|
||||||
|
* `Utils`:
|
||||||
|
* Rename `UserId` extension `link` to `userLink`
|
||||||
|
* `Core`
|
||||||
|
* `ChatJoinRequest#inviteLink` is nullable due to the fact that join requests without link do not require invite link
|
||||||
|
|
||||||
## 2.1.2
|
## 2.1.2
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
* `Coroutines`: `1.6.1` -> `1.6.3`
|
* `Coroutines`: `1.6.1` -> `1.6.3`
|
||||||
* `Ktor`: `2.0.2` -> `2.0.3`
|
* `Ktor`: `2.0.2` -> `2.0.3`
|
||||||
* `MicroUtils`: `0.11.6` -> `0.11.9`
|
* `MicroUtils`: `0.11.6` -> `0.11.9`
|
||||||
|
|
||||||
## 2.1.1
|
## 2.1.1
|
||||||
|
|
||||||
|
@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=2.1.2
|
library_version=2.1.3
|
||||||
|
@ -11,7 +11,7 @@ korlibs = "2.7.0"
|
|||||||
uuid = "0.4.1"
|
uuid = "0.4.1"
|
||||||
ktor = "2.0.3"
|
ktor = "2.0.3"
|
||||||
|
|
||||||
microutils = "0.11.9"
|
microutils = "0.11.12"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ import kotlinx.serialization.encoding.Encoder
|
|||||||
import kotlinx.serialization.json.JsonPrimitive
|
import kotlinx.serialization.json.JsonPrimitive
|
||||||
import kotlinx.serialization.json.longOrNull
|
import kotlinx.serialization.json.longOrNull
|
||||||
|
|
||||||
|
const val internalLinkBeginning = "https://t.me"
|
||||||
|
|
||||||
@Serializable(ChatIdentifierSerializer::class)
|
@Serializable(ChatIdentifierSerializer::class)
|
||||||
sealed class ChatIdentifier
|
sealed class ChatIdentifier
|
||||||
|
|
||||||
@ -26,16 +28,29 @@ data class ChatId(
|
|||||||
* https://core.telegram.org/bots/api#formatting-options
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
*/
|
*/
|
||||||
@Warning("This API have restrictions in Telegram System")
|
@Warning("This API have restrictions in Telegram System")
|
||||||
val Identifier.link: String
|
val Identifier.userLink: String
|
||||||
get() = "tg://user?id=$this"
|
get() = "tg://user?id=$this"
|
||||||
/**
|
/**
|
||||||
* https://core.telegram.org/bots/api#formatting-options
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
*/
|
*/
|
||||||
@Warning("This API have restrictions in Telegram System")
|
@Warning("This API have restrictions in Telegram System")
|
||||||
val UserId.link: String
|
val UserId.userLink: String
|
||||||
get() = chatId.link
|
get() = chatId.userLink
|
||||||
val User.link: String
|
val User.link: String
|
||||||
get() = id.link
|
get() = id.userLink
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
||||||
|
val Identifier.link: String
|
||||||
|
get() = "tg://user?id=$this"
|
||||||
|
/**
|
||||||
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
||||||
|
val ChatId.link: String
|
||||||
|
get() = chatId.link
|
||||||
|
|
||||||
typealias UserId = ChatId
|
typealias UserId = ChatId
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ data class ChatJoinRequest(
|
|||||||
@SerialName(dateField)
|
@SerialName(dateField)
|
||||||
val date: TelegramDate,
|
val date: TelegramDate,
|
||||||
@SerialName(inviteLinkField)
|
@SerialName(inviteLinkField)
|
||||||
val inviteLink: ChatInviteLink,
|
val inviteLink: ChatInviteLink? = null,
|
||||||
@SerialName(bioField)
|
@SerialName(bioField)
|
||||||
val bio: String? = null
|
val bio: String? = null
|
||||||
) : FromUser {
|
) : FromUser {
|
||||||
|
@ -28,7 +28,7 @@ class ChatIdentifierTests {
|
|||||||
@Test
|
@Test
|
||||||
fun `Creating_link_from_ChatId_is_correct`() {
|
fun `Creating_link_from_ChatId_is_correct`() {
|
||||||
val chatId = chatIdentifierChatId.toChatId()
|
val chatId = chatIdentifierChatId.toChatId()
|
||||||
assertEquals(chatIdentifierLink, chatId.link)
|
assertEquals(chatIdentifierLink, chatId.userLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -5,5 +5,5 @@ import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
|||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
|
||||||
@RiskFeature(RawFieldsUsageWarning)
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
val ChatJoinRequest.invite_link: ChatInviteLink
|
val ChatJoinRequest.invite_link: ChatInviteLink?
|
||||||
get() = inviteLink
|
get() = inviteLink
|
||||||
|
@ -5,8 +5,6 @@ import dev.inmo.tgbotapi.types.message.textsources.link
|
|||||||
import dev.inmo.tgbotapi.types.chat.*
|
import dev.inmo.tgbotapi.types.chat.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
private const val internalLinkBeginning = "https://t.me"
|
|
||||||
|
|
||||||
fun makeUsernameLink(username: String) = "$internalLinkBeginning/$username"
|
fun makeUsernameLink(username: String) = "$internalLinkBeginning/$username"
|
||||||
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
|
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
|
||||||
inline val Username.link
|
inline val Username.link
|
||||||
@ -73,7 +71,7 @@ val Message.link: String?
|
|||||||
val Chat.link: String?
|
val Chat.link: String?
|
||||||
get() {
|
get() {
|
||||||
if (this is UsernameChat) {
|
if (this is UsernameChat) {
|
||||||
username ?.username ?.let { return it }
|
username ?.link
|
||||||
}
|
}
|
||||||
if (this is ExtendedPublicChat) {
|
if (this is ExtendedPublicChat) {
|
||||||
inviteLink ?.let { return it }
|
inviteLink ?.let { return it }
|
||||||
|
Loading…
Reference in New Issue
Block a user