diff --git a/CHANGELOG.md b/CHANGELOG.md index eae79d019f..6216320bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ * **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`** * `SendMessage` was renamed to `SendTextMessage` and previous `SendMessage` is deprecated +* All `AbleToBe*` interfaces was renamed to `Possibly*` + * `AbleToBeEditedMessage` -> `PossiblyEditedMessage` + * `AbleToBeForwardedMessage` -> `PossiblyForwardedMessage` + * `AbleToBeMarkedUp` -> `PossiblyMarkedUp` + * `AbleToBeEditedMessage` -> `PossiblyEditedMessage` +* `ForwardedMessage` type was renamed to `ForwardInfo` + * `AnonymousForwardedMessage` -> `AnonymousForwardInfo` + * `UserForwardedMessage` -> `UserForwardInfo` + * `ForwardedFromChannelMessage` -> `ForwardFromChannelInfo` + * `PossiblyForwardedMessage#forwarded` field now renamed to `forwardInfo` * Most part of requests have changed return type. They are listed below:
diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt index 66940cb2f1..ad9b12c266 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/ForwardMessage.kt @@ -3,12 +3,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import kotlinx.serialization.* -private val AbleToBeForwardedMessageDeserializer = TelegramBotAPIMessageDeserializationStrategyClass() +private val AbleToBeForwardedMessageDeserializer = TelegramBotAPIMessageDeserializationStrategyClass() @Serializable data class ForwardMessage( @@ -20,13 +18,13 @@ data class ForwardMessage( override val messageId: MessageIdentifier, @SerialName(disableNotificationField) val disableNotification: Boolean = false -): SimpleRequest, MessageAction { +): SimpleRequest, MessageAction { override val chatId: ChatIdentifier get() = fromChatId override fun method(): String = "forwardMessage" - override val resultDeserializer: DeserializationStrategy + override val resultDeserializer: DeserializationStrategy get() = AbleToBeForwardedMessageDeserializer override val requestSerializer: SerializationStrategy<*> get() = serializer() diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMediaGroupMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMediaGroupMessage.kt index b6f84d2a02..dffb332367 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMediaGroupMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMediaGroupMessage.kt @@ -16,7 +16,7 @@ data class ChannelMediaGroupMessage( override val mediaGroupId: MediaGroupIdentifier, override val content: MediaGroupContent, override val editDate: DateTime?, - override val forwarded: ForwardedMessage?, + override val forwardInfo: ForwardInfo?, override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup? ) : MediaGroupMessage diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt index 4129da66fc..990804d6b1 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt @@ -15,7 +15,7 @@ data class ChannelMessage( override val content: T, override val date: DateTime, override val editDate: DateTime?, - override val forwarded: ForwardedMessage?, + override val forwardInfo: ForwardInfo?, override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup?, val authorSignature: AuthorSignature? diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMediaGroupMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMediaGroupMessage.kt index 026469d707..cc4c0307cc 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMediaGroupMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMediaGroupMessage.kt @@ -15,7 +15,7 @@ data class CommonMediaGroupMessage( override val mediaGroupId: MediaGroupIdentifier, override val content: MediaGroupContent, override val editDate: DateTime?, - override val forwarded: ForwardedMessage?, + override val forwardInfo: ForwardInfo?, override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup? ) : MediaGroupMessage, FromUserMessage diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt index e58b5f6852..d54fcec119 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt @@ -16,7 +16,7 @@ data class CommonMessageImpl( override val content: T, override val date: DateTime, override val editDate: DateTime?, - override val forwarded: ForwardedMessage?, + override val forwardInfo: ForwardInfo?, override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup?, val paymentInfo: PaymentInfo? diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardInfo.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardInfo.kt new file mode 100644 index 0000000000..662987f39a --- /dev/null +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardInfo.kt @@ -0,0 +1,57 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.message + +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat + +@Deprecated( + "Renamed", + ReplaceWith( + "ForwardInfo", + "com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo" + ) +) +typealias ForwardedMessage = ForwardInfo +sealed class ForwardInfo { + abstract val dateOfOriginal: TelegramDate +} + +@Deprecated( + "Renamed", + ReplaceWith( + "AnonymousForwardInfo", + "com.github.insanusmokrassar.TelegramBotAPI.types.message.AnonymousForwardInfo" + ) +) +typealias AnonymousForwardedMessage = AnonymousForwardInfo +data class AnonymousForwardInfo( + override val dateOfOriginal: TelegramDate, + val senderName: String +) : ForwardInfo() + +@Deprecated( + "Renamed", + ReplaceWith( + "UserForwardInfo", + "com.github.insanusmokrassar.TelegramBotAPI.types.message.UserForwardInfo" + ) +) +typealias UserForwardedMessage = UserForwardInfo +data class UserForwardInfo( + override val dateOfOriginal: TelegramDate, + val from: User +) : ForwardInfo() + +@Deprecated( + "Renamed", + ReplaceWith( + "ForwardFromChannelInfo", + "com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardFromChannelInfo" + ) +) +typealias ForwardedFromChannelMessage = ForwardFromChannelInfo +data class ForwardFromChannelInfo( + override val dateOfOriginal: TelegramDate, + val messageId: MessageIdentifier, + val channelChat: Chat, + val signature: String? = null +) : ForwardInfo() diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardedMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardedMessage.kt deleted file mode 100644 index 7d6b370c41..0000000000 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ForwardedMessage.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.github.insanusmokrassar.TelegramBotAPI.types.message - -import com.github.insanusmokrassar.TelegramBotAPI.types.* -import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat - -sealed class ForwardedMessage { - abstract val dateOfOriginal: TelegramDate -} - -data class AnonymousForwardedMessage( - override val dateOfOriginal: TelegramDate, - val senderName: String -) : ForwardedMessage() - -data class UserForwardedMessage( - override val dateOfOriginal: TelegramDate, - val from: User -) : ForwardedMessage() - -data class ForwardedFromChannelMessage( - override val dateOfOriginal: TelegramDate, - val messageId: MessageIdentifier, - val channelChat: Chat, - val signature: String? = null -) : ForwardedMessage() diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt index 1a48869f16..ef6537a122 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt @@ -134,20 +134,20 @@ internal data class RawMessage( } @Transient - private val forwarded: ForwardedMessage? by lazy { + private val forwarded: ForwardInfo? by lazy { forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field when { - forward_sender_name != null -> AnonymousForwardedMessage( + forward_sender_name != null -> AnonymousForwardInfo( forward_date, forward_sender_name ) - forward_from_chat != null -> ForwardedFromChannelMessage( + forward_from_chat != null -> ForwardFromChannelInfo( forward_date, forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"), forward_from_chat, forward_signature ) - forward_from != null -> UserForwardedMessage( + forward_from != null -> UserForwardInfo( forward_date, forward_from ) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeForwardedMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeForwardedMessage.kt deleted file mode 100644 index c1acd3a459..0000000000 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeForwardedMessage.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts - -import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage - -interface AbleToBeForwardedMessage : Message { - val forwarded: ForwardedMessage? -} \ No newline at end of file diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/CommonMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/CommonMessage.kt index ba53e0cfac..80b56bdc20 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/CommonMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/CommonMessage.kt @@ -3,8 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent interface CommonMessage : Message, - AbleToBeForwardedMessage, - AbleToBeEditedMessage, - AbleToReplyMessage, - AbleToBeMarkedUp, + PossiblyForwardedMessage, + PossiblyEditedMessage, + PossiblyReplyMessage, + PossiblyMarkedUp, ContentMessage diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeEditedMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyEditedMessage.kt similarity index 75% rename from src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeEditedMessage.kt rename to src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyEditedMessage.kt index 1c94dd56ae..710889181b 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeEditedMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyEditedMessage.kt @@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts import com.soywiz.klock.DateTime -interface AbleToBeEditedMessage : Message { +interface PossiblyEditedMessage : Message { val editDate: DateTime? } \ No newline at end of file diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyForwardedMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyForwardedMessage.kt new file mode 100644 index 0000000000..01e2b58768 --- /dev/null +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyForwardedMessage.kt @@ -0,0 +1,13 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts + +import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo + +interface PossiblyForwardedMessage : Message { + val forwardInfo: ForwardInfo? + @Deprecated( + "Renamed", + ReplaceWith("forwardInfo") + ) + val forwarded: ForwardInfo? + get() = forwardInfo +} \ No newline at end of file diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeMarkedUp.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyMarkedUp.kt similarity index 87% rename from src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeMarkedUp.kt rename to src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyMarkedUp.kt index aa0d969786..7e2e89ee42 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBeMarkedUp.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyMarkedUp.kt @@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup -interface AbleToBeMarkedUp { +interface PossiblyMarkedUp { val replyMarkup: InlineKeyboardMarkup? } \ No newline at end of file diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBePaymentedMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyPaymentMessage.kt similarity index 81% rename from src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBePaymentedMessage.kt rename to src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyPaymentMessage.kt index 5a879b9e9c..ab2a5d5b29 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToBePaymentedMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyPaymentMessage.kt @@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo -interface AbleToBePaymentedMessage : Message { +interface PossiblyPaymentMessage : Message { val paymentInfo: PaymentInfo? } \ No newline at end of file diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToReplyMessage.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyReplyMessage.kt similarity index 75% rename from src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToReplyMessage.kt rename to src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyReplyMessage.kt index 3cbe77739e..a68494790e 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/AbleToReplyMessage.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/PossiblyReplyMessage.kt @@ -1,5 +1,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts -interface AbleToReplyMessage { +interface PossiblyReplyMessage { val replyTo: Message? } \ No newline at end of file diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MediaGroupList.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MediaGroupList.kt index 3f8961013c..bdfd2313ce 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MediaGroupList.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/utils/MediaGroupList.kt @@ -2,18 +2,18 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate -val List.forwarded: ForwardedMessage? +val List.forwarded: ForwardInfo? get() = first().let { - (it as? AbleToBeForwardedMessage) ?.forwarded + (it as? PossiblyForwardedMessage) ?.forwardInfo } val List.replyTo: Message? get() = first().let { - (it as? AbleToReplyMessage) ?.replyTo + (it as? PossiblyReplyMessage) ?.replyTo } val List.chat: Chat?