From 64ef0fa160b7e2d3e4b71674c441b4a81bafea47 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Apr 2024 22:04:24 +0600 Subject: [PATCH] potentially finally add support of business chats input --- tgbotapi.core/api/tgbotapi.core.api | 168 +++++++++++++++++- .../dev/inmo/tgbotapi/types/ChatIdentifier.kt | 8 +- .../tgbotapi/types/chat/ChatSerializers.kt | 42 +++-- .../dev/inmo/tgbotapi/types/chat/Extended.kt | 9 + .../dev/inmo/tgbotapi/types/chat/Impls.kt | 2 +- .../message/BusinessContentMessageImpl.kt | 4 +- .../inmo/tgbotapi/types/message/RawMessage.kt | 5 +- .../abstracts/BusinessContentMessage.kt | 3 +- tgbotapi.utils/api/tgbotapi.utils.api | 3 - .../extensions/utils/ClassCastsNew.kt | 40 +++++ 10 files changed, 251 insertions(+), 33 deletions(-) diff --git a/tgbotapi.core/api/tgbotapi.core.api b/tgbotapi.core/api/tgbotapi.core.api index 0a85591454..3611fc8ace 100644 --- a/tgbotapi.core/api/tgbotapi.core.api +++ b/tgbotapi.core/api/tgbotapi.core.api @@ -7170,6 +7170,33 @@ public final class dev/inmo/tgbotapi/types/BotShortDescription$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; + public static fun constructor-impl (JLjava/lang/String;)Lkotlin/Pair; + public static fun constructor-impl (Lkotlin/Pair;)Lkotlin/Pair; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lkotlin/Pair;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lkotlin/Pair;Lkotlin/Pair;)Z + public fun getBusinessId-T-_HSQI ()Ljava/lang/String; + public static fun getBusinessId-T-_HSQI (Lkotlin/Pair;)Ljava/lang/String; + public synthetic fun getBusinessId-nXr5wdE ()Ljava/lang/String; + public fun getChatId-iyD94Bc ()J + public static fun getChatId-iyD94Bc (Lkotlin/Pair;)J + public final fun getChatIdWithBusinessConnectionId ()Lkotlin/Pair; + public fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId; + public static fun getThreadId-S3HF-10 (Lkotlin/Pair;)Ldev/inmo/tgbotapi/types/MessageThreadId; + public fun hashCode ()I + public static fun hashCode-impl (Lkotlin/Pair;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lkotlin/Pair;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lkotlin/Pair; +} + +public final class dev/inmo/tgbotapi/types/BusinessChatId$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/inmo/tgbotapi/types/CallbackQueryId { public static final field Companion Ldev/inmo/tgbotapi/types/CallbackQueryId$Companion; public static final synthetic fun box-impl (Ljava/lang/String;)Ldev/inmo/tgbotapi/types/CallbackQueryId; @@ -7207,6 +7234,8 @@ public final class dev/inmo/tgbotapi/types/ChatId : dev/inmo/tgbotapi/types/IdCh public fun equals (Ljava/lang/Object;)Z public static fun equals-impl (JLjava/lang/Object;)Z public static final fun equals-impl0 (JJ)Z + public fun getBusinessId-nXr5wdE ()Ljava/lang/String; + public static fun getBusinessId-nXr5wdE (J)Ljava/lang/String; public fun getChatId-iyD94Bc ()J public fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId; public static fun getThreadId-S3HF-10 (J)Ldev/inmo/tgbotapi/types/MessageThreadId; @@ -7229,6 +7258,8 @@ public final class dev/inmo/tgbotapi/types/ChatIdWithThreadId : dev/inmo/tgbotap public fun equals (Ljava/lang/Object;)Z public static fun equals-impl (Lkotlin/Pair;Ljava/lang/Object;)Z public static final fun equals-impl0 (Lkotlin/Pair;Lkotlin/Pair;)Z + public fun getBusinessId-nXr5wdE ()Ljava/lang/String; + public static fun getBusinessId-nXr5wdE (Lkotlin/Pair;)Ljava/lang/String; public fun getChatId-iyD94Bc ()J public static fun getChatId-iyD94Bc (Lkotlin/Pair;)J public final fun getChatIdWithThreadId ()Lkotlin/Pair; @@ -7262,6 +7293,7 @@ public final class dev/inmo/tgbotapi/types/ChatIdentifierKt { public static final fun getUserLink (Ldev/inmo/tgbotapi/types/chat/User;)Ljava/lang/String; public static final fun getUserLink-0218hRU (J)Ljava/lang/String; public static final fun getUserLink-HZVsHAI (J)Ljava/lang/String; + public static final fun toBusinessChatId-X6RVWW0 (Ldev/inmo/tgbotapi/types/IdChatIdentifier;Ljava/lang/String;)Ldev/inmo/tgbotapi/types/IdChatIdentifier; public static final fun toChatId (B)Ldev/inmo/tgbotapi/types/IdChatIdentifier; public static final fun toChatId (I)Ldev/inmo/tgbotapi/types/IdChatIdentifier; public static final fun toChatId (J)J @@ -7527,6 +7559,9 @@ public final class dev/inmo/tgbotapi/types/CommonKt { public static final field botIsMemberField Ljava/lang/String; public static final field botUsernameField Ljava/lang/String; public static final field businessConnectionIdField Ljava/lang/String; + public static final field businessIntroField Ljava/lang/String; + public static final field businessLocationField Ljava/lang/String; + public static final field businessOpeningHoursField Ljava/lang/String; public static final field buttonField Ljava/lang/String; public static final field buttonTextField Ljava/lang/String; public static final field cacheTimeField Ljava/lang/String; @@ -8097,6 +8132,7 @@ public final class dev/inmo/tgbotapi/types/FullChatIdentifierSerializer : kotlin public abstract interface class dev/inmo/tgbotapi/types/IdChatIdentifier : dev/inmo/tgbotapi/types/ChatIdentifier { public static final field Companion Ldev/inmo/tgbotapi/types/IdChatIdentifier$Companion; + public abstract fun getBusinessId-nXr5wdE ()Ljava/lang/String; public abstract fun getChatId-iyD94Bc ()J public abstract fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId; } @@ -8104,10 +8140,12 @@ public abstract interface class dev/inmo/tgbotapi/types/IdChatIdentifier : dev/i public final class dev/inmo/tgbotapi/types/IdChatIdentifier$Companion { public final fun invoke-0PTMirw (J)J public final fun invoke-FNqv5JM (JLdev/inmo/tgbotapi/types/MessageThreadId;)Ldev/inmo/tgbotapi/types/IdChatIdentifier; + public final fun invoke-y2sHuGA (JLjava/lang/String;)Ldev/inmo/tgbotapi/types/IdChatIdentifier; public final fun serializer ()Lkotlinx/serialization/KSerializer; } public final class dev/inmo/tgbotapi/types/IdChatIdentifier$DefaultImpls { + public static fun getBusinessId-nXr5wdE (Ldev/inmo/tgbotapi/types/IdChatIdentifier;)Ljava/lang/String; public static fun getThreadId-S3HF-10 (Ldev/inmo/tgbotapi/types/IdChatIdentifier;)Ldev/inmo/tgbotapi/types/MessageThreadId; } @@ -12868,6 +12906,47 @@ public final class dev/inmo/tgbotapi/types/chat/Bot$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public abstract interface class dev/inmo/tgbotapi/types/chat/BusinessChat : dev/inmo/tgbotapi/types/chat/Chat { + public static final field Companion Ldev/inmo/tgbotapi/types/chat/BusinessChat$Companion; + public abstract fun getId-y8AA8dk ()Lkotlin/Pair; + public abstract fun getOriginal ()Ldev/inmo/tgbotapi/types/chat/PrivateChat; +} + +public final class dev/inmo/tgbotapi/types/chat/BusinessChat$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/chat/BusinessChatImpl : dev/inmo/tgbotapi/types/chat/PreviewBusinessChat { + public static final field Companion Ldev/inmo/tgbotapi/types/chat/BusinessChatImpl$Companion; + public synthetic fun (Lkotlin/Pair;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-y8AA8dk ()Lkotlin/Pair; + public final fun component2 ()Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat; + public final fun copy-rh-56jM (Lkotlin/Pair;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;)Ldev/inmo/tgbotapi/types/chat/BusinessChatImpl; + public static synthetic fun copy-rh-56jM$default (Ldev/inmo/tgbotapi/types/chat/BusinessChatImpl;Lkotlin/Pair;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/chat/BusinessChatImpl; + public fun equals (Ljava/lang/Object;)Z + public synthetic fun getId ()Ldev/inmo/tgbotapi/types/IdChatIdentifier; + public fun getId-y8AA8dk ()Lkotlin/Pair; + public fun getOriginal ()Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat; + public synthetic fun getOriginal ()Ldev/inmo/tgbotapi/types/chat/PrivateChat; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/inmo/tgbotapi/types/chat/BusinessChatImpl$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/chat/BusinessChatImpl$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/chat/BusinessChatImpl; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/chat/BusinessChatImpl;)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/chat/BusinessChatImpl$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public abstract interface class dev/inmo/tgbotapi/types/chat/ChannelChat : dev/inmo/tgbotapi/types/chat/SuperPublicChat { public static final field Companion Ldev/inmo/tgbotapi/types/chat/ChannelChat$Companion; public abstract fun getId-tHkBKVM ()J @@ -13491,6 +13570,51 @@ public final class dev/inmo/tgbotapi/types/chat/ExtendedBot$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public abstract interface class dev/inmo/tgbotapi/types/chat/ExtendedBusinessChat : dev/inmo/tgbotapi/types/chat/BusinessChat, dev/inmo/tgbotapi/types/chat/ExtendedChat { + public static final field Companion Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChat$Companion; + public abstract fun getOriginal ()Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChat; +} + +public final class dev/inmo/tgbotapi/types/chat/ExtendedBusinessChat$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl : dev/inmo/tgbotapi/types/chat/ExtendedBusinessChat, dev/inmo/tgbotapi/types/chat/ExtendedChat { + public static final field Companion Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl$Companion; + public synthetic fun (Lkotlin/Pair;Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChat;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1-y8AA8dk ()Lkotlin/Pair; + public final fun component2 ()Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChat; + public final fun copy-rh-56jM (Lkotlin/Pair;Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChat;)Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl; + public static synthetic fun copy-rh-56jM$default (Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl;Lkotlin/Pair;Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChat;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl; + public fun equals (Ljava/lang/Object;)Z + public fun getAccentColorId-f3WtEc0 ()I + public fun getBackgroundCustomEmojiId-GbmMWyQ ()Ljava/lang/String; + public fun getChatPhoto ()Ldev/inmo/tgbotapi/types/ChatPhoto; + public synthetic fun getId ()Ldev/inmo/tgbotapi/types/IdChatIdentifier; + public fun getId-y8AA8dk ()Lkotlin/Pair; + public fun getOriginal ()Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChat; + public synthetic fun getOriginal ()Ldev/inmo/tgbotapi/types/chat/PrivateChat; + public fun getProfileAccentColorId-mg_h9nU ()Ldev/inmo/tgbotapi/types/colors/ColorId; + public fun getProfileBackgroundCustomEmojiId-GbmMWyQ ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/chat/ExtendedBusinessChatImpl;)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/chat/ExtendedBusinessChatImpl$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public abstract interface class dev/inmo/tgbotapi/types/chat/ExtendedChannelChat : dev/inmo/tgbotapi/types/chat/ChannelChat, dev/inmo/tgbotapi/types/chat/ExtendedChatWithUsername, dev/inmo/tgbotapi/types/chat/ExtendedPublicChat { public static final field Companion Ldev/inmo/tgbotapi/types/chat/ExtendedChannelChat$Companion; public abstract fun getLinkedGroupChatId ()Ldev/inmo/tgbotapi/types/IdChatIdentifier; @@ -13585,6 +13709,12 @@ public abstract class dev/inmo/tgbotapi/types/chat/ExtendedChatSerializer : kotl public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } +public final class dev/inmo/tgbotapi/types/chat/ExtendedChatSerializer$BasedOnBusinessConnection : dev/inmo/tgbotapi/types/chat/ExtendedChatSerializer { + public synthetic fun (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/chat/ExtendedChat; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; +} + public final class dev/inmo/tgbotapi/types/chat/ExtendedChatSerializer$BasedOnForumThread : dev/inmo/tgbotapi/types/chat/ExtendedChatSerializer { public synthetic fun (JLkotlin/jvm/internal/DefaultConstructorMarker;)V public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/chat/ExtendedChat; @@ -13775,6 +13905,9 @@ public abstract interface class dev/inmo/tgbotapi/types/chat/ExtendedPrivateChat public static final field Companion Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChat$Companion; public abstract fun getAllowCreateUserIdLink ()Z public abstract fun getBio ()Ljava/lang/String; + public abstract fun getBusinessIntro ()Ldev/inmo/tgbotapi/types/business_connection/BusinessIntro; + public abstract fun getBusinessLocation ()Ldev/inmo/tgbotapi/types/business_connection/BusinessLocation; + public abstract fun getBusinessOpeningHours ()Ldev/inmo/tgbotapi/types/business_connection/BusinessOpeningHours; public abstract fun getHasPrivateForwards ()Z public abstract fun getHasRestrictedVoiceAndVideoMessages ()Z } @@ -13789,8 +13922,8 @@ public final class dev/inmo/tgbotapi/types/chat/ExtendedPrivateChat$DefaultImpls public final class dev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl : dev/inmo/tgbotapi/types/chat/ExtendedPrivateChat { public static final field Companion Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl$Companion; - public synthetic fun (JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/business_connection/BusinessIntro;Ldev/inmo/tgbotapi/types/business_connection/BusinessLocation;Ldev/inmo/tgbotapi/types/business_connection/BusinessOpeningHours;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/business_connection/BusinessIntro;Ldev/inmo/tgbotapi/types/business_connection/BusinessLocation;Ldev/inmo/tgbotapi/types/business_connection/BusinessOpeningHours;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1-tHkBKVM ()J public final fun component10-GbmMWyQ ()Ljava/lang/String; public final fun component11 ()Ldev/inmo/tgbotapi/types/TelegramDate; @@ -13798,6 +13931,9 @@ public final class dev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl : dev/in public final fun component13-mg_h9nU ()Ldev/inmo/tgbotapi/types/colors/ColorId; public final fun component14-GbmMWyQ ()Ljava/lang/String; public final fun component15-GbmMWyQ ()Ljava/lang/String; + public final fun component16 ()Ldev/inmo/tgbotapi/types/business_connection/BusinessIntro; + public final fun component17 ()Ldev/inmo/tgbotapi/types/business_connection/BusinessLocation; + public final fun component18 ()Ldev/inmo/tgbotapi/types/business_connection/BusinessOpeningHours; public final fun component2 ()Ldev/inmo/tgbotapi/types/ChatPhoto; public final fun component3-san03mo ()Ljava/lang/String; public final fun component4 ()Ljava/util/List; @@ -13806,14 +13942,17 @@ public final class dev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl : dev/in public final fun component7 ()Ljava/lang/String; public final fun component8 ()Z public final fun component9 ()Z - public final fun copy-e_ALIDo (JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;)Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl; - public static synthetic fun copy-e_ALIDo$default (Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl;JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl; + public final fun copy-4P93q3c (JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/business_connection/BusinessIntro;Ldev/inmo/tgbotapi/types/business_connection/BusinessLocation;Ldev/inmo/tgbotapi/types/business_connection/BusinessOpeningHours;)Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl; + public static synthetic fun copy-4P93q3c$default (Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl;JLdev/inmo/tgbotapi/types/ChatPhoto;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ldev/inmo/tgbotapi/types/TelegramDate;ILdev/inmo/tgbotapi/types/colors/ColorId;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/business_connection/BusinessIntro;Ldev/inmo/tgbotapi/types/business_connection/BusinessLocation;Ldev/inmo/tgbotapi/types/business_connection/BusinessOpeningHours;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/chat/ExtendedPrivateChatImpl; public fun equals (Ljava/lang/Object;)Z public fun getAccentColorId-f3WtEc0 ()I public fun getActiveUsernames ()Ljava/util/List; public fun getAllowCreateUserIdLink ()Z public fun getBackgroundCustomEmojiId-GbmMWyQ ()Ljava/lang/String; public fun getBio ()Ljava/lang/String; + public fun getBusinessIntro ()Ldev/inmo/tgbotapi/types/business_connection/BusinessIntro; + public fun getBusinessLocation ()Ldev/inmo/tgbotapi/types/business_connection/BusinessLocation; + public fun getBusinessOpeningHours ()Ldev/inmo/tgbotapi/types/business_connection/BusinessOpeningHours; public fun getChatPhoto ()Ldev/inmo/tgbotapi/types/ChatPhoto; public fun getFirstName ()Ljava/lang/String; public fun getHasPrivateForwards ()Z @@ -14050,6 +14189,14 @@ public final class dev/inmo/tgbotapi/types/chat/PreviewBot$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public abstract interface class dev/inmo/tgbotapi/types/chat/PreviewBusinessChat : dev/inmo/tgbotapi/types/chat/BusinessChat, dev/inmo/tgbotapi/types/chat/PreviewChat { + public static final field Companion Ldev/inmo/tgbotapi/types/chat/PreviewBusinessChat$Companion; +} + +public final class dev/inmo/tgbotapi/types/chat/PreviewBusinessChat$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public abstract interface class dev/inmo/tgbotapi/types/chat/PreviewChannelChat : dev/inmo/tgbotapi/types/chat/ChannelChat, dev/inmo/tgbotapi/types/chat/PreviewSuperPublicChat { public static final field Companion Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat$Companion; } @@ -17132,13 +17279,16 @@ public final class dev/inmo/tgbotapi/types/message/AnonymousGroupContentMessageI } public final class dev/inmo/tgbotapi/types/message/BusinessContentMessageImpl : dev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage { - public synthetic fun (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/ForwardInfo;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/MessageOrigin;Ldev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/ForwardInfo;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/PreviewBot;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/ForwardInfo;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/PreviewBot;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/MessageOrigin;Ldev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/PreviewBot;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/MessageOrigin;Ldev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/PreviewBot;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1-APLFQys ()J public final fun component10 ()Ldev/inmo/tgbotapi/types/ReplyInfo; public final fun component11 ()Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup; public final fun component12 ()Ldev/inmo/tgbotapi/types/chat/CommonBot; public final fun component13-CsYhHCU ()Ljava/lang/String; + public final fun component14 ()Ldev/inmo/tgbotapi/types/chat/PreviewBot; public final fun component2 ()Ldev/inmo/tgbotapi/types/chat/User; public final fun component3 ()Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat; public final fun component4-T-_HSQI ()Ljava/lang/String; @@ -17147,8 +17297,8 @@ public final class dev/inmo/tgbotapi/types/message/BusinessContentMessageImpl : public final fun component7-Ivn3T5g ()Lkorlibs/time/DateTime; public final fun component8 ()Z public final fun component9 ()Ldev/inmo/tgbotapi/types/message/MessageOrigin; - public final fun copy-DsA41C8 (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/MessageOrigin;Ldev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;)Ldev/inmo/tgbotapi/types/message/BusinessContentMessageImpl; - public static synthetic fun copy-DsA41C8$default (Ldev/inmo/tgbotapi/types/message/BusinessContentMessageImpl;JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/MessageOrigin;Ldev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/message/BusinessContentMessageImpl; + public final fun copy-FGAwJ3U (JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/MessageOrigin;Ldev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/PreviewBot;)Ldev/inmo/tgbotapi/types/message/BusinessContentMessageImpl; + public static synthetic fun copy-FGAwJ3U$default (Ldev/inmo/tgbotapi/types/message/BusinessContentMessageImpl;JLdev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/content/MessageContent;DLkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/MessageOrigin;Ldev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/PreviewBot;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/message/BusinessContentMessageImpl; public fun equals (Ljava/lang/Object;)Z public fun getBusinessConnectionId-T-_HSQI ()Ljava/lang/String; public synthetic fun getBusinessConnectionId-nXr5wdE ()Ljava/lang/String; @@ -17169,6 +17319,7 @@ public final class dev/inmo/tgbotapi/types/message/BusinessContentMessageImpl : public fun getReplyMarkup ()Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup; public fun getReplyTo ()Ldev/inmo/tgbotapi/types/message/abstracts/Message; public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot; + public fun getSenderBusinessBot ()Ldev/inmo/tgbotapi/types/chat/PreviewBot; public fun getUser ()Ldev/inmo/tgbotapi/types/chat/User; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -18447,6 +18598,7 @@ public final class dev/inmo/tgbotapi/types/message/abstracts/AnonymousGroupConte public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage : dev/inmo/tgbotapi/abstracts/types/WithBusinessConnectionId, dev/inmo/tgbotapi/types/message/abstracts/FromUserMessage, dev/inmo/tgbotapi/types/message/abstracts/PossiblySentViaBotCommonMessage { public abstract fun getBusinessConnectionId-T-_HSQI ()Ljava/lang/String; public abstract fun getChat ()Ldev/inmo/tgbotapi/types/chat/PreviewPrivateChat; + public abstract fun getSenderBusinessBot ()Ldev/inmo/tgbotapi/types/chat/PreviewBot; } public final class dev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage$DefaultImpls { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt index 6a566ceb4b..fe7591e076 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt @@ -34,13 +34,13 @@ sealed interface IdChatIdentifier : ChatIdentifier { get() = null companion object { - operator fun invoke(chatId: RawChatId) = ChatId(chatId) - operator fun invoke(chatId: RawChatId, threadId: MessageThreadId?) = threadId ?.let { + operator fun invoke(chatId: RawChatId, threadId: MessageThreadId? = null, businessConnectionId: BusinessConnectionId? = null) = threadId ?.let { ChatIdWithThreadId(chatId, threadId) - } ?: ChatId(chatId) - operator fun invoke(chatId: RawChatId, businessConnectionId: BusinessConnectionId?) = businessConnectionId ?.let { + } ?: businessConnectionId ?.let { BusinessChatId(chatId, businessConnectionId) } ?: ChatId(chatId) + operator fun invoke(chatId: RawChatId, threadId: MessageThreadId) = ChatIdWithThreadId(chatId, threadId) + operator fun invoke(chatId: RawChatId, businessConnectionId: BusinessConnectionId) = BusinessChatId(chatId, businessConnectionId) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt index e88bce2509..0a655096e8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt @@ -63,8 +63,9 @@ object ChatSerializer : KSerializer { return try { formatter.decodeFromJsonElement(ExtendedChatSerializer, decodedJson) } catch (e: SerializationException) { - val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson") + val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true + val original = decodedJson[originField] when (type) { ChatType.Sender -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson) @@ -81,6 +82,12 @@ object ChatSerializer : KSerializer { decodedJson.toString(), decodedJson ) + null -> { + when { + original != null -> formatter.decodeFromJsonElement(BusinessChatImpl.serializer(), decodedJson) + else -> error("Field $typeField must be presented for common types (excluding Business chats), but absent in $decodedJson") + } + } } } } @@ -102,19 +109,13 @@ object PreviewChatSerializer : KSerializer { override fun deserialize(decoder: Decoder): PreviewChat { val decodedJson = JsonObject.serializer().deserialize(decoder) - val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson") + val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true - val isBusiness = decodedJson[chatIdField] ?.jsonPrimitive ?.contentOrNull ?.contains("//") == true + val original = decodedJson[originField] return when (type) { ChatType.Sender -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson) - ChatType.Private -> { - if (isBusiness) { - formatter.decodeFromJsonElement(BusinessChatImpl.serializer(), decodedJson) - } else { - formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson) - } - } + ChatType.Private -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson) ChatType.Group -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson) ChatType.Supergroup -> if (isForum) { formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson) @@ -127,6 +128,12 @@ object PreviewChatSerializer : KSerializer { decodedJson.toString(), decodedJson ) + null -> { + when { + original != null -> formatter.decodeFromJsonElement(PreviewBusinessChat.serializer(), decodedJson) + else -> error("Field $typeField must be presented for common types (excluding Business chats), but absent in $decodedJson") + } + } } } @@ -153,8 +160,9 @@ sealed class ExtendedChatSerializer : KSerializer { override fun deserialize(decoder: Decoder): ExtendedChat { val decodedJson = JsonObject.serializer().deserialize(decoder) - val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson") + val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true + val original = decodedJson[originField] return when (type) { ChatType.Sender -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson) @@ -171,11 +179,18 @@ sealed class ExtendedChatSerializer : KSerializer { decodedJson.toString(), decodedJson ) + null -> { + when { + original != null -> formatter.decodeFromJsonElement(ExtendedBusinessChatImpl.serializer(), decodedJson) + else -> error("Field $typeField must be presented for common types (excluding Business chats), but absent in $decodedJson") + } + } } } override fun serialize(encoder: Encoder, value: ExtendedChat) { when (value) { + is ExtendedBusinessChatImpl -> ExtendedBusinessChatImpl.serializer().serialize(encoder, value) is ExtendedPrivateChatImpl -> ExtendedPrivateChatImpl.serializer().serialize(encoder, value) is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, value) is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, value) @@ -203,8 +218,9 @@ sealed class ExtendedChatSerializer : KSerializer { override fun deserialize(decoder: Decoder): ExtendedChat { return super.deserialize(decoder).let { if (it is ExtendedPrivateChatImpl) { - it.copy( - id = (it.id as? BusinessChatId) ?: BusinessChatId(it.id.chatId, businessConnectionId) + ExtendedBusinessChatImpl( + BusinessChatId(it.id.chatId, businessConnectionId), + it ) } else { it diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index 55517b3031..2c6a462acd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -263,6 +263,7 @@ data class ExtendedForumChatImpl( @Serializable data class ExtendedBot( + @SerialName(idField) override val id: UserId, @SerialName(firstNameField) override val firstName: String, @@ -291,6 +292,14 @@ data class ExtendedBot( private val isBot = true } +@Serializable +data class ExtendedBusinessChatImpl( + @SerialName(idField) + override val id: BusinessChatId, + @SerialName(originField) + override val original: ExtendedPrivateChat +) : ExtendedBusinessChat, ExtendedChat by original + data class UnknownExtendedChat( override val id: IdChatIdentifier, val raw: String, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt index be6419add7..9a3c8dc204 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt @@ -35,7 +35,7 @@ data class PrivateChatImpl( data class BusinessChatImpl( @SerialName(idField) override val id: BusinessChatId, - @SerialName(firstNameField) + @SerialName(originField) override val original: PreviewPrivateChat ) : PreviewBusinessChat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/BusinessContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/BusinessContentMessageImpl.kt index 28ba296012..d3ff18f251 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/BusinessContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/BusinessContentMessageImpl.kt @@ -15,7 +15,7 @@ import dev.inmo.tgbotapi.types.message.content.MessageContent data class BusinessContentMessageImpl( override val messageId: MessageId, override val from: User, - override val chat: PreviewPrivateChat, + override val chat: PreviewBusinessChat, override val businessConnectionId: BusinessConnectionId, override val content: T, override val date: DateTime, @@ -31,7 +31,7 @@ data class BusinessContentMessageImpl( constructor( messageId: MessageId, from: User, - chat: PreviewPrivateChat, + chat: PreviewBusinessChat, businessConnectionId: BusinessConnectionId, content: T, date: DateTime, 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 1a32f6efc9..acc4da16a2 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 @@ -533,7 +533,10 @@ internal data class RawMessage( BusinessContentMessageImpl( messageId, from ?: error("Was detected common message, but owner (sender) of the message was not found"), - chat, + BusinessChatImpl( + chat.id.toBusinessChatId(business_connection_id), + chat + ), business_connection_id, content, date.asDate, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage.kt index 09e314ea10..eb46e4fe9e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/BusinessContentMessage.kt @@ -3,12 +3,13 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.abstracts.types.WithBusinessConnectionId import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.chat.PreviewBot +import dev.inmo.tgbotapi.types.chat.PreviewBusinessChat import dev.inmo.tgbotapi.types.chat.PreviewPrivateChat import dev.inmo.tgbotapi.types.message.content.MessageContent interface BusinessContentMessage : PossiblySentViaBotCommonMessage, FromUserMessage, WithBusinessConnectionId { - override val chat: PreviewPrivateChat + override val chat: PreviewBusinessChat override val businessConnectionId: BusinessConnectionId val senderBusinessBot: PreviewBot? } diff --git a/tgbotapi.utils/api/tgbotapi.utils.api b/tgbotapi.utils/api/tgbotapi.utils.api index 1abc029081..716b6b5f15 100644 --- a/tgbotapi.utils/api/tgbotapi.utils.api +++ b/tgbotapi.utils/api/tgbotapi.utils.api @@ -1745,7 +1745,6 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt { public static final fun ifPollAnswerUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifPollContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifPollUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun ifPossiblyBusinessMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifPossiblyEditedMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifPossiblyForwardedMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifPossiblyMediaGroupMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; @@ -2158,8 +2157,6 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt { public static final fun pollContentOrThrow (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/PollContent; public static final fun pollUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/PollUpdate; public static final fun pollUpdateOrThrow (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/PollUpdate; - public static final fun possiblyBusinessMessageOrNull (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyBusinessMessage; - public static final fun possiblyBusinessMessageOrThrow (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyBusinessMessage; public static final fun possiblyEditedMessageOrNull (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyEditedMessage; public static final fun possiblyEditedMessageOrThrow (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyEditedMessage; public static final fun possiblyForwardedMessageOrNull (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage; 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 d4483e361a..8cfbfffacf 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 @@ -16,6 +16,7 @@ import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink import dev.inmo.tgbotapi.requests.send.payments.SendInvoice import dev.inmo.tgbotapi.requests.stickers.InputSticker +import dev.inmo.tgbotapi.types.BusinessChatId import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.ChatIdWithThreadId import dev.inmo.tgbotapi.types.ChatIdentifier @@ -112,6 +113,7 @@ import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardRemove import dev.inmo.tgbotapi.types.chat.AbleToAddInAttachmentMenuChat import dev.inmo.tgbotapi.types.chat.Bot +import dev.inmo.tgbotapi.types.chat.BusinessChat import dev.inmo.tgbotapi.types.chat.ChannelChat import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.ChatJoinRequest @@ -119,6 +121,7 @@ import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.ExtendedBot +import dev.inmo.tgbotapi.types.chat.ExtendedBusinessChat import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat import dev.inmo.tgbotapi.types.chat.ExtendedChat import dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername @@ -132,6 +135,7 @@ import dev.inmo.tgbotapi.types.chat.ForumChat import dev.inmo.tgbotapi.types.chat.GroupChat import dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat import dev.inmo.tgbotapi.types.chat.PreviewBot +import dev.inmo.tgbotapi.types.chat.PreviewBusinessChat import dev.inmo.tgbotapi.types.chat.PreviewChannelChat import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.chat.PreviewForumChat @@ -1108,6 +1112,15 @@ public inline fun ChatIdentifier.chatIdWithThreadIdOrThrow(): ChatIdWithThreadId public inline fun ChatIdentifier.ifChatIdWithThreadId(block: (ChatIdWithThreadId) -> T): T? = chatIdWithThreadIdOrNull() ?.let(block) +public inline fun ChatIdentifier.businessChatIdOrNull(): BusinessChatId? = this as? + dev.inmo.tgbotapi.types.BusinessChatId + +public inline fun ChatIdentifier.businessChatIdOrThrow(): BusinessChatId = this as + dev.inmo.tgbotapi.types.BusinessChatId + +public inline fun ChatIdentifier.ifBusinessChatId(block: (BusinessChatId) -> T): T? = + businessChatIdOrNull() ?.let(block) + public inline fun ChatIdentifier.usernameOrNull(): Username? = this as? dev.inmo.tgbotapi.types.Username @@ -2047,6 +2060,15 @@ public inline fun Chat.privateChatOrThrow(): PrivateChat = this as public inline fun Chat.ifPrivateChat(block: (PrivateChat) -> T): T? = privateChatOrNull() ?.let(block) +public inline fun Chat.businessChatOrNull(): BusinessChat? = this as? + dev.inmo.tgbotapi.types.chat.BusinessChat + +public inline fun Chat.businessChatOrThrow(): BusinessChat = this as + dev.inmo.tgbotapi.types.chat.BusinessChat + +public inline fun Chat.ifBusinessChat(block: (BusinessChat) -> T): T? = businessChatOrNull() + ?.let(block) + public inline fun Chat.publicChatOrNull(): PublicChat? = this as? dev.inmo.tgbotapi.types.chat.PublicChat @@ -2217,6 +2239,15 @@ public inline fun Chat.extendedChatWithUsernameOrThrow(): ExtendedChatWithUserna public inline fun Chat.ifExtendedChatWithUsername(block: (ExtendedChatWithUsername) -> T): T? = extendedChatWithUsernameOrNull() ?.let(block) +public inline fun Chat.extendedBusinessChatOrNull(): ExtendedBusinessChat? = this as? + dev.inmo.tgbotapi.types.chat.ExtendedBusinessChat + +public inline fun Chat.extendedBusinessChatOrThrow(): ExtendedBusinessChat = this as + dev.inmo.tgbotapi.types.chat.ExtendedBusinessChat + +public inline fun Chat.ifExtendedBusinessChat(block: (ExtendedBusinessChat) -> T): T? = + extendedBusinessChatOrNull() ?.let(block) + public inline fun Chat.userOrNull(): User? = this as? dev.inmo.tgbotapi.types.chat.User public inline fun Chat.userOrThrow(): User = this as dev.inmo.tgbotapi.types.chat.User @@ -2291,6 +2322,15 @@ public inline fun Chat.previewPrivateChatOrThrow(): PreviewPrivateChat = this as public inline fun Chat.ifPreviewPrivateChat(block: (PreviewPrivateChat) -> T): T? = previewPrivateChatOrNull() ?.let(block) +public inline fun Chat.previewBusinessChatOrNull(): PreviewBusinessChat? = this as? + dev.inmo.tgbotapi.types.chat.PreviewBusinessChat + +public inline fun Chat.previewBusinessChatOrThrow(): PreviewBusinessChat = this as + dev.inmo.tgbotapi.types.chat.PreviewBusinessChat + +public inline fun Chat.ifPreviewBusinessChat(block: (PreviewBusinessChat) -> T): T? = + previewBusinessChatOrNull() ?.let(block) + public inline fun Chat.previewPublicChatOrNull(): PreviewPublicChat? = this as? dev.inmo.tgbotapi.types.chat.PreviewPublicChat