mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +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`
|
* Small refactoring of work with response in `KtorRequestsExecutor`
|
||||||
* Kotlin version `1.3.30` -> `1.3.31`
|
* Kotlin version `1.3.30` -> `1.3.31`
|
||||||
* Kotlin coroutines `1.2.0` -> `1.2.1`
|
* 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
|
## 0.13.0 Telegram Polls
|
||||||
|
|
||||||
|
@ -12,21 +12,20 @@ data class AnonymousForwardedMessage(
|
|||||||
val senderName: String
|
val senderName: String
|
||||||
) : ForwardedMessage()
|
) : ForwardedMessage()
|
||||||
|
|
||||||
sealed class PublicForwardedMessage : ForwardedMessage() {
|
data class UserForwardedMessage(
|
||||||
abstract val messageId: MessageIdentifier
|
|
||||||
abstract val from: User?
|
|
||||||
}
|
|
||||||
|
|
||||||
data class CommonForwardedMessage(
|
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
override val dateOfOriginal: TelegramDate,
|
override val dateOfOriginal: TelegramDate,
|
||||||
override val from: User
|
val from: User
|
||||||
) : PublicForwardedMessage()
|
) : ForwardedMessage()
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Renamed according to correct meaning",
|
||||||
|
ReplaceWith("UserForwardedMessage", "com.github.insanusmokrassar.TelegramBotAPI.types.message.UserForwardedMessage")
|
||||||
|
)
|
||||||
|
typealias CommonForwardedMessage = UserForwardedMessage
|
||||||
|
|
||||||
data class ForwardedFromChannelMessage(
|
data class ForwardedFromChannelMessage(
|
||||||
override val messageId: MessageIdentifier,
|
|
||||||
override val dateOfOriginal: TelegramDate,
|
override val dateOfOriginal: TelegramDate,
|
||||||
override val from: User?,
|
val messageId: MessageIdentifier,
|
||||||
val channelChat: Chat,
|
val channelChat: Chat,
|
||||||
val signature: String? = null
|
val signature: String? = null
|
||||||
) : PublicForwardedMessage()
|
) : ForwardedMessage()
|
||||||
|
@ -134,25 +134,22 @@ 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_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||||
forward_sender_name ?.let {
|
when {
|
||||||
AnonymousForwardedMessage(
|
forward_sender_name != null -> AnonymousForwardedMessage(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_sender_name
|
forward_sender_name
|
||||||
)
|
)
|
||||||
} ?: forward_from_message_id ?.let {
|
forward_from_chat != null -> ForwardedFromChannelMessage(
|
||||||
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_date,
|
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