mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
add support of is_automatic_forward
This commit is contained in:
parent
0581587adf
commit
69f4033807
@ -4,11 +4,10 @@ import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class ChannelContentMessageImpl<T: MessageContent>(
|
||||
data class ConnectedChannelContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: ChannelChat,
|
||||
override val content: T,
|
||||
@ -19,4 +18,4 @@ data class ChannelContentMessageImpl<T: MessageContent>(
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : ChannelContentMessage<T>
|
||||
) : ConnectedChannelContentMessage<T>
|
@ -42,6 +42,7 @@ internal data class RawMessage(
|
||||
private val forward_signature: ForwardSignature? = null,
|
||||
private val forward_sender_name: ForwardSenderName? = null,
|
||||
private val forward_date: TelegramDate? = null,
|
||||
private val is_automatic_forward: Boolean? = null,
|
||||
private val reply_to_message: RawMessage? = null,
|
||||
private val via_bot: CommonBot? = null,
|
||||
private val edit_date: TelegramDate? = null,
|
||||
@ -269,18 +270,33 @@ internal data class RawMessage(
|
||||
}
|
||||
} ?: when (chat) {
|
||||
is PublicChat -> when (chat) {
|
||||
is ChannelChat -> ChannelContentMessageImpl(
|
||||
messageId,
|
||||
chat,
|
||||
content,
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
is ChannelChat -> if (is_automatic_forward == true) {
|
||||
ConnectedChannelContentMessageImpl(
|
||||
messageId,
|
||||
chat,
|
||||
content,
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
} else {
|
||||
UnconnectedChannelContentMessageImpl(
|
||||
messageId,
|
||||
chat,
|
||||
content,
|
||||
date.asDate,
|
||||
edit_date?.asDate,
|
||||
forwarded,
|
||||
reply_to_message?.asMessage,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
author_signature
|
||||
)
|
||||
}
|
||||
is GroupChat -> when (sender_chat) {
|
||||
is ChannelChat -> FromChannelGroupContentMessageImpl(
|
||||
chat,
|
||||
|
@ -0,0 +1,24 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class UnconnectedChannelContentMessageImpl<T: MessageContent>(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val chat: ChannelChat,
|
||||
override val content: T,
|
||||
override val date: DateTime,
|
||||
override val editDate: DateTime?,
|
||||
override val forwardInfo: ForwardInfo?,
|
||||
override val replyTo: Message?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?
|
||||
) : UnconnectedChannelContentMessage<T>
|
||||
|
||||
@Deprecated("Renamed to UnconnectedChannelContentMessage", ReplaceWith("UnconnectedChannelContentMessage", "dev.inmo.tgbotapi.types.message.UnconnectedChannelContentMessageImpl"))
|
||||
typealias ChannelContentMessageImpl<T> = UnconnectedChannelContentMessage<T>
|
@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||
|
||||
interface ChannelContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, SignedMessage, WithSenderChatMessage {
|
||||
sealed interface ChannelContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, SignedMessage, WithSenderChatMessage {
|
||||
override val chat: ChannelChat
|
||||
override val senderChat: ChannelChat
|
||||
get() = chat
|
@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
interface ConnectedChannelContentMessage<T: MessageContent> : ChannelContentMessage<T>
|
@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||
|
||||
interface UnconnectedChannelContentMessage<T: MessageContent> : ChannelContentMessage<T>
|
@ -915,15 +915,15 @@ inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupCont
|
||||
this as AnonymousGroupContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenChannelContentMessageImpl(block: (ChannelContentMessageImpl<MessageContent>) -> T) = asChannelContentMessageImpl() ?.let(block)
|
||||
inline fun <T> Message.whenChannelContentMessageImpl(block: (UnconnectedChannelContentMessageImpl<MessageContent>) -> T) = asChannelContentMessageImpl() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asChannelContentMessageImpl(): ChannelContentMessageImpl<MessageContent>? =
|
||||
this as? ChannelContentMessageImpl<MessageContent>
|
||||
inline fun Message.asChannelContentMessageImpl(): UnconnectedChannelContentMessageImpl<MessageContent>? =
|
||||
this as? UnconnectedChannelContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireChannelContentMessageImpl(): ChannelContentMessageImpl<MessageContent> =
|
||||
this as ChannelContentMessageImpl<MessageContent>
|
||||
inline fun Message.requireChannelContentMessageImpl(): UnconnectedChannelContentMessageImpl<MessageContent> =
|
||||
this as UnconnectedChannelContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenFromChannelGroupContentMessageImpl(block: (FromChannelGroupContentMessageImpl<MessageContent>) -> T) = asFromChannelGroupContentMessageImpl() ?.let(block)
|
||||
@ -1027,11 +1027,33 @@ inline fun <T> Message.whenChannelContentMessage(block: (ChannelContentMessage<M
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asChannelContentMessage(): ChannelContentMessage<MessageContent>? =
|
||||
this as? ChannelContentMessageImpl<MessageContent>
|
||||
this as? ChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireChannelContentMessage(): ChannelContentMessageImpl<MessageContent> =
|
||||
this as ChannelContentMessageImpl<MessageContent>
|
||||
inline fun Message.requireChannelContentMessage(): ChannelContentMessage<MessageContent> =
|
||||
this as ChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenConnectedChannelContentMessage(block: (ConnectedChannelContentMessage<MessageContent>) -> T) = asConnectedChannelContentMessage() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asConnectedChannelContentMessage(): ConnectedChannelContentMessage<MessageContent>? =
|
||||
this as? ConnectedChannelContentMessageImpl<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireConnectedChannelContentMessage(): ConnectedChannelContentMessage<MessageContent> =
|
||||
this as ConnectedChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenUnconnectedChannelContentMessage(block: (UnconnectedChannelContentMessage<MessageContent>) -> T) = asUnconnectedChannelContentMessage() ?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.asUnconnectedChannelContentMessage(): UnconnectedChannelContentMessage<MessageContent>? =
|
||||
this as? UnconnectedChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun Message.requireUnconnectedChannelContentMessage(): UnconnectedChannelContentMessage<MessageContent> =
|
||||
this as UnconnectedChannelContentMessage<MessageContent>
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> Message.whenChatEventMessage(block: (ChatEventMessage<ChatEvent>) -> T) = asChatEventMessage() ?.let(block)
|
||||
|
Loading…
Reference in New Issue
Block a user