1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-21 15:53: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.chat.CommonBot
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.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MessageContent
data class ChannelContentMessageImpl<T: MessageContent>(
override val messageId: MessageId,
override val from: User?,
override val chat: PreviewChannelChat,
override val senderChat: PreviewChat,
override val content: T,
override val date: DateTime,
override val editDate: DateTime?,
@ -27,8 +28,8 @@ data class ChannelContentMessageImpl<T: MessageContent>(
) : ChannelContentMessage<T> {
constructor(
messageId: MessageId,
from: User?,
chat: PreviewChannelChat,
senderChat: PreviewChat,
content: T,
date: DateTime,
editDate: DateTime?,
@ -41,6 +42,6 @@ data class ChannelContentMessageImpl<T: MessageContent>(
mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : 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,
@SerialName(messageThreadIdField)
private val messageThreadId: MessageThreadId? = null,
private val from: User? = null,
private val from: PreviewUser? = null,
private val sender_chat: PreviewPublicChat? = null,
private val forward_origin: MessageOrigin? = null,
private val is_topic_message: Boolean? = null,
@ -339,8 +339,8 @@ internal data class RawMessage(
is PreviewPublicChat -> when (chat) {
is PreviewChannelChat -> ChannelContentMessageImpl(
messageId = messageId,
from = checkedFrom ?: from,
chat = chat,
senderChat = checkedFrom ?: sender_chat ?: chat,
content = content,
date = date.asDate,
editDate = edit_date?.asDate,

View File

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