1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 09:07:12 +00:00

add support of personal chat, is_from_offline and can_connect_to_business

This commit is contained in:
InsanusMokrassar 2024-04-16 22:57:07 +06:00
parent 64ef0fa160
commit 953bdef657
11 changed files with 247 additions and 195 deletions

View File

@ -150,6 +150,7 @@ const val accentColorIdField = "accent_color_id"
const val profileAccentColorIdField = "profile_accent_color_id" const val profileAccentColorIdField = "profile_accent_color_id"
const val backgroundCustomEmojiIdField = "background_custom_emoji_id" const val backgroundCustomEmojiIdField = "background_custom_emoji_id"
const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id" const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id"
const val personalChatField = "personal_chat"
const val hasVisibleHistoryField = "has_visible_history" const val hasVisibleHistoryField = "has_visible_history"
const val unrestrictBoostsCountField = "unrestrict_boost_count" const val unrestrictBoostsCountField = "unrestrict_boost_count"
const val customEmojiStickerSetNameField = "custom_emoji_sticker_set_name" const val customEmojiStickerSetNameField = "custom_emoji_sticker_set_name"
@ -158,6 +159,7 @@ const val canJoinGroupsField = "can_join_groups"
const val canReadAllGroupMessagesField = "can_read_all_group_messages" const val canReadAllGroupMessagesField = "can_read_all_group_messages"
const val canReplyField = "can_reply" const val canReplyField = "can_reply"
const val supportInlineQueriesField = "supports_inline_queries" const val supportInlineQueriesField = "supports_inline_queries"
const val canConnectToBusinessField = "can_connect_to_business"
const val textEntitiesField = "text_entities" const val textEntitiesField = "text_entities"
const val entitiesField = "entities" const val entitiesField = "entities"
const val stickerSetNameField = "set_name" const val stickerSetNameField = "set_name"

View File

@ -133,6 +133,9 @@ data class ExtendedPrivateChatImpl(
override val businessLocation: BusinessLocation? = null, override val businessLocation: BusinessLocation? = null,
@SerialName(businessOpeningHoursField) @SerialName(businessOpeningHoursField)
override val businessOpeningHours: BusinessOpeningHours? = null, override val businessOpeningHours: BusinessOpeningHours? = null,
@SerialName(personalChatField)
@Serializable(PreviewChatSerializer::class)
override val personalChat: PreviewChannelChat? = null
) : ExtendedPrivateChat ) : ExtendedPrivateChat
typealias ExtendedUser = ExtendedPrivateChatImpl typealias ExtendedUser = ExtendedPrivateChatImpl
@ -277,6 +280,8 @@ data class ExtendedBot(
val canReadAllGroupMessages: Boolean = false, val canReadAllGroupMessages: Boolean = false,
@SerialName(supportInlineQueriesField) @SerialName(supportInlineQueriesField)
val supportsInlineQueries: Boolean = false, val supportsInlineQueries: Boolean = false,
@SerialName(canConnectToBusinessField)
val canConnectToBusiness: Boolean = false,
@SerialName(photoField) @SerialName(photoField)
override val chatPhoto: ChatPhoto? = null, override val chatPhoto: ChatPhoto? = null,
@SerialName(accentColorIdField) @SerialName(accentColorIdField)

View File

@ -46,6 +46,8 @@ sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername, Ex
val businessLocation: BusinessLocation? val businessLocation: BusinessLocation?
val businessOpeningHours: BusinessOpeningHours? val businessOpeningHours: BusinessOpeningHours?
val personalChat: PreviewChannelChat?
val allowCreateUserIdLink: Boolean val allowCreateUserIdLink: Boolean
get() = hasPrivateForwards get() = hasPrivateForwards
} }

View File

