From ef9941134ea97465cecc2688a180d226b5ef349b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 17 Apr 2022 20:03:00 +0600 Subject: [PATCH] voice(_c/C)hat* -> video(_c/C)hat* renames --- .../expectations/WaitEventAction.kt | 49 ++++++-- .../triggers_handling/EventTriggers.kt | 112 +++++++++++++++--- .../ChatEvents/abstracts/VideoChatEvent.kt | 8 ++ .../ChatEvents/abstracts/VoiceChatEvent.kt | 3 - .../{VoiceChatEnded.kt => VideoChatEnded.kt} | 9 +- .../voice/VideoChatParticipantsInvited.kt | 16 +++ ...ChatScheduled.kt => VideoChatScheduled.kt} | 9 +- .../ChatEvents/voice/VideoChatStarted.kt | 10 ++ .../voice/VoiceChatParticipantsInvited.kt | 13 -- .../ChatEvents/voice/VoiceChatStarted.kt | 7 -- .../inmo/tgbotapi/types/message/RawMessage.kt | 16 +-- .../tgbotapi/extensions/utils/ClassCasts.kt | 98 ++++++++++++--- .../utils/extensions/raw/Message.kt | 24 +++- 13 files changed, 290 insertions(+), 84 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/{VoiceChatEnded.kt => VideoChatEnded.kt} (60%) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/{VoiceChatScheduled.kt => VideoChatScheduled.kt} (50%) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 841f9bcf06..5b270016b9 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -89,33 +89,66 @@ suspend fun BehaviourContext.waitChatEvents( mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) +@Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) +@Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatStartedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) +@Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatEndedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) +@Deprecated("Renamed as Video instead of Voice") suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter, mapper) + +suspend fun BehaviourContext.waitVideoChatEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitVideoChatStartedEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitVideoChatEndedEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitVideoChatParticipantsInvitedEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents( diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index f39245b11d..6787e26d9b 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -94,11 +94,12 @@ suspend fun BC.onChatEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ +@Deprecated("Renamed as Video instead of Voice") suspend fun BC.onVoiceChatEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -113,11 +114,12 @@ suspend fun BC.onVoiceChatEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ +@Deprecated("Renamed as Video instead of Voice") suspend fun BC.onVoiceChatStartedEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -132,11 +134,12 @@ suspend fun BC.onVoiceChatStartedEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ +@Deprecated("Renamed as Video instead of Voice") suspend fun BC.onVoiceChatEndedEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -151,11 +154,88 @@ suspend fun BC.onVoiceChatEndedEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ +@Deprecated("Renamed as Video instead of Voice") suspend fun BC.onVoiceChatParticipantsInvitedEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onVideoChatEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onVideoChatStartedEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onVideoChatEndedEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onVideoChatParticipantsInvitedEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt new file mode 100644 index 0000000000..077f9d32ba --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VideoChatEvent.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts + +import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled + +interface VideoChatEvent : PublicChatEvent + +@Deprecated("Renamed", ReplaceWith("VideoChatEvent", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEvent")) +typealias VoiceChatEvent = VideoChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt deleted file mode 100644 index f06f52d765..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts - -interface VoiceChatEvent : PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatEnded.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt similarity index 60% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatEnded.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt index 3969e603fd..d13204b791 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatEnded.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt @@ -4,15 +4,18 @@ import com.soywiz.klock.TimeSpan import com.soywiz.klock.seconds import dev.inmo.tgbotapi.types.Seconds import dev.inmo.tgbotapi.types.durationField -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class VoiceChatEnded( +data class VideoChatEnded( @SerialName(durationField) val duration: Seconds -) : VoiceChatEvent { +) : VideoChatEvent { val timeSpan: TimeSpan get() = TimeSpan(duration.seconds.milliseconds) } + +@Deprecated("Renamed", ReplaceWith("VideoChatEnded", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded")) +typealias VoiceChatEnded = VideoChatEnded diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt new file mode 100644 index 0000000000..aa856c9f5e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatParticipantsInvited.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.voice + +import dev.inmo.tgbotapi.types.User +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent +import dev.inmo.tgbotapi.types.usersField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class VideoChatParticipantsInvited( + @SerialName(usersField) + val users: List = emptyList() +) : VideoChatEvent + +@Deprecated("Renamed", ReplaceWith("VideoChatParticipantsInvited", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited")) +typealias VoiceChatParticipantsInvited = VideoChatParticipantsInvited diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatScheduled.kt similarity index 50% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatScheduled.kt index 8db852aecc..5bb18b6ec2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatScheduled.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatScheduled.kt @@ -1,13 +1,16 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.voice import dev.inmo.tgbotapi.types.TelegramDate -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent import dev.inmo.tgbotapi.types.startDateField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class VoiceChatScheduled( +data class VideoChatScheduled( @SerialName(startDateField) val startDate: TelegramDate -) : VoiceChatEvent +) : VideoChatEvent + +@Deprecated("Renamed", ReplaceWith("VideoChatScheduled", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled")) +typealias VoiceChatScheduled = VideoChatScheduled diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt new file mode 100644 index 0000000000..0c9d08546a --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatStarted.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.voice + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent +import kotlinx.serialization.Serializable + +@Serializable +object VideoChatStarted : VideoChatEvent + +@Deprecated("Renamed", ReplaceWith("VideoChatStarted", "dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatStarted")) +typealias VoiceChatStarted = VideoChatStarted diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt deleted file mode 100644 index 3df3f3d711..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.message.ChatEvents.voice - -import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent -import dev.inmo.tgbotapi.types.usersField -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class VoiceChatParticipantsInvited( - @SerialName(usersField) - val users: List = emptyList() -) : VoiceChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt deleted file mode 100644 index 9b72796ac1..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.inmo.tgbotapi.types.message.ChatEvents.voice - -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent -import kotlinx.serialization.Serializable - -@Serializable -object VoiceChatStarted : VoiceChatEvent 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 8b7f040437..06bd0e4fa7 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 @@ -84,10 +84,10 @@ internal data class RawMessage( private val successful_payment: SuccessfulPayment? = null, // Voice Chat Service Messages - private val voice_chat_scheduled: VoiceChatScheduled? = null, - private val voice_chat_started: VoiceChatStarted? = null, - private val voice_chat_ended: VoiceChatEnded? = null, - private val voice_chat_participants_invited: VoiceChatParticipantsInvited? = null, + private val video_chat_scheduled: VideoChatScheduled? = null, + private val video_chat_started: VideoChatStarted? = null, + private val video_chat_ended: VideoChatEnded? = null, + private val video_chat_participants_invited: VideoChatParticipantsInvited? = null, // AutoDelete Message time changed private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null, @@ -186,11 +186,11 @@ internal data class RawMessage( left_chat_member != null -> LeftChatMember(left_chat_member) new_chat_title != null -> NewChatTitle(new_chat_title) new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList()) - voice_chat_started != null -> voice_chat_started - voice_chat_scheduled != null -> voice_chat_scheduled + 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 - voice_chat_ended != null -> voice_chat_ended - voice_chat_participants_invited != null -> voice_chat_participants_invited + video_chat_ended != null -> video_chat_ended + video_chat_participants_invited != null -> video_chat_participants_invited delete_chat_photo -> DeleteChatPhoto() group_chat_created -> GroupChatCreated( migrate_to_chat_id diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 6cd5a943f4..071effbcbb 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -30,8 +30,6 @@ import dev.inmo.tgbotapi.types.chat.abstracts.* import dev.inmo.tgbotapi.types.chat.abstracts.extended.* import dev.inmo.tgbotapi.types.dice.* import dev.inmo.tgbotapi.types.files.* -import dev.inmo.tgbotapi.types.files.* -import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.* @@ -3191,51 +3189,113 @@ inline fun ChatEvent.asSupergroupEvent(): SupergroupEvent? = this as? Supergroup inline fun ChatEvent.requireSupergroupEvent(): SupergroupEvent = this as SupergroupEvent @PreviewFeature -inline fun ChatEvent.whenVoiceChatEvent(block: (VoiceChatEvent) -> T) = asVoiceChatEvent() ?.let(block) +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.whenVoiceChatEvent(block: (VideoChatEvent) -> T) = asVoiceChatEvent() ?.let(block) @PreviewFeature -inline fun ChatEvent.asVoiceChatEvent(): VoiceChatEvent? = this as? VoiceChatEvent +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.asVoiceChatEvent(): VideoChatEvent? = this as? VideoChatEvent @PreviewFeature -inline fun ChatEvent.requireVoiceChatEvent(): VoiceChatEvent = this as VoiceChatEvent +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.requireVoiceChatEvent(): VideoChatEvent = this as VideoChatEvent @PreviewFeature -inline fun ChatEvent.whenVoiceChatEnded(block: (VoiceChatEnded) -> T) = asVoiceChatEnded() ?.let(block) +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.whenVoiceChatEnded(block: (VideoChatEnded) -> T) = asVoiceChatEnded() ?.let(block) @PreviewFeature -inline fun ChatEvent.asVoiceChatEnded(): VoiceChatEnded? = this as? VoiceChatEnded +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.asVoiceChatEnded(): VideoChatEnded? = this as? VideoChatEnded @PreviewFeature -inline fun ChatEvent.requireVoiceChatEnded(): VoiceChatEnded = this as VoiceChatEnded +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.requireVoiceChatEnded(): VideoChatEnded = this as VideoChatEnded @PreviewFeature -inline fun ChatEvent.whenVoiceChatParticipantsInvited(block: (VoiceChatParticipantsInvited) -> T) = asVoiceChatParticipantsInvited() ?.let(block) +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.whenVoiceChatParticipantsInvited(block: (VideoChatParticipantsInvited) -> T) = asVoiceChatParticipantsInvited() ?.let(block) @PreviewFeature -inline fun ChatEvent.asVoiceChatParticipantsInvited(): VoiceChatParticipantsInvited? = - this as? VoiceChatParticipantsInvited +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.asVoiceChatParticipantsInvited(): VideoChatParticipantsInvited? = + this as? VideoChatParticipantsInvited @PreviewFeature -inline fun ChatEvent.requireVoiceChatParticipantsInvited(): VoiceChatParticipantsInvited = - this as VoiceChatParticipantsInvited +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.requireVoiceChatParticipantsInvited(): VideoChatParticipantsInvited = + this as VideoChatParticipantsInvited @PreviewFeature -inline fun ChatEvent.whenVoiceChatStarted(block: (VoiceChatStarted) -> T) = asVoiceChatStarted() ?.let(block) +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.whenVoiceChatStarted(block: (VideoChatStarted) -> T) = asVoiceChatStarted() ?.let(block) @PreviewFeature -inline fun ChatEvent.asVoiceChatStarted(): VoiceChatStarted? = this as? VoiceChatStarted +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.asVoiceChatStarted(): VideoChatStarted? = this as? VideoChatStarted @PreviewFeature -inline fun ChatEvent.requireVoiceChatStarted(): VoiceChatStarted = this as VoiceChatStarted +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.requireVoiceChatStarted(): VideoChatStarted = this as VideoChatStarted @PreviewFeature -inline fun ChatEvent.whenVoiceChatScheduled(block: (VoiceChatScheduled) -> T) = asVoiceChatScheduled() ?.let(block) +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.whenVoiceChatScheduled(block: (VideoChatScheduled) -> T) = asVoiceChatScheduled() ?.let(block) @PreviewFeature -inline fun ChatEvent.asVoiceChatScheduled(): VoiceChatScheduled? = this as? VoiceChatScheduled +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.asVoiceChatScheduled(): VideoChatScheduled? = this as? VideoChatScheduled @PreviewFeature -inline fun ChatEvent.requireVoiceChatScheduled(): VoiceChatScheduled = this as VoiceChatScheduled +@Deprecated("Renamed as Video instead of Voice") +inline fun ChatEvent.requireVoiceChatScheduled(): VideoChatScheduled = this as VideoChatScheduled + +@PreviewFeature +inline fun ChatEvent.whenVideoChatEvent(block: (VideoChatEvent) -> T) = asVideoChatEvent() ?.let(block) + +@PreviewFeature +inline fun ChatEvent.asVideoChatEvent(): VideoChatEvent? = this as? VideoChatEvent + +@PreviewFeature +inline fun ChatEvent.requireVideoChatEvent(): VideoChatEvent = this as VideoChatEvent + +@PreviewFeature +inline fun ChatEvent.whenVideoChatEnded(block: (VideoChatEnded) -> T) = asVideoChatEnded() ?.let(block) + +@PreviewFeature +inline fun ChatEvent.asVideoChatEnded(): VideoChatEnded? = this as? VideoChatEnded + +@PreviewFeature +inline fun ChatEvent.requireVideoChatEnded(): VideoChatEnded = this as VideoChatEnded + +@PreviewFeature +inline fun ChatEvent.whenVideoChatParticipantsInvited(block: (VideoChatParticipantsInvited) -> T) = asVideoChatParticipantsInvited() ?.let(block) + +@PreviewFeature +inline fun ChatEvent.asVideoChatParticipantsInvited(): VideoChatParticipantsInvited? = + this as? VideoChatParticipantsInvited + +@PreviewFeature +inline fun ChatEvent.requireVideoChatParticipantsInvited(): VideoChatParticipantsInvited = + this as VideoChatParticipantsInvited + +@PreviewFeature +inline fun ChatEvent.whenVideoChatStarted(block: (VideoChatStarted) -> T) = asVideoChatStarted() ?.let(block) + +@PreviewFeature +inline fun ChatEvent.asVideoChatStarted(): VideoChatStarted? = this as? VideoChatStarted + +@PreviewFeature +inline fun ChatEvent.requireVideoChatStarted(): VideoChatStarted = this as VideoChatStarted + +@PreviewFeature +inline fun ChatEvent.whenVideoChatScheduled(block: (VideoChatScheduled) -> T) = asVideoChatScheduled() ?.let(block) + +@PreviewFeature +inline fun ChatEvent.asVideoChatScheduled(): VideoChatScheduled? = this as? VideoChatScheduled + +@PreviewFeature +inline fun ChatEvent.requireVideoChatScheduled(): VideoChatScheduled = this as VideoChatScheduled @PreviewFeature inline fun ChatEvent.whenUserLoggedIn(block: (UserLoggedIn) -> T) = asUserLoggedIn() ?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index e54383169d..dc65d6cf7b 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -177,17 +177,33 @@ inline val Message.successful_payment: SuccessfulPayment? get() = asChatEventMessage() ?.chatEvent ?.asSuccessfulPaymentEvent() ?.payment @RiskFeature(RawFieldsUsageWarning) -inline val Message.voice_chat_scheduled: VoiceChatScheduled? +@Deprecated("Renamed as video instead of voice") +inline val Message.voice_chat_scheduled: VideoChatScheduled? get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatScheduled() @RiskFeature(RawFieldsUsageWarning) -inline val Message.voice_chat_started: VoiceChatStarted? +@Deprecated("Renamed as video instead of voice") +inline val Message.voice_chat_started: VideoChatStarted? get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatStarted() @RiskFeature(RawFieldsUsageWarning) -inline val Message.voice_chat_ended: VoiceChatEnded? +@Deprecated("Renamed as video instead of voice") +inline val Message.voice_chat_ended: VideoChatEnded? get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatEnded() @RiskFeature(RawFieldsUsageWarning) -inline val Message.voice_chat_participants_invited: VoiceChatParticipantsInvited? +@Deprecated("Renamed as video instead of voice") +inline val Message.voice_chat_participants_invited: VideoChatParticipantsInvited? get() = asChatEventMessage() ?.chatEvent ?.asVoiceChatParticipantsInvited() +@RiskFeature(RawFieldsUsageWarning) +inline val Message.video_chat_scheduled: VideoChatScheduled? + get() = asChatEventMessage() ?.chatEvent ?.asVideoChatScheduled() +@RiskFeature(RawFieldsUsageWarning) +inline val Message.video_chat_started: VideoChatStarted? + get() = asChatEventMessage() ?.chatEvent ?.asVideoChatStarted() +@RiskFeature(RawFieldsUsageWarning) +inline val Message.video_chat_ended: VideoChatEnded? + get() = asChatEventMessage() ?.chatEvent ?.asVideoChatEnded() +@RiskFeature(RawFieldsUsageWarning) +inline val Message.video_chat_participants_invited: VideoChatParticipantsInvited? + get() = asChatEventMessage() ?.chatEvent ?.asVideoChatParticipantsInvited() @RiskFeature(RawFieldsUsageWarning) inline val Message.message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged?