From de13ddeb547ed329b30c579d0c0222e611e46291 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 6 Apr 2026 15:47:38 +0600 Subject: [PATCH] complete support of ManagedBotCreated and ManagedBotUpdated, add getManagedBotToken and replaceManagedBotToken --- tgbotapi.api/api/tgbotapi.api.api | 8 ++ .../api/managed_bots/GetManagedBotToken.kt | 12 ++ .../managed_bots/ReplaceManagedBotToken.kt | 12 ++ .../api/tgbotapi.behaviour_builder.fsm.api | 1 + .../api/tgbotapi.behaviour_builder.api | 17 +++ .../expectations/WaitManagedBotUpdate.kt | 17 +++ .../filters/MessageFilterByChat.kt | 9 ++ .../ManagedBotUpdateTriggers.kt | 34 +++++ .../ByUserManagedBotUpdatedMarkerFactory.kt | 7 + tgbotapi.core/api/tgbotapi.core.api | 123 ++++++++++++++++++ .../managed_bots/GetManagedBotToken.kt | 19 +++ .../managed_bots/ReplaceManagedBotToken.kt | 19 +++ .../dev/inmo/tgbotapi/types/BotToken.kt | 8 ++ .../dev/inmo/tgbotapi/types/UpdateTypes.kt | 4 + .../inmo/tgbotapi/types/message/RawMessage.kt | 5 +- .../tgbotapi/types/update/ManagedBotUpdate.kt | 13 ++ .../inmo/tgbotapi/types/update/RawUpdate.kt | 3 + .../updateshandlers/FlowsUpdatesFilter.kt | 2 + tgbotapi.utils/api/tgbotapi.utils.api | 6 + .../tgbotapi/extensions/utils/ClassCasts.kt | 9 ++ .../extensions/utils/ClassCastsNew.kt | 7 + 21 files changed, 333 insertions(+), 2 deletions(-) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/GetManagedBotToken.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/ReplaceManagedBotToken.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitManagedBotUpdate.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ManagedBotUpdateTriggers.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserManagedBotUpdatedMarkerFactory.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotToken.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ManagedBotUpdate.kt diff --git a/tgbotapi.api/api/tgbotapi.api.api b/tgbotapi.api/api/tgbotapi.api.api index f98641dffa..95245964ef 100644 --- a/tgbotapi.api/api/tgbotapi.api.api +++ b/tgbotapi.api/api/tgbotapi.api.api @@ -1268,6 +1268,14 @@ public final class dev/inmo/tgbotapi/extensions/api/inline/SavePreparedInlineMes public static synthetic fun savePreparedInlineMessage$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult;ZZZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } +public final class dev/inmo/tgbotapi/extensions/api/managed_bots/GetManagedBotTokenKt { + public static final fun getManagedBotToken-dEpx-Zg (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/inmo/tgbotapi/extensions/api/managed_bots/ReplaceManagedBotTokenKt { + public static final fun replaceManagedBotToken-dEpx-Zg (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public final class dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrorsKt { public static final fun setPassportDataErrors (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ldev/inmo/tgbotapi/types/passport/PassportData;Ldev/inmo/tgbotapi/utils/passport/Decryptor;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun setPassportDataErrors (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/GetManagedBotToken.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/GetManagedBotToken.kt new file mode 100644 index 0000000000..deba73ccd8 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/GetManagedBotToken.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.extensions.api.managed_bots + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.managed_bots.GetManagedBotToken +import dev.inmo.tgbotapi.types.BotToken +import dev.inmo.tgbotapi.types.ChatId + +public suspend fun TelegramBot.getManagedBotToken( + userId: ChatId +): BotToken = execute( + GetManagedBotToken(userId = userId) +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/ReplaceManagedBotToken.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/ReplaceManagedBotToken.kt new file mode 100644 index 0000000000..dfe2eee547 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/managed_bots/ReplaceManagedBotToken.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.extensions.api.managed_bots + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.managed_bots.ReplaceManagedBotToken +import dev.inmo.tgbotapi.types.BotToken +import dev.inmo.tgbotapi.types.ChatId + +public suspend fun TelegramBot.replaceManagedBotToken( + userId: ChatId +): BotToken = execute( + ReplaceManagedBotToken(userId = userId) +) diff --git a/tgbotapi.behaviour_builder.fsm/api/tgbotapi.behaviour_builder.fsm.api b/tgbotapi.behaviour_builder.fsm/api/tgbotapi.behaviour_builder.fsm.api index bfebf44c5f..fd88162aa5 100644 --- a/tgbotapi.behaviour_builder.fsm/api/tgbotapi.behaviour_builder.fsm.api +++ b/tgbotapi.behaviour_builder.fsm/api/tgbotapi.behaviour_builder.fsm.api @@ -106,6 +106,7 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultBehavio public fun getFlowsUpdatesFilter ()Ldev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter; public fun getInlineQueriesFlow ()Lkotlinx/coroutines/flow/Flow; public fun getLog ()Ldev/inmo/kslog/common/KSLog; + public fun getManagedBotUpdatesFlow ()Lkotlinx/coroutines/flow/Flow; public fun getMessageMediaGroupsFlow ()Lkotlinx/coroutines/flow/Flow; public fun getMessagesFlow ()Lkotlinx/coroutines/flow/Flow; public fun getMyChatMemberUpdatesFlow ()Lkotlinx/coroutines/flow/Flow; diff --git a/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api b/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api index b3b6940e04..03e6e87a33 100644 --- a/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api +++ b/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api @@ -852,6 +852,11 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W public static synthetic fun waitLocationInlineQuery$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; } +public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitManagedBotUpdateKt { + public static final fun waitManagedBotUpdated (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun waitManagedBotUpdated$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; +} + public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupKt { public static final fun waitDocumentsGroup (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow; public static synthetic fun waitDocumentsGroup$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; @@ -981,6 +986,7 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/filters/Messag public static final fun getChatJoinRequestFilterByChat ()Lkotlin/jvm/functions/Function4; public static final fun getChatMemberUpdatedFilterByChat ()Lkotlin/jvm/functions/Function4; public static final fun getInlineQueryFilterByUser ()Lkotlin/jvm/functions/Function4; + public static final fun getManagedBotUpdatedFilterByUser ()Lkotlin/jvm/functions/Function4; public static final fun getMessageFilterByChat ()Lkotlin/jvm/functions/Function4; public static final fun getMessagesFilterByChat ()Lkotlin/jvm/functions/Function4; public static final fun getPreCheckoutQueryFilterByUser ()Lkotlin/jvm/functions/Function4; @@ -1495,6 +1501,11 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handl public static synthetic fun onLocationInlineQuery$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; } +public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ManagedBotUpdateTriggersKt { + public static final fun onManagedBotUpdate (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job; + public static synthetic fun onManagedBotUpdate$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; +} + public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupMessagesTriggersKt { public static final fun onDocumentsGroupMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job; public static synthetic fun onDocumentsGroupMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; @@ -1837,6 +1848,12 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_f public synthetic fun invoke (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } +public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserManagedBotUpdatedMarkerFactory : dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory { + public static final field INSTANCE Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserManagedBotUpdatedMarkerFactory; + public fun invoke (Ldev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public synthetic fun invoke (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserMessageMarkerFactory : dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory { public static final field INSTANCE Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserMessageMarkerFactory; public fun invoke (Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitManagedBotUpdate.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitManagedBotUpdate.kt new file mode 100644 index 0000000000..46e169d861 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitManagedBotUpdate.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.utils.managedBotUpdateOrNull +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated +import kotlinx.coroutines.flow.Flow + +fun BehaviourContext.waitManagedBotUpdated( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( + initRequest, + errorFactory +) { + (it.managedBotUpdateOrNull() ?.data).let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt index fd7820f464..6de04694d1 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat import dev.inmo.tgbotapi.extensions.utils.extensions.sourceUser import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.chat.ChatJoinRequest +import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery @@ -60,6 +61,14 @@ val InlineQueryFilterByUser: BehaviourContextAndTwoTypesReceiver = { managedBotUpdated, update -> + update.sourceUser() ?.let { + it.id == managedBotUpdated.user.id + } != false +} /** * Allow only events from the same chat as base [ChatMemberUpdated] */ diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ManagedBotUpdateTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ManagedBotUpdateTriggers.kt new file mode 100644 index 0000000000..b54e7c703a --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ManagedBotUpdateTriggers.kt @@ -0,0 +1,34 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.CustomBehaviourContextAndTwoTypesReceiver +import dev.inmo.tgbotapi.extensions.behaviour_builder.CustomBehaviourContextAndTypeReceiver +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserManagedBotUpdatedMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.utils.managedBotUpdateOrNull +import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated +import dev.inmo.tgbotapi.types.update.abstracts.Update + +/** + * @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] **Pass null to handle requests fully parallel**. 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 + */ +fun BC.onManagedBotUpdate( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory? = ByUserManagedBotUpdatedMarkerFactory, + additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver? = null, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, additionalSubcontextInitialAction, scenarioReceiver) { + (it.managedBotUpdateOrNull() ?.data) ?.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserManagedBotUpdatedMarkerFactory.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserManagedBotUpdatedMarkerFactory.kt new file mode 100644 index 0000000000..41dfed8668 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByUserManagedBotUpdatedMarkerFactory.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated + +object ByUserManagedBotUpdatedMarkerFactory : MarkerFactory { + override suspend fun invoke(data: ManagedBotUpdated) = data.user +} diff --git a/tgbotapi.core/api/tgbotapi.core.api b/tgbotapi.core/api/tgbotapi.core.api index c55708e75a..4c852f3bfb 100644 --- a/tgbotapi.core/api/tgbotapi.core.api +++ b/tgbotapi.core/api/tgbotapi.core.api @@ -5741,6 +5741,66 @@ public final class dev/inmo/tgbotapi/requests/local/LogOut : dev/inmo/tgbotapi/r public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { + public static final field Companion Ldev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken$Companion; + public synthetic fun (JLkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-tHkBKVM ()J + public final fun copy-HZVsHAI (J)Ldev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken; + public static synthetic fun copy-HZVsHAI$default (Ldev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken;JILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken; + public fun equals (Ljava/lang/Object;)Z + public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; + public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public final fun getUserId-tHkBKVM ()J + public fun hashCode ()I + public fun method ()Ljava/lang/String; + public fun toString ()Ljava/lang/String; +} + +public final synthetic class dev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { + public static final field Companion Ldev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken$Companion; + public synthetic fun (JLkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-tHkBKVM ()J + public final fun copy-HZVsHAI (J)Ldev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken; + public static synthetic fun copy-HZVsHAI$default (Ldev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken;JILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken; + public fun equals (Ljava/lang/Object;)Z + public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; + public fun getResultDeserializer ()Lkotlinx/serialization/DeserializationStrategy; + public final fun getUserId-tHkBKVM ()J + public fun hashCode ()I + public fun method ()Ljava/lang/String; + public fun toString ()Ljava/lang/String; +} + +public final synthetic class dev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/requests/send/CopyMessage : dev/inmo/tgbotapi/abstracts/TextedOutput, dev/inmo/tgbotapi/abstracts/WithCustomStartMediaData, dev/inmo/tgbotapi/abstracts/types/MessageAction, dev/inmo/tgbotapi/abstracts/types/OptionallyWithEffectId, dev/inmo/tgbotapi/abstracts/types/ProtectContent, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest, dev/inmo/tgbotapi/requests/send/abstracts/OptionallyMessageThreadRequest, dev/inmo/tgbotapi/requests/send/abstracts/ReplyingMarkupSendMessageRequest, dev/inmo/tgbotapi/requests/send/abstracts/WithCustomizableCaptionRequest { public static final field Companion Ldev/inmo/tgbotapi/requests/send/CopyMessage$Companion; public synthetic fun (Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/ChatIdentifier;JLjava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ZLdev/inmo/tgbotapi/types/MessageThreadId;Ldev/inmo/tgbotapi/types/DirectMessageThreadId;Ljava/lang/Integer;ZZZLjava/lang/String;Ldev/inmo/tgbotapi/types/message/SuggestedPostParameters;Ldev/inmo/tgbotapi/types/ReplyParameters;Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -9954,6 +10014,36 @@ public final class dev/inmo/tgbotapi/types/BotShortDescription$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/inmo/tgbotapi/types/BotToken { + public static final field Companion Ldev/inmo/tgbotapi/types/BotToken$Companion; + public static final synthetic fun box-impl (Ljava/lang/String;)Ldev/inmo/tgbotapi/types/BotToken; + public static fun constructor-impl (Ljava/lang/String;)Ljava/lang/String; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z + public final fun getString ()Ljava/lang/String; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/lang/String;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/lang/String; +} + +public final synthetic class dev/inmo/tgbotapi/types/BotToken$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/BotToken$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun deserialize-Xc4KczI (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/String; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public final fun serialize-Y8d-Zco (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/String;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/BotToken$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/BusinessChatId : dev/inmo/tgbotapi/types/IdChatIdentifier { public static final field Companion Ldev/inmo/tgbotapi/types/BusinessChatId$Companion; public static final synthetic fun box-impl (Lkotlin/Pair;)Ldev/inmo/tgbotapi/types/BusinessChatId; @@ -14557,6 +14647,7 @@ public final class dev/inmo/tgbotapi/types/UpdateTypesKt { public static final field UPDATE_EDITED_CHANNEL_POST Ljava/lang/String; public static final field UPDATE_EDITED_MESSAGE Ljava/lang/String; public static final field UPDATE_INLINE_QUERY Ljava/lang/String; + public static final field UPDATE_MANAGED_BOT Ljava/lang/String; public static final field UPDATE_MESSAGE Ljava/lang/String; public static final field UPDATE_MESSAGE_REACTION Ljava/lang/String; public static final field UPDATE_MESSAGE_REACTION_COUNT Ljava/lang/String; @@ -33604,6 +33695,36 @@ public final class dev/inmo/tgbotapi/types/update/InlineQueryUpdate : dev/inmo/t public fun toString ()Ljava/lang/String; } +public final class dev/inmo/tgbotapi/types/update/ManagedBotUpdate : dev/inmo/tgbotapi/types/update/abstracts/Update { + public static final field Companion Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate$Companion; + public synthetic fun (JLdev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-4k5XoGU ()J + public final fun component2 ()Ldev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated; + public final fun copy-VElHuNg (JLdev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated;)Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate; + public static synthetic fun copy-VElHuNg$default (Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate;JLdev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate; + public fun equals (Ljava/lang/Object;)Z + public fun getData ()Ldev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated; + public synthetic fun getData ()Ljava/lang/Object; + public fun getUpdateId-4k5XoGU ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final synthetic class dev/inmo/tgbotapi/types/update/ManagedBotUpdate$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate$$serializer; + public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/update/ManagedBotUpdate$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/update/MessageUpdate : dev/inmo/tgbotapi/types/update/abstracts/BaseSentMessageUpdate { public synthetic fun (JLdev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1-4k5XoGU ()J @@ -33891,6 +34012,7 @@ public abstract class dev/inmo/tgbotapi/updateshandlers/AbstractFlowsUpdatesFilt public fun getEditedMessageMediaGroupsFlow ()Lkotlinx/coroutines/flow/Flow; public fun getEditedMessagesFlow ()Lkotlinx/coroutines/flow/Flow; public fun getInlineQueriesFlow ()Lkotlinx/coroutines/flow/Flow; + public fun getManagedBotUpdatesFlow ()Lkotlinx/coroutines/flow/Flow; public fun getMessageMediaGroupsFlow ()Lkotlinx/coroutines/flow/Flow; public fun getMessagesFlow ()Lkotlinx/coroutines/flow/Flow; public fun getMyChatMemberUpdatesFlow ()Lkotlinx/coroutines/flow/Flow; @@ -33932,6 +34054,7 @@ public abstract interface class dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFi public fun getEditedMessageMediaGroupsFlow ()Lkotlinx/coroutines/flow/Flow; public abstract fun getEditedMessagesFlow ()Lkotlinx/coroutines/flow/Flow; public abstract fun getInlineQueriesFlow ()Lkotlinx/coroutines/flow/Flow; + public abstract fun getManagedBotUpdatesFlow ()Lkotlinx/coroutines/flow/Flow; public fun getMessageMediaGroupsFlow ()Lkotlinx/coroutines/flow/Flow; public abstract fun getMessagesFlow ()Lkotlinx/coroutines/flow/Flow; public abstract fun getMyChatMemberUpdatesFlow ()Lkotlinx/coroutines/flow/Flow; diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken.kt new file mode 100644 index 0000000000..960f776b70 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/GetManagedBotToken.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.requests.managed_bots + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.BotToken +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.userIdField +import kotlinx.serialization.* + +@Serializable +data class GetManagedBotToken( + @SerialName(userIdField) + val userId: ChatId +) : SimpleRequest { + override fun method(): String = "getManagedBotToken" + override val resultDeserializer: DeserializationStrategy + get() = BotToken.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken.kt new file mode 100644 index 0000000000..19c0c4678c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/managed_bots/ReplaceManagedBotToken.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.requests.managed_bots + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.BotToken +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.userIdField +import kotlinx.serialization.* + +@Serializable +data class ReplaceManagedBotToken( + @SerialName(userIdField) + val userId: ChatId +) : SimpleRequest { + override fun method(): String = "replaceManagedBotToken" + override val resultDeserializer: DeserializationStrategy + get() = BotToken.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotToken.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotToken.kt new file mode 100644 index 0000000000..35524c6cce --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/BotToken.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.Serializable +import kotlin.jvm.JvmInline + +@Serializable +@JvmInline +value class BotToken(val string: String) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt index ebe257e35b..3f66c52225 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt @@ -24,6 +24,8 @@ const val UPDATE_BUSINESS_MESSAGE = "business_message" const val UPDATE_EDITED_BUSINESS_MESSAGE = "edited_business_message" const val UPDATE_DELETED_BUSINESS_MESSAGES = "deleted_business_messages" +const val UPDATE_MANAGED_BOT = "managed_bot" + val ALL_UPDATES_LIST_WITHOUT_REACTIONS = listOf( UPDATE_MESSAGE, UPDATE_EDITED_MESSAGE, @@ -57,6 +59,8 @@ val ALL_UPDATES_LIST_WITHOUT_REACTIONS = listOf( UPDATE_CHAT_BOOST, UPDATE_REMOVE_CHAT_BOOST, + + UPDATE_MANAGED_BOT, ) val ALL_UPDATES_LIST = ALL_UPDATES_LIST_WITHOUT_REACTIONS + listOf( 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 bcd6b919c0..e653965b0d 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 @@ -18,6 +18,7 @@ import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceivedEvent import dev.inmo.tgbotapi.types.giveaway.* import dev.inmo.tgbotapi.types.message.content.GiveawayContent import dev.inmo.tgbotapi.types.location.Location +import dev.inmo.tgbotapi.types.managed_bots.ManagedBotCreated import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -206,7 +207,7 @@ internal data class RawMessage( private val gift_upgrade_sent: GiftSentOrReceivedEvent.RegularGift? = null, private val chat_owner_left: ChatOwnerLeft? = null, private val chat_owner_changed: ChatOwnerChanged? = null, - private val managed_bot_updated: ManagedBotUpdated? = null + private val managed_bot_created: ManagedBotCreated? = null ) { @Suppress("SERIALIZER_TYPE_INCOMPATIBLE") private val checkedFrom = from ?.takeIf { !it.isFakeTelegramUser() } @@ -345,7 +346,7 @@ internal data class RawMessage( suggested_post_declined != null -> suggested_post_declined suggested_post_paid != null -> suggested_post_paid suggested_post_refunded != null -> suggested_post_refunded - managed_bot_updated != null -> managed_bot_updated + managed_bot_created != null -> managed_bot_created else -> null } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ManagedBotUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ManagedBotUpdate.kt new file mode 100644 index 0000000000..48c429d8ac --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ManagedBotUpdate.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.types.update + +import dev.inmo.tgbotapi.types.UpdateId +import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlinx.serialization.Serializable + +@Serializable +data class ManagedBotUpdate( + override val updateId: UpdateId, + override val data: ManagedBotUpdated +) : Update { +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt index 6ddaae877c..a5dba2d31e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt @@ -12,6 +12,7 @@ import dev.inmo.tgbotapi.types.chat.ChatJoinRequest import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated +import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.payments.PaidMediaPurchased import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery @@ -64,6 +65,7 @@ internal data class RawUpdate constructor( private val edited_business_message: BusinessContentMessage<*>? = null, private val deleted_business_messages: BusinessMessagesDeleted? = null, private val purchased_paid_media: PaidMediaPurchased? = null, + private val managed_bot: ManagedBotUpdated? = null, ) { @Transient private var initedUpdate: Update? = null @@ -100,6 +102,7 @@ internal data class RawUpdate constructor( edited_business_message != null -> EditBusinessMessageUpdate(updateId, edited_business_message) deleted_business_messages != null -> DeletedBusinessMessageUpdate(updateId, deleted_business_messages) purchased_paid_media != null -> PaidMediaPurchasedUpdate(updateId, purchased_paid_media) + managed_bot != null -> ManagedBotUpdate(updateId, managed_bot) else -> UnknownUpdate( updateId, raw diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt index 6f158a7e00..3c4f1d2db7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt @@ -45,6 +45,7 @@ interface FlowsUpdatesFilter : UpdatesFilter { val editBusinessMessageUpdatesFlow: Flow val deleteBusinessMessageUpdatesFlow: Flow val paidMediaPurchasedUpdatesFlow: Flow + val managedBotUpdatesFlow: Flow val unknownUpdatesFlow: Flow } @@ -73,6 +74,7 @@ abstract class AbstractFlowsUpdatesFilter : FlowsUpdatesFilter { override val editBusinessMessageUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val deleteBusinessMessageUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val paidMediaPurchasedUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val managedBotUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } } /** diff --git a/tgbotapi.utils/api/tgbotapi.utils.api b/tgbotapi.utils/api/tgbotapi.utils.api index ca937cffb4..e270a636d4 100644 --- a/tgbotapi.utils/api/tgbotapi.utils.api +++ b/tgbotapi.utils/api/tgbotapi.utils.api @@ -177,6 +177,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt { public static final fun asLocationContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/LocationContent; public static final fun asLocationInlineQuery (Ldev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery;)Ldev/inmo/tgbotapi/types/InlineQueries/query/LocationInlineQuery; public static final fun asLoginURLInlineKeyboardButton (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/LoginURLInlineKeyboardButton; + public static final fun asManagedBotUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate; public static final fun asMediaCollectionContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/MediaCollectionContent; public static final fun asMediaContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/MediaContent; public static final fun asMediaGroupContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/MediaGroupPartContent; @@ -523,6 +524,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt { public static final fun requireLocationContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/LocationContent; public static final fun requireLocationInlineQuery (Ldev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery;)Ldev/inmo/tgbotapi/types/InlineQueries/query/LocationInlineQuery; public static final fun requireLoginURLInlineKeyboardButton (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/LoginURLInlineKeyboardButton; + public static final fun requireManagedBotUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate; public static final fun requireMediaCollectionContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/MediaCollectionContent; public static final fun requireMediaContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/MediaContent; public static final fun requireMediaGroupContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/MediaGroupPartContent; @@ -869,6 +871,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt { public static final fun whenLocationContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun whenLocationInlineQuery (Ldev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun whenLoginURLInlineKeyboardButton (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun whenManagedBotUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun whenMediaCollectionContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun whenMediaContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun whenMediaGroupContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; @@ -1894,6 +1897,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt { public static final fun ifLocationInlineQuery (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifLoginURLInlineKeyboardButton (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifManagedBotCreated (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun ifManagedBotUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifManagedBotUpdated (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifMask (Ldev/inmo/tgbotapi/requests/stickers/InputSticker;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifMaskAnimatedSticker (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; @@ -2308,6 +2312,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt { public static final fun loginURLInlineKeyboardButtonOrThrow (Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton;)Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/LoginURLInlineKeyboardButton; public static final fun managedBotCreatedOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/managed_bots/ManagedBotCreated; public static final fun managedBotCreatedOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/managed_bots/ManagedBotCreated; + public static final fun managedBotUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate; + public static final fun managedBotUpdateOrThrow (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/ManagedBotUpdate; public static final fun managedBotUpdatedOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated; public static final fun managedBotUpdatedOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/managed_bots/ManagedBotUpdated; public static final fun maskAnimatedStickerOrNull (Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;)Ldev/inmo/tgbotapi/types/files/MaskAnimatedSticker; 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 d52ea1f3d8..9455f59aeb 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 @@ -2193,6 +2193,15 @@ inline fun Update.asInlineQueryUpdate(): InlineQueryUpdate? = this as? InlineQue @PreviewFeature inline fun Update.requireInlineQueryUpdate(): InlineQueryUpdate = this as InlineQueryUpdate +@PreviewFeature +inline fun Update.whenManagedBotUpdate(block: (ManagedBotUpdate) -> T) = asManagedBotUpdate()?.let(block) + +@PreviewFeature +inline fun Update.asManagedBotUpdate(): ManagedBotUpdate? = this as? ManagedBotUpdate + +@PreviewFeature +inline fun Update.requireManagedBotUpdate(): ManagedBotUpdate = this as ManagedBotUpdate + @PreviewFeature inline fun Update.whenMessageUpdate(block: (MessageUpdate) -> T) = asMessageUpdate()?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index d5d7458ec7..4eaf6a79d2 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -531,6 +531,7 @@ import dev.inmo.tgbotapi.types.update.EditBusinessMessageUpdate import dev.inmo.tgbotapi.types.update.EditChannelPostUpdate import dev.inmo.tgbotapi.types.update.EditMessageUpdate import dev.inmo.tgbotapi.types.update.InlineQueryUpdate +import dev.inmo.tgbotapi.types.update.ManagedBotUpdate import dev.inmo.tgbotapi.types.update.MessageUpdate import dev.inmo.tgbotapi.types.update.MyChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.PaidMediaPurchasedUpdate @@ -4092,6 +4093,12 @@ public inline fun Update.chosenInlineResultUpdateOrThrow(): ChosenInlineResultUp public inline fun Update.ifChosenInlineResultUpdate(block: (ChosenInlineResultUpdate) -> T): T? = chosenInlineResultUpdateOrNull() ?.let(block) +public inline fun Update.managedBotUpdateOrNull(): ManagedBotUpdate? = this as? dev.inmo.tgbotapi.types.update.ManagedBotUpdate + +public inline fun Update.managedBotUpdateOrThrow(): ManagedBotUpdate = this as dev.inmo.tgbotapi.types.update.ManagedBotUpdate + +public inline fun Update.ifManagedBotUpdate(block: (ManagedBotUpdate) -> T): T? = managedBotUpdateOrNull() ?.let(block) + public inline fun Update.shippingQueryUpdateOrNull(): ShippingQueryUpdate? = this as? dev.inmo.tgbotapi.types.update.ShippingQueryUpdate public inline fun Update.shippingQueryUpdateOrThrow(): ShippingQueryUpdate = this as dev.inmo.tgbotapi.types.update.ShippingQueryUpdate