From ad75aef64fc197ec30c1d7fff8c715a01afc411f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 6 Nov 2022 14:56:01 +0600 Subject: [PATCH] add support of forum topic service messages --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 ++ .../ChatEvents/abstracts/ForumEvent.kt | 3 +++ .../ChatEvents/forum/ForumTopicClosed.kt | 7 +++++++ .../ChatEvents/forum/ForumTopicCreated.kt | 20 +++++++++++++++++++ .../ChatEvents/forum/ForumTopicReopened.kt | 7 +++++++ .../inmo/tgbotapi/types/message/RawMessage.kt | 11 ++++++++++ .../dev/inmo/tgbotapi/utils/RGBColor.kt | 10 ++++++++++ 7 files changed, 60 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ForumEvent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicClosed.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicReopened.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/RGBColor.kt 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 c4d9321b59..4ba5a7c60d 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 @@ -171,6 +171,7 @@ const val isPremiumField = "is_premium" const val hasPrivateForwardsField = "has_private_forwards" const val hasRestrictedVoiceAndVideoMessagesField = "has_restricted_voice_and_video_messages" const val emojiStatusCustomEmojiIdField = "emoji_status_custom_emoji_id" +const val iconCustomEmojiIdField = "icon_custom_emoji_id" const val canJoinGroupsField = "can_join_groups" const val canReadAllGroupMessagesField = "can_read_all_group_messages" const val supportInlineQueriesField = "supports_inline_queries" @@ -250,6 +251,7 @@ const val expireDateField = "expire_date" const val createsJoinRequestField = "creates_join_request" const val pendingJoinRequestCountField = "pending_join_request_count" const val memberLimitField = "member_limit" +const val iconColorField = "icon_color" const val requestContactField = "request_contact" const val requestLocationField = "request_location" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ForumEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ForumEvent.kt new file mode 100644 index 0000000000..cffe4f281c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ForumEvent.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts + +interface ForumEvent: SupergroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicClosed.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicClosed.kt new file mode 100644 index 0000000000..637f63b72f --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicClosed.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.forum + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent +import kotlinx.serialization.Serializable + +@Serializable +object ForumTopicClosed : ForumEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated.kt new file mode 100644 index 0000000000..b93064982d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.forum + +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.iconColorField +import dev.inmo.tgbotapi.types.iconCustomEmojiIdField +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent +import dev.inmo.tgbotapi.types.nameField +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ForumTopicCreated( + @SerialName(nameField) + val name: String, + @SerialName(iconColorField) + val iconColor: RGBColor, + @SerialName(iconCustomEmojiIdField) + val iconEmojiId: CustomEmojiId? = null +) : ForumEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicReopened.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicReopened.kt new file mode 100644 index 0000000000..6daef136ab --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicReopened.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.forum + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent +import kotlinx.serialization.Serializable + +@Serializable +object ForumTopicReopened : ForumEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 319a5931aa..65f2635202 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -12,6 +12,9 @@ import dev.inmo.tgbotapi.types.games.RawGame import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.content.* @@ -91,6 +94,11 @@ internal data class RawMessage( private val video_chat_ended: VideoChatEnded? = null, private val video_chat_participants_invited: VideoChatParticipantsInvited? = null, + // Forum + private val forum_topic_created: ForumTopicCreated? = null, + private val forum_topic_closed: ForumTopicClosed? = null, + private val forum_topic_reopened: ForumTopicReopened? = null, + // AutoDelete Message time changed private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null, @@ -204,6 +212,9 @@ internal data class RawMessage( video_chat_started != null -> video_chat_started video_chat_scheduled != null -> video_chat_scheduled message_auto_delete_timer_changed != null -> message_auto_delete_timer_changed + forum_topic_created != null -> forum_topic_created + forum_topic_closed != null -> forum_topic_closed + forum_topic_reopened != null -> forum_topic_reopened video_chat_ended != null -> video_chat_ended video_chat_participants_invited != null -> video_chat_participants_invited delete_chat_photo -> DeleteChatPhoto() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/RGBColor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/RGBColor.kt new file mode 100644 index 0000000000..4c9c0d4caf --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/RGBColor.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.utils + +import kotlinx.serialization.Serializable +import kotlin.jvm.JvmInline + +@Serializable +@JvmInline +value class RGBColor( + val int: Int +)