1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

complete support of sender chat

This commit is contained in:
InsanusMokrassar 2024-08-14 22:53:38 +06:00
parent 76eae0a54f
commit b7ff6a3061
3 changed files with 9 additions and 8 deletions

View File

@ -5,14 +5,15 @@ import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.CommonBot
import dev.inmo.tgbotapi.types.chat.PreviewChannelChat import dev.inmo.tgbotapi.types.chat.PreviewChannelChat
import dev.inmo.tgbotapi.types.chat.PreviewChat
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
data class ChannelContentMessageImpl<T: MessageContent>( data class ChannelContentMessageImpl<T: MessageContent>(
override val messageId: MessageId, override val messageId: MessageId,
override val from: User?,
override val chat: PreviewChannelChat, override val chat: PreviewChannelChat,
override val senderChat: PreviewChat,
override val content: T, override val content: T,
override val date: DateTime, override val date: DateTime,
override val editDate: DateTime?, override val editDate: DateTime?,
@ -27,8 +28,8 @@ data class ChannelContentMessageImpl<T: MessageContent>(
) : ChannelContentMessage<T> { ) : ChannelContentMessage<T> {
constructor( constructor(
messageId: MessageId, messageId: MessageId,
from: User?,
chat: PreviewChannelChat, chat: PreviewChannelChat,
senderChat: PreviewChat,
content: T, content: T,
date: DateTime, date: DateTime,
editDate: DateTime?, editDate: DateTime?,
@ -41,6 +42,6 @@ data class ChannelContentMessageImpl<T: MessageContent>(
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean, fromOffline: Boolean,
) : this( ) : this(
messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, authorSignature, mediaGroupId, fromOffline messageId, chat, senderChat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, authorSignature, mediaGroupId, fromOffline
) )
} }

View File

@ -51,7 +51,7 @@ internal data class RawMessage(
private val chat: PreviewChat, private val chat: PreviewChat,
@SerialName(messageThreadIdField) @SerialName(messageThreadIdField)
private val messageThreadId: MessageThreadId? = null, private val messageThreadId: MessageThreadId? = null,
private val from: User? = null, private val from: PreviewUser? = null,
private val sender_chat: PreviewPublicChat? = null, private val sender_chat: PreviewPublicChat? = null,
private val forward_origin: MessageOrigin? = null, private val forward_origin: MessageOrigin? = null,
private val is_topic_message: Boolean? = null, private val is_topic_message: Boolean? = null,
@ -339,8 +339,8 @@ internal data class RawMessage(
is PreviewPublicChat -> when (chat) { is PreviewPublicChat -> when (chat) {
is PreviewChannelChat -> ChannelContentMessageImpl( is PreviewChannelChat -> ChannelContentMessageImpl(
messageId = messageId, messageId = messageId,
from = checkedFrom ?: from,
chat = chat, chat = chat,
senderChat = checkedFrom ?: sender_chat ?: chat,
content = content, content = content,
date = date.asDate, date = date.asDate,
editDate = edit_date?.asDate, editDate = edit_date?.asDate,

View File

@ -1,11 +1,11 @@
package dev.inmo.tgbotapi.types.message.abstracts package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.chat.ChannelChat
import dev.inmo.tgbotapi.types.chat.PreviewChannelChat import dev.inmo.tgbotapi.types.chat.PreviewChannelChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
interface ChannelContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, SignedMessage, WithSenderChatMessage, OptionallyFromUserMessage { interface ChannelContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, SignedMessage, WithSenderChatMessage, OptionallyFromUserMessage {
override val chat: PreviewChannelChat override val chat: PreviewChannelChat
override val senderChat: PreviewChannelChat override val from: User?
get() = chat get() = senderChat as? User
} }