1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 03:58:44 +00:00

support of has_protected_content field

This commit is contained in:
InsanusMokrassar 2021-12-18 23:11:28 +06:00
parent ee815c7335
commit dc89e914a1
8 changed files with 139 additions and 10 deletions

View File

@ -16,7 +16,21 @@ data class ChannelMediaGroupMessage<T : MediaGroupContent>(
override val mediaGroupId: MediaGroupIdentifier,
override val content: T,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val forwardInfo: ForwardInfo?,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?
) : MediaGroupMessage<T>
) : MediaGroupMessage<T> {
@Deprecated("Use the constructor with forwardable field")
constructor(
messageId: MessageIdentifier,
chat: Chat,
date: DateTime,
mediaGroupId: MediaGroupIdentifier,
content: T,
editDate: DateTime?,
forwardInfo: ForwardInfo?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?
) : this(messageId, chat, date, mediaGroupId, content, editDate, true, forwardInfo, replyTo, replyMarkup)
}

View File

@ -15,7 +15,22 @@ data class CommonMediaGroupMessage<T : MediaGroupContent>(
override val mediaGroupId: MediaGroupIdentifier,
override val content: T,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val forwardInfo: ForwardInfo?,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?
) : MediaGroupMessage<T>, FromUserMessage
) : MediaGroupMessage<T>, FromUserMessage {
@Deprecated("Use the constructor with forwardable field")
constructor(
messageId: MessageIdentifier,
from: User,
chat: Chat,
date: DateTime,
mediaGroupId: MediaGroupIdentifier,
content: T,
editDate: DateTime?,
forwardInfo: ForwardInfo?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?
) : this(messageId, from, chat, date, mediaGroupId, content, editDate, true, forwardInfo, replyTo, replyMarkup)
}

View File

@ -13,9 +13,24 @@ data class ConnectedChannelContentMessageImpl<T: MessageContent>(
override val content: T,
override val date: DateTime,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val forwardInfo: ForwardInfo?,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?
) : ConnectedChannelContentMessage<T>
) : ConnectedChannelContentMessage<T> {
@Deprecated("Use the constructor with forwardable field")
constructor(
messageId: MessageIdentifier,
chat: ChannelChat,
content: T,
date: DateTime,
editDate: DateTime?,
forwardInfo: ForwardInfo?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?,
senderBot: CommonBot?,
authorSignature: AuthorSignature?
) : this(messageId, chat, content, date, editDate, true, forwardInfo, replyTo, replyMarkup, senderBot, authorSignature)
}

View File

@ -15,12 +15,28 @@ data class FromChannelGroupContentMessageImpl<T : MessageContent>(
override val date: DateTime,
override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?,
override val content: T,
override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?
) : FromChannelGroupContentMessage<T>
) : FromChannelGroupContentMessage<T> {
@Deprecated("Use the constructor with forwardable field")
constructor(
chat: GroupChat,
channel: ChannelChat,
messageId: MessageIdentifier,
date: DateTime,
forwardInfo: ForwardInfo?,
editDate: DateTime?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?,
content: T,
senderBot: CommonBot?,
authorSignature: AuthorSignature?
) : this(chat, channel, messageId, date, forwardInfo, editDate, true, replyTo, replyMarkup, content, senderBot, authorSignature)
}
data class AnonymousGroupContentMessageImpl<T : MessageContent>(
override val chat: GroupChat,
@ -28,12 +44,27 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
override val date: DateTime,
override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?,
override val content: T,
override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?
) : AnonymousGroupContentMessage<T>
) : AnonymousGroupContentMessage<T> {
@Deprecated("Use the constructor with forwardable field")
constructor(
chat: GroupChat,
messageId: MessageIdentifier,
date: DateTime,
forwardInfo: ForwardInfo?,
editDate: DateTime?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?,
content: T,
senderBot: CommonBot?,
authorSignature: AuthorSignature?
) : this(chat, messageId, date, forwardInfo, editDate, true, replyTo, replyMarkup, content, senderBot, authorSignature)
}
data class CommonGroupContentMessageImpl<T : MessageContent>(
override val chat: GroupChat,
@ -42,8 +73,23 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
override val date: DateTime,
override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?,
override val content: T,
override val senderBot: CommonBot?
) : CommonGroupContentMessage<T>
) : CommonGroupContentMessage<T> {
@Deprecated("Use the constructor with forwardable field")
constructor(
chat: GroupChat,
messageId: MessageIdentifier,
from: User,
date: DateTime,
forwardInfo: ForwardInfo?,
editDate: DateTime?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?,
content: T,
senderBot: CommonBot?
) : this(chat, messageId, from, date, forwardInfo, editDate, true, replyTo, replyMarkup, content, senderBot)
}