@ -26,7 +26,8 @@ data class BusinessContentMessageImpl<T: MessageContent>(
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val senderBusinessBot: PreviewBot? = null override val senderBusinessBot: PreviewBot?,
override val fromOffline: Boolean,
) : BusinessContentMessage<T> { ) : BusinessContentMessage<T> {
constructor( constructor(
messageId: MessageId, messageId: MessageId,
@ -42,7 +43,8 @@ data class BusinessContentMessageImpl<T: MessageContent>(
replyMarkup: InlineKeyboardMarkup?, replyMarkup: InlineKeyboardMarkup?,
senderBot: CommonBot?, senderBot: CommonBot?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
senderBusinessBot: PreviewBot? = null, senderBusinessBot: PreviewBot?,
fromOffline: Boolean,
) : this( ) : this(
messageId = messageId, messageId = messageId,
from = from, from = from,
@ -57,6 +59,7 @@ data class BusinessContentMessageImpl<T: MessageContent>(
replyMarkup = replyMarkup, replyMarkup = replyMarkup,
senderBot = senderBot, senderBot = senderBot,
mediaGroupId = mediaGroupId, mediaGroupId = mediaGroupId,
senderBusinessBot = senderBusinessBot senderBusinessBot = senderBusinessBot,
fromOffline = fromOffline
) )
} }

View File

@ -21,6 +21,7 @@ data class ChannelContentMessageImpl<T: MessageContent>(
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?, override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
) : ChannelContentMessage<T> { ) : ChannelContentMessage<T> {
constructor( constructor(
messageId: MessageId, messageId: MessageId,
@ -35,7 +36,8 @@ data class ChannelContentMessageImpl<T: MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
authorSignature: AuthorSignature?, authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : this( ) : this(
messageId, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, authorSignature, mediaGroupId messageId, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, authorSignature, mediaGroupId, fromOffline
) )
} }

View File

@ -23,6 +23,7 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?, override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
) : ConnectedFromChannelGroupContentMessage<T> { ) : ConnectedFromChannelGroupContentMessage<T> {
constructor( constructor(
@ -39,8 +40,9 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
authorSignature: AuthorSignature?, authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : this( ) : this(
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
) )
} }
@ -58,6 +60,7 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?, override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
) : UnconnectedFromChannelGroupContentMessage<T> { ) : UnconnectedFromChannelGroupContentMessage<T> {
constructor( constructor(
chat: PreviewGroupChat, chat: PreviewGroupChat,
@ -73,8 +76,9 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
authorSignature: AuthorSignature?, authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : this( ) : this(
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
) )
} }
@ -91,6 +95,7 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?, override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
) : AnonymousGroupContentMessage<T> { ) : AnonymousGroupContentMessage<T> {
constructor( constructor(
chat: PreviewGroupChat, chat: PreviewGroupChat,
@ -105,8 +110,9 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
authorSignature: AuthorSignature?, authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : this( ) : this(
chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
) )
} }
@ -123,7 +129,8 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val senderBoostsCount: Int? override val senderBoostsCount: Int?,
override val fromOffline: Boolean,
) : CommonGroupContentMessage<T> { ) : CommonGroupContentMessage<T> {
constructor( constructor(
chat: PreviewGroupChat, chat: PreviewGroupChat,
@ -139,8 +146,9 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
senderBoostsCount: Int?, senderBoostsCount: Int?,
fromOffline: Boolean,
) : this( ) : this(
chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount, fromOffline
) )
} }
@ -159,6 +167,7 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?, override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
) : FromChannelForumContentMessage<T> { ) : FromChannelForumContentMessage<T> {
constructor( constructor(
chat: PreviewForumChat, chat: PreviewForumChat,
@ -175,8 +184,9 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
authorSignature: AuthorSignature?, authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : this( ) : this(
chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
) )
} }
@ -194,6 +204,7 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?, override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
) : AnonymousForumContentMessage<T> { ) : AnonymousForumContentMessage<T> {
constructor( constructor(
chat: PreviewForumChat, chat: PreviewForumChat,
@ -209,8 +220,9 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
authorSignature: AuthorSignature?, authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : this( ) : this(
chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
) )
} }
@ -229,6 +241,7 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val senderBoostsCount: Int?, override val senderBoostsCount: Int?,
override val fromOffline: Boolean,
) : CommonForumContentMessage<T> { ) : CommonForumContentMessage<T> {
constructor( constructor(
chat: PreviewForumChat, chat: PreviewForumChat,
@ -245,7 +258,8 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
senderBot: CommonBot?, senderBot: CommonBot?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
senderBoostsCount: Int?, senderBoostsCount: Int?,
fromOffline: Boolean,
) : this( ) : this(
chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount, fromOffline
) )
} }

View File

@ -23,6 +23,7 @@ data class PrivateContentMessageImpl<T: MessageContent>(
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val mediaGroupId: MediaGroupId?, override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
) : PrivateContentMessage<T> { ) : PrivateContentMessage<T> {
constructor( constructor(
messageId: MessageId, messageId: MessageId,
@ -37,7 +38,8 @@ data class PrivateContentMessageImpl<T: MessageContent>(
replyMarkup: InlineKeyboardMarkup?, replyMarkup: InlineKeyboardMarkup?,
senderBot: CommonBot?, senderBot: CommonBot?,
mediaGroupId: MediaGroupId?, mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
) : this( ) : this(
messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, mediaGroupId messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, mediaGroupId, fromOffline
) )
} }

View File

@ -105,6 +105,8 @@ internal data class RawMessage(
private val users_shared: UsersShared? = null, private val users_shared: UsersShared? = null,
private val chat_shared: ChatShared? = null, private val chat_shared: ChatShared? = null,
private val is_from_offline: Boolean = false,
// Voice Chat Service Messages // Voice Chat Service Messages
private val video_chat_scheduled: VideoChatScheduled? = null, private val video_chat_scheduled: VideoChatScheduled? = null,
private val video_chat_started: VideoChatStarted? = null, private val video_chat_started: VideoChatStarted? = null,
@ -313,18 +315,19 @@ internal data class RawMessage(
when (chat) { when (chat) {
is PreviewPublicChat -> when (chat) { is PreviewPublicChat -> when (chat) {
is PreviewChannelChat -> ChannelContentMessageImpl( is PreviewChannelChat -> ChannelContentMessageImpl(
messageId, messageId = messageId,
chat, chat = chat,
content, content = content,
date.asDate, date = date.asDate,
edit_date?.asDate, editDate = edit_date?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
forward_origin, forwardOrigin = forward_origin,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
is PreviewForumChat -> if (messageThreadId != null) { is PreviewForumChat -> if (messageThreadId != null) {
val chatId = ChatIdWithThreadId( val chatId = ChatIdWithThreadId(
@ -336,218 +339,231 @@ internal data class RawMessage(
} }
when (sender_chat) { when (sender_chat) {
is PreviewChannelChat -> FromChannelForumContentMessageImpl( is PreviewChannelChat -> FromChannelForumContentMessageImpl(
actualForumChat, chat = actualForumChat,
sender_chat, channel = sender_chat,
messageId, messageId = messageId,
messageThreadId, threadId = messageThreadId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
is PreviewGroupChat -> AnonymousForumContentMessageImpl( is PreviewGroupChat -> AnonymousForumContentMessageImpl(
actualForumChat, chat = actualForumChat,
messageId, messageId = messageId,
messageThreadId, threadId = messageThreadId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
null -> CommonForumContentMessageImpl( null -> CommonForumContentMessageImpl(
actualForumChat, chat = actualForumChat,
messageId, messageId = messageId,
messageThreadId, threadId = messageThreadId,
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), from = from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
media_group_id, mediaGroupId = media_group_id,
sender_boost_count senderBoostsCount = sender_boost_count,
fromOffline = is_from_offline
) )
} }
} else { } else {
when (sender_chat) { when (sender_chat) {
is PreviewChannelChat -> if (is_automatic_forward == true) { is PreviewChannelChat -> if (is_automatic_forward == true) {
ConnectedFromChannelGroupContentMessageImpl( ConnectedFromChannelGroupContentMessageImpl(
chat, chat = chat,
sender_chat, channel = sender_chat,
messageId, messageId = messageId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
} else { } else {
UnconnectedFromChannelGroupContentMessageImpl( UnconnectedFromChannelGroupContentMessageImpl(
chat, chat = chat,
sender_chat, channel = sender_chat,
messageId, messageId = messageId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
} }
is GroupChat -> AnonymousGroupContentMessageImpl( is GroupChat -> AnonymousGroupContentMessageImpl(
chat, chat = chat,
messageId, messageId = messageId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
null -> CommonGroupContentMessageImpl( null -> CommonGroupContentMessageImpl(
chat, chat = chat,
messageId, messageId = messageId,
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), from = from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
media_group_id, mediaGroupId = media_group_id,
sender_boost_count senderBoostsCount = sender_boost_count,
fromOffline = is_from_offline
) )
} }
} }
is PreviewGroupChat -> when (sender_chat) { is PreviewGroupChat -> when (sender_chat) {
is PreviewChannelChat -> if (is_automatic_forward == true) { is PreviewChannelChat -> if (is_automatic_forward == true) {
ConnectedFromChannelGroupContentMessageImpl( ConnectedFromChannelGroupContentMessageImpl(
chat, chat = chat,
sender_chat, channel = sender_chat,
messageId, messageId = messageId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
} else { } else {
UnconnectedFromChannelGroupContentMessageImpl( UnconnectedFromChannelGroupContentMessageImpl(
chat, chat = chat,
sender_chat, channel = sender_chat,
messageId, messageId = messageId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
} }
is PreviewGroupChat -> AnonymousGroupContentMessageImpl( is PreviewGroupChat -> AnonymousGroupContentMessageImpl(
chat, chat = chat,
messageId, messageId = messageId,
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
author_signature, authorSignature = author_signature,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
null -> CommonGroupContentMessageImpl( null -> CommonGroupContentMessageImpl(
chat, chat = chat,
messageId, messageId = messageId,
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), from = from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
date.asDate, date = date.asDate,
forward_origin, forwardOrigin = forward_origin,
edit_date ?.asDate, editDate = edit_date ?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
content, content = content,
via_bot, senderBot = via_bot,
media_group_id, mediaGroupId = media_group_id,
sender_boost_count senderBoostsCount = sender_boost_count,
fromOffline = is_from_offline
) )
} }
} }
is PreviewPrivateChat -> if (business_connection_id == null) { is PreviewPrivateChat -> if (business_connection_id == null) {
PrivateContentMessageImpl( PrivateContentMessageImpl(
messageId, messageId = messageId,
from ?: error("Was detected common message, but owner (sender) of the message was not found"), from = from ?: error("Was detected common message, but owner (sender) of the message was not found"),
chat, chat = chat,
content, content = content,
date.asDate, date = date.asDate,
edit_date?.asDate, editDate = edit_date?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
forward_origin, forwardOrigin = forward_origin,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
via_bot, senderBot = via_bot,
media_group_id mediaGroupId = media_group_id,
fromOffline = is_from_offline
) )
} else { } else {
BusinessContentMessageImpl( BusinessContentMessageImpl(
messageId, messageId = messageId,
from ?: error("Was detected common message, but owner (sender) of the message was not found"), from = from ?: error("Was detected common message, but owner (sender) of the message was not found"),
BusinessChatImpl( chat = BusinessChatImpl(
chat.id.toBusinessChatId(business_connection_id), chat.id.toBusinessChatId(business_connection_id),
chat chat
), ),
business_connection_id, businessConnectionId = business_connection_id,
content, content = content,
date.asDate, date = date.asDate,
edit_date?.asDate, editDate = edit_date?.asDate,
has_protected_content == true, hasProtectedContent = has_protected_content == true,
forward_origin, forwardOrigin = forward_origin,
replyInfo, replyInfo = replyInfo,
reply_markup, replyMarkup = reply_markup,
via_bot, senderBot = via_bot,
media_group_id, mediaGroupId = media_group_id,
sender_business_bot senderBusinessBot = sender_business_bot,
fromOffline = is_from_offline
) )
} }
else -> error("Unknown type of chat: $chat") else -> error("Unknown type of chat: $chat")

View File

@ -8,5 +8,6 @@ sealed interface CommonMessage<out T: MessageContent> : AccessibleMessage,
PossiblyReplyMessage, PossiblyReplyMessage,
PossiblyMarkedUp, PossiblyMarkedUp,
PossiblyBusinessMessage, PossiblyBusinessMessage,
PossiblyOfflineMessage,
PossiblyMediaGroupMessage<T>, PossiblyMediaGroupMessage<T>,
ContentMessage<T> ContentMessage<T>

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.message.abstracts
interface PossiblyOfflineMessage : Message {
val fromOffline: Boolean
}

View File

@ -3,6 +3,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.chat.PreviewPrivateChat import dev.inmo.tgbotapi.types.chat.PreviewPrivateChat
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
interface PrivateContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, FromUserMessage { interface PrivateContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, FromUserMessage, PossiblyOfflineMessage {
override val chat: PreviewPrivateChat override val chat: PreviewPrivateChat
} }