mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
AnonymousForwardedMessage
This commit is contained in:
parent
2b831a803a
commit
ba368e9fa4
@ -16,6 +16,8 @@ by their parents
|
|||||||
`com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts` package
|
`com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts` package
|
||||||
* Common Groups now may have pinned message
|
* Common Groups now may have pinned message
|
||||||
* `is_member` field added into `RestrictedChatMember`
|
* `is_member` field added into `RestrictedChatMember`
|
||||||
|
* **BREAK CHANGES** Now `ForwardedMessages` can be `AnonymousForwardedMessage` and `PublicForwardedMessage`. Old
|
||||||
|
implementations now extend `PublicForwardedMessage`
|
||||||
|
|
||||||
## 0.12.0 Webhooks
|
## 0.12.0 Webhooks
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ typealias InlineQueryIdentifier = String
|
|||||||
typealias UpdateIdentifier = Long
|
typealias UpdateIdentifier = Long
|
||||||
typealias MediaGroupIdentifier = String
|
typealias MediaGroupIdentifier = String
|
||||||
typealias ForwardSignature = String
|
typealias ForwardSignature = String
|
||||||
|
typealias ForwardSenderName = String
|
||||||
typealias AuthorSignature = ForwardSignature
|
typealias AuthorSignature = ForwardSignature
|
||||||
typealias CallbackQueryIdentifier = String
|
typealias CallbackQueryIdentifier = String
|
||||||
typealias PaymentQueryIdentifier = String
|
typealias PaymentQueryIdentifier = String
|
||||||
|
@ -4,8 +4,16 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
sealed class ForwardedMessage {
|
sealed class ForwardedMessage {
|
||||||
abstract val messageId: MessageIdentifier
|
|
||||||
abstract val dateOfOriginal: TelegramDate
|
abstract val dateOfOriginal: TelegramDate
|
||||||
|
}
|
||||||
|
|
||||||
|
data class AnonymousForwardedMessage(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val senderName: String
|
||||||
|
) : ForwardedMessage()
|
||||||
|
|
||||||
|
sealed class PublicForwardedMessage : ForwardedMessage() {
|
||||||
|
abstract val messageId: MessageIdentifier
|
||||||
abstract val from: User?
|
abstract val from: User?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +21,7 @@ data class CommonForwardedMessage(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
override val dateOfOriginal: TelegramDate,
|
override val dateOfOriginal: TelegramDate,
|
||||||
override val from: User
|
override val from: User
|
||||||
) : ForwardedMessage()
|
) : PublicForwardedMessage()
|
||||||
|
|
||||||
data class ForwardedFromChannelMessage(
|
data class ForwardedFromChannelMessage(
|
||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@ -21,4 +29,4 @@ data class ForwardedFromChannelMessage(
|
|||||||
override val from: User?,
|
override val from: User?,
|
||||||
val channelChat: Chat,
|
val channelChat: Chat,
|
||||||
val signature: String? = null
|
val signature: String? = null
|
||||||
) : ForwardedMessage()
|
) : PublicForwardedMessage()
|
||||||
|
@ -37,6 +37,7 @@ data class RawMessage(
|
|||||||
private val forward_from_chat: RawChat? = null,
|
private val forward_from_chat: RawChat? = null,
|
||||||
private val forward_from_message_id: MessageIdentifier? = null,
|
private val forward_from_message_id: MessageIdentifier? = null,
|
||||||
private val forward_signature: ForwardSignature? = null,
|
private val forward_signature: ForwardSignature? = null,
|
||||||
|
private val forward_sender_name: ForwardSenderName? = null,
|
||||||
private val forward_date: TelegramDate? = null,
|
private val forward_date: TelegramDate? = null,
|
||||||
private val reply_to_message: RawMessage? = null,
|
private val reply_to_message: RawMessage? = null,
|
||||||
private val edit_date: TelegramDate? = null,
|
private val edit_date: TelegramDate? = null,
|
||||||
@ -132,8 +133,9 @@ data class RawMessage(
|
|||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private val forwarded: ForwardedMessage? by lazy {
|
private val forwarded: ForwardedMessage? by lazy {
|
||||||
|
forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||||
forward_from_message_id ?.let {
|
forward_from_message_id ?.let {
|
||||||
forward_date ?: throw IllegalStateException("For forwarded messages date of original message declared as set up required")
|
forward_from ?: throw IllegalStateException("For common forwarded messages author of original message declared as set up required")
|
||||||
forward_from_chat ?.let {
|
forward_from_chat ?.let {
|
||||||
ForwardedFromChannelMessage(
|
ForwardedFromChannelMessage(
|
||||||
forward_from_message_id,
|
forward_from_message_id,
|
||||||
@ -146,7 +148,11 @@ data class RawMessage(
|
|||||||
forward_from_message_id,
|
forward_from_message_id,
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from
|
forward_from
|
||||||
?: throw IllegalStateException("For common forwarded messages author of original message declared as set up required")
|
)
|
||||||
|
} ?: forward_sender_name ?.let {
|
||||||
|
AnonymousForwardedMessage(
|
||||||
|
forward_date,
|
||||||
|
forward_sender_name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user