mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-03-03 09:22:22 +00:00
add support of extended chat id in private chats
This commit is contained in:
@@ -123,7 +123,7 @@ val RawChatId.userLink: String
|
|||||||
val UserId.userLink: String
|
val UserId.userLink: String
|
||||||
get() = chatId.userLink
|
get() = chatId.userLink
|
||||||
val User.userLink: String
|
val User.userLink: String
|
||||||
get() = id.userLink
|
get() = id.toChatId().userLink
|
||||||
|
|
||||||
typealias UserId = ChatId
|
typealias UserId = ChatId
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ sealed interface UsernameChat : Chat {
|
|||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@Serializable(ChatSerializer::class)
|
@Serializable(ChatSerializer::class)
|
||||||
sealed interface PrivateChat : Chat, UsernameChat {
|
sealed interface PrivateChat : Chat, UsernameChat {
|
||||||
override val id: UserId
|
override val id: IdChatIdentifier
|
||||||
val firstName: String
|
val firstName: String
|
||||||
val lastName: String
|
val lastName: String
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ sealed interface PrivateUserChat : PrivateChat
|
|||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@Serializable(ChatSerializer::class)
|
@Serializable(ChatSerializer::class)
|
||||||
sealed interface PrivateForumChat : PrivateUserChat, ForumChat {
|
sealed interface PrivateForumChat : PrivateUserChat, ForumChat {
|
||||||
|
override val id: IdChatIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ data class ExtendedPrivateChatImpl(
|
|||||||
data class ExtendedPrivateForumChatImpl(
|
data class ExtendedPrivateForumChatImpl(
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: UserId,
|
override val id: IdChatIdentifier,
|
||||||
@SerialName(photoField)
|
@SerialName(photoField)
|
||||||
override val chatPhoto: ChatPhoto? = null,
|
override val chatPhoto: ChatPhoto? = null,
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ data class PrivateChatImpl(
|
|||||||
data class PrivateForumChatImpl(
|
data class PrivateForumChatImpl(
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: UserId,
|
override val id: IdChatIdentifier,
|
||||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||||
@SerialName(usernameField)
|
@SerialName(usernameField)
|
||||||
override val username: Username? = null,
|
override val username: Username? = null,
|
||||||
|
|||||||
@@ -750,14 +750,22 @@ internal data class RawMessage(
|
|||||||
is PreviewPrivateChat -> if (business_connection_id == null) {
|
is PreviewPrivateChat -> if (business_connection_id == null) {
|
||||||
when {
|
when {
|
||||||
is_topic_message == true -> {
|
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(
|
PrivateForumContentMessageImpl(
|
||||||
messageId = messageId,
|
messageId = messageId,
|
||||||
from = checkedFrom ?: from
|
from = checkedFrom ?: from ?: error("Was detected common message, but owner (sender) of the message was not found"),
|
||||||
?: error("Was detected common message, but owner (sender) of the message was not found"),
|
threadId = messageThreadId,
|
||||||
threadId = messageThreadId
|
|
||||||
?: error("Was detected forum private message, but message thread id was not found"),
|
|
||||||
threadCreatingInfo = forum_topic_created,
|
threadCreatingInfo = forum_topic_created,
|
||||||
chat = chat,
|
chat = actualForumChat,
|
||||||
content = content,
|
content = content,
|
||||||
date = date.asDate,
|
date = date.asDate,
|
||||||
editDate = edit_date?.asDate,
|
editDate = edit_date?.asDate,
|
||||||
|
|||||||
Reference in New Issue
Block a user