From 2531f3779e51f8bb7100970a3f61f968a9a7884d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 22:00:17 +0600 Subject: [PATCH] fixes for MessageAutoDeleteTimerChanged --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../ChatEvents/MessageAutoDeleteTimerChanged.kt | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 8eaef26cfb..ff8adabedd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -163,6 +163,7 @@ const val ipAddressField = "ip_address" const val linkedChatIdField = "linked_chat_id" const val horizontalAccuracyField = "horizontal_accuracy" const val revokeMessagesField = "revoke_messages" +const val messageAutoDeleteTimeField = "message_auto_delete_time" const val requestContactField = "request_contact" const val requestLocationField = "request_location" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt index e54c53fdd3..adbce62869 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt @@ -1,10 +1,23 @@ package dev.inmo.tgbotapi.types.message.ChatEvents +import com.soywiz.klock.hours import dev.inmo.tgbotapi.types.Seconds import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.messageAutoDeleteTimeField +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +private val seconds24Hours: Seconds = 60 * 60 * 24 +private val seconds7Days: Seconds = seconds24Hours * 7 + @Serializable data class MessageAutoDeleteTimerChanged( + @SerialName(messageAutoDeleteTimeField) val newAutoDeleteTime: Seconds // TODO:: check that it is seconds ) : ChannelEvent, GroupEvent, SupergroupEvent + +val MessageAutoDeleteTimerChanged.is24Hours + get() = newAutoDeleteTime == seconds24Hours + +val MessageAutoDeleteTimerChanged.is7Days + get() = newAutoDeleteTime == seconds7Days