View File

@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
data class PrivateContentMessageImpl<T: MessageContent>(
override val messageId: MessageIdentifier,
@ -16,8 +15,23 @@ data class PrivateContentMessageImpl<T: MessageContent>(
override val content: T,
override val date: DateTime,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val forwardInfo: ForwardInfo?,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?,
) : PrivateContentMessage<T>
override val senderBot: CommonBot?
) : PrivateContentMessage<T> {
@Deprecated("Use the constructor with forwardable field")
constructor(
messageId: MessageIdentifier,
from: User,
chat: Chat,
content: T,
date: DateTime,
editDate: DateTime?,
forwardInfo: ForwardInfo?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?,
senderBot: CommonBot?
) : this(messageId, from, chat, content, date, editDate, true, forwardInfo, replyTo, replyMarkup, senderBot)
}

View File

@ -46,6 +46,7 @@ internal data class RawMessage(
private val reply_to_message: RawMessage? = null,
private val via_bot: CommonBot? = null,
private val edit_date: TelegramDate? = null,
private val has_protected_content: Boolean? = null,
private val media_group_id: MediaGroupIdentifier? = null,
private val author_signature: AuthorSignature? = null,
private val text: String? = null,
@ -251,6 +252,7 @@ internal data class RawMessage(
it,
checkedContent,
edit_date?.asDate,
has_protected_content == true,
forwarded,
reply_to_message?.asMessage,
reply_markup
@ -263,6 +265,7 @@ internal data class RawMessage(
it,
checkedContent,
edit_date?.asDate,
has_protected_content == true,
forwarded,
reply_to_message?.asMessage,
reply_markup
@ -277,6 +280,7 @@ internal data class RawMessage(
content,
date.asDate,
edit_date?.asDate,
has_protected_content == true,
forwarded,
reply_to_message?.asMessage,
reply_markup,
@ -290,6 +294,7 @@ internal data class RawMessage(
content,
date.asDate,
edit_date?.asDate,
has_protected_content == true,
forwarded,
reply_to_message?.asMessage,
reply_markup,
@ -305,6 +310,7 @@ internal data class RawMessage(
date.asDate,
forwarded,
edit_date ?.asDate,
has_protected_content == true,
reply_to_message ?.asMessage,
reply_markup,
content,
@ -317,6 +323,7 @@ internal data class RawMessage(
date.asDate,
forwarded,
edit_date ?.asDate,
has_protected_content == true,
reply_to_message ?.asMessage,
reply_markup,
content,
@ -330,6 +337,7 @@ internal data class RawMessage(
date.asDate,
forwarded,
edit_date ?.asDate,
has_protected_content == true,
reply_to_message ?.asMessage,
reply_markup,
content,
@ -346,6 +354,7 @@ internal data class RawMessage(
content,
date.asDate,
edit_date?.asDate,
has_protected_content == true,
forwarded,
reply_to_message?.asMessage,
reply_markup,

View File

@ -13,12 +13,27 @@ data class UnconnectedChannelContentMessageImpl<T: MessageContent>(
override val content: T,
override val date: DateTime,
override val editDate: DateTime?,
override val forwardable: Boolean,
override val forwardInfo: ForwardInfo?,
override val replyTo: Message?,
override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?
) : UnconnectedChannelContentMessage<T>
) : UnconnectedChannelContentMessage<T> {
@Deprecated("Use the constructor with forwardable field")
constructor(
messageId: MessageIdentifier,
chat: ChannelChat,
content: T,
date: DateTime,
editDate: DateTime?,
forwardInfo: ForwardInfo?,
replyTo: Message?,
replyMarkup: InlineKeyboardMarkup?,
senderBot: CommonBot?,
authorSignature: AuthorSignature?
) : this(messageId, chat, content, date, editDate, true, forwardInfo, replyTo, replyMarkup, senderBot, authorSignature)
}
@Deprecated("Renamed to UnconnectedChannelContentMessage", ReplaceWith("UnconnectedChannelContentMessage", "dev.inmo.tgbotapi.types.message.UnconnectedChannelContentMessageImpl"))
typealias ChannelContentMessageImpl<T> = UnconnectedChannelContentMessage<T>

View File

@ -3,5 +3,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
interface ContentMessage<T: MessageContent>: Message {
val forwardable: Boolean
val content: T
}