1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2026-03-03 17:32:23 +00:00

add support of extended chat id in private chats

This commit is contained in:
2026-02-15 23:51:39 +06:00
parent 9f0ca8143c
commit 9fea7390e8
5 changed files with 18 additions and 9 deletions

View File

@@ -123,7 +123,7 @@ val RawChatId.userLink: String
val UserId.userLink: String
get() = chatId.userLink
val User.userLink: String
get() = id.userLink
get() = id.toChatId().userLink
typealias UserId = ChatId

View File

@@ -13,7 +13,7 @@ sealed interface UsernameChat : Chat {
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@Serializable(ChatSerializer::class)
sealed interface PrivateChat : Chat, UsernameChat {
override val id: UserId
override val id: IdChatIdentifier
val firstName: String
val lastName: String
}
@@ -25,6 +25,7 @@ sealed interface PrivateUserChat : PrivateChat
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@Serializable(ChatSerializer::class)
sealed interface PrivateForumChat : PrivateUserChat, ForumChat {
override val id: IdChatIdentifier
}
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")

View File

@@ -183,7 +183,7 @@ data class ExtendedPrivateChatImpl(
data class ExtendedPrivateForumChatImpl(
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@SerialName(idField)
override val id: UserId,
override val id: IdChatIdentifier,
@SerialName(photoField)
override val chatPhoto: ChatPhoto? = null,
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")

View File

@@ -38,7 +38,7 @@ data class PrivateChatImpl(
data class PrivateForumChatImpl(
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@SerialName(idField)
override val id: UserId,
override val id: IdChatIdentifier,
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@SerialName(usernameField)
override val username: Username? = null,

View File

@@ -750,14 +750,22 @@ internal data class RawMessage(
is PreviewPrivateChat -> if (business_connection_id == null) {
when {
is_topic_message == true -> {
val chatId = ChatIdWithThreadId(
chat.id.chatId,
messageThreadId ?: error("Was detected forum private message, but message thread id was not found")
)
val actualForumChat = when (chat) {
is PrivateForumChatImpl -> chat.copy(id = chatId)
is CommonUser -> chat
is CommonBot -> chat
is PrivateChatImpl -> chat
}
PrivateForumContentMessageImpl(
messageId = messageId,
from = checkedFrom ?: from
?: error("Was detected common message, but owner (sender) of the message was not found"),
threadId = messageThreadId
?: error("Was detected forum private message, but message thread id was not found"),
from = checkedFrom ?: from ?: error("Was detected common message, but owner (sender) of the message was not found"),
threadId = messageThreadId,
threadCreatingInfo = forum_topic_created,
chat = chat,
chat = actualForumChat,
content = content,
date = date.asDate,
editDate = edit_date?.asDate,