mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-10-25 01:00:13 +00:00
fix of direct message typing
This commit is contained in:
@@ -16167,7 +16167,7 @@ public final class dev/inmo/tgbotapi/types/chat/ChannelChatImpl$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public abstract interface class dev/inmo/tgbotapi/types/chat/ChannelDirectMessagesChat : dev/inmo/tgbotapi/types/chat/ForumChat {
|
||||
public abstract interface class dev/inmo/tgbotapi/types/chat/ChannelDirectMessagesChat : dev/inmo/tgbotapi/types/chat/SupergroupChat {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/chat/ChannelDirectMessagesChat$Companion;
|
||||
public fun isDirectMessages ()Z
|
||||
}
|
||||
@@ -17028,7 +17028,7 @@ public final class dev/inmo/tgbotapi/types/chat/ExtendedChannelChatImpl$Companio
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public abstract interface class dev/inmo/tgbotapi/types/chat/ExtendedChannelDirectMessagesChat : dev/inmo/tgbotapi/types/chat/ChannelDirectMessagesChat, dev/inmo/tgbotapi/types/chat/ExtendedForumChat {
|
||||
public abstract interface class dev/inmo/tgbotapi/types/chat/ExtendedChannelDirectMessagesChat : dev/inmo/tgbotapi/types/chat/ChannelDirectMessagesChat, dev/inmo/tgbotapi/types/chat/ExtendedSupergroupChat {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/chat/ExtendedChannelDirectMessagesChat$Companion;
|
||||
public abstract fun getChannelChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat;
|
||||
}
|
||||
@@ -17742,7 +17742,7 @@ public final class dev/inmo/tgbotapi/types/chat/PreviewChannelChat$DefaultImpls
|
||||
public static fun isDirectMessages (Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat;)Z
|
||||
}
|
||||
|
||||
public abstract interface class dev/inmo/tgbotapi/types/chat/PreviewChannelDirectMessagesChat : dev/inmo/tgbotapi/types/chat/ChannelDirectMessagesChat, dev/inmo/tgbotapi/types/chat/PreviewForumChat {
|
||||
public abstract interface class dev/inmo/tgbotapi/types/chat/PreviewChannelDirectMessagesChat : dev/inmo/tgbotapi/types/chat/ChannelDirectMessagesChat, dev/inmo/tgbotapi/types/chat/PreviewSupergroupChat {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/chat/PreviewChannelDirectMessagesChat$Companion;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ sealed interface ForumChat : SupergroupChat
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(ChatSerializer::class)
|
||||
sealed interface ChannelDirectMessagesChat : ForumChat {
|
||||
sealed interface ChannelDirectMessagesChat : SupergroupChat {
|
||||
override val isDirectMessages: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
@@ -77,16 +77,17 @@ object ChatSerializer : KSerializer<Chat> {
|
||||
} catch (_: SerializationException) {
|
||||
val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType
|
||||
val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||
val isDirectMessages = decodedJson[isDirectMessagesField] ?.jsonPrimitive ?.booleanOrNull == true
|
||||
val original = decodedJson[originField]
|
||||
|
||||
when (type) {
|
||||
ChatType.Sender -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Private -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Group -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.Supergroup -> if (isForum) {
|
||||
formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||
} else {
|
||||
formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.Supergroup -> when {
|
||||
isForum -> formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||
isDirectMessages -> formatter.decodeFromJsonElement(ChannelDirectMessagesChatImpl.serializer(), decodedJson)
|
||||
else -> formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
ChatType.Channel -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
is ChatType.Unknown -> UnknownChatType(
|
||||
@@ -131,11 +132,10 @@ object PreviewChatSerializer : KSerializer<PreviewChat> {
|
||||
ChatType.Private -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Group -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.Supergroup -> {
|
||||
@Suppress("SimplifyBooleanWithConstants")
|
||||
when {
|
||||
isForum == false -> formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
isForum -> formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||
isChannelDirectMessages -> formatter.decodeFromJsonElement(ChannelDirectMessagesChatImpl.serializer(), decodedJson)
|
||||
else -> formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson)
|
||||
else -> formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
}
|
||||
ChatType.Channel -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson)
|
||||
@@ -187,11 +187,10 @@ sealed class ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||
ChatType.Private -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson)
|
||||
ChatType.Group -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson)
|
||||
ChatType.Supergroup -> {
|
||||
@Suppress("SimplifyBooleanWithConstants")
|
||||
when {
|
||||
isForum == false -> formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson)
|
||||
isForum -> formatter.decodeFromJsonElement(ExtendedForumChatImpl.serializer(), decodedJson)
|
||||
isChannelDirectMessages -> formatter.decodeFromJsonElement(ExtendedChannelDirectMessagesChatImpl.serializer(), decodedJson)
|
||||
else -> formatter.decodeFromJsonElement(ExtendedForumChatImpl.serializer(), decodedJson)
|
||||
else -> formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson)
|
||||
}
|
||||
}
|
||||
ChatType.Channel -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson)
|
||||
|
||||
@@ -116,7 +116,7 @@ sealed interface ExtendedForumChat : ExtendedSupergroupChat, ForumChat
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface ExtendedChannelDirectMessagesChat : ExtendedForumChat, ChannelDirectMessagesChat {
|
||||
sealed interface ExtendedChannelDirectMessagesChat : ExtendedSupergroupChat, ChannelDirectMessagesChat {
|
||||
val channelChat: PreviewChannelChat
|
||||
}
|
||||
|
||||
|
||||
@@ -43,4 +43,4 @@ sealed interface PreviewForumChat : PreviewSupergroupChat, ForumChat
|
||||
|
||||
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
sealed interface PreviewChannelDirectMessagesChat : PreviewForumChat, ChannelDirectMessagesChat
|
||||
sealed interface PreviewChannelDirectMessagesChat : PreviewSupergroupChat, ChannelDirectMessagesChat
|
||||
|
||||
@@ -399,6 +399,55 @@ internal data class RawMessage(
|
||||
else -> null
|
||||
}
|
||||
when (chat) {
|
||||
is PreviewChannelDirectMessagesChat -> {
|
||||
if (direct_messages_topic == null) error("direct_messages_topic must be presented for ChannelDirectMessagesChat messages")
|
||||
val chatId = ChatIdWithChannelDirectMessageThreadId(
|
||||
chat.id.chatId,
|
||||
direct_messages_topic.threadId
|
||||
)
|
||||
val actualForumChat = when (chat) {
|
||||
is ChannelDirectMessagesChatImpl -> chat.copy(id = chatId)
|
||||
}
|
||||
when (sender_chat) {
|
||||
is PreviewChannelChat -> FromChannelChannelDirectMessagesContentMessageImpl(
|
||||
chat = actualForumChat,
|
||||
channel = sender_chat,
|
||||
messageId = messageId,
|
||||
date = date.asDate,
|
||||
directMessageTopic = direct_messages_topic,
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
is PreviewGroupChat,
|
||||
null -> CommonChannelDirectMessagesContentMessageImpl(
|
||||
chat = actualForumChat,
|
||||
messageId = messageId,
|
||||
from = checkedFrom ?: from ?: error("It is expected that in direct channel messages from non anonymous channels user must be specified"),
|
||||
date = date.asDate,
|
||||
directMessageTopic = direct_messages_topic,
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBoostsCount = sender_boost_count,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
}
|
||||
is PreviewPublicChat -> when (chat) {
|
||||
is PreviewChannelChat -> if (is_paid_post) {
|
||||
ChannelContentMessageImpl(
|
||||
@@ -438,153 +487,6 @@ internal data class RawMessage(
|
||||
)
|
||||
}
|
||||
is PreviewForumChat -> when(chat) {
|
||||
is PreviewChannelDirectMessagesChat -> {
|
||||
if (messageThreadId != null) {
|
||||
val chatId = ChatIdWithThreadId(
|
||||
chat.id.chatId,
|
||||
messageThreadId
|
||||
)
|
||||
val actualForumChat = when (chat) {
|
||||
is ChannelDirectMessagesChatImpl -> chat.copy(id = chatId)
|
||||
}
|
||||
when (sender_chat) {
|
||||
is PreviewChannelChat -> FromChannelChannelDirectMessagesContentMessageImpl(
|
||||
chat = actualForumChat,
|
||||
channel = sender_chat,
|
||||
messageId = messageId,
|
||||
date = date.asDate,
|
||||
directMessageTopic = direct_messages_topic ?: error("direct_messages_topic must be presented for FromChannelChannelDirectMessagesContentMessage"),
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
is PreviewGroupChat,
|
||||
null -> CommonChannelDirectMessagesContentMessageImpl(
|
||||
chat = actualForumChat,
|
||||
messageId = messageId,
|
||||
from = checkedFrom ?: from ?: error("It is expected that in direct channel messages from non anonymous channels user must be specified"),
|
||||
date = date.asDate,
|
||||
directMessageTopic = direct_messages_topic ?: error("direct_messages_topic must be presented for CommonChannelDirectMessagesContentMessage"),
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBoostsCount = sender_boost_count,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
when (sender_chat) {
|
||||
is PreviewChannelChat -> when {
|
||||
is_automatic_forward == true -> ConnectedFromChannelGroupContentMessageImpl(
|
||||
chat = chat,
|
||||
channel = sender_chat,
|
||||
messageId = messageId,
|
||||
date = date.asDate,
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
direct_messages_topic != null -> CommonChannelDirectMessagesContentMessageImpl(
|
||||
chat = when (chat) {
|
||||
is ChannelDirectMessagesChatImpl -> chat.copy(
|
||||
id = ChatIdWithChannelDirectMessageThreadId(
|
||||
chat.id.chatId,
|
||||
direct_messages_topic.threadId
|
||||
)
|
||||
)
|
||||
},
|
||||
messageId = messageId,
|
||||
from = checkedFrom ?: from ?: error("It is expected that in direct channel messages from non anonymous channels user must be specified"),
|
||||
date = date.asDate,
|
||||
directMessageTopic = direct_messages_topic ?: error("direct_messages_topic must be presented for CommonChannelDirectMessagesContentMessage"),
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBoostsCount = sender_boost_count,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
else -> UnconnectedFromChannelGroupContentMessageImpl(
|
||||
chat = chat,
|
||||
channel = sender_chat,
|
||||
messageId = messageId,
|
||||
date = date.asDate,
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
is GroupChat -> AnonymousGroupContentMessageImpl(
|
||||
chat = chat,
|
||||
messageId = messageId,
|
||||
date = date.asDate,
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
authorSignature = author_signature,
|
||||
mediaGroupId = media_group_id,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
null -> CommonGroupContentMessageImpl(
|
||||
chat = chat,
|
||||
messageId = messageId,
|
||||
from = checkedFrom ?: from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
|
||||
date = date.asDate,
|
||||
forwardOrigin = forward_origin,
|
||||
editDate = edit_date ?.asDate,
|
||||
hasProtectedContent = has_protected_content == true,
|
||||
replyInfo = replyInfo,
|
||||
replyMarkup = reply_markup,
|
||||
content = content,
|
||||
senderBot = via_bot,
|
||||
mediaGroupId = media_group_id,
|
||||
senderBoostsCount = sender_boost_count,
|
||||
fromOffline = is_from_offline,
|
||||
cost = paid_star_count,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
is ForumChatImpl -> {
|
||||
if (messageThreadId != null) {
|
||||
val chatId = ChatIdWithThreadId(
|
||||
|
||||
Reference in New Issue
Block a user