mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
add support of MessageOrigin
This commit is contained in:
parent
b5f4219635
commit
6c76e1c47a
@ -201,6 +201,10 @@ const val tgWebAppStartParamField = "tgWebAppStartParam"
|
||||
|
||||
const val chatIdField = "chat_id"
|
||||
const val senderChatIdField = "sender_chat_id"
|
||||
const val senderChatField = "sender_chat"
|
||||
const val authorSignatureField = "author_signature"
|
||||
const val senderUserField = "sender_user"
|
||||
const val senderUserNameField = "sender_user_name"
|
||||
const val messageIdField = "message_id"
|
||||
const val giveawayMessageIdField = "giveaway_message_id"
|
||||
const val messageIdsField = "message_ids"
|
||||
|
@ -15,10 +15,27 @@ data class ChannelContentMessageImpl<T: MessageContent>(
|
||||
override val date: DateTime,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : ChannelContentMessage<T>
|
||||
) : ChannelContentMessage<T> {
|
||||
constructor(
|
||||
messageId: MessageId,
|
||||
chat: PreviewChannelChat,
|
||||
content: T,
|
||||
date: DateTime,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
forwardInfo: ForwardInfo,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
messageId, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo, replyMarkup, senderBot, authorSignature, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
@ -57,3 +57,55 @@ sealed interface ForwardInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun MessageOrigin.forwardInfo() = when(this) {
|
||||
is MessageOrigin.HiddenUser -> ForwardInfo.ByAnonymous(
|
||||
date,
|
||||
name
|
||||
)
|
||||
is MessageOrigin.Public.Channel -> ForwardInfo.PublicChat.FromChannel(
|
||||
date,
|
||||
messageId,
|
||||
chat,
|
||||
authorSignature
|
||||
)
|
||||
is MessageOrigin.Public.Sender -> when (chat) {
|
||||
is ChannelChat -> ForwardInfo.PublicChat.SentByChannel(
|
||||
date,
|
||||
chat
|
||||
)
|
||||
is SupergroupChat -> ForwardInfo.PublicChat.FromSupergroup(
|
||||
date,
|
||||
chat
|
||||
)
|
||||
}
|
||||
is MessageOrigin.User -> ForwardInfo.ByUser(
|
||||
date,
|
||||
user
|
||||
)
|
||||
}
|
||||
|
||||
fun ForwardInfo.messageOrigin() = when (this) {
|
||||
is ForwardInfo.ByAnonymous -> MessageOrigin.HiddenUser(
|
||||
senderName,
|
||||
dateOfOriginal
|
||||
)
|
||||
is ForwardInfo.ByUser -> MessageOrigin.User(
|
||||
user,
|
||||
dateOfOriginal
|
||||
)
|
||||
is ForwardInfo.PublicChat.FromChannel -> MessageOrigin.Public.Channel(
|
||||
channelChat,
|
||||
messageId,
|
||||
dateOfOriginal,
|
||||
signature
|
||||
)
|
||||
is ForwardInfo.PublicChat.FromSupergroup -> MessageOrigin.Public.Sender(
|
||||
group,
|
||||
dateOfOriginal
|
||||
)
|
||||
is ForwardInfo.PublicChat.SentByChannel -> MessageOrigin.Public.Sender(
|
||||
channelChat,
|
||||
dateOfOriginal
|
||||
)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
|
||||
override val channel: PreviewChannelChat,
|
||||
override val messageId: MessageId,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
@ -23,14 +23,33 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : ConnectedFromChannelGroupContentMessage<T>
|
||||
) : ConnectedFromChannelGroupContentMessage<T> {
|
||||
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
channel: PreviewChannelChat,
|
||||
messageId: MessageId,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
||||
data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
|
||||
override val chat: PreviewGroupChat,
|
||||
override val channel: PreviewChannelChat,
|
||||
override val messageId: MessageId,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
@ -39,13 +58,31 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : UnconnectedFromChannelGroupContentMessage<T>
|
||||
) : UnconnectedFromChannelGroupContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
channel: PreviewChannelChat,
|
||||
messageId: MessageId,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
||||
data class AnonymousGroupContentMessageImpl<T : MessageContent>(
|
||||
override val chat: PreviewGroupChat,
|
||||
override val messageId: MessageId,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
@ -54,14 +91,31 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : AnonymousGroupContentMessage<T>
|
||||
) : AnonymousGroupContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
messageId: MessageId,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
||||
data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val chat: PreviewGroupChat,
|
||||
override val messageId: MessageId,
|
||||
override val from: User,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
@ -69,7 +123,24 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : CommonGroupContentMessage<T>
|
||||
) : CommonGroupContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewGroupChat,
|
||||
messageId: MessageId,
|
||||
from: User,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
||||
data class FromChannelForumContentMessageImpl<T: MessageContent>(
|
||||
override val chat: PreviewForumChat,
|
||||
@ -77,7 +148,7 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageId,
|
||||
override val threadId: MessageThreadId,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
@ -86,14 +157,33 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : FromChannelForumContentMessage<T>
|
||||
) : FromChannelForumContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewForumChat,
|
||||
channel: PreviewChannelChat,
|
||||
messageId: MessageId,
|
||||
threadId: MessageThreadId,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
||||
data class AnonymousForumContentMessageImpl<T : MessageContent>(
|
||||
override val chat: PreviewForumChat,
|
||||
override val messageId: MessageId,
|
||||
override val threadId: MessageThreadId,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
@ -102,7 +192,25 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : AnonymousForumContentMessage<T>
|
||||
) : AnonymousForumContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewForumChat,
|
||||
messageId: MessageId,
|
||||
threadId: MessageThreadId,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
authorSignature: AuthorSignature?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
||||
data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
override val chat: PreviewForumChat,
|
||||
@ -110,7 +218,7 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
override val threadId: MessageThreadId,
|
||||
override val from: User,
|
||||
override val date: DateTime,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
@ -118,4 +226,22 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : CommonForumContentMessage<T>
|
||||
) : CommonForumContentMessage<T> {
|
||||
constructor(
|
||||
chat: PreviewForumChat,
|
||||
messageId: MessageId,
|
||||
threadId: MessageThreadId,
|
||||
from: User,
|
||||
date: DateTime,
|
||||
forwardInfo: ForwardInfo,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
content: T,
|
||||
senderBot: CommonBot?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.*
|
||||
import kotlinx.serialization.Required
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface MessageOrigin {
|
||||
val type: String
|
||||
val date: TelegramDate
|
||||
|
||||
@Serializable
|
||||
data class User(
|
||||
@SerialName(senderUserField)
|
||||
val user: dev.inmo.tgbotapi.types.chat.User,
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate
|
||||
) : MessageOrigin {
|
||||
@SerialName(typeField)
|
||||
@Required
|
||||
override val type: String = Companion.type
|
||||
|
||||
companion object {
|
||||
val type: String = "user"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class HiddenUser(
|
||||
@SerialName(senderUserNameField)
|
||||
val name: String,
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate
|
||||
) : MessageOrigin {
|
||||
@SerialName(typeField)
|
||||
@Required
|
||||
override val type: String = Companion.type
|
||||
|
||||
companion object {
|
||||
val type: String = "hidden_user"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed interface Public : MessageOrigin {
|
||||
val chat: PublicChat
|
||||
val authorSignature: AuthorSignature?
|
||||
|
||||
@Serializable
|
||||
data class Sender(
|
||||
@SerialName(senderChatField)
|
||||
override val chat: SuperPublicChat,
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate,
|
||||
@SerialName(authorSignatureField)
|
||||
override val authorSignature: AuthorSignature? = null
|
||||
) : Public {
|
||||
@SerialName(typeField)
|
||||
@Required
|
||||
override val type: String = Companion.type
|
||||
|
||||
companion object {
|
||||
val type: String = "chat"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Channel(
|
||||
@SerialName(chatField)
|
||||
override val chat: ChannelChat,
|
||||
@SerialName(messageIdField)
|
||||
val messageId: MessageId,
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate,
|
||||
@SerialName(authorSignatureField)
|
||||
override val authorSignature: AuthorSignature? = null
|
||||
) : Public {
|
||||
@SerialName(typeField)
|
||||
@Required
|
||||
override val type: String = Companion.type
|
||||
|
||||
companion object {
|
||||
val type: String = "channel"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,9 +18,26 @@ data class PrivateContentMessageImpl<T: MessageContent>(
|
||||
override val date: DateTime,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
) : PrivateContentMessage<T>
|
||||
) : PrivateContentMessage<T> {
|
||||
constructor(
|
||||
messageId: MessageId,
|
||||
from: User,
|
||||
chat: PreviewPrivateChat,
|
||||
content: T,
|
||||
date: DateTime,
|
||||
editDate: DateTime?,
|
||||
hasProtectedContent: Boolean,
|
||||
forwardInfo: ForwardInfo,
|
||||
replyTo: AccessibleMessage?,
|
||||
replyMarkup: InlineKeyboardMarkup?,
|
||||
senderBot: CommonBot?,
|
||||
mediaGroupId: MediaGroupIdentifier?,
|
||||
) : this(
|
||||
messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo, replyMarkup, senderBot, mediaGroupId
|
||||
)
|
||||
}
|
||||
|
@ -52,12 +52,8 @@ internal data class RawMessage(
|
||||
private val messageThreadId: MessageThreadId? = null,
|
||||
private val from: User? = null,
|
||||
private val sender_chat: PreviewPublicChat? = null,
|
||||
private val forward_from: User? = null,
|
||||
private val forward_from_chat: Chat? = null,
|
||||
private val forward_from_message_id: MessageId? = null,
|
||||
private val forward_signature: ForwardSignature? = null,
|
||||
private val forward_sender_name: ForwardSenderName? = null,
|
||||
private val forward_date: TelegramDate? = null,
|
||||
private val forward_origin: MessageOrigin? = null,
|
||||
private val is_topic_message: Boolean? = null,
|
||||
private val is_automatic_forward: Boolean? = null,
|
||||
private val reply_to_message: RawMessage? = null,
|
||||
private val via_bot: CommonBot? = null,
|
||||
@ -201,44 +197,6 @@ internal data class RawMessage(
|
||||
}
|
||||
}
|
||||
|
||||
private val forwarded: ForwardInfo? by lazy {
|
||||
forward_date
|
||||
?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||
when {
|
||||
forward_sender_name != null -> ForwardInfo.ByAnonymous(
|
||||
forward_date,
|
||||
forward_sender_name
|
||||
)
|
||||
|
||||
forward_from_chat is ChannelChat -> if (forward_from_message_id == null) {
|
||||
ForwardInfo.PublicChat.SentByChannel(
|
||||
forward_date,
|
||||
forward_from_chat,
|
||||
forward_signature
|
||||
)
|
||||
} else {
|
||||
ForwardInfo.PublicChat.FromChannel(
|
||||
forward_date,
|
||||
forward_from_message_id,
|
||||
forward_from_chat,
|
||||
forward_signature
|
||||
)
|
||||
}
|
||||
|
||||
forward_from_chat is SupergroupChat -> ForwardInfo.PublicChat.FromSupergroup(
|
||||
forward_date,
|
||||
forward_from_chat
|
||||
)
|
||||
|
||||
forward_from != null -> ForwardInfo.ByUser(
|
||||
forward_date,
|
||||
forward_from
|
||||
)
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private val chatEvent: ChatEvent? by lazy {
|
||||
when {
|
||||
new_chat_members != null -> NewChatMembers(new_chat_members.toList())
|
||||
@ -334,7 +292,7 @@ internal data class RawMessage(
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
has_protected_content == true,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
@ -356,7 +314,7 @@ internal data class RawMessage(
|
||||
messageId,
|
||||
messageThreadId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -371,7 +329,7 @@ internal data class RawMessage(
|
||||
messageId,
|
||||
messageThreadId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -387,7 +345,7 @@ internal data class RawMessage(
|
||||
messageThreadId,
|
||||
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -405,7 +363,7 @@ internal data class RawMessage(
|
||||
sender_chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -421,7 +379,7 @@ internal data class RawMessage(
|
||||
sender_chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -436,7 +394,7 @@ internal data class RawMessage(
|
||||
chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -451,7 +409,7 @@ internal data class RawMessage(
|
||||
messageId,
|
||||
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -469,7 +427,7 @@ internal data class RawMessage(
|
||||
sender_chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -485,7 +443,7 @@ internal data class RawMessage(
|
||||
sender_chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -500,7 +458,7 @@ internal data class RawMessage(
|
||||
chat,
|
||||
messageId,
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -515,7 +473,7 @@ internal data class RawMessage(
|
||||
messageId,
|
||||
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),
|
||||
date.asDate,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
@ -534,7 +492,7 @@ internal data class RawMessage(
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
has_protected_content == true,
|
||||
forwarded,
|
||||
forward_origin,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
|
@ -1,7 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.ForwardInfo
|
||||
import dev.inmo.tgbotapi.types.message.MessageOrigin
|
||||
import dev.inmo.tgbotapi.types.message.forwardInfo
|
||||
|
||||
interface PossiblyForwardedMessage : AccessibleMessage {
|
||||
val forwardOrigin: MessageOrigin?
|
||||
val forwardInfo: ForwardInfo?
|
||||
get() = forwardOrigin ?.forwardInfo()
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.utils.extensions
|
||||
|
||||
import dev.inmo.tgbotapi.types.MediaGroupIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl
|
||||
import dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl
|
||||
@ -15,7 +14,6 @@ import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ConnectedFromChannelGroupContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
||||
@ -41,7 +39,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.date,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyMarkup,
|
||||
sourceMessage.senderBot,
|
||||
@ -56,7 +54,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.date,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyMarkup,
|
||||
sourceMessage.senderBot,
|
||||
@ -66,7 +64,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.chat,
|
||||
sourceMessage.messageId,
|
||||
sourceMessage.date,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
@ -81,7 +79,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.messageId,
|
||||
sourceMessage.user,
|
||||
sourceMessage.date,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
@ -95,7 +93,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.channel,
|
||||
sourceMessage.messageId,
|
||||
sourceMessage.date,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
@ -110,7 +108,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.channel,
|
||||
sourceMessage.messageId,
|
||||
sourceMessage.date,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
@ -125,7 +123,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.messageId,
|
||||
sourceMessage.threadId,
|
||||
sourceMessage.date,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
@ -141,7 +139,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.threadId,
|
||||
sourceMessage.user,
|
||||
sourceMessage.date,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
@ -156,7 +154,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.messageId,
|
||||
sourceMessage.threadId,
|
||||
sourceMessage.date,
|
||||
sourceMessage.forwardInfo,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
|
Loading…
Reference in New Issue
Block a user