mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
forwarded messages changes
This commit is contained in:
parent
562bc0357d
commit
cfb988ec7f
@ -11,6 +11,12 @@ some default library
|
||||
* Small refactoring of work with response in `KtorRequestsExecutor`
|
||||
* Kotlin version `1.3.30` -> `1.3.31`
|
||||
* Kotlin coroutines `1.2.0` -> `1.2.1`
|
||||
* `CommonForwardedMessage` was renamed to `UserForwardedMessage`
|
||||
* All forwarded messages are now just childs of `ForwardedMessage`:
|
||||
* `AnonymousForwardedMessage` - for messages without forwarded info
|
||||
* `UserForwardedMessage` - for messages from users and groups (contains not message id)
|
||||
* `ForwardedFromChannelMessage` - for messages from channels
|
||||
* Changed logic of forwarded messages preparing
|
||||
|
||||
## 0.13.0 Telegram Polls
|
||||
|
||||
|
@ -12,21 +12,20 @@ data class AnonymousForwardedMessage(
|
||||
val senderName: String
|
||||
) : ForwardedMessage()
|
||||
|
||||
sealed class PublicForwardedMessage : ForwardedMessage() {
|
||||
abstract val messageId: MessageIdentifier
|
||||
abstract val from: User?
|
||||
}
|
||||
|
||||
data class CommonForwardedMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
data class UserForwardedMessage(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
override val from: User
|
||||
) : PublicForwardedMessage()
|
||||
val from: User
|
||||
) : ForwardedMessage()
|
||||
|
||||
@Deprecated(
|
||||
"Renamed according to correct meaning",
|
||||
ReplaceWith("UserForwardedMessage", "com.github.insanusmokrassar.TelegramBotAPI.types.message.UserForwardedMessage")
|
||||
)
|
||||
typealias CommonForwardedMessage = UserForwardedMessage
|
||||
|
||||
data class ForwardedFromChannelMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
override val from: User?,
|
||||
val messageId: MessageIdentifier,
|
||||
val channelChat: Chat,
|
||||
val signature: String? = null
|
||||
) : PublicForwardedMessage()
|
||||
) : ForwardedMessage()
|
||||
|
@ -134,25 +134,22 @@ data class RawMessage(
|
||||
@Transient
|
||||
private val forwarded: ForwardedMessage? by lazy {
|
||||
forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||
forward_sender_name ?.let {
|
||||
AnonymousForwardedMessage(
|
||||
when {
|
||||
forward_sender_name != null -> AnonymousForwardedMessage(
|
||||
forward_date,
|
||||
forward_sender_name
|
||||
)
|
||||
} ?: forward_from_message_id ?.let {
|
||||
forward_from_chat ?.let {
|
||||
ForwardedFromChannelMessage(
|
||||
forward_from_message_id,
|
||||
forward_date,
|
||||
forward_from,
|
||||
forward_from_chat.extractChat(),
|
||||
forward_signature
|
||||
)
|
||||
} ?: CommonForwardedMessage(
|
||||
forward_from_message_id,
|
||||
forward_from_chat != null -> ForwardedFromChannelMessage(
|
||||
forward_date,
|
||||
forward_from ?: throw IllegalStateException("For common forwarded messages author of original message declared as set up required")
|
||||
forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"),
|
||||
forward_from_chat.extractChat(),
|
||||
forward_signature
|
||||
)
|
||||
forward_from != null -> UserForwardedMessage(
|
||||
forward_date,
|
||||
forward_from
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user