diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/GroupEventMessage.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonGroupEventMessage.kt similarity index 76% rename from TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/GroupEventMessage.kt rename to TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonGroupEventMessage.kt index c3b4340c52..b43b08035f 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/GroupEventMessage.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonGroupEventMessage.kt @@ -1,14 +1,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.GroupEvent -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ChatEventMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.GroupEventMessage import com.soywiz.klock.DateTime -data class GroupEventMessage( +data class CommonGroupEventMessage( override val messageId: MessageIdentifier, + override val user: User, override val chat: GroupChat, override val chatEvent: GroupEvent, override val date: DateTime -) : ChatEventMessage +) : GroupEventMessage diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/SupergroupEventMessage.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonSupergroupEventMessage.kt similarity index 75% rename from TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/SupergroupEventMessage.kt rename to TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonSupergroupEventMessage.kt index 89229f1a5d..541ca2d068 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/SupergroupEventMessage.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonSupergroupEventMessage.kt @@ -1,14 +1,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.SupergroupEvent -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ChatEventMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.SupergroupEventMessage import com.soywiz.klock.DateTime -data class SupergroupEventMessage( +data class CommonSupergroupEventMessage( override val messageId: MessageIdentifier, + override val user: User, override val chat: SupergroupChat, override val chatEvent: SupergroupEvent, override val date: DateTime -) : ChatEventMessage +) : SupergroupEventMessage diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt index 5786d90b4b..e1837adb0b 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt @@ -192,14 +192,16 @@ internal data class RawMessage( try { chatEvent?.let { chatEvent -> when (chat) { - is SupergroupChat -> SupergroupEventMessage( + is SupergroupChat -> CommonSupergroupEventMessage( messageId, + from ?: error("Supergroup events are expected to contain 'from' field"), chat, chatEvent as? SupergroupEvent ?: throwWrongChatEvent(SupergroupEvent::class, chatEvent), date.asDate ) - is GroupChat -> GroupEventMessage( + is GroupChat -> CommonGroupEventMessage( messageId, + from ?: error("Supergroup events are expected to contain 'from' field"), chat, chatEvent as? GroupEvent ?: throwWrongChatEvent(GroupChat::class, chatEvent), date.asDate diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/GroupEventMessage.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/GroupEventMessage.kt new file mode 100644 index 0000000000..9ab76cbb50 --- /dev/null +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/GroupEventMessage.kt @@ -0,0 +1,3 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts + +interface GroupEventMessage : ChatEventMessage, FromUserMessage diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/SupergroupEventMessage.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/SupergroupEventMessage.kt new file mode 100644 index 0000000000..c88bcabbbe --- /dev/null +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/abstracts/SupergroupEventMessage.kt @@ -0,0 +1,3 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts + +interface SupergroupEventMessage : GroupEventMessage diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/chat_events/ChatEventsSourcesConversations.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/chat_events/ChatEventsSourcesConversations.kt index cc1d263aab..8243a0670b 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/chat_events/ChatEventsSourcesConversations.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/chat_events/ChatEventsSourcesConversations.kt @@ -17,5 +17,5 @@ fun Flow.divideBySource(contentType: KC } fun Flow.onlyChannelEvents() = divideBySource(ChannelEventMessage::class) -fun Flow.onlyGroupEvents() = divideBySource(GroupEventMessage::class) -fun Flow.onlySupergroupEvents() = divideBySource(SupergroupEventMessage::class) +fun Flow.onlyGroupEvents() = divideBySource(CommonGroupEventMessage::class) +fun Flow.onlySupergroupEvents() = divideBySource(CommonSupergroupEventMessage::class)