From 152728afcad240e63068d58f6aa65ff85331390f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 30 Dec 2023 02:41:42 +0600 Subject: [PATCH 01/65] start 10.0.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c424e3fa2..6d474e4617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 10.0.0 + ## 9.4.3 **IetfLanguageCode has been renamed to IetfLang in MicroUtils** diff --git a/gradle.properties b/gradle.properties index 6e40231f5b..3b3324bf08 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=9.4.3 +library_version=10.0.0 From e124bb18df2e8732a20ea8adfaa961815bad7099 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 30 Dec 2023 02:42:05 +0600 Subject: [PATCH 02/65] update ksp --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 00c5ee3dbe..8befa9eaa5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ korlibs = "4.0.10" uuid = "0.8.2" ktor = "2.3.7" -ksp = "1.9.21-1.0.16" +ksp = "1.9.22-1.0.16" kotlin-poet = "1.15.3" microutils = "0.20.23" From a622c4d6faca038554bb5c6b0cc1e44a09d85449 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 30 Dec 2023 03:02:21 +0600 Subject: [PATCH 03/65] add Reaction type --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../inmo/tgbotapi/types/reactions/Reaction.kt | 93 +++++++++++++++++++ .../extensions/utils/ClassCastsNew.kt | 28 ++++++ 3 files changed, 122 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index ee4df3827e..b30bc94e4e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -229,6 +229,7 @@ const val textEntitiesField = "text_entities" const val entitiesField = "entities" const val stickerSetNameField = "set_name" const val customEmojiIdField = "custom_emoji_id" +const val customEmojiField = "custom_emoji" const val customEmojiIdsField = "custom_emoji_ids" const val premiumAnimationField = "premium_animation" const val stickerSetNameFullField = "sticker_set_name" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt new file mode 100644 index 0000000000..15aadf8e94 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt @@ -0,0 +1,93 @@ +package dev.inmo.tgbotapi.types.reactions + +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.customEmojiField +import dev.inmo.tgbotapi.types.emojiField +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded +import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.JsonDecoder +import kotlinx.serialization.json.JsonElement + +@Serializable +@ClassCastsIncluded +sealed interface Reaction { + val type: String + + @Serializable(Reaction.Companion::class) + data class Emoji( + val emoji: String + ) : Reaction { + override val type: String + get() = Companion.type + companion object { + const val type: String = "emoji" + } + } + + @Serializable(Reaction.Companion::class) + data class CustomEmoji( + val customEmoji: CustomEmojiId + ) : Reaction { + override val type: String + get() = Companion.type + companion object { + const val type: String = "custom_emoji" + } + } + + @Serializable(Reaction.Companion::class) + data class Unknown( + override val type: String, + val sourceJson: JsonElement? + ) : Reaction + + @Serializable + private data class Surrogate( + val type: String, + @SerialName(emojiField) + val emoji: String? = null, + @SerialName(customEmojiField) + val customEmoji: CustomEmojiId? = null + ) + + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): Reaction { + val (surrogate, json) = if (decoder is JsonDecoder) { + val json = decoder.decodeJsonElement() + decoder.json.decodeFromJsonElement(Surrogate.serializer(), json) to json + } else { + Surrogate.serializer().deserialize(decoder) to null + } + + return when { + surrogate.emoji != null -> Emoji(surrogate.emoji) + surrogate.customEmoji != null -> CustomEmoji(surrogate.customEmoji) + else -> Unknown(surrogate.type, json) + } + } + + override fun serialize(encoder: Encoder, value: Reaction) { + if (value is Unknown && value.sourceJson != null) { + JsonElement.serializer().serialize(encoder, value.sourceJson) + } else { + Surrogate.serializer().serialize( + encoder, + Surrogate( + type = value.type, + emoji = (value as? Emoji) ?.emoji, + customEmoji = (value as? CustomEmoji) ?.customEmoji, + ) + ) + } + } + + } +} 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 5dadba2ded..932b1e9fc9 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 @@ -415,6 +415,7 @@ import dev.inmo.tgbotapi.types.queries.callback.MessageCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType +import dev.inmo.tgbotapi.types.reactions.Reaction import dev.inmo.tgbotapi.types.request.ChatShared import dev.inmo.tgbotapi.types.request.ChatSharedRequest import dev.inmo.tgbotapi.types.request.RequestResponse @@ -4485,6 +4486,33 @@ public inline fun Poll.quizPollOrThrow(): QuizPoll = this as dev.inmo.tgbotapi.t public inline fun Poll.ifQuizPoll(block: (QuizPoll) -> T): T? = quizPollOrNull() ?.let(block) +public inline fun Reaction.customEmojiOrNull(): Reaction.CustomEmoji? = this as? + dev.inmo.tgbotapi.types.reactions.Reaction.CustomEmoji + +public inline fun Reaction.customEmojiOrThrow(): Reaction.CustomEmoji = this as + dev.inmo.tgbotapi.types.reactions.Reaction.CustomEmoji + +public inline fun Reaction.ifCustomEmoji(block: (Reaction.CustomEmoji) -> T): T? = + customEmojiOrNull() ?.let(block) + +public inline fun Reaction.emojiOrNull(): Reaction.Emoji? = this as? + dev.inmo.tgbotapi.types.reactions.Reaction.Emoji + +public inline fun Reaction.emojiOrThrow(): Reaction.Emoji = this as + dev.inmo.tgbotapi.types.reactions.Reaction.Emoji + +public inline fun Reaction.ifEmoji(block: (Reaction.Emoji) -> T): T? = emojiOrNull() + ?.let(block) + +public inline fun Reaction.unknownOrNull(): Reaction.Unknown? = this as? + dev.inmo.tgbotapi.types.reactions.Reaction.Unknown + +public inline fun Reaction.unknownOrThrow(): Reaction.Unknown = this as + dev.inmo.tgbotapi.types.reactions.Reaction.Unknown + +public inline fun Reaction.ifUnknown(block: (Reaction.Unknown) -> T): T? = unknownOrNull() + ?.let(block) + public inline fun RequestResponse.chatSharedOrNull(): ChatShared? = this as? dev.inmo.tgbotapi.types.request.ChatShared From 63975cc88e2744e2d8faf109296c461dd080cdf6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 31 Dec 2023 16:16:26 +0600 Subject: [PATCH 04/65] add workarounds for reactions --- .../WaitChatMessageReactionUpdatedUpdates.kt | 31 ++++ ...ChatMessageReactionsCountUpdatedUpdates.kt | 21 +++ ...atMessageReactionUpdatedUpdatesTriggers.kt | 94 ++++++++++ ...atMessageReactionUpdatedMarkerFactories.kt | 7 + .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 5 + .../dev/inmo/tgbotapi/types/UpdateTypes.kt | 21 +++ .../types/chat/ChatMessageReactionUpdated.kt | 162 ++++++++++++++++++ .../chat/ChatMessageReactionsCountUpdated.kt | 19 ++ .../inmo/tgbotapi/types/reactions/Reaction.kt | 2 +- .../types/reactions/ReactionsCount.kt | 14 ++ .../ChatMessageReactionUpdatedUpdate.kt | 12 ++ .../ChatMessageReactionsCountUpdatedUpdate.kt | 13 ++ .../inmo/tgbotapi/types/update/RawUpdate.kt | 8 +- .../updateshandlers/FlowsUpdatesFilter.kt | 4 + .../extensions/utils/ClassCastsNew.kt | 55 ++++++ .../utils/extensions/UpdateChatRetriever.kt | 4 + 16 files changed, 470 insertions(+), 2 deletions(-) create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionUpdatedUpdates.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionsCountUpdatedUpdates.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionUpdatedUpdatesTriggers.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionUpdatedMarkerFactories.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/ReactionsCount.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionUpdatedUpdate.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionsCountUpdatedUpdate.kt diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionUpdatedUpdates.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionUpdatedUpdates.kt new file mode 100644 index 0000000000..70b2307604 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionUpdatedUpdates.kt @@ -0,0 +1,31 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow + +@RiskFeature(lowLevelRiskFeatureMessage) +suspend inline fun BehaviourContext.waitChatMessageReactionUpdated( + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( + initRequest, + errorFactory +) { + (it.chatMessageReactionUpdatedUpdateOrNull() ?.data as? O).let(::listOfNotNull) +} + +suspend fun BehaviourContext.waitChatMessageReactionUpdatedByUser( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitChatMessageReactionUpdated(initRequest, errorFactory) + + +suspend fun BehaviourContext.waitChatMessageReactionUpdatedByChat( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitChatMessageReactionUpdated(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionsCountUpdatedUpdates.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionsCountUpdatedUpdates.kt new file mode 100644 index 0000000000..40292de55e --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMessageReactionsCountUpdatedUpdates.kt @@ -0,0 +1,21 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull +import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionsCountUpdatedUpdateOrNull +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage +import kotlinx.coroutines.flow.Flow + +suspend inline fun BehaviourContext.waitChatMessageReactionsCountUpdated( + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( + initRequest, + errorFactory +) { + (it.chatMessageReactionsCountUpdatedUpdateOrNull() ?.data).let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionUpdatedUpdatesTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionUpdatedUpdatesTriggers.kt new file mode 100644 index 0000000000..fcad229211 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionUpdatedUpdatesTriggers.kt @@ -0,0 +1,94 @@ +@file:Suppress("unused") + +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatIdChatMessageReactionUpdatedMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.polls.* +import dev.inmo.tgbotapi.types.update.abstracts.Update + +internal suspend inline fun BC.onChatMessageReactionUpdated( + initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByChatIdChatMessageReactionUpdatedMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.chatMessageReactionUpdatedUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull) +} + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onChatMessageReactionUpdatedByUser( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByChatIdChatMessageReactionUpdatedMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onChatMessageReactionUpdated( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onChatMessageReactionUpdatedByChat( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByChatIdChatMessageReactionUpdatedMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onChatMessageReactionUpdated( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onChatMessageReactionUpdatedUnknown( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByChatIdChatMessageReactionUpdatedMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onChatMessageReactionUpdated( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionUpdatedMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionUpdatedMarkerFactories.kt new file mode 100644 index 0000000000..aa9c80213d --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionUpdatedMarkerFactories.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated + +object ByChatIdChatMessageReactionUpdatedMarkerFactory : MarkerFactory { + override suspend fun invoke(data: ChatMessageReactionUpdated) = data.chat.id +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index b30bc94e4e..43f7e212b6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -196,6 +196,7 @@ const val tgWebAppStartParamField = "tgWebAppStartParam" const val chatIdField = "chat_id" const val senderChatIdField = "sender_chat_id" const val messageIdField = "message_id" +const val actorChatField = "actor_chat" const val messageThreadIdField = "message_thread_id" const val mediaGroupIdField = "media_group_id" const val updateIdField = "update_id" @@ -461,6 +462,9 @@ const val fromField = "from" const val userChatIdField = "user_chat_id" const val userField = "user" const val dateField = "date" +const val reactionsField = "reactions" +const val oldReactionField = "old_reaction" +const val newReactionField = "new_reaction" const val chatField = "chat" const val usernameField = "username" const val bioField = "bio" @@ -524,6 +528,7 @@ const val shippingQueryIdField = "shipping_query_id" const val preCheckoutQueryIdField = "pre_checkout_query_id" const val shippingOptionsField = "shipping_options" const val countryCodeField = "country_code" +const val totalCountField = "total_count" const val stateField = "state" const val cityField = "city" const val firstStreetLineField = "street_line1" 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 2aa6dc43e8..b7fbeaea86 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 @@ -14,8 +14,29 @@ const val UPDATE_POLL_ANSWER = "poll_answer" const val UPDATE_MY_CHAT_MEMBER = "my_chat_member" const val UPDATE_CHAT_MEMBER = "chat_member" const val UPDATE_CHAT_JOIN_REQUEST = "chat_join_request" +const val UPDATE_MESSAGE_REACTION = "message_reaction" +const val UPDATE_MESSAGE_REACTION_COUNT = "message_reaction_count" val ALL_UPDATES_LIST = listOf( + UPDATE_MESSAGE, + UPDATE_EDITED_MESSAGE, + UPDATE_CHANNEL_POST, + UPDATE_EDITED_CHANNEL_POST, + UPDATE_CHOSEN_INLINE_RESULT, + UPDATE_INLINE_QUERY, + UPDATE_CALLBACK_QUERY, + UPDATE_SHIPPING_QUERY, + UPDATE_PRE_CHECKOUT_QUERY, + UPDATE_POLL, + UPDATE_POLL_ANSWER, + UPDATE_MY_CHAT_MEMBER, + UPDATE_CHAT_MEMBER, + UPDATE_CHAT_JOIN_REQUEST, + UPDATE_MESSAGE_REACTION, + UPDATE_MESSAGE_REACTION_COUNT +) + +val ALL_UPDATES_LIST_WITHOUT_REACTIONS = listOf( UPDATE_MESSAGE, UPDATE_EDITED_MESSAGE, UPDATE_CHANNEL_POST, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt new file mode 100644 index 0000000000..ba919d69bb --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt @@ -0,0 +1,162 @@ +package dev.inmo.tgbotapi.types.chat + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.reactions.Reaction +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded +import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.JsonDecoder +import kotlinx.serialization.json.JsonElement + +@Serializable(ChatMessageReactionUpdated.Companion::class) +@ClassCastsIncluded +sealed interface ChatMessageReactionUpdated { + val chat: PreviewChat + val messageId: MessageIdentifier + val reactedUser: PreviewUser? + val reactedChat: PreviewChat? + val date: TelegramDate + val old: List + val new: List + + @Serializable(Companion::class) + data class ByUser( + @SerialName(chatField) + override val chat: PreviewChat, + @SerialName(messageIdField) + override val messageId: MessageIdentifier, + @SerialName(userField) + override val reactedUser: PreviewUser, + @Serializable(TelegramDateSerializer::class) + @SerialName(dateField) + override val date: TelegramDate, + @SerialName(oldReactionField) + override val old: List, + @SerialName(newReactionField) + override val new: List + ) : ChatMessageReactionUpdated { + override val reactedChat: PreviewChat? + get() = null + } + + @Serializable(Companion::class) + data class ByChat( + @SerialName(chatField) + override val chat: PreviewChat, + @SerialName(messageIdField) + override val messageId: MessageIdentifier, + @SerialName(actorChatField) + override val reactedChat: PreviewChat, + @Serializable(TelegramDateSerializer::class) + @SerialName(dateField) + override val date: TelegramDate, + @SerialName(oldReactionField) + override val old: List, + @SerialName(newReactionField) + override val new: List + ) : ChatMessageReactionUpdated { + override val reactedUser: PreviewUser? + get() = null + } + + @Serializable(Companion::class) + data class Unknown( + @SerialName(chatField) + override val chat: PreviewChat, + @SerialName(messageIdField) + override val messageId: MessageIdentifier, + @SerialName(actorChatField) + override val reactedChat: PreviewChat?, + @SerialName(userField) + override val reactedUser: PreviewUser?, + @Serializable(TelegramDateSerializer::class) + @SerialName(dateField) + override val date: TelegramDate, + @SerialName(oldReactionField) + override val old: List, + @SerialName(newReactionField) + override val new: List, + val source: JsonElement? + ) : ChatMessageReactionUpdated + + @Serializable + data class Surrogate internal constructor( + @SerialName(chatField) + val chat: PreviewChat, + @SerialName(messageIdField) + val messageId: MessageIdentifier, + @SerialName(userField) + val reactedUser: PreviewUser? = null, + @SerialName(actorChatField) + val reactedChat: PreviewChat? = null, + @Serializable(TelegramDateSerializer::class) + @SerialName(dateField) + val date: TelegramDate, + @SerialName(oldReactionField) + val old: List, + @SerialName(newReactionField) + val new: List + ) + + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): ChatMessageReactionUpdated { + val (surrogate, jsonElement) = if (decoder is JsonDecoder) { + val jsonElement = decoder.decodeJsonElement() + decoder.json.decodeFromJsonElement(Surrogate.serializer(), jsonElement) to jsonElement + } else { + Surrogate.serializer().deserialize(decoder) to null + } + return when { + surrogate.reactedUser != null -> ByUser( + surrogate.chat, + surrogate.messageId, + surrogate.reactedUser, + surrogate.date, + surrogate.old, + surrogate.new + ) + surrogate.reactedChat != null -> ByChat( + surrogate.chat, + surrogate.messageId, + surrogate.reactedChat, + surrogate.date, + surrogate.old, + surrogate.new + ) + else -> Unknown( + surrogate.chat, + surrogate.messageId, + surrogate.reactedUser, + surrogate.reactedChat, + surrogate.date, + surrogate.old, + surrogate.new, + jsonElement + ) + } + } + + override fun serialize(encoder: Encoder, value: ChatMessageReactionUpdated) { + if (value is Unknown && value.source != null) { + JsonElement.serializer().serialize(encoder, value.source) + } else { + Surrogate( + value.chat, + value.messageId, + value.reactedUser, + value.reactedChat, + value.date, + value.old, + value.new + ) + } + } + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt new file mode 100644 index 0000000000..28f440fbd0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.types.chat + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.reactions.ReactionsCount +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ChatMessageReactionsCountUpdated( + @SerialName(chatField) + val chat: PreviewChat, + @SerialName(messageIdField) + val messageId: MessageIdentifier, + @Serializable(TelegramDateSerializer::class) + @SerialName(dateField) + val date: TelegramDate, + @SerialName(reactionsField) + val reactions: List +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt index 15aadf8e94..3cb993ed28 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt @@ -13,7 +13,7 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.JsonDecoder import kotlinx.serialization.json.JsonElement -@Serializable +@Serializable(Reaction.Companion::class) @ClassCastsIncluded sealed interface Reaction { val type: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/ReactionsCount.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/ReactionsCount.kt new file mode 100644 index 0000000000..3e1bbf5437 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/ReactionsCount.kt @@ -0,0 +1,14 @@ +package dev.inmo.tgbotapi.types.reactions + +import dev.inmo.tgbotapi.types.totalCountField +import dev.inmo.tgbotapi.types.typeField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ReactionsCount( + @SerialName(typeField) + val reaction: Reaction, + @SerialName(totalCountField) + val count: Int +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionUpdatedUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionUpdatedUpdate.kt new file mode 100644 index 0000000000..75303b6a6f --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionUpdatedUpdate.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.types.update + +import dev.inmo.tgbotapi.types.UpdateIdentifier +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlinx.serialization.Serializable + +@Serializable +data class ChatMessageReactionUpdatedUpdate( + override val updateId: UpdateIdentifier, + override val data: ChatMessageReactionUpdated +) : Update \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionsCountUpdatedUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionsCountUpdatedUpdate.kt new file mode 100644 index 0000000000..62ed8a6e1b --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatMessageReactionsCountUpdatedUpdate.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.types.update + +import dev.inmo.tgbotapi.types.UpdateIdentifier +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlinx.serialization.Serializable + +@Serializable +data class ChatMessageReactionsCountUpdatedUpdate( + override val updateId: UpdateIdentifier, + override val data: ChatMessageReactionsCountUpdated +) : 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 20f57940c0..61cee808e6 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 @@ -5,6 +5,8 @@ import dev.inmo.tgbotapi.types.queries.callback.RawCallbackQuery import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.RawChosenInlineResult import dev.inmo.tgbotapi.types.InlineQueries.query.RawInlineQuery 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.message.abstracts.* import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery @@ -38,7 +40,9 @@ internal data class RawUpdate constructor( private val poll_answer: PollAnswer? = null, private val my_chat_member: ChatMemberUpdated? = null, private val chat_member: ChatMemberUpdated? = null, - private val chat_join_request: ChatJoinRequest? = null + private val chat_join_request: ChatJoinRequest? = null, + private val message_reaction: ChatMessageReactionUpdated? = null, + private val message_reaction_count: ChatMessageReactionsCountUpdated? = null ) { private var initedUpdate: Update? = null /** @@ -65,6 +69,8 @@ internal data class RawUpdate constructor( my_chat_member != null -> MyChatMemberUpdatedUpdate(updateId, my_chat_member) chat_member != null -> CommonChatMemberUpdatedUpdate(updateId, chat_member) chat_join_request != null -> ChatJoinRequestUpdate(updateId, chat_join_request) + message_reaction != null -> ChatMessageReactionUpdatedUpdate(updateId, message_reaction) + message_reaction_count != null -> ChatMessageReactionsCountUpdatedUpdate(updateId, message_reaction_count) 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 b1e7c195bf..40e1bfd106 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 @@ -37,6 +37,8 @@ interface FlowsUpdatesFilter : UpdatesFilter { val chatMemberUpdatesFlow: Flow val myChatMemberUpdatesFlow: Flow val chatJoinRequestUpdateFlow: Flow + val chatMessageReactionUpdatedUpdateFlow: Flow + val chatMessageReactionsCountUpdatedUpdateFlow: Flow val unknownUpdatesFlow: Flow } @@ -55,6 +57,8 @@ abstract class AbstractFlowsUpdatesFilter : FlowsUpdatesFilter { override val chatMemberUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val myChatMemberUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val chatJoinRequestUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val chatMessageReactionUpdatedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val chatMessageReactionsCountUpdatedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val unknownUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } } 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 932b1e9fc9..97c231c46c 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 @@ -112,6 +112,7 @@ import dev.inmo.tgbotapi.types.chat.Bot import dev.inmo.tgbotapi.types.chat.ChannelChat import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.ChatJoinRequest +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 @@ -423,6 +424,8 @@ import dev.inmo.tgbotapi.types.request.UserShared import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate import dev.inmo.tgbotapi.types.update.ChannelPostUpdate import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate +import dev.inmo.tgbotapi.types.update.ChatMessageReactionUpdatedUpdate +import dev.inmo.tgbotapi.types.update.ChatMessageReactionsCountUpdatedUpdate import dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.EditChannelPostUpdate @@ -2112,6 +2115,36 @@ public inline fun Chat.unknownChatTypeOrThrow(): UnknownChatType = this as public inline fun Chat.ifUnknownChatType(block: (UnknownChatType) -> T): T? = unknownChatTypeOrNull() ?.let(block) +public inline fun ChatMessageReactionUpdated.byChatOrNull(): ChatMessageReactionUpdated.ByChat? = + this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByChat + +public inline fun ChatMessageReactionUpdated.byChatOrThrow(): ChatMessageReactionUpdated.ByChat = + this as dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByChat + +public inline fun + ChatMessageReactionUpdated.ifByChat(block: (ChatMessageReactionUpdated.ByChat) -> T): T? = + byChatOrNull() ?.let(block) + +public inline fun ChatMessageReactionUpdated.byUserOrNull(): ChatMessageReactionUpdated.ByUser? = + this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByUser + +public inline fun ChatMessageReactionUpdated.byUserOrThrow(): ChatMessageReactionUpdated.ByUser = + this as dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByUser + +public inline fun + ChatMessageReactionUpdated.ifByUser(block: (ChatMessageReactionUpdated.ByUser) -> T): T? = + byUserOrNull() ?.let(block) + +public inline fun ChatMessageReactionUpdated.unknownOrNull(): ChatMessageReactionUpdated.Unknown? = + this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.Unknown + +public inline fun ChatMessageReactionUpdated.unknownOrThrow(): ChatMessageReactionUpdated.Unknown = + this as dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.Unknown + +public inline fun + ChatMessageReactionUpdated.ifUnknown(block: (ChatMessageReactionUpdated.Unknown) -> T): T? = + unknownOrNull() ?.let(block) + public inline fun DiceAnimationType.cubeDiceAnimationTypeOrNull(): CubeDiceAnimationType? = this as? dev.inmo.tgbotapi.types.dice.CubeDiceAnimationType @@ -4567,6 +4600,28 @@ public inline fun Update.chatJoinRequestUpdateOrThrow(): ChatJoinRequestUpdate = public inline fun Update.ifChatJoinRequestUpdate(block: (ChatJoinRequestUpdate) -> T): T? = chatJoinRequestUpdateOrNull() ?.let(block) +public inline fun Update.chatMessageReactionUpdatedUpdateOrNull(): ChatMessageReactionUpdatedUpdate? + = this as? dev.inmo.tgbotapi.types.update.ChatMessageReactionUpdatedUpdate + +public inline fun Update.chatMessageReactionUpdatedUpdateOrThrow(): ChatMessageReactionUpdatedUpdate + = this as dev.inmo.tgbotapi.types.update.ChatMessageReactionUpdatedUpdate + +public inline fun + Update.ifChatMessageReactionUpdatedUpdate(block: (ChatMessageReactionUpdatedUpdate) -> T): T? = + chatMessageReactionUpdatedUpdateOrNull() ?.let(block) + +public inline fun Update.chatMessageReactionsCountUpdatedUpdateOrNull(): + ChatMessageReactionsCountUpdatedUpdate? = this as? + dev.inmo.tgbotapi.types.update.ChatMessageReactionsCountUpdatedUpdate + +public inline fun Update.chatMessageReactionsCountUpdatedUpdateOrThrow(): + ChatMessageReactionsCountUpdatedUpdate = this as + dev.inmo.tgbotapi.types.update.ChatMessageReactionsCountUpdatedUpdate + +public inline fun + Update.ifChatMessageReactionsCountUpdatedUpdate(block: (ChatMessageReactionsCountUpdatedUpdate) -> T): + T? = chatMessageReactionsCountUpdatedUpdateOrNull() ?.let(block) + public inline fun Update.chosenInlineResultUpdateOrNull(): ChosenInlineResultUpdate? = this as? dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt index b3de4b565f..c92600b96a 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt @@ -40,6 +40,8 @@ fun Update.sourceChatWithConverters( editChannelPostUpdateConverter: (EditChannelPostUpdate) -> Chat? = { it.data.chat }, editMessageUpdateConverter: (EditMessageUpdate) -> Chat? = { it.data.chat }, myChatMemberUpdatedUpdateConverter: (MyChatMemberUpdatedUpdate) -> Chat? = { it.data.chat }, + chatMessageReactionUpdatedUpdateConverter: (ChatMessageReactionUpdatedUpdate) -> Chat? = { it.data.chat }, + chatMessageReactionsCountUpdatedUpdateConverter: (ChatMessageReactionsCountUpdatedUpdate) -> Chat? = { it.data.chat }, commonChatMemberUpdatedUpdateConverter: (CommonChatMemberUpdatedUpdate) -> Chat? = { it.data.chat } ): Chat? = when (this) { is BaseMessageUpdate -> baseMessageUpdateConverter(this) @@ -57,6 +59,8 @@ fun Update.sourceChatWithConverters( is EditMessageUpdate -> editMessageUpdateConverter(this) is MyChatMemberUpdatedUpdate -> myChatMemberUpdatedUpdateConverter(this) is CommonChatMemberUpdatedUpdate -> commonChatMemberUpdatedUpdateConverter(this) + is ChatMessageReactionUpdatedUpdate -> chatMessageReactionUpdatedUpdateConverter(this) + is ChatMessageReactionsCountUpdatedUpdate -> chatMessageReactionsCountUpdatedUpdateConverter(this) else -> { when (val data = data) { is FromUser -> data.from From 3026c8708d90c79c6ab0780b537ca1adffb86470 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 31 Dec 2023 16:27:35 +0600 Subject: [PATCH 05/65] add support of setMessageReactions --- .../api/send/SetMessageReactions.kt | 55 +++++++++++++++++++ .../requests/send/SetMessageReactions.kt | 31 +++++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 + 3 files changed, 88 insertions(+) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SetMessageReactions.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt new file mode 100644 index 0000000000..c94fdeff1f --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt @@ -0,0 +1,55 @@ +package dev.inmo.tgbotapi.extensions.api.send + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.send.SendAction +import dev.inmo.tgbotapi.requests.send.SetMessageReactions +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageId +import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.actions.* +import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.reactions.Reaction +import dev.inmo.tgbotapi.types.threadId + +suspend fun TelegramBot.setMessageReactions( + chatId: ChatIdentifier, + messageId: MessageId, + reactions: List, + big: Boolean = false +) = execute( + SetMessageReactions(chatId, messageId, reactions, big) +) + +suspend fun TelegramBot.setMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + reaction: Reaction?, + big: Boolean = false +) = setMessageReactions(chatId, messageId, listOfNotNull(reaction), big) + +suspend fun TelegramBot.setMessageReactions( + chat: Chat, + messageId: MessageId, + reactions: List, + big: Boolean = false +) = setMessageReactions(chat.id, messageId, reactions, big) + +suspend fun TelegramBot.setMessageReaction( + chat: Chat, + messageId: MessageId, + reaction: Reaction?, + big: Boolean = false +) = setMessageReaction(chat.id, messageId, reaction, big) + +suspend fun TelegramBot.setMessageReactions( + message: Message, + reactions: List, + big: Boolean = false +) = setMessageReactions(message.chat, message.messageId, reactions, big) + +suspend fun TelegramBot.setMessageReaction( + message: Message, + reaction: Reaction?, + big: Boolean = false +) = setMessageReaction(message.chat, message.messageId, reaction, big) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SetMessageReactions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SetMessageReactions.kt new file mode 100644 index 0000000000..2603a6be56 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SetMessageReactions.kt @@ -0,0 +1,31 @@ +package dev.inmo.tgbotapi.requests.send + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.reactions.Reaction +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy +import kotlinx.serialization.builtins.serializer + +@Serializable +data class SetMessageReactions( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageIdField) + val messageId: MessageId, + @SerialName(reactionField) + val reactions: List, + @SerialName(isBigField) + val big: Boolean = false +) : SimpleRequest, ChatRequest { + override fun method(): String = "setMessageReaction" + + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 43f7e212b6..02cdbf293c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -463,6 +463,8 @@ const val userChatIdField = "user_chat_id" const val userField = "user" const val dateField = "date" const val reactionsField = "reactions" +const val reactionField = "reaction" +const val isBigField = "is_big" const val oldReactionField = "old_reaction" const val newReactionField = "new_reaction" const val chatField = "chat" From 90225a9380a941bccd42ea6600fa8ba8a9b5af42 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 31 Dec 2023 16:38:22 +0600 Subject: [PATCH 06/65] add support of availableReactions --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../dev/inmo/tgbotapi/types/chat/Extended.kt | 17 +++++++++++++---- .../tgbotapi/types/chat/ExtendedAbstracts.kt | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 02cdbf293c..4ca6a283b2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -464,6 +464,7 @@ const val userField = "user" const val dateField = "date" const val reactionsField = "reactions" const val reactionField = "reaction" +const val availableReactionsField = "available_reactions" const val isBigField = "is_big" const val oldReactionField = "old_reaction" const val newReactionField = "new_reaction" 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 91d502f931..017e3be087 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.chat import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer +import dev.inmo.tgbotapi.types.reactions.Reaction import dev.inmo.tgbotapi.utils.RiskFeature import korlibs.time.DateTime import kotlinx.serialization.SerialName @@ -32,7 +33,9 @@ data class ExtendedChannelChatImpl( @SerialName(linkedChatIdField) override val linkedGroupChatId: IdChatIdentifier? = null, @SerialName(hasHiddenMembersField) - override val membersHidden: Boolean = false + override val membersHidden: Boolean = false, + @SerialName(availableReactionsField) + override val availableReactions: List? = null ) : ExtendedChannelChat @Serializable @@ -54,7 +57,9 @@ data class ExtendedGroupChatImpl( @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) override val pinnedMessage: Message? = null, @SerialName(hasHiddenMembersField) - override val membersHidden: Boolean = false + override val membersHidden: Boolean = false, + @SerialName(availableReactionsField) + override val availableReactions: List? = null ) : ExtendedGroupChat @Serializable @@ -125,7 +130,9 @@ data class ExtendedSupergroupChatImpl( @SerialName(hasAggressiveAntiSpamEnabledField) override val isAggressiveAntiSpamEnabled: Boolean = false, @SerialName(hasHiddenMembersField) - override val membersHidden: Boolean = false + override val membersHidden: Boolean = false, + @SerialName(availableReactionsField) + override val availableReactions: List? = null ) : ExtendedSupergroupChat @Serializable @@ -167,7 +174,9 @@ data class ExtendedForumChatImpl( @SerialName(hasAggressiveAntiSpamEnabledField) override val isAggressiveAntiSpamEnabled: Boolean = false, @SerialName(hasHiddenMembersField) - override val membersHidden: Boolean = false + override val membersHidden: Boolean = false, + @SerialName(availableReactionsField) + override val availableReactions: List? = null ) : ExtendedForumChat @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 09ac9d6f4f..36092957be 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.chat import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer +import dev.inmo.tgbotapi.types.reactions.Reaction import korlibs.time.DateTime import kotlinx.serialization.Serializable @@ -34,6 +35,7 @@ sealed interface ExtendedPublicChat : ExtendedChat, PublicChat { @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) val pinnedMessage: Message? val membersHidden: Boolean + val availableReactions: List? } @Serializable(ExtendedChatSerializer.Companion::class) From 4e1ecc0e34ad63458937984286d53b1b7379b143 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 2 Jan 2024 21:55:28 +0600 Subject: [PATCH 07/65] add LinkPreviewOptions --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 4 + .../inmo/tgbotapi/types/LinkPreviewOptions.kt | 79 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 4ca6a283b2..70f7ee5c37 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -545,6 +545,10 @@ const val providerTokenField = "provider_token" const val providerDataField = "provider_data" const val usersField = "users" const val startDateField = "start_date" +const val showAboveTextField = "show_above_text" +const val isDisabledField = "is_disabled" +const val preferSmallMediaField = "prefer_small_media" +const val preferLargeMediaField = "prefer_large_media" const val requireNameField = "need_name" const val requirePhoneNumberField = "need_phone_number" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt new file mode 100644 index 0000000000..3db380420b --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -0,0 +1,79 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.Required +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +sealed interface LinkPreviewOptions { + val isDisabled: Boolean + val url: String? + val preferSmallMedia: Boolean + val preferLargeMedia: Boolean + val showAboveText: Boolean + + @Serializable + data object Disabled : LinkPreviewOptions { + @Required + @SerialName(isDisabledField) + override val isDisabled: Boolean = true + override val url: String? + get() = null + override val preferSmallMedia: Boolean + get() = false + override val preferLargeMedia: Boolean + get() = false + override val showAboveText: Boolean + get() = false + } + + @Serializable + data class Large( + @SerialName(urlField) + override val url: String?, + @SerialName(showAboveTextField) + override val showAboveText: Boolean + ) : LinkPreviewOptions { + @Required + @SerialName(isDisabledField) + override val isDisabled: Boolean = false + @Required + @SerialName(preferLargeMediaField) + override val preferLargeMedia: Boolean = true + override val preferSmallMedia: Boolean + get() = false + } + + @Serializable + data class Small( + @SerialName(urlField) + override val url: String?, + @SerialName(showAboveTextField) + override val showAboveText: Boolean + ) : LinkPreviewOptions { + @Required + @SerialName(isDisabledField) + override val isDisabled: Boolean = false + @Required + @SerialName(preferSmallMediaField) + override val preferSmallMedia: Boolean = true + override val preferLargeMedia: Boolean + get() = false + } + + @Serializable + data class Medium( + @SerialName(urlField) + override val url: String?, + @SerialName(showAboveTextField) + override val showAboveText: Boolean + ) : LinkPreviewOptions { + @Required + @SerialName(isDisabledField) + override val isDisabled: Boolean = false + override val preferSmallMedia: Boolean + get() = false + override val preferLargeMedia: Boolean + get() = false + } +} \ No newline at end of file From a01a9910b5eed165273d194c849c89b5deb10bef Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 2 Jan 2024 22:22:47 +0600 Subject: [PATCH 08/65] add full support of link preview customization --- .../tgbotapi/extensions/api/edit/Edits.kt | 40 ++++++------ .../extensions/api/edit/InlineEdits.kt | 16 ++--- .../api/edit/text/EditChatMessageText.kt | 61 +++++++++--------- .../api/edit/text/EditInlineMessageText.kt | 17 ++--- .../tgbotapi/extensions/api/send/Replies.kt | 16 ++--- .../api/send/RepliesWithChatsAndMessages.kt | 16 ++--- .../extensions/api/send/SendMessage.kt | 64 +++++++++---------- .../tgbotapi/extensions/api/send/Sends.kt | 32 +++++----- .../abstracts/types/DisableWebPagePreview.kt | 5 -- .../types/LinkPreviewOptionsContainer.kt | 12 ++++ .../EditDisableWebPagePreviewMessage.kt | 5 -- .../EditLinkPreviewOptionsContainer.kt | 8 +++ .../requests/edit/text/EditChatMessageText.kt | 14 ++-- .../edit/text/EditInlineMessageText.kt | 14 ++-- .../tgbotapi/requests/send/SendMessage.kt | 16 ++--- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../InputTextMessageContent.kt | 16 ++--- .../inmo/tgbotapi/types/message/RawMessage.kt | 4 +- .../types/message/content/TextContent.kt | 4 +- 19 files changed, 189 insertions(+), 172 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/DisableWebPagePreview.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/LinkPreviewOptionsContainer.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditDisableWebPagePreviewMessage.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditLinkPreviewOptionsContainer.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt index 4cd890c605..f7f9690a67 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt @@ -194,9 +194,9 @@ suspend fun TelegramBot.edit( messageId: MessageId, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup) +) = editMessageText(chatId, messageId, text, parseMode, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -206,9 +206,9 @@ suspend fun TelegramBot.edit( chatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup) +) = editMessageText(chatId, messageId, entities, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -218,10 +218,10 @@ suspend fun TelegramBot.edit( chatId: ChatIdentifier, messageId: MessageId, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -231,10 +231,10 @@ suspend fun TelegramBot.edit( chatId: ChatIdentifier, messageId: MessageId, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -244,9 +244,9 @@ suspend fun TelegramBot.edit( message: ContentMessage, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = edit(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup) +) = edit(message.chat.id, message.messageId, text, parseMode, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -255,9 +255,9 @@ suspend fun TelegramBot.edit( suspend fun TelegramBot.edit( message: ContentMessage, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) +) = edit(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -266,10 +266,10 @@ suspend fun TelegramBot.edit( suspend fun TelegramBot.edit( message: ContentMessage, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -278,10 +278,10 @@ suspend fun TelegramBot.edit( suspend fun TelegramBot.edit( message: ContentMessage, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -290,10 +290,10 @@ suspend fun TelegramBot.edit( suspend fun TelegramBot.editMessageText( message: ContentMessage, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -302,7 +302,7 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( message: ContentMessage, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/InlineEdits.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/InlineEdits.kt index 5f9f26f003..c77db5f62f 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/InlineEdits.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/InlineEdits.kt @@ -74,9 +74,9 @@ suspend fun TelegramBot.edit( messageId: InlineMessageIdentifier, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(messageId, text, parseMode, disableWebPagePreview, replyMarkup) +) = editMessageText(messageId, text, parseMode, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -85,9 +85,9 @@ suspend fun TelegramBot.edit( suspend fun TelegramBot.edit( messageId: InlineMessageIdentifier, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(messageId, entities, disableWebPagePreview, replyMarkup) +) = editMessageText(messageId, entities, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -96,10 +96,10 @@ suspend fun TelegramBot.edit( suspend fun TelegramBot.edit( messageId: InlineMessageIdentifier, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -108,7 +108,7 @@ suspend fun TelegramBot.edit( suspend fun TelegramBot.edit( messageId: InlineMessageIdentifier, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = edit(messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt index c66886e28a..1cda2d3fd7 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.LinkPreviewOptions import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.message.ParseMode @@ -23,10 +24,10 @@ suspend fun TelegramBot.editMessageText( messageId: MessageId, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute( - EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup) + EditChatMessageText(chatId, messageId, text, parseMode, linkPreviewOptions, replyMarkup) ) /** @@ -38,9 +39,9 @@ suspend fun TelegramBot.editMessageText( messageId: MessageId, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup) +) = editMessageText(chat.id, messageId, text, parseMode, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -50,9 +51,9 @@ suspend fun TelegramBot.editMessageText( message: ContentMessage, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup) +) = editMessageText(message.chat.id, message.messageId, text, parseMode, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -62,10 +63,10 @@ suspend fun TelegramBot.editMessageText( chatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute( - EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup) + EditChatMessageText(chatId, messageId, entities, linkPreviewOptions, replyMarkup) ) /** @@ -76,10 +77,10 @@ suspend fun TelegramBot.editMessageText( chatId: ChatIdentifier, messageId: MessageId, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -89,10 +90,10 @@ suspend fun TelegramBot.editMessageText( chatId: ChatIdentifier, messageId: MessageId, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -102,9 +103,9 @@ suspend fun TelegramBot.editMessageText( chat: Chat, messageId: MessageId, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup) +) = editMessageText(chat.id, messageId, entities, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -114,10 +115,10 @@ suspend fun TelegramBot.editMessageText( chat: Chat, messageId: MessageId, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -127,10 +128,10 @@ suspend fun TelegramBot.editMessageText( chat: Chat, messageId: MessageId, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -139,9 +140,9 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( message: ContentMessage, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) +) = editMessageText(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -150,10 +151,10 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( message: ContentMessage, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -162,10 +163,10 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( message: ContentMessage, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -175,9 +176,9 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( message: Message, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) +) = editMessageText(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -187,10 +188,10 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( message: Message, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -200,7 +201,7 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( message: Message, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt index 47d24abe1c..a49fac5503 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText import dev.inmo.tgbotapi.types.InlineMessageIdentifier +import dev.inmo.tgbotapi.types.LinkPreviewOptions import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -18,9 +19,9 @@ suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup)) +) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, linkPreviewOptions, replyMarkup)) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -29,9 +30,9 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null -) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup)) +) = execute(EditInlineMessageText(inlineMessageId, entities, linkPreviewOptions, replyMarkup)) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -40,10 +41,10 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -52,7 +53,7 @@ suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) +) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 69ef258f6a..8552f54aae 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -176,7 +176,7 @@ suspend inline fun TelegramBot.reply( to: Message, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -185,7 +185,7 @@ suspend inline fun TelegramBot.reply( to.chat, text, parseMode, - disableWebPagePreview, + linkPreviewOptions, to.threadIdOrNull, disableNotification, protectContent, @@ -201,7 +201,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( to: Message, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -209,7 +209,7 @@ suspend inline fun TelegramBot.reply( ) = sendTextMessage( to.chat, entities, - disableWebPagePreview, + linkPreviewOptions, to.threadIdOrNull, disableNotification, protectContent, @@ -225,13 +225,13 @@ suspend inline fun TelegramBot.reply( suspend fun TelegramBot.reply( to: Message, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -240,13 +240,13 @@ suspend fun TelegramBot.reply( suspend fun TelegramBot.reply( to: Message, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 67af3688cb..a81151755e 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -187,7 +187,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -197,7 +197,7 @@ suspend inline fun TelegramBot.reply( toChatId, text, parseMode, - disableWebPagePreview, + linkPreviewOptions, threadId, disableNotification, protectContent, @@ -214,7 +214,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -223,7 +223,7 @@ suspend inline fun TelegramBot.reply( ) = sendTextMessage( toChatId, entities, - disableWebPagePreview, + linkPreviewOptions, threadId, disableNotification, protectContent, @@ -240,14 +240,14 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -257,14 +257,14 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt index 9bdc7b1cbb..2c7ee237fc 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt @@ -19,7 +19,7 @@ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -31,7 +31,7 @@ suspend fun TelegramBot.sendMessage( chatId, text, parseMode, - disableWebPagePreview, + linkPreviewOptions, threadId, disableNotification, protectContent, @@ -49,7 +49,7 @@ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -57,7 +57,7 @@ suspend fun TelegramBot.sendTextMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -68,14 +68,14 @@ suspend fun TelegramBot.sendTextMessage( chat: Chat, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -86,14 +86,14 @@ suspend fun TelegramBot.sendMessage( chat: Chat, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -102,7 +102,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -110,7 +110,7 @@ suspend fun TelegramBot.sendMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) /** @@ -120,7 +120,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -128,7 +128,7 @@ suspend fun TelegramBot.sendMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -138,7 +138,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -146,7 +146,7 @@ suspend fun TelegramBot.sendMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -155,7 +155,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -163,7 +163,7 @@ suspend fun TelegramBot.sendTextMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -173,7 +173,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -181,7 +181,7 @@ suspend fun TelegramBot.sendTextMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -191,7 +191,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -199,7 +199,7 @@ suspend fun TelegramBot.sendTextMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -208,14 +208,14 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendMessage( chat: Chat, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -224,7 +224,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendMessage( chat: Chat, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -232,7 +232,7 @@ suspend fun TelegramBot.sendMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -242,7 +242,7 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendMessage( chat: Chat, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -250,7 +250,7 @@ suspend fun TelegramBot.sendMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -260,14 +260,14 @@ suspend fun TelegramBot.sendMessage( suspend fun TelegramBot.sendTextMessage( chat: Chat, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -276,7 +276,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendTextMessage( chat: Chat, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -284,7 +284,7 @@ suspend fun TelegramBot.sendTextMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -294,7 +294,7 @@ suspend fun TelegramBot.sendTextMessage( suspend fun TelegramBot.sendTextMessage( chat: Chat, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -302,4 +302,4 @@ suspend fun TelegramBot.sendTextMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt index c9ce336499..283367d9e3 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt @@ -550,14 +550,14 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendTextMessage] request @@ -568,14 +568,14 @@ suspend fun TelegramBot.send( chat: Chat, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendTextMessage] request @@ -585,14 +585,14 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -601,7 +601,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -609,7 +609,7 @@ suspend fun TelegramBot.send( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -619,7 +619,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -627,7 +627,7 @@ suspend fun TelegramBot.send( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -638,14 +638,14 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -654,7 +654,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -662,7 +662,7 @@ suspend fun TelegramBot.send( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -672,7 +672,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -680,7 +680,7 @@ suspend fun TelegramBot.send( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/DisableWebPagePreview.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/DisableWebPagePreview.kt deleted file mode 100644 index 2cb37e84a8..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/DisableWebPagePreview.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.inmo.tgbotapi.abstracts.types - -interface DisableWebPagePreview { - val disableWebPagePreview: Boolean? -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/LinkPreviewOptionsContainer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/LinkPreviewOptionsContainer.kt new file mode 100644 index 0000000000..c6c8144b5d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/LinkPreviewOptionsContainer.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.abstracts.types + +import dev.inmo.tgbotapi.types.LinkPreviewOptions + +interface LinkPreviewOptionsContainer { + val linkPreviewOptions: LinkPreviewOptions? + val disableWebPagePreview: Boolean? + get() = linkPreviewOptions ?.isDisabled != true +} + +@Deprecated("Renamed", ReplaceWith("LinkPreviewOptionsContainer", "dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer")) +typealias DisableWebPagePreview = LinkPreviewOptionsContainer diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditDisableWebPagePreviewMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditDisableWebPagePreviewMessage.kt deleted file mode 100644 index 3cb0160c0d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditDisableWebPagePreviewMessage.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.inmo.tgbotapi.requests.edit.abstracts - -interface EditDisableWebPagePreviewMessage { - val disableWebPagePreview: Boolean? -} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditLinkPreviewOptionsContainer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditLinkPreviewOptionsContainer.kt new file mode 100644 index 0000000000..b7c56eeca4 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/abstracts/EditLinkPreviewOptionsContainer.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.requests.edit.abstracts + +import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer + +interface EditLinkPreviewOptionsContainer : LinkPreviewOptionsContainer + +@Deprecated("Renamed", ReplaceWith("EditLinkPreviewOptionsContainer", "dev.inmo.tgbotapi.requests.edit.abstracts.EditLinkPreviewOptionsContainer")) +typealias EditDisableWebPagePreviewMessage = EditLinkPreviewOptionsContainer \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt index b7b9200742..f220fbfa54 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditChatMessageText.kt @@ -22,7 +22,7 @@ fun EditChatMessageText( messageId: MessageId, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageText( chatId, @@ -30,7 +30,7 @@ fun EditChatMessageText( text, parseMode, null, - disableWebPagePreview, + linkPreviewOptions, replyMarkup ) @@ -38,7 +38,7 @@ fun EditChatMessageText( chatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditChatMessageText( chatId, @@ -46,7 +46,7 @@ fun EditChatMessageText( entities.makeString(), null, entities.toRawMessageEntities(), - disableWebPagePreview, + linkPreviewOptions, replyMarkup ) @@ -62,11 +62,11 @@ data class EditChatMessageText internal constructor( override val parseMode: ParseMode? = null, @SerialName(entitiesField) private val rawEntities: List? = null, - @SerialName(disableWebPagePreviewField) - override val disableWebPagePreview: Boolean? = null, + @SerialName(linkPreviewOptionsField) + override val linkPreviewOptions: LinkPreviewOptions? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null -) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { +) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt index 4793aaa1e3..9d4ed48d50 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/edit/text/EditInlineMessageText.kt @@ -16,28 +16,28 @@ fun EditInlineMessageText( inlineMessageId: InlineMessageIdentifier, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageText( inlineMessageId, text, parseMode, null, - disableWebPagePreview, + linkPreviewOptions, replyMarkup ) fun EditInlineMessageText( inlineMessageId: InlineMessageIdentifier, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null ) = EditInlineMessageText( inlineMessageId, entities.makeString(), null, entities.toRawMessageEntities(), - disableWebPagePreview, + linkPreviewOptions, replyMarkup ) @@ -51,11 +51,11 @@ data class EditInlineMessageText internal constructor( override val parseMode: ParseMode? = null, @SerialName(entitiesField) private val rawEntities: List? = null, - @SerialName(disableWebPagePreviewField) - override val disableWebPagePreview: Boolean? = null, + @SerialName(linkPreviewOptionsField) + override val linkPreviewOptions: LinkPreviewOptions? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null -) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { +) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt index 85e69e7406..8cbc0e1d24 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.requests.send -import dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview +import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList @@ -24,7 +24,7 @@ fun SendTextMessage( chatId: ChatIdentifier, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -37,7 +37,7 @@ fun SendTextMessage( parseMode, null, threadId, - disableWebPagePreview, + linkPreviewOptions, disableNotification, protectContent, replyToMessageId, @@ -48,7 +48,7 @@ fun SendTextMessage( fun SendTextMessage( chatId: ChatIdentifier, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -61,7 +61,7 @@ fun SendTextMessage( null, entities.toRawMessageEntities(), threadId, - disableWebPagePreview, + linkPreviewOptions, disableNotification, protectContent, replyToMessageId, @@ -81,8 +81,8 @@ data class SendTextMessage internal constructor( private val rawEntities: List? = null, @SerialName(messageThreadIdField) override val threadId: MessageThreadId? = chatId.threadId, - @SerialName(disableWebPagePreviewField) - override val disableWebPagePreview: Boolean? = null, + @SerialName(linkPreviewOptionsField) + override val linkPreviewOptions: LinkPreviewOptions? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -96,7 +96,7 @@ data class SendTextMessage internal constructor( ) : SendMessageRequest>, ReplyingMarkupSendMessageRequest>, TextableSendMessageRequest>, - DisableWebPagePreview + LinkPreviewOptionsContainer { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 70f7ee5c37..b6e7dd2c83 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -202,6 +202,7 @@ const val mediaGroupIdField = "media_group_id" const val updateIdField = "update_id" const val fromChatIdField = "from_chat_id" const val disableWebPagePreviewField = "disable_web_page_preview" +const val linkPreviewOptionsField = "link_preview_options" const val disableNotificationField = "disable_notification" const val protectContentField = "protect_content" const val replyToMessageIdField = "reply_to_message_id" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt index d81fa7ac00..c09581176e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InputMessageContent/InputTextMessageContent.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent import dev.inmo.tgbotapi.abstracts.TextedOutput -import dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview +import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.ParseMode @@ -19,16 +19,16 @@ import kotlinx.serialization.Serializable fun InputTextMessageContent( text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null -) = InputTextMessageContent(text, parseMode, null, disableWebPagePreview) + linkPreviewOptions: LinkPreviewOptions? = null +) = InputTextMessageContent(text, parseMode, null, linkPreviewOptions) /** * Represents the [InputMessageContent] of a text message to be sent as the result of an inline query. */ fun InputTextMessageContent( entities: TextSourcesList, - disableWebPagePreview: Boolean? = null -) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview) + linkPreviewOptions: LinkPreviewOptions? = null +) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), linkPreviewOptions) @Serializable data class InputTextMessageContent internal constructor( @@ -38,9 +38,9 @@ data class InputTextMessageContent internal constructor( override val parseMode: ParseMode? = null, @SerialName(entitiesField) private val rawEntities: List? = null, - @SerialName(disableWebPagePreviewField) - override val disableWebPagePreview: Boolean? = null -) : TextedOutput, DisableWebPagePreview, InputMessageContent { + @SerialName(linkPreviewOptionsField) + override val linkPreviewOptions: LinkPreviewOptions? = null +) : TextedOutput, LinkPreviewOptionsContainer, InputMessageContent { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) } 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 fcaf6164b5..8f0186f90b 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 @@ -128,6 +128,8 @@ internal data class RawMessage( private val passport_data: PassportData? = null, private val proximity_alert_triggered: ProximityAlertTriggered? = null, + private val link_preview_options: LinkPreviewOptions? = null, + private val reply_markup: InlineKeyboardMarkup? = null ) { private val content: MessageContent? by lazy { @@ -141,7 +143,7 @@ internal data class RawMessage( messageId, story ) - text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text)) + text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text), link_preview_options) audio != null -> AudioContent( audio, caption, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index ff83c6abc2..567841dd0c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.abstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.LinkPreviewOptions import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId @@ -15,6 +16,7 @@ import kotlinx.serialization.Serializable data class TextContent( override val text: String, override val textSources: TextSourcesList = emptyList(), + val linkPreviewOptions: LinkPreviewOptions? = null ) : TextedContent { override fun createResend( chatId: ChatIdentifier, @@ -27,7 +29,7 @@ data class TextContent( ): Request> = SendTextMessage( chatId, textSources, - false, + linkPreviewOptions, messageThreadId, disableNotification, protectContent, From db2101d85c3abf8606de715e041486240d4cb69d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 2 Jan 2024 23:26:47 +0600 Subject: [PATCH 09/65] add blockquote --- .../types/message/RawMessageEntity.kt | 39 ++++++++++--------- .../textsources/BlockquoteTextSource.kt | 26 +++++++++++++ .../inmo/tgbotapi/utils/EntitiesBuilder.kt | 37 ++++++++++++++++++ .../utils/extensions/TextSourcesList.kt | 19 ++++++++- .../MultilevelTextSourceFormatting.kt | 9 ++++- .../utils/internal/StringFormatting.kt | 4 ++ .../types/MessageEntity/EntitiesTestText.kt | 18 +++++++-- .../MessageEntity/StringFormattingTests.kt | 8 +++- 8 files changed, 135 insertions(+), 25 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BlockquoteTextSource.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt index b056f26c2f..dde5a1fdb7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt @@ -22,24 +22,25 @@ internal data class RawMessageEntity( val priority by lazy { when (type) { // Types with potential subsources should have priority - "mention" -> 0 - "hashtag" -> 0 - "cashtag" -> 0 - "email" -> 0 - "phone_number" -> 0 - "bold" -> 0 - "italic" -> 0 - "text_mention" -> 0 - "strikethrough" -> 0 - "underline" -> 0 - "spoiler" -> 0 - "custom_emoji" -> 0 - "bot_command" -> 1 - "url" -> 1 - "code" -> 1 - "pre" -> 1 - "text_link" -> 1 - else -> 1 + "mention" -> 1 + "hashtag" -> 1 + "cashtag" -> 1 + "email" -> 1 + "phone_number" -> 1 + "bold" -> 1 + "blockquote" -> 0 + "italic" -> 1 + "text_mention" -> 1 + "strikethrough" -> 1 + "underline" -> 1 + "spoiler" -> 1 + "custom_emoji" -> 1 + "bot_command" -> 2 + "url" -> 2 + "code" -> 2 + "pre" -> 2 + "text_link" -> 2 + else -> 2 } } } @@ -61,6 +62,7 @@ internal fun RawMessageEntity.asTextSource( "email" -> EMailTextSource(sourceSubstring, subPartsWithRegulars) "phone_number" -> PhoneNumberTextSource(sourceSubstring, subPartsWithRegulars) "bold" -> BoldTextSource(sourceSubstring, subPartsWithRegulars) + "blockquote" -> BlockquoteTextSource(sourceSubstring, subPartsWithRegulars) "italic" -> ItalicTextSource(sourceSubstring, subPartsWithRegulars) "code" -> CodeTextSource(sourceSubstring) "pre" -> PreTextSource(sourceSubstring, language) @@ -180,6 +182,7 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List RawMessageEntity("email", offset, length) is PhoneNumberTextSource -> RawMessageEntity("phone_number", offset, length) is BoldTextSource -> RawMessageEntity("bold", offset, length) + is BlockquoteTextSource -> RawMessageEntity("blockquote", offset, length) is ItalicTextSource -> RawMessageEntity("italic", offset, length) is CodeTextSource -> RawMessageEntity("code", offset, length) is PreTextSource -> RawMessageEntity("pre", offset, length, language = language) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BlockquoteTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BlockquoteTextSource.kt new file mode 100644 index 0000000000..dca58afbc9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/BlockquoteTextSource.kt @@ -0,0 +1,26 @@ +package dev.inmo.tgbotapi.types.message.textsources + +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.extensions.makeString +import dev.inmo.tgbotapi.utils.internal.* +import kotlinx.serialization.Serializable + +/** + * @see blockquote + */ +@Serializable +data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( + override val source: String, + override val subsources: TextSourcesList +) : MultilevelTextSource { + override val markdown: String by lazy { source.blockquoteMarkdown() } + override val markdownV2: String by lazy { blockquoteMarkdownV2() } + override val html: String by lazy { blockquoteHTML() } +} + +@Suppress("NOTHING_TO_INLINE") +inline fun blockquote(parts: TextSourcesList) = BlockquoteTextSource(parts.makeString(), parts) +@Suppress("NOTHING_TO_INLINE") +inline fun blockquote(vararg parts: TextSource) = blockquote(parts.toList()) +@Suppress("NOTHING_TO_INLINE") +inline fun blockquote(text: String) = blockquote(regular(text)) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt index 8e6f52a42a..60930f0507 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt @@ -103,6 +103,43 @@ inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.mess */ inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine +/** + * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote] + */ +inline fun EntitiesBuilder.blockquote(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(parts)) +/** + * Version of [EntitiesBuilder.blockquote] with new line at the end + */ +inline fun EntitiesBuilder.blockquoteln(parts: TextSourcesList) = blockquote(parts) + newLine +/** + * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.blockquote(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.blockquote] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.blockquoteln(noinline init: EntitiesBuilderBody) = blockquote(init) + newLine +/** + * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote] + */ +inline fun EntitiesBuilder.blockquote(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(*parts)) +/** + * Version of [EntitiesBuilder.blockquote] with new line at the end + */ +inline fun EntitiesBuilder.blockquoteln(vararg parts: TextSource) = blockquote(*parts) + newLine +/** + * Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote] + */ +inline fun EntitiesBuilder.blockquote(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(text)) +/** + * Version of [EntitiesBuilder.blockquote] with new line at the end + */ +inline fun EntitiesBuilder.blockquoteln(text: String) = blockquote(text) + newLine + /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/TextSourcesList.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/TextSourcesList.kt index 1480054c1a..c8dac1c7ac 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/TextSourcesList.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/TextSourcesList.kt @@ -3,6 +3,8 @@ package dev.inmo.tgbotapi.utils.extensions import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.* +val eachLineRegex = Regex("^[^\n]") + inline fun TextSourcesList.makeString( parseMode: ParseMode? = null ) = when (parseMode) { @@ -21,8 +23,23 @@ inline fun TextSourcesList.makeHtmlString() = joinToString("") { it.html } -inline fun TextSourcesList.makeMarkdownV2String() = joinToString("") { +inline fun TextSourcesList.makeMarkdownV2String(eachLineSeparator: String? = null) = joinToString("") { it.markdownV2 +}.let { + if (eachLineSeparator == null) { + it + } else { + it.let { + if (it.startsWith("\n")) { + it + } else { + "$eachLineSeparator$it" + } + }.replace( + "\n", + "\n$eachLineSeparator" + ) + } } inline fun TextSourcesList.makeMarkdownString() = joinToString("") { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt index 54338b3a7a..c1dd5c6c67 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt @@ -6,8 +6,9 @@ import dev.inmo.tgbotapi.utils.extensions.* internal fun MultilevelTextSource.markdownV2Default( openControlSymbol: String, - closeControlSymbol: String = openControlSymbol -) = "$openControlSymbol${subsources.makeMarkdownV2String()}$closeControlSymbol" + closeControlSymbol: String = openControlSymbol, + eachLineSeparator: String? = null +) = "$openControlSymbol${subsources.makeMarkdownV2String(eachLineSeparator)}$closeControlSymbol" internal fun MultilevelTextSource.htmlDefault( openControlSymbol: String, closeControlSymbol: String = openControlSymbol @@ -40,6 +41,10 @@ internal fun MultilevelTextSource.boldMarkdownV2(): String = markdownV2Default(m internal fun MultilevelTextSource.boldHTML(): String = htmlDefault(htmlBoldControl) +internal fun MultilevelTextSource.blockquoteMarkdownV2(): String = markdownV2Default("", eachLineSeparator = markdownBlockquoteControl) +internal fun MultilevelTextSource.blockquoteHTML(): String = htmlDefault(htmlBlockquoteControl) + + internal fun MultilevelTextSource.cashTagMarkdownV2(): String = subsources.makeMarkdownV2String() internal fun MultilevelTextSource.cashTagHTML(): String = subsources.makeHtmlString() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt index ce3a22f25e..a8a0e4673a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/StringFormatting.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.message.* import dev.inmo.tgbotapi.utils.extensions.* const val markdownBoldControl = "*" +const val markdownBlockquoteControl = ">" const val markdownItalicControl = "_" const val markdownSpoilerControl = "||" const val markdownCodeControl = "`" @@ -17,6 +18,7 @@ const val markdownV2UnderlineEndControl = "$markdownV2UnderlineControl$markdownV const val markdownV2ItalicEndControl = "$markdownItalicControl$markdownV2ItalicUnderlineDelimiter" const val htmlBoldControl = "b" +const val htmlBlockquoteControl = "blockquote" const val htmlItalicControl = "i" const val htmlSpoilerControl = "span class=\"tg-spoiler\"" const val htmlSpoilerClosingControl = "span" @@ -47,6 +49,8 @@ internal fun String.linkHTML(link: String): String = "${toHtml internal fun String.boldMarkdown(): String = markdownDefault(markdownBoldControl) +internal fun String.blockquoteMarkdown(): String = regularMarkdown() + internal fun String.italicMarkdown(): String = markdownDefault(markdownItalicControl) internal fun String.spoilerMarkdown(): String = regularMarkdown() diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt index 6621ed1137..6bc3340139 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt @@ -4,9 +4,11 @@ import dev.inmo.tgbotapi.types.message.RawMessageEntity import dev.inmo.tgbotapi.types.message.textsources.* import kotlin.test.assertTrue -const val testText = "It (is?) is simple hello world with #tag and @mention" -const val formattedV2Text = "It \\(is?\\) *_is_ ~__simple__~* ||hello world|| with \\#tag and @mention" -const val formattedHtmlText = "It (is?) is simple hello world with #tag and @mention" +const val testText = "It (is?) is simple hello world with #tag and @mention. Start of blockquote: Block quotation started\n" + + "Block quotation continued\n" + + "The last line of the block quotation" +const val formattedV2Text = "It \\(is?\\) *_is_ ~__simple__~* ||hello world|| with \\#tag and @mention\\. Start of blockquote: >Block quotation started\n>Block quotation continued\n>The last line of the block quotation" +const val formattedHtmlText = "It (is?) is simple hello world with #tag and @mention. Start of blockquote:
Block quotation started\nBlock quotation continued\nThe last line of the block quotation
" internal val testTextEntities = listOf( RawMessageEntity( "bold", @@ -42,6 +44,11 @@ internal val testTextEntities = listOf( "mention", 45, 8 + ), + RawMessageEntity( + "blockquote", + 76, + 86 ) ) @@ -54,10 +61,15 @@ fun TextSourcesList.testTextSources() { assertTrue (get(5) is HashTagTextSource) assertTrue (get(6) is RegularTextSource) assertTrue (get(7) is MentionTextSource) + assertTrue (get(8) is RegularTextSource) + assertTrue (get(9) is BlockquoteTextSource) val boldSource = get(1) as BoldTextSource assertTrue (boldSource.subsources.first() is ItalicTextSource) assertTrue (boldSource.subsources[1] is RegularTextSource) assertTrue (boldSource.subsources[2] is StrikethroughTextSource) assertTrue ((boldSource.subsources[2] as StrikethroughTextSource).subsources.first() is UnderlineTextSource) + + val blockquoteSource = get(9) as BlockquoteTextSource + assertTrue (blockquoteSource.subsources.first() is RegularTextSource) } diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt index db723156cd..8077fbede4 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/StringFormattingTests.kt @@ -48,7 +48,13 @@ class StringFormattingTests { " with " + hashtag("tag") + " and " + - mention("mention") + mention("mention") + + ". Start of blockquote: " + + blockquote( + "Block quotation started\n" + + "Block quotation continued\n" + + "The last line of the block quotation" + ) sources.testTextSources() assertEquals(formattedV2Text, sources.toMarkdownV2Texts().first()) From c025a027c6d990c962ebc9875e5edba9b5487435 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 3 Jan 2024 16:06:54 +0600 Subject: [PATCH 10/65] add support of copy/forward/delete messages --- .../tgbotapi/extensions/api/DeleteMessages.kt | 67 ++++++++ .../extensions/api/ForwardMessages.kt | 156 ++++++++++++++++++ .../extensions/api/send/CopyMessages.kt | 84 ++++++++++ .../abstracts/types/MessagesAction.kt | 7 + .../inmo/tgbotapi/requests/DeleteMessages.kt | 29 ++++ .../inmo/tgbotapi/requests/ForwardMessages.kt | 85 ++++++++++ .../tgbotapi/requests/send/CopyMessages.kt | 91 ++++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 6 + 8 files changed, 525 insertions(+) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessagesAction.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/DeleteMessages.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessages.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessages.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt new file mode 100644 index 0000000000..406af2bae1 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt @@ -0,0 +1,67 @@ +package dev.inmo.tgbotapi.extensions.api + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.DeleteMessage +import dev.inmo.tgbotapi.requests.DeleteMessages +import dev.inmo.tgbotapi.requests.ForwardMessages +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.abstracts.Message + +suspend fun TelegramBot.deleteMessages( + chatId: ChatIdentifier, + messageIds: List +) = messageIds.chunked(deleteMessagesLimit.last).map { + execute( + DeleteMessages( + chatId = chatId, + messageIds = it + ) + ) +}.all { it } + +suspend fun TelegramBot.deleteMessages( + chatId: ChatIdentifier, + messageIds: Array +) = deleteMessages( + chatId = chatId, + messageIds = messageIds.toList() +) + +suspend fun TelegramBot.deleteMessages( + chatId: ChatIdentifier, + firstMessageId: MessageId, + vararg messageIds: MessageId +) = deleteMessages( + chatId = chatId, + messageIds = (listOf(firstMessageId) + messageIds.toList()) +) + +suspend fun TelegramBot.deleteMessages( + messages: List +) = messages.groupBy { it.chat }.map { (chat, messages) -> + deleteMessages( + chatId = chat.id, + messageIds = messages.map { it.messageId } + ) +}.all { it } + +suspend fun TelegramBot.delete( + chatId: ChatIdentifier, + messageIds: List +) = deleteMessages(chatId = chatId, messageIds = messageIds) + +suspend fun TelegramBot.delete( + chatId: ChatIdentifier, + messageIds: Array +) = deleteMessages(chatId = chatId, messageIds = messageIds) + +suspend fun TelegramBot.delete( + chatId: ChatIdentifier, + firstMessageId: MessageId, + secondMessageId: MessageId, + vararg messageIds: MessageId +) = deleteMessages(chatId = chatId, messageIds = (listOf(firstMessageId, secondMessageId) + messageIds.toList())) + +suspend fun TelegramBot.delete( + messages: List +) = deleteMessages(messages) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt new file mode 100644 index 0000000000..894b2ca1da --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt @@ -0,0 +1,156 @@ +package dev.inmo.tgbotapi.extensions.api + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.ForwardMessages +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.abstracts.Message + +suspend fun TelegramBot.forwardMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = messageIds.chunked(forwardMessagesLimit.last).flatMap { + execute( + ForwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = it, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption + ) + ) +} + +suspend fun TelegramBot.forwardMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: Array, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds.toList(), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.forwardMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + firstMessageId: MessageId, + vararg messageIds: MessageId, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = (listOf(firstMessageId) + messageIds.toList()), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.forwardMessages( + toChatId: ChatIdentifier, + messages: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = messages.groupBy { it.chat }.flatMap { (chat, messages) -> + forwardMessages( + toChatId = toChatId, + fromChatId = chat.id, + messageIds = messages.map { it.messageId }, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption + ) +} + +suspend fun TelegramBot.forward( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.forward( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: Array, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.forward( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + firstMessageId: MessageId, + vararg messageIds: MessageId, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + firstMessageId = firstMessageId, + messageIds = *messageIds, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.forward( + toChatId: ChatIdentifier, + messages: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + messages = messages, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt new file mode 100644 index 0000000000..cfca65c3ff --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt @@ -0,0 +1,84 @@ +package dev.inmo.tgbotapi.extensions.api.send + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.send.CopyMessages +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.abstracts.Message + +suspend fun TelegramBot.copyMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = messageIds.chunked(copyMessagesLimit.last).flatMap { + execute( + CopyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = it, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption + ) + ) +} + +suspend fun TelegramBot.copyMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: Array, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds.toList(), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.copyMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + firstMessageId: MessageId, + vararg messageIds: MessageId, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = (listOf(firstMessageId) + messageIds.toList()), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.copyMessages( + toChatId: ChatIdentifier, + messages: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = messages.groupBy { it.chat }.flatMap { (chat, messages) -> + copyMessages( + toChatId = toChatId, + fromChatId = chat.id, + messageIds = messages.map { it.messageId }, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption + ) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessagesAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessagesAction.kt new file mode 100644 index 0000000000..51b8dcca07 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessagesAction.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.abstracts.types + +import dev.inmo.tgbotapi.types.MessageId + +interface MessagesAction: ChatRequest { + val messageIds: List +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/DeleteMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/DeleteMessages.kt new file mode 100644 index 0000000000..155bd0b73a --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/DeleteMessages.kt @@ -0,0 +1,29 @@ +package dev.inmo.tgbotapi.requests + +import dev.inmo.tgbotapi.abstracts.types.MessageAction +import dev.inmo.tgbotapi.abstracts.types.MessagesAction +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class DeleteMessages( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageIdsField) + override val messageIds: List +) : SimpleRequest, MessagesAction { + override fun method(): String = "deleteMessages" + + init { + require(messageIds.size in deleteMessagesLimit) { + "Messages count for deleteMessages must be in $deleteMessagesLimit range" + } + } + + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessages.kt new file mode 100644 index 0000000000..5985aa8396 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessages.kt @@ -0,0 +1,85 @@ +package dev.inmo.tgbotapi.requests + +import dev.inmo.tgbotapi.abstracts.types.DisableNotification +import dev.inmo.tgbotapi.abstracts.types.MessagesAction +import dev.inmo.tgbotapi.abstracts.types.ProtectContent +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* +import kotlinx.serialization.builtins.ListSerializer + +fun ForwardMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: Array, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = ForwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds.toList(), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +fun ForwardMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageId: MessageId, + vararg messageIds: MessageId, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = ForwardMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = (listOf(messageId) + messageIds.toList()), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +@Serializable +data class ForwardMessages ( + @SerialName(chatIdField) + val toChatId: ChatIdentifier, + @SerialName(fromChatIdField) + val fromChatId: ChatIdentifier, + @SerialName(messageIdsField) + override val messageIds: List, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = toChatId.threadId, + @SerialName(disableNotificationField) + override val disableNotification: Boolean = false, + @SerialName(protectContentField) + override val protectContent: Boolean = false, + @SerialName(removeCaptionField) + private val removeCaption: Boolean = false +): SimpleRequest>, + MessagesAction, + ProtectContent, + OptionallyMessageThreadRequest, + DisableNotification { + override val chatId: ChatIdentifier + get() = fromChatId + + init { + require(messageIds.size in forwardMessagesLimit) { + "Messages count for forwardMessages must be in $forwardMessagesLimit range" + } + } + + override fun method(): String = "forwardMessages" + + override val resultDeserializer: DeserializationStrategy> + get() = ListSerializer(MessageIdSerializer) + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessages.kt new file mode 100644 index 0000000000..38e5c296d2 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessages.kt @@ -0,0 +1,91 @@ +package dev.inmo.tgbotapi.requests.send + +import dev.inmo.tgbotapi.abstracts.types.DisableNotification +import dev.inmo.tgbotapi.abstracts.types.MessagesAction +import dev.inmo.tgbotapi.abstracts.types.ProtectContent +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.textsources.TextSource +import dev.inmo.tgbotapi.types.message.ParseMode +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.message.* +import dev.inmo.tgbotapi.types.message.toRawMessageEntities +import dev.inmo.tgbotapi.utils.extensions.makeString +import kotlinx.serialization.* +import kotlinx.serialization.builtins.ListSerializer + +fun CopyMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: Array, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = CopyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds.toList(), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +fun CopyMessages( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageId: MessageId, + vararg messageIds: MessageId, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = CopyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = (listOf(messageId) + messageIds.toList()), + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +@Serializable +data class CopyMessages ( + @SerialName(chatIdField) + val toChatId: ChatIdentifier, + @SerialName(fromChatIdField) + val fromChatId: ChatIdentifier, + @SerialName(messageIdsField) + override val messageIds: List, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = toChatId.threadId, + @SerialName(disableNotificationField) + override val disableNotification: Boolean = false, + @SerialName(protectContentField) + override val protectContent: Boolean = false, + @SerialName(removeCaptionField) + private val removeCaption: Boolean = false +): SimpleRequest>, + MessagesAction, + ProtectContent, + OptionallyMessageThreadRequest, + DisableNotification { + override val chatId: ChatIdentifier + get() = fromChatId + + init { + require(messageIds.size in copyMessagesLimit) { + "Messages count for copyMessages must be in $copyMessagesLimit range" + } + } + + override fun method(): String = "copyMessages" + + override val resultDeserializer: DeserializationStrategy> + get() = ListSerializer(MessageIdSerializer) + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index b6e7dd2c83..3d55e4d95e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -175,6 +175,10 @@ val keywordsInStickerLimit = 0 .. 20 val stickerKeywordLengthLimit = 0 .. 64 +val forwardMessagesLimit = 1 .. 100 +val copyMessagesLimit = forwardMessagesLimit +val deleteMessagesLimit = forwardMessagesLimit + const val botActionActualityTime: Seconds = 5 val cloudStorageKeyLimit = 1 .. 128 @@ -196,6 +200,7 @@ const val tgWebAppStartParamField = "tgWebAppStartParam" const val chatIdField = "chat_id" const val senderChatIdField = "sender_chat_id" const val messageIdField = "message_id" +const val messageIdsField = "message_ids" const val actorChatField = "actor_chat" const val messageThreadIdField = "message_thread_id" const val mediaGroupIdField = "media_group_id" @@ -205,6 +210,7 @@ const val disableWebPagePreviewField = "disable_web_page_preview" const val linkPreviewOptionsField = "link_preview_options" const val disableNotificationField = "disable_notification" const val protectContentField = "protect_content" +const val removeCaptionField = "remove_caption" const val replyToMessageIdField = "reply_to_message_id" const val allowSendingWithoutReplyField = "allow_sending_without_reply" const val replyMarkupField = "reply_markup" From fc183bfd2fcfff1be0470b02ded2a7a35e362200 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 3 Jan 2024 16:28:56 +0600 Subject: [PATCH 11/65] update user shared to users shared --- .../expectations/WaitEventAction.kt | 4 +- .../expectations/WaitEventActionMessages.kt | 4 +- .../triggers_handling/EventTriggers.kt | 10 ++-- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 5 ++ .../tgbotapi/types/buttons/KeyboardButton.kt | 12 ++--- ...tUser.kt => KeyboardButtonRequestUsers.kt} | 51 +++++++++++------- .../reply/ReplyKeyboardButtonsShortcuts.kt | 14 ++--- .../inmo/tgbotapi/types/message/RawMessage.kt | 6 +-- .../request/{UserShared.kt => UsersShared.kt} | 17 +++--- .../extensions/utils/ClassCastsNew.kt | 54 +++++++++---------- .../types/buttons/ReplyKeyboardBuilder.kt | 14 ++--- 11 files changed, 105 insertions(+), 86 deletions(-) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/{KeyboardButtonRequestUser.kt => KeyboardButtonRequestUsers.kt} (59%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/{UserShared.kt => UsersShared.kt} (54%) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 5a7165c7e5..d65419b704 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.request.ChatShared import dev.inmo.tgbotapi.types.request.ChatSharedRequest -import dev.inmo.tgbotapi.types.request.UserShared +import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow @@ -202,7 +202,7 @@ suspend fun BehaviourContext.waitChatSharedRequest( suspend fun BehaviourContext.waitUserShared( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEvents(initRequest, errorFactory) +) = waitEvents(initRequest, errorFactory) suspend fun BehaviourContext.waitChatShared( initRequest: Request<*>? = null, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt index faa8c4f4d5..9143f2bca6 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt @@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.request.ChatShared import dev.inmo.tgbotapi.types.request.ChatSharedRequest -import dev.inmo.tgbotapi.types.request.UserShared +import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow @@ -196,7 +196,7 @@ suspend fun BehaviourContext.waitChatSharedRequestEventsMessages( suspend fun BehaviourContext.waitUserSharedEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEventsMessages(initRequest, errorFactory) +) = waitEventsMessages(initRequest, errorFactory) suspend fun BehaviourContext.waitChatSharedEventsMessages( initRequest: Request<*>? = null, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index bf966d6ce0..5826757feb 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -25,7 +25,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.request.ChatShared import dev.inmo.tgbotapi.types.request.ChatSharedRequest -import dev.inmo.tgbotapi.types.request.UserShared +import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.types.update.abstracts.Update internal suspend inline fun BC.onEvent( @@ -776,10 +776,10 @@ suspend fun BC.onChatSharedRequest( * data */ suspend fun BC.onUserShared( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 3d55e4d95e..0b703caf8d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -175,6 +175,8 @@ val keywordsInStickerLimit = 0 .. 20 val stickerKeywordLengthLimit = 0 .. 64 +val keyboardButtonRequestUserLimit = 1 .. 10 + val forwardMessagesLimit = 1 .. 100 val copyMessagesLimit = forwardMessagesLimit val deleteMessagesLimit = forwardMessagesLimit @@ -245,6 +247,7 @@ const val slowModeDelayField = "slow_mode_delay" const val maskPositionField = "mask_position" const val phoneNumberField = "phone_number" const val userIdField = "user_id" +const val userIdsField = "user_ids" const val onlyIfBannedField = "only_if_banned" const val containsMasksField = "contains_masks" const val resultIdField = "result_id" @@ -331,8 +334,10 @@ const val requestContactField = "request_contact" const val requestLocationField = "request_location" const val requestPollField = "request_poll" const val requestUserField = "request_user" +const val requestUsersField = "request_users" const val requestChatField = "request_chat" const val requestIdField = "request_id" +const val maxQuantityField = "max_quantity" const val userIsBotField = "user_is_bot" const val userIsPremiumField = "user_is_premium" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt index 64c326637d..c7b2aaaa37 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt @@ -103,13 +103,13 @@ data class RequestPollKeyboardButton( * * In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is * recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming - * [dev.inmo.tgbotapi.types.request.UserShared.requestId] + * [dev.inmo.tgbotapi.types.request.UsersShared.requestId] */ @Serializable data class RequestUserKeyboardButton( override val text: String, - @SerialName(requestUserField) - val requestUser: KeyboardButtonRequestUser + @SerialName(requestUsersField) + val requestUsers: KeyboardButtonRequestUsers ) : KeyboardButton /** @@ -160,11 +160,11 @@ object KeyboardButtonSerializer : KSerializer { asJson[requestPollField] ?.jsonObject ?: buildJsonObject { } ) ) - asJson is JsonObject && asJson[requestUserField] != null -> RequestUserKeyboardButton( + asJson is JsonObject && asJson[requestUsersField] != null -> RequestUserKeyboardButton( asJson[textField]!!.jsonPrimitive.content, nonstrictJsonFormat.decodeFromJsonElement( - KeyboardButtonRequestUser.serializer(), - asJson[requestUserField] ?.jsonObject ?: buildJsonObject { } + KeyboardButtonRequestUsers.serializer(), + asJson[requestUsersField] ?.jsonObject ?: buildJsonObject { } ) ) asJson is JsonObject && asJson[requestChatField] != null -> RequestChatKeyboardButton( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUsers.kt similarity index 59% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUser.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUsers.kt index 99169842ad..152284564b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUser.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUsers.kt @@ -1,9 +1,7 @@ package dev.inmo.tgbotapi.types.buttons +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.request.RequestId -import dev.inmo.tgbotapi.types.requestIdField -import dev.inmo.tgbotapi.types.userIsBotField -import dev.inmo.tgbotapi.types.userIsPremiumField import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import kotlinx.serialization.EncodeDefault import kotlinx.serialization.KSerializer @@ -14,17 +12,20 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -@Serializable(KeyboardButtonRequestUser.Companion::class) +@Serializable(KeyboardButtonRequestUsers.Companion::class) @ClassCastsIncluded -sealed interface KeyboardButtonRequestUser { +sealed interface KeyboardButtonRequestUsers { val requestId: RequestId val isBot: Boolean? + val maxCount: Int @Serializable data class Any( @SerialName(requestIdField) - override val requestId: RequestId - ) : KeyboardButtonRequestUser { + override val requestId: RequestId, + @SerialName(maxQuantityField) + override val maxCount: Int = keyboardButtonRequestUserLimit.first + ) : KeyboardButtonRequestUsers { @SerialName(userIsBotField) @EncodeDefault override val isBot: Boolean? = null @@ -35,8 +36,10 @@ sealed interface KeyboardButtonRequestUser { @SerialName(requestIdField) override val requestId: RequestId, @SerialName(userIsPremiumField) - val isPremium: Boolean? = null - ) : KeyboardButtonRequestUser { + val isPremium: Boolean? = null, + @SerialName(maxQuantityField) + override val maxCount: Int = keyboardButtonRequestUserLimit.first + ) : KeyboardButtonRequestUsers { @SerialName(userIsBotField) @EncodeDefault override val isBot: Boolean = false @@ -45,15 +48,17 @@ sealed interface KeyboardButtonRequestUser { @Serializable data class Bot( @SerialName(requestIdField) - override val requestId: RequestId - ) : KeyboardButtonRequestUser { + override val requestId: RequestId, + @SerialName(maxQuantityField) + override val maxCount: Int = keyboardButtonRequestUserLimit.first + ) : KeyboardButtonRequestUsers { @SerialName(userIsBotField) @EncodeDefault override val isBot: Boolean = true } - @Serializer(KeyboardButtonRequestUser::class) - companion object : KSerializer { + @Serializer(KeyboardButtonRequestUsers::class) + companion object : KSerializer { @Serializable private data class Surrogate( @SerialName(requestIdField) @@ -61,31 +66,37 @@ sealed interface KeyboardButtonRequestUser { @SerialName(userIsBotField) val userIsBot: Boolean? = null, @SerialName(userIsPremiumField) - val userIsPremium: Boolean? = null + val userIsPremium: Boolean? = null, + @SerialName(maxQuantityField) + val maxCount: Int = keyboardButtonRequestUserLimit.first ) private val realSerializer = Surrogate.serializer() override val descriptor: SerialDescriptor = realSerializer.descriptor - override fun deserialize(decoder: Decoder): KeyboardButtonRequestUser { + override fun deserialize(decoder: Decoder): KeyboardButtonRequestUsers { val surrogate = realSerializer.deserialize(decoder) return when (surrogate.userIsBot) { - true -> Bot(surrogate.requestId) - false -> Common(surrogate.requestId, surrogate.userIsPremium) - null -> Any(surrogate.requestId) + true -> Bot(surrogate.requestId, surrogate.maxCount) + false -> Common(surrogate.requestId, surrogate.userIsPremium, surrogate.maxCount) + null -> Any(surrogate.requestId, surrogate.maxCount) } } - override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUser) { + override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUsers) { realSerializer.serialize( encoder, Surrogate( value.requestId, value.isBot, - (value as? Common) ?.isPremium + (value as? Common) ?.isPremium, + value.maxCount ) ) } } } + +@Deprecated("Renamed", ReplaceWith("KeyboardButtonRequestUsers", "dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers")) +typealias KeyboardButtonRequestUser = KeyboardButtonRequestUsers diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt index e22ed517e7..87bed43fa4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt @@ -57,25 +57,25 @@ inline fun webAppReplyButton( */ inline fun requestUserReplyButton( text: String, - requestUser: KeyboardButtonRequestUser + requestUser: KeyboardButtonRequestUsers ) = RequestUserKeyboardButton( text, requestUser ) /** - * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] */ inline fun requestBotReplyButton( text: String, requestId: RequestId ) = requestUserReplyButton( text, - KeyboardButtonRequestUser.Bot(requestId) + KeyboardButtonRequestUsers.Bot(requestId) ) /** - * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common] */ inline fun requestUserReplyButton( text: String, @@ -83,18 +83,18 @@ inline fun requestUserReplyButton( premiumUser: Boolean? = null ) = requestUserReplyButton( text, - KeyboardButtonRequestUser.Common(requestId, premiumUser) + KeyboardButtonRequestUsers.Common(requestId, premiumUser) ) /** - * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any] */ inline fun requestUserOrBotReplyButton( text: String, requestId: RequestId ) = requestUserReplyButton( text, - KeyboardButtonRequestUser.Any(requestId) + KeyboardButtonRequestUsers.Any(requestId) ) 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 8f0186f90b..43f928f24a 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 @@ -30,7 +30,7 @@ import dev.inmo.tgbotapi.types.payments.Invoice import dev.inmo.tgbotapi.types.payments.SuccessfulPayment import dev.inmo.tgbotapi.types.polls.Poll import dev.inmo.tgbotapi.types.request.ChatShared -import dev.inmo.tgbotapi.types.request.UserShared +import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.types.stories.Story import dev.inmo.tgbotapi.types.venue.Venue import kotlinx.serialization.SerialName @@ -97,7 +97,7 @@ internal data class RawMessage( private val dice: Dice? = null, private val successful_payment: SuccessfulPayment? = null, - private val user_shared: UserShared? = null, + private val users_shared: UsersShared? = null, private val chat_shared: ChatShared? = null, // Voice Chat Service Messages @@ -266,7 +266,7 @@ internal data class RawMessage( successful_payment != null -> SuccessfulPaymentEvent(successful_payment) connected_website != null -> UserLoggedIn(connected_website) web_app_data != null -> web_app_data - user_shared != null -> user_shared + users_shared != null -> users_shared chat_shared != null -> chat_shared else -> null } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/UserShared.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/UsersShared.kt similarity index 54% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/UserShared.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/UsersShared.kt index 74b6f55667..59622a71ed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/UserShared.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/request/UsersShared.kt @@ -1,19 +1,22 @@ package dev.inmo.tgbotapi.types.request -import dev.inmo.tgbotapi.types.ChatId -import dev.inmo.tgbotapi.types.UserId -import dev.inmo.tgbotapi.types.requestIdField -import dev.inmo.tgbotapi.types.userIdField +import dev.inmo.tgbotapi.types.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class UserShared( +data class UsersShared( @SerialName(requestIdField) override val requestId: RequestId, - @SerialName(userIdField) - val userId: UserId + @SerialName(userIdsField) + val userIds: List ) : ChatSharedRequest { + val userId: UserId + get() = userIds.first() + constructor( + requestId: RequestId, + userId: UserId + ) : this(requestId, listOf(userId)) override val chatId: ChatId get() = userId } 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 97c231c46c..e9f0908aca 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 @@ -102,7 +102,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardBu import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.WebAppInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser +import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.ReplyForce import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup @@ -420,7 +420,7 @@ import dev.inmo.tgbotapi.types.reactions.Reaction import dev.inmo.tgbotapi.types.request.ChatShared import dev.inmo.tgbotapi.types.request.ChatSharedRequest import dev.inmo.tgbotapi.types.request.RequestResponse -import dev.inmo.tgbotapi.types.request.UserShared +import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate import dev.inmo.tgbotapi.types.update.ChannelPostUpdate import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate @@ -1735,32 +1735,32 @@ public inline fun InlineKeyboardButton.ifWebAppInlineKeyboardButton(block: (WebAppInlineKeyboardButton) -> T): T? = webAppInlineKeyboardButtonOrNull() ?.let(block) -public inline fun KeyboardButtonRequestUser.anyOrNull(): KeyboardButtonRequestUser.Any? = this as? - dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Any +public inline fun KeyboardButtonRequestUsers.anyOrNull(): KeyboardButtonRequestUsers.Any? = this as? + dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any -public inline fun KeyboardButtonRequestUser.anyOrThrow(): KeyboardButtonRequestUser.Any = this as - dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Any +public inline fun KeyboardButtonRequestUsers.anyOrThrow(): KeyboardButtonRequestUsers.Any = this as + dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any -public inline fun KeyboardButtonRequestUser.ifAny(block: (KeyboardButtonRequestUser.Any) -> T): +public inline fun KeyboardButtonRequestUsers.ifAny(block: (KeyboardButtonRequestUsers.Any) -> T): T? = anyOrNull() ?.let(block) -public inline fun KeyboardButtonRequestUser.botOrNull(): KeyboardButtonRequestUser.Bot? = this as? - dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Bot +public inline fun KeyboardButtonRequestUsers.botOrNull(): KeyboardButtonRequestUsers.Bot? = this as? + dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot -public inline fun KeyboardButtonRequestUser.botOrThrow(): KeyboardButtonRequestUser.Bot = this as - dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Bot +public inline fun KeyboardButtonRequestUsers.botOrThrow(): KeyboardButtonRequestUsers.Bot = this as + dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot -public inline fun KeyboardButtonRequestUser.ifBot(block: (KeyboardButtonRequestUser.Bot) -> T): +public inline fun KeyboardButtonRequestUsers.ifBot(block: (KeyboardButtonRequestUsers.Bot) -> T): T? = botOrNull() ?.let(block) -public inline fun KeyboardButtonRequestUser.commonOrNull(): KeyboardButtonRequestUser.Common? = this - as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Common +public inline fun KeyboardButtonRequestUsers.commonOrNull(): KeyboardButtonRequestUsers.Common? = this + as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common -public inline fun KeyboardButtonRequestUser.commonOrThrow(): KeyboardButtonRequestUser.Common = this - as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Common +public inline fun KeyboardButtonRequestUsers.commonOrThrow(): KeyboardButtonRequestUsers.Common = this + as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common public inline fun - KeyboardButtonRequestUser.ifCommon(block: (KeyboardButtonRequestUser.Common) -> T): T? = + KeyboardButtonRequestUsers.ifCommon(block: (KeyboardButtonRequestUsers.Common) -> T): T? = commonOrNull() ?.let(block) public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as? @@ -2972,13 +2972,13 @@ public inline fun ChatEvent.chatSharedRequestOrThrow(): ChatSharedRequest = this public inline fun ChatEvent.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? = chatSharedRequestOrNull() ?.let(block) -public inline fun ChatEvent.userSharedOrNull(): UserShared? = this as? - dev.inmo.tgbotapi.types.request.UserShared +public inline fun ChatEvent.userSharedOrNull(): UsersShared? = this as? + dev.inmo.tgbotapi.types.request.UsersShared -public inline fun ChatEvent.userSharedOrThrow(): UserShared = this as - dev.inmo.tgbotapi.types.request.UserShared +public inline fun ChatEvent.userSharedOrThrow(): UsersShared = this as + dev.inmo.tgbotapi.types.request.UsersShared -public inline fun ChatEvent.ifUserShared(block: (UserShared) -> T): T? = userSharedOrNull() +public inline fun ChatEvent.ifUserShared(block: (UsersShared) -> T): T? = userSharedOrNull() ?.let(block) public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as? @@ -4564,13 +4564,13 @@ public inline fun RequestResponse.chatSharedRequestOrThrow(): ChatSharedRequest public inline fun RequestResponse.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? = chatSharedRequestOrNull() ?.let(block) -public inline fun RequestResponse.userSharedOrNull(): UserShared? = this as? - dev.inmo.tgbotapi.types.request.UserShared +public inline fun RequestResponse.userSharedOrNull(): UsersShared? = this as? + dev.inmo.tgbotapi.types.request.UsersShared -public inline fun RequestResponse.userSharedOrThrow(): UserShared = this as - dev.inmo.tgbotapi.types.request.UserShared +public inline fun RequestResponse.userSharedOrThrow(): UsersShared = this as + dev.inmo.tgbotapi.types.request.UsersShared -public inline fun RequestResponse.ifUserShared(block: (UserShared) -> T): T? = +public inline fun RequestResponse.ifUserShared(block: (UsersShared) -> T): T? = userSharedOrNull() ?.let(block) public inline fun Update.callbackQueryUpdateOrNull(): CallbackQueryUpdate? = this as? diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt index 8a7525a972..6af5aa3a24 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt @@ -139,7 +139,7 @@ inline fun ReplyKeyboardRowBuilder.webAppButton( */ inline fun ReplyKeyboardRowBuilder.requestUserButton( text: String, - requestUser: KeyboardButtonRequestUser + requestUser: KeyboardButtonRequestUsers ) = add( requestUserReplyButton( text, @@ -148,7 +148,7 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( ) /** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] * * @see replyKeyboard * @see ReplyKeyboardBuilder.row @@ -158,11 +158,11 @@ inline fun ReplyKeyboardRowBuilder.requestBotButton( requestId: RequestId ) = requestUserButton( text, - KeyboardButtonRequestUser.Bot(requestId) + KeyboardButtonRequestUsers.Bot(requestId) ) /** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common] * * @see replyKeyboard * @see ReplyKeyboardBuilder.row @@ -173,11 +173,11 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( premiumUser: Boolean? = null ) = requestUserButton( text, - KeyboardButtonRequestUser.Common(requestId, premiumUser) + KeyboardButtonRequestUsers.Common(requestId, premiumUser) ) /** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any] * * @see replyKeyboard * @see ReplyKeyboardBuilder.row @@ -187,7 +187,7 @@ inline fun ReplyKeyboardRowBuilder.requestUserOrBotButton( requestId: RequestId ) = requestUserButton( text, - KeyboardButtonRequestUser.Any(requestId) + KeyboardButtonRequestUsers.Any(requestId) ) From 57f53813c8d88b27249a8e85f0065b51f75d666b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 10:30:28 +0600 Subject: [PATCH 12/65] update class casts --- .../extensions/utils/ClassCastsNew.kt | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) 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 e9f0908aca..99730c0981 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 @@ -314,6 +314,7 @@ import dev.inmo.tgbotapi.types.message.content.VideoNoteContent import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.VoiceContent import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent +import dev.inmo.tgbotapi.types.message.textsources.BlockquoteTextSource import dev.inmo.tgbotapi.types.message.textsources.BoldTextSource import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource import dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource @@ -1741,8 +1742,9 @@ public inline fun KeyboardButtonRequestUsers.anyOrNull(): KeyboardButtonRequestU public inline fun KeyboardButtonRequestUsers.anyOrThrow(): KeyboardButtonRequestUsers.Any = this as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any -public inline fun KeyboardButtonRequestUsers.ifAny(block: (KeyboardButtonRequestUsers.Any) -> T): - T? = anyOrNull() ?.let(block) +public inline fun + KeyboardButtonRequestUsers.ifAny(block: (KeyboardButtonRequestUsers.Any) -> T): T? = anyOrNull() + ?.let(block) public inline fun KeyboardButtonRequestUsers.botOrNull(): KeyboardButtonRequestUsers.Bot? = this as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot @@ -1750,14 +1752,15 @@ public inline fun KeyboardButtonRequestUsers.botOrNull(): KeyboardButtonRequestU public inline fun KeyboardButtonRequestUsers.botOrThrow(): KeyboardButtonRequestUsers.Bot = this as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot -public inline fun KeyboardButtonRequestUsers.ifBot(block: (KeyboardButtonRequestUsers.Bot) -> T): - T? = botOrNull() ?.let(block) +public inline fun + KeyboardButtonRequestUsers.ifBot(block: (KeyboardButtonRequestUsers.Bot) -> T): T? = botOrNull() + ?.let(block) -public inline fun KeyboardButtonRequestUsers.commonOrNull(): KeyboardButtonRequestUsers.Common? = this - as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common +public inline fun KeyboardButtonRequestUsers.commonOrNull(): KeyboardButtonRequestUsers.Common? = + this as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common -public inline fun KeyboardButtonRequestUsers.commonOrThrow(): KeyboardButtonRequestUsers.Common = this - as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common +public inline fun KeyboardButtonRequestUsers.commonOrThrow(): KeyboardButtonRequestUsers.Common = + this as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common public inline fun KeyboardButtonRequestUsers.ifCommon(block: (KeyboardButtonRequestUsers.Common) -> T): T? = @@ -2972,13 +2975,13 @@ public inline fun ChatEvent.chatSharedRequestOrThrow(): ChatSharedRequest = this public inline fun ChatEvent.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? = chatSharedRequestOrNull() ?.let(block) -public inline fun ChatEvent.userSharedOrNull(): UsersShared? = this as? +public inline fun ChatEvent.usersSharedOrNull(): UsersShared? = this as? dev.inmo.tgbotapi.types.request.UsersShared -public inline fun ChatEvent.userSharedOrThrow(): UsersShared = this as +public inline fun ChatEvent.usersSharedOrThrow(): UsersShared = this as dev.inmo.tgbotapi.types.request.UsersShared -public inline fun ChatEvent.ifUserShared(block: (UsersShared) -> T): T? = userSharedOrNull() +public inline fun ChatEvent.ifUsersShared(block: (UsersShared) -> T): T? = usersSharedOrNull() ?.let(block) public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as? @@ -3679,6 +3682,15 @@ public inline fun ResendableContent.voiceContentOrThrow(): VoiceContent = this a public inline fun ResendableContent.ifVoiceContent(block: (VoiceContent) -> T): T? = voiceContentOrNull() ?.let(block) +public inline fun TextSource.blockquoteTextSourceOrNull(): BlockquoteTextSource? = this as? + dev.inmo.tgbotapi.types.message.textsources.BlockquoteTextSource + +public inline fun TextSource.blockquoteTextSourceOrThrow(): BlockquoteTextSource = this as + dev.inmo.tgbotapi.types.message.textsources.BlockquoteTextSource + +public inline fun TextSource.ifBlockquoteTextSource(block: (BlockquoteTextSource) -> T): T? = + blockquoteTextSourceOrNull() ?.let(block) + public inline fun TextSource.boldTextSourceOrNull(): BoldTextSource? = this as? dev.inmo.tgbotapi.types.message.textsources.BoldTextSource @@ -4564,14 +4576,14 @@ public inline fun RequestResponse.chatSharedRequestOrThrow(): ChatSharedRequest public inline fun RequestResponse.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? = chatSharedRequestOrNull() ?.let(block) -public inline fun RequestResponse.userSharedOrNull(): UsersShared? = this as? +public inline fun RequestResponse.usersSharedOrNull(): UsersShared? = this as? dev.inmo.tgbotapi.types.request.UsersShared -public inline fun RequestResponse.userSharedOrThrow(): UsersShared = this as +public inline fun RequestResponse.usersSharedOrThrow(): UsersShared = this as dev.inmo.tgbotapi.types.request.UsersShared -public inline fun RequestResponse.ifUserShared(block: (UsersShared) -> T): T? = - userSharedOrNull() ?.let(block) +public inline fun RequestResponse.ifUsersShared(block: (UsersShared) -> T): T? = + usersSharedOrNull() ?.let(block) public inline fun Update.callbackQueryUpdateOrNull(): CallbackQueryUpdate? = this as? dev.inmo.tgbotapi.types.update.CallbackQueryUpdate From fb9ff653ef562e6032ccc273f2329d2672ab55e6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 11:38:30 +0600 Subject: [PATCH 13/65] add boosts support --- .../extensions/api/get/GetUserChatBoosts.kt | 19 ++ .../expectations/WaitChatBoostRemoved.kt | 17 ++ .../expectations/WaitChatBoostUpdated.kt | 17 ++ .../ChatBoostRemovedTriggers.kt | 34 ++++ .../ChatBoostUpdatedTriggers.kt | 34 ++++ .../ByIdChatBoostRemovedMarkerFactory.kt | 9 + .../ByIdChatBoostUpdatedMarkerFactory.kt | 8 + .../inmo/tgbotapi/abstracts/WithMessageId.kt | 10 + .../abstracts/WithPreviewChatAndMessageId.kt | 3 + .../tgbotapi/abstracts/types/MessageAction.kt | 6 +- .../requests/get/GetUserChatBoosts.kt | 24 +++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 9 + .../dev/inmo/tgbotapi/types/boosts/BoostId.kt | 10 + .../inmo/tgbotapi/types/boosts/ChatBoost.kt | 17 ++ .../tgbotapi/types/boosts/ChatBoostRemoved.kt | 19 ++ .../tgbotapi/types/boosts/ChatBoostSource.kt | 171 ++++++++++++++++++ .../tgbotapi/types/boosts/ChatBoostUpdated.kt | 16 ++ .../tgbotapi/types/boosts/UserChatBoosts.kt | 11 ++ .../types/chat/ChatMessageReactionUpdated.kt | 6 +- .../chat/ChatMessageReactionsCountUpdated.kt | 8 +- .../types/message/abstracts/Message.kt | 5 +- .../types/update/ChatBoostRemovedUpdate.kt | 14 ++ .../types/update/ChatBoostUpdatedUpdate.kt | 13 ++ .../inmo/tgbotapi/types/update/RawUpdate.kt | 8 +- .../updateshandlers/FlowsUpdatesFilter.kt | 4 + .../extensions/utils/ClassCastsNew.kt | 84 +++++++++ .../utils/extensions/UpdateChatRetriever.kt | 4 + 27 files changed, 567 insertions(+), 13 deletions(-) create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserChatBoosts.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostRemoved.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostUpdated.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostRemovedTriggers.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostUpdatedTriggers.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostRemovedMarkerFactory.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostUpdatedMarkerFactory.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithMessageId.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithPreviewChatAndMessageId.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/get/GetUserChatBoosts.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/BoostId.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoost.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostRemoved.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostUpdated.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/UserChatBoosts.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostRemovedUpdate.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostUpdatedUpdate.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserChatBoosts.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserChatBoosts.kt new file mode 100644 index 0000000000..23b4d42111 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserChatBoosts.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.extensions.api.get + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.get.GetUserChatBoosts +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.Chat + +suspend fun TelegramBot.getUserChatBoosts( + chatId: ChatIdentifier, + userId: UserId +) = execute( + GetUserChatBoosts(chatId = chatId, userId = userId) +) + +suspend fun TelegramBot.getUserChatBoosts( + chat: Chat, + userId: UserId +) = getUserChatBoosts(chatId = chat.id, userId = userId) \ No newline at end of file diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostRemoved.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostRemoved.kt new file mode 100644 index 0000000000..aefb0cad80 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostRemoved.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.chatBoostRemovedUpdateOrNull +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved +import kotlinx.coroutines.flow.Flow + +suspend fun BehaviourContext.waitChatBoostRemoved( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( + initRequest, + errorFactory +) { + it.chatBoostRemovedUpdateOrNull() ?.data.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostUpdated.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostUpdated.kt new file mode 100644 index 0000000000..926f7ad712 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatBoostUpdated.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.chatBoostUpdatedUpdateOrNull +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated +import kotlinx.coroutines.flow.Flow + +suspend fun BehaviourContext.waitChatBoostUpdated( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +): Flow = expectFlow( + initRequest, + errorFactory +) { + it.chatBoostUpdatedUpdateOrNull() ?.data.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostRemovedTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostRemovedTriggers.kt new file mode 100644 index 0000000000..3dae6f99ef --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostRemovedTriggers.kt @@ -0,0 +1,34 @@ +@file:Suppress("unused") + +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.ByIdChatBoostRemovedMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.utils.chatBoostRemovedUpdateOrNull +import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved +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] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onChatBoostRemoved( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdChatBoostRemovedMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.chatBoostRemovedUpdateOrNull() ?.data) ?.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostUpdatedTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostUpdatedTriggers.kt new file mode 100644 index 0000000000..5e94dab7ce --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatBoostUpdatedTriggers.kt @@ -0,0 +1,34 @@ +@file:Suppress("unused") + +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.ByIdChatBoostUpdatedMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.utils.chatBoostUpdatedUpdateOrNull +import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated +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] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onChatBoostUpdated( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdChatBoostUpdatedMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.chatBoostUpdatedUpdateOrNull() ?.data) ?.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostRemovedMarkerFactory.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostRemovedMarkerFactory.kt new file mode 100644 index 0000000000..ad9957e859 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostRemovedMarkerFactory.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved +import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated +import dev.inmo.tgbotapi.types.polls.PollAnswer + +object ByIdChatBoostRemovedMarkerFactory : MarkerFactory { + override suspend fun invoke(data: ChatBoostRemoved) = data.chat.id +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostUpdatedMarkerFactory.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostUpdatedMarkerFactory.kt new file mode 100644 index 0000000000..a72040ff8d --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ByIdChatBoostUpdatedMarkerFactory.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated +import dev.inmo.tgbotapi.types.polls.PollAnswer + +object ByIdChatBoostUpdatedMarkerFactory : MarkerFactory { + override suspend fun invoke(data: ChatBoostUpdated) = data.chat.id +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithMessageId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithMessageId.kt new file mode 100644 index 0000000000..681f869ef3 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithMessageId.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.abstracts + +import dev.inmo.tgbotapi.types.MessageId + +/** + * All inheritors of this interface have [messageId] field and related to this [messageId] + */ +interface WithMessageId { + val messageId: MessageId +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithPreviewChatAndMessageId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithPreviewChatAndMessageId.kt new file mode 100644 index 0000000000..5465e73650 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithPreviewChatAndMessageId.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.abstracts + +interface WithPreviewChatAndMessageId : WithPreviewChat, WithMessageId diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessageAction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessageAction.kt index 16ac3bd26e..4e38baa5bd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessageAction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/MessageAction.kt @@ -1,7 +1,5 @@ package dev.inmo.tgbotapi.abstracts.types -import dev.inmo.tgbotapi.types.MessageId +import dev.inmo.tgbotapi.abstracts.WithMessageId -interface MessageAction: ChatRequest { - val messageId: MessageId -} +interface MessageAction : ChatRequest, WithMessageId diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/get/GetUserChatBoosts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/get/GetUserChatBoosts.kt new file mode 100644 index 0000000000..0e4e08b8de --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/get/GetUserChatBoosts.kt @@ -0,0 +1,24 @@ +package dev.inmo.tgbotapi.requests.get + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.boosts.UserChatBoosts +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy + +@Serializable +data class GetUserChatBoosts( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(userIdField) + val userId: UserId +) : SimpleRequest, ChatRequest { + override fun method(): String = "getUserChatBoosts" + override val resultDeserializer: DeserializationStrategy + get() = UserChatBoosts.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 0b703caf8d..e66e407779 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -202,6 +202,7 @@ const val tgWebAppStartParamField = "tgWebAppStartParam" const val chatIdField = "chat_id" const val senderChatIdField = "sender_chat_id" const val messageIdField = "message_id" +const val giveawayMessageIdField = "giveaway_message_id" const val messageIdsField = "message_ids" const val actorChatField = "actor_chat" const val messageThreadIdField = "message_thread_id" @@ -609,6 +610,7 @@ const val secretField = "secret" const val errorsField = "errors" const val sourceField = "source" +const val isUnclaimedField = "is_unclaimed" const val fieldNameField = "field_name" const val dataHashField = "data_hash" const val fileHashField = "file_hash" @@ -634,3 +636,10 @@ const val buttonTextField = "button_text" const val webAppField = "web_app" const val webAppNameField = "web_app_name" const val menuButtonField = "menu_button" + +const val boostIdField = "boost_id" +const val boostField = "boost" +const val addDateField = "add_date" +const val expirationDateField = "expiration_date" +const val removeDateField = "remove_date" +const val boostsField = "boosts" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/BoostId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/BoostId.kt new file mode 100644 index 0000000000..a26387039c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/BoostId.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types.boosts + +import kotlinx.serialization.Serializable +import kotlin.jvm.JvmInline + +@Serializable +@JvmInline +value class BoostId( + val string: String +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoost.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoost.kt new file mode 100644 index 0000000000..5ed94eafbc --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoost.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.types.boosts + +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ChatBoost( + @SerialName(boostIdField) + val id: BoostId, + @SerialName(addDateField) + val addDate: TelegramDate, + @SerialName(expirationDateField) + val expirationDate: TelegramDate, + @SerialName(sourceField) + val source: ChatBoostSource +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostRemoved.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostRemoved.kt new file mode 100644 index 0000000000..070d326a5e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostRemoved.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.types.boosts + +import dev.inmo.tgbotapi.abstracts.WithPreviewChat +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.PreviewChat +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ChatBoostRemoved( + @SerialName(chatField) + override val chat: PreviewChat, + @SerialName(boostIdField) + val boostId: BoostId, + @SerialName(removeDateField) + val removeDate: TelegramDate, + @SerialName(sourceField) + val source: ChatBoostSource +) : WithPreviewChat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt new file mode 100644 index 0000000000..1fc74ec9c8 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt @@ -0,0 +1,171 @@ +package dev.inmo.tgbotapi.types.boosts + +import dev.inmo.tgbotapi.abstracts.WithMessageId +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.PreviewUser +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Required +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.JsonDecoder +import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.decodeFromJsonElement + +@Serializable(ChatBoostSource.Companion::class) +@ClassCastsIncluded +sealed interface ChatBoostSource { + val sourceName: String + val user: PreviewUser? + + sealed interface ByUser : ChatBoostSource { + override val user: PreviewUser + } + + @Serializable(ChatBoostSource.Companion::class) + data class Premium( + @SerialName(userField) + override val user: PreviewUser + ) : ByUser { + @Required + @SerialName(sourceField) + override val sourceName: String = sourceCode + + companion object { + const val sourceCode = "premium" + } + } + + @Serializable(ChatBoostSource.Companion::class) + data class GiftCode( + @SerialName(userField) + override val user: PreviewUser + ) : ByUser { + @Required + @SerialName(sourceField) + override val sourceName: String = sourceCode + + companion object { + const val sourceCode = "gift_code" + } + } + + @Serializable(ChatBoostSource.Companion::class) + sealed interface Giveaway : ChatBoostSource, WithMessageId { + val unclaimed: Boolean + val claimed: Boolean + get() = !unclaimed + + @Serializable(ChatBoostSource.Companion::class) + data class Claimed( + @SerialName(giveawayMessageIdField) + override val messageId: MessageId, + @SerialName(userField) + override val user: PreviewUser + ) : Giveaway, ByUser { + @Required + @SerialName(sourceField) + override val sourceName: String = Giveaway.sourceCode + @Required + @SerialName(isUnclaimedField) + override val unclaimed: Boolean = false + } + + @Serializable(ChatBoostSource.Companion::class) + data class Unclaimed( + @SerialName(giveawayMessageIdField) + override val messageId: MessageId + ) : Giveaway { + @Required + @SerialName(sourceField) + override val sourceName: String = Giveaway.sourceCode + @Required + @SerialName(isUnclaimedField) + override val unclaimed: Boolean = true + @SerialName(userField) + override val user: PreviewUser? = null + } + + companion object { + val sourceCode = "giveaway" + } + } + + @Serializable(ChatBoostSource.Companion::class) + data class Unknown( + override val sourceName: String, + override val user: PreviewUser?, + val json: JsonElement? + ) : ChatBoostSource + + @Serializable + private data class Surrogate( + @Required + @SerialName(sourceField) + val sourceName: String, + @SerialName(userField) + val user: PreviewUser? = null, + @SerialName(giveawayMessageIdField) + val messageId: MessageId? = null, + @SerialName(isUnclaimedField) + val unclaimed: Boolean? = null + ) + + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): ChatBoostSource { + val (surrogate, json) = when { + decoder is JsonDecoder -> { + val json = decoder.decodeJsonElement() + val surrogate = decoder.json.decodeFromJsonElement(Surrogate.serializer(), json) + surrogate to json + } + else -> Surrogate.serializer().deserialize(decoder) to null + } + + return when { + surrogate.sourceName == Premium.sourceCode && surrogate.user != null -> { + Premium(surrogate.user) + } + surrogate.sourceName == GiftCode.sourceCode && surrogate.user != null -> { + GiftCode(surrogate.user) + } + surrogate.sourceName == Giveaway.sourceCode && surrogate.messageId != null -> { + when { + surrogate.user != null && surrogate.unclaimed == false -> Giveaway.Claimed( + surrogate.messageId, + surrogate.user + ) + surrogate.unclaimed == true -> Giveaway.Unclaimed( + surrogate.messageId + ) + else -> null + } + } + else -> null + } ?: Unknown(surrogate.sourceName, surrogate.user, json) + } + + override fun serialize(encoder: Encoder, value: ChatBoostSource) { + if (value is Unknown && value.json != null) { + JsonElement.serializer().serialize(encoder, value.json) + return + } + + val surrogate = Surrogate( + value.sourceName, + value.user, + (value as? Giveaway) ?.messageId, + (value as? Giveaway) ?.unclaimed, + ) + + Surrogate.serializer().serialize(encoder, surrogate) + } + + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostUpdated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostUpdated.kt new file mode 100644 index 0000000000..7f2180ea40 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostUpdated.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.boosts + +import dev.inmo.tgbotapi.abstracts.WithPreviewChat +import dev.inmo.tgbotapi.types.boostField +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.chatField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ChatBoostUpdated( + @SerialName(chatField) + override val chat: PreviewChat, + @SerialName(boostField) + val boost: ChatBoost +) : WithPreviewChat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/UserChatBoosts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/UserChatBoosts.kt new file mode 100644 index 0000000000..caac5cbc5c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/UserChatBoosts.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.types.boosts + +import dev.inmo.tgbotapi.types.boostsField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class UserChatBoosts( + @SerialName(boostsField) + val boosts: List +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt index ba919d69bb..96ecb4a24b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt @@ -1,5 +1,7 @@ package dev.inmo.tgbotapi.types.chat +import dev.inmo.tgbotapi.abstracts.WithPreviewChat +import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.reactions.Reaction import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded @@ -14,9 +16,7 @@ import kotlinx.serialization.json.JsonElement @Serializable(ChatMessageReactionUpdated.Companion::class) @ClassCastsIncluded -sealed interface ChatMessageReactionUpdated { - val chat: PreviewChat - val messageId: MessageIdentifier +sealed interface ChatMessageReactionUpdated : WithPreviewChatAndMessageId { val reactedUser: PreviewUser? val reactedChat: PreviewChat? val date: TelegramDate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt index 28f440fbd0..313b754fb1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt @@ -1,5 +1,7 @@ package dev.inmo.tgbotapi.types.chat +import dev.inmo.tgbotapi.abstracts.WithPreviewChat +import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.reactions.ReactionsCount import kotlinx.serialization.SerialName @@ -8,12 +10,12 @@ import kotlinx.serialization.Serializable @Serializable data class ChatMessageReactionsCountUpdated( @SerialName(chatField) - val chat: PreviewChat, + override val chat: PreviewChat, @SerialName(messageIdField) - val messageId: MessageIdentifier, + override val messageId: MessageIdentifier, @Serializable(TelegramDateSerializer::class) @SerialName(dateField) val date: TelegramDate, @SerialName(reactionsField) val reactions: List -) +) : WithPreviewChatAndMessageId diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt index 0b34ea85a1..5e1fcba29c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt @@ -1,7 +1,9 @@ package dev.inmo.tgbotapi.types.message.abstracts +import dev.inmo.tgbotapi.abstracts.WithMessageId import korlibs.time.DateTime import dev.inmo.tgbotapi.abstracts.WithPreviewChat +import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.chat.Chat @@ -13,8 +15,7 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @ClassCastsIncluded(excludeRegex = ".*Impl") -interface Message : WithPreviewChat { - val messageId: MessageId +interface Message : WithPreviewChatAndMessageId { val date: DateTime } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostRemovedUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostRemovedUpdate.kt new file mode 100644 index 0000000000..2e13161d9f --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostRemovedUpdate.kt @@ -0,0 +1,14 @@ +package dev.inmo.tgbotapi.types.update + +import dev.inmo.tgbotapi.types.UpdateIdentifier +import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved +import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlinx.serialization.Serializable + +@Serializable +data class ChatBoostRemovedUpdate( + override val updateId: UpdateIdentifier, + override val data: ChatBoostRemoved +) : Update \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostUpdatedUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostUpdatedUpdate.kt new file mode 100644 index 0000000000..e23e963550 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChatBoostUpdatedUpdate.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.types.update + +import dev.inmo.tgbotapi.types.UpdateIdentifier +import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlinx.serialization.Serializable + +@Serializable +data class ChatBoostUpdatedUpdate( + override val updateId: UpdateIdentifier, + override val data: ChatBoostUpdated +) : 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 61cee808e6..c7894c973c 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 @@ -4,6 +4,8 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.queries.callback.RawCallbackQuery import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.RawChosenInlineResult import dev.inmo.tgbotapi.types.InlineQueries.query.RawInlineQuery +import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved +import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated import dev.inmo.tgbotapi.types.chat.ChatJoinRequest import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated @@ -42,7 +44,9 @@ internal data class RawUpdate constructor( private val chat_member: ChatMemberUpdated? = null, private val chat_join_request: ChatJoinRequest? = null, private val message_reaction: ChatMessageReactionUpdated? = null, - private val message_reaction_count: ChatMessageReactionsCountUpdated? = null + private val message_reaction_count: ChatMessageReactionsCountUpdated? = null, + private val chat_boost: ChatBoostUpdated? = null, + private val removed_chat_boost: ChatBoostRemoved? = null ) { private var initedUpdate: Update? = null /** @@ -71,6 +75,8 @@ internal data class RawUpdate constructor( chat_join_request != null -> ChatJoinRequestUpdate(updateId, chat_join_request) message_reaction != null -> ChatMessageReactionUpdatedUpdate(updateId, message_reaction) message_reaction_count != null -> ChatMessageReactionsCountUpdatedUpdate(updateId, message_reaction_count) + chat_boost != null -> ChatBoostUpdatedUpdate(updateId, chat_boost) + removed_chat_boost != null -> ChatBoostRemovedUpdate(updateId, removed_chat_boost) 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 40e1bfd106..b2886f2cf8 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 @@ -39,6 +39,8 @@ interface FlowsUpdatesFilter : UpdatesFilter { val chatJoinRequestUpdateFlow: Flow val chatMessageReactionUpdatedUpdateFlow: Flow val chatMessageReactionsCountUpdatedUpdateFlow: Flow + val chatBoostUpdatedUpdateFlow: Flow + val chatBoostRemovedUpdateFlow: Flow val unknownUpdatesFlow: Flow } @@ -60,6 +62,8 @@ abstract class AbstractFlowsUpdatesFilter : FlowsUpdatesFilter { override val chatMessageReactionUpdatedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val chatMessageReactionsCountUpdatedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val unknownUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val chatBoostUpdatedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val chatBoostRemovedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } } /** 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 99730c0981..b4fc81fc39 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 @@ -90,6 +90,7 @@ import dev.inmo.tgbotapi.types.actions.UploadPhotoAction import dev.inmo.tgbotapi.types.actions.UploadVideoAction import dev.inmo.tgbotapi.types.actions.UploadVideoNoteAction import dev.inmo.tgbotapi.types.actions.UploadVoiceAction +import dev.inmo.tgbotapi.types.boosts.ChatBoostSource import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton @@ -424,6 +425,8 @@ import dev.inmo.tgbotapi.types.request.RequestResponse import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate import dev.inmo.tgbotapi.types.update.ChannelPostUpdate +import dev.inmo.tgbotapi.types.update.ChatBoostRemovedUpdate +import dev.inmo.tgbotapi.types.update.ChatBoostUpdatedUpdate import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate import dev.inmo.tgbotapi.types.update.ChatMessageReactionUpdatedUpdate import dev.inmo.tgbotapi.types.update.ChatMessageReactionsCountUpdatedUpdate @@ -1620,6 +1623,69 @@ public inline fun BotAction.customBotActionOrThrow(): CustomBotAction = this as public inline fun BotAction.ifCustomBotAction(block: (CustomBotAction) -> T): T? = customBotActionOrNull() ?.let(block) +public inline fun ChatBoostSource.byUserOrNull(): ChatBoostSource.ByUser? = this as? + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.ByUser + +public inline fun ChatBoostSource.byUserOrThrow(): ChatBoostSource.ByUser = this as + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.ByUser + +public inline fun ChatBoostSource.ifByUser(block: (ChatBoostSource.ByUser) -> T): T? = + byUserOrNull() ?.let(block) + +public inline fun ChatBoostSource.giftCodeOrNull(): ChatBoostSource.GiftCode? = this as? + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.GiftCode + +public inline fun ChatBoostSource.giftCodeOrThrow(): ChatBoostSource.GiftCode = this as + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.GiftCode + +public inline fun ChatBoostSource.ifGiftCode(block: (ChatBoostSource.GiftCode) -> T): T? = + giftCodeOrNull() ?.let(block) + +public inline fun ChatBoostSource.claimedOrNull(): ChatBoostSource.Giveaway.Claimed? = this as? + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Claimed + +public inline fun ChatBoostSource.claimedOrThrow(): ChatBoostSource.Giveaway.Claimed = this as + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Claimed + +public inline fun ChatBoostSource.ifClaimed(block: (ChatBoostSource.Giveaway.Claimed) -> T): T? + = claimedOrNull() ?.let(block) + +public inline fun ChatBoostSource.premiumOrNull(): ChatBoostSource.Premium? = this as? + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Premium + +public inline fun ChatBoostSource.premiumOrThrow(): ChatBoostSource.Premium = this as + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Premium + +public inline fun ChatBoostSource.ifPremium(block: (ChatBoostSource.Premium) -> T): T? = + premiumOrNull() ?.let(block) + +public inline fun ChatBoostSource.giveawayOrNull(): ChatBoostSource.Giveaway? = this as? + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway + +public inline fun ChatBoostSource.giveawayOrThrow(): ChatBoostSource.Giveaway = this as + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway + +public inline fun ChatBoostSource.ifGiveaway(block: (ChatBoostSource.Giveaway) -> T): T? = + giveawayOrNull() ?.let(block) + +public inline fun ChatBoostSource.unclaimedOrNull(): ChatBoostSource.Giveaway.Unclaimed? = this as? + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Unclaimed + +public inline fun ChatBoostSource.unclaimedOrThrow(): ChatBoostSource.Giveaway.Unclaimed = this as + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Unclaimed + +public inline fun ChatBoostSource.ifUnclaimed(block: (ChatBoostSource.Giveaway.Unclaimed) -> T): + T? = unclaimedOrNull() ?.let(block) + +public inline fun ChatBoostSource.unknownOrNull(): ChatBoostSource.Unknown? = this as? + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Unknown + +public inline fun ChatBoostSource.unknownOrThrow(): ChatBoostSource.Unknown = this as + dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Unknown + +public inline fun ChatBoostSource.ifUnknown(block: (ChatBoostSource.Unknown) -> T): T? = + unknownOrNull() ?.let(block) + public inline fun InlineKeyboardButton.unknownInlineKeyboardButtonOrNull(): UnknownInlineKeyboardButton? = this as? dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton @@ -4603,6 +4669,24 @@ public inline fun Update.channelPostUpdateOrThrow(): ChannelPostUpdate = this as public inline fun Update.ifChannelPostUpdate(block: (ChannelPostUpdate) -> T): T? = channelPostUpdateOrNull() ?.let(block) +public inline fun Update.chatBoostRemovedUpdateOrNull(): ChatBoostRemovedUpdate? = this as? + dev.inmo.tgbotapi.types.update.ChatBoostRemovedUpdate + +public inline fun Update.chatBoostRemovedUpdateOrThrow(): ChatBoostRemovedUpdate = this as + dev.inmo.tgbotapi.types.update.ChatBoostRemovedUpdate + +public inline fun Update.ifChatBoostRemovedUpdate(block: (ChatBoostRemovedUpdate) -> T): T? = + chatBoostRemovedUpdateOrNull() ?.let(block) + +public inline fun Update.chatBoostUpdatedUpdateOrNull(): ChatBoostUpdatedUpdate? = this as? + dev.inmo.tgbotapi.types.update.ChatBoostUpdatedUpdate + +public inline fun Update.chatBoostUpdatedUpdateOrThrow(): ChatBoostUpdatedUpdate = this as + dev.inmo.tgbotapi.types.update.ChatBoostUpdatedUpdate + +public inline fun Update.ifChatBoostUpdatedUpdate(block: (ChatBoostUpdatedUpdate) -> T): T? = + chatBoostUpdatedUpdateOrNull() ?.let(block) + public inline fun Update.chatJoinRequestUpdateOrNull(): ChatJoinRequestUpdate? = this as? dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt index c92600b96a..b7831999b9 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt @@ -42,6 +42,8 @@ fun Update.sourceChatWithConverters( myChatMemberUpdatedUpdateConverter: (MyChatMemberUpdatedUpdate) -> Chat? = { it.data.chat }, chatMessageReactionUpdatedUpdateConverter: (ChatMessageReactionUpdatedUpdate) -> Chat? = { it.data.chat }, chatMessageReactionsCountUpdatedUpdateConverter: (ChatMessageReactionsCountUpdatedUpdate) -> Chat? = { it.data.chat }, + chatBoostUpdatedUpdateFlow: (ChatBoostUpdatedUpdate) -> Chat? = { it.data.chat }, + chatBoostRemovedUpdateFlow: (ChatBoostRemovedUpdate) -> Chat? = { it.data.chat }, commonChatMemberUpdatedUpdateConverter: (CommonChatMemberUpdatedUpdate) -> Chat? = { it.data.chat } ): Chat? = when (this) { is BaseMessageUpdate -> baseMessageUpdateConverter(this) @@ -61,6 +63,8 @@ fun Update.sourceChatWithConverters( is CommonChatMemberUpdatedUpdate -> commonChatMemberUpdatedUpdateConverter(this) is ChatMessageReactionUpdatedUpdate -> chatMessageReactionUpdatedUpdateConverter(this) is ChatMessageReactionsCountUpdatedUpdate -> chatMessageReactionsCountUpdatedUpdateConverter(this) + is ChatBoostUpdatedUpdate -> chatBoostUpdatedUpdateFlow(this) + is ChatBoostRemovedUpdate -> chatBoostRemovedUpdateFlow(this) else -> { when (val data = data) { is FromUser -> data.from From dce63713f9321ab3da5fcf2a529dd17a09558b6f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 13:10:05 +0600 Subject: [PATCH 14/65] add giveaways support --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 12 ++ .../inmo/tgbotapi/types/giveaway/Giveaway.kt | 30 ++++ .../types/giveaway/GiveawayCreated.kt | 8 + .../tgbotapi/types/giveaway/GiveawayInfo.kt | 15 ++ .../types/giveaway/GiveawayPrivateResults.kt | 16 ++ .../types/giveaway/GiveawayPublicResults.kt | 162 ++++++++++++++++++ .../types/giveaway/GiveawayResults.kt | 11 ++ .../inmo/tgbotapi/types/message/RawMessage.kt | 16 +- .../extensions/utils/ClassCastsNew.kt | 50 ++++++ 9 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayCreated.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayInfo.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index e66e407779..77fe66ed95 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -482,6 +482,7 @@ const val isBigField = "is_big" const val oldReactionField = "old_reaction" const val newReactionField = "new_reaction" const val chatField = "chat" +const val chatsField = "chats" const val usernameField = "username" const val bioField = "bio" const val nameField = "name" @@ -544,6 +545,7 @@ const val shippingQueryIdField = "shipping_query_id" const val preCheckoutQueryIdField = "pre_checkout_query_id" const val shippingOptionsField = "shipping_options" const val countryCodeField = "country_code" +const val countryCodesField = "country_codes" const val totalCountField = "total_count" const val stateField = "state" const val cityField = "city" @@ -643,3 +645,13 @@ const val addDateField = "add_date" const val expirationDateField = "expiration_date" const val removeDateField = "remove_date" const val boostsField = "boosts" +const val winnersSelectionDateField = "winners_selection_date" +const val winnersCountField = "winner_count" +const val onlyNewMembersField = "only_new_members" +const val hasPublicWinnersField = "has_public_winners" +const val prizeDescriptionField = "prize_description" +const val premiumSubscriptionMonthCountField = "premium_subscription_month_count" +const val winnersField = "winners" +const val additionalChatCountField = "additional_chat_count" +const val unclaimedPrizeCountField = "unclaimed_prize_count" +const val wasRefundedField = "was_refunded" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt new file mode 100644 index 0000000000..cbae4c2740 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt @@ -0,0 +1,30 @@ +package dev.inmo.tgbotapi.types.giveaway + +import dev.inmo.micro_utils.language_codes.IetfLang +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class Giveaway( + @SerialName(chatsField) + val chats: List, + @SerialName(winnersSelectionDateField) + override val selectionDate: TelegramDate, + @SerialName(winnersCountField) + val count: Int, + @SerialName(onlyNewMembersField) + override val onlyNewMembers: Boolean = false, + @SerialName(hasPublicWinnersField) + val publicWinners: Boolean = false, + @SerialName(prizeDescriptionField) + override val additionalPrizeDescription: String? = null, + @SerialName(countryCodesField) + val countries: List? = null, + @SerialName(premiumSubscriptionMonthCountField) + override val premiumMonths: Int? = null +) : GiveawayInfo, ChatEvent, PublicChatEvent \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayCreated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayCreated.kt new file mode 100644 index 0000000000..25694a90cd --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayCreated.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.types.giveaway + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent +import kotlinx.serialization.Serializable + +@Serializable +object GiveawayCreated : ChatEvent, PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayInfo.kt new file mode 100644 index 0000000000..559f001773 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayInfo.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.types.giveaway + +import dev.inmo.micro_utils.language_codes.IetfLang +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.PreviewChat +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +sealed interface GiveawayInfo { + val selectionDate: TelegramDate + val onlyNewMembers: Boolean + val premiumMonths: Int? + val additionalPrizeDescription: String? +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt new file mode 100644 index 0000000000..63e3fb7f4b --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.giveaway + +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import dev.inmo.tgbotapi.types.message.abstracts.Message +import kotlinx.serialization.Serializable +import kotlinx.serialization.Transient + +@Serializable +data class GiveawayPrivateResults( + override val chat: PreviewChat, + override val unclaimedCount: Int, + @Transient // TODO::Add message serializer + val message: Message? = null +) : GiveawayResults diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt new file mode 100644 index 0000000000..b908d2e314 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt @@ -0,0 +1,162 @@ +package dev.inmo.tgbotapi.types.giveaway + +import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.chat.PreviewUser +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Required +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +@Serializable(GiveawayPublicResults.Companion::class) +sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId { + val count: Int + val winners: List + val additionalChats: Int + val publicWinners: Boolean + val refunded: Boolean + + @Serializable(GiveawayPublicResults.Companion::class) + data class Refunded( + @SerialName(chatsField) + override val chat: PreviewChat, + @SerialName(giveawayMessageIdField) + override val messageId: MessageId, + @SerialName(winnersSelectionDateField) + override val selectionDate: TelegramDate, + ) : GiveawayPublicResults { + @SerialName(wasRefundedField) + @Required + override val refunded: Boolean = true + @SerialName(winnersCountField) + override val count: Int = 0 + @SerialName(winnersField) + override val winners: List = emptyList() + @SerialName(additionalChatCountField) + override val additionalChats: Int = 0 + @SerialName(unclaimedPrizeCountField) + override val unclaimedCount: Int = 0 + @SerialName(onlyNewMembersField) + override val onlyNewMembers: Boolean = false + @SerialName(hasPublicWinnersField) + override val publicWinners: Boolean = false + @SerialName(prizeDescriptionField) + override val additionalPrizeDescription: String? = null + @SerialName(premiumSubscriptionMonthCountField) + override val premiumMonths: Int? = null + } + + @Serializable(GiveawayPublicResults.Companion::class) + data class Winners ( + @SerialName(chatsField) + override val chat: PreviewChat, + @SerialName(giveawayMessageIdField) + override val messageId: MessageId, + @SerialName(winnersSelectionDateField) + override val selectionDate: TelegramDate, + @SerialName(winnersCountField) + override val count: Int, + @SerialName(winnersField) + override val winners: List, + @SerialName(additionalChatCountField) + override val additionalChats: Int = 0, + @SerialName(unclaimedPrizeCountField) + override val unclaimedCount: Int = 0, + @SerialName(onlyNewMembersField) + override val onlyNewMembers: Boolean = false, + @SerialName(hasPublicWinnersField) + override val publicWinners: Boolean = false, + @SerialName(prizeDescriptionField) + override val additionalPrizeDescription: String? = null, + @SerialName(premiumSubscriptionMonthCountField) + override val premiumMonths: Int? = null + ) : GiveawayPublicResults { + @SerialName(wasRefundedField) + @Required + override val refunded: Boolean = false + } + + @Serializable + private data class Surrogate( + @SerialName(chatsField) + val chat: PreviewChat, + @SerialName(giveawayMessageIdField) + val messageId: MessageId, + @SerialName(winnersSelectionDateField) + val selectionDate: TelegramDate, + @SerialName(winnersCountField) + val count: Int, + @SerialName(winnersField) + val winners: List, + @SerialName(additionalChatCountField) + val additionalChats: Int = 0, + @SerialName(unclaimedPrizeCountField) + val unclaimedCount: Int = 0, + @SerialName(onlyNewMembersField) + val onlyNewMembers: Boolean = false, + @SerialName(hasPublicWinnersField) + val publicWinners: Boolean = false, + @SerialName(wasRefundedField) + val refunded: Boolean = false, + @SerialName(prizeDescriptionField) + val additionalPrizeDescription: String? = null, + @SerialName(premiumSubscriptionMonthCountField) + val premiumMonths: Int? = null + ) + + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): GiveawayPublicResults { + val surrogate = Surrogate.serializer().deserialize(decoder) + + return when (surrogate.refunded) { + true -> Refunded( + chat = surrogate.chat, + messageId = surrogate.messageId, + selectionDate = surrogate.selectionDate + ) + false -> { + Winners( + chat = surrogate.chat, + messageId = surrogate.messageId, + selectionDate = surrogate.selectionDate, + count = surrogate.count, + winners = surrogate.winners, + additionalChats = surrogate.additionalChats, + unclaimedCount = surrogate.unclaimedCount, + onlyNewMembers = surrogate.onlyNewMembers, + publicWinners = surrogate.publicWinners, + additionalPrizeDescription = surrogate.additionalPrizeDescription, + premiumMonths = surrogate.premiumMonths, + ) + } + } + } + + override fun serialize(encoder: Encoder, value: GiveawayPublicResults) { + val surrogate = Surrogate( + chat = value.chat, + messageId = value.messageId, + selectionDate = value.selectionDate, + count = value.count, + winners = value.winners, + additionalChats = value.additionalChats, + unclaimedCount = value.unclaimedCount, + onlyNewMembers = value.onlyNewMembers, + publicWinners = value.publicWinners, + additionalPrizeDescription = value.additionalPrizeDescription, + premiumMonths = value.premiumMonths, + refunded = value.refunded + ) + + Surrogate.serializer().serialize(encoder, surrogate) + } + + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt new file mode 100644 index 0000000000..fc193537e6 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.types.giveaway + +import dev.inmo.tgbotapi.abstracts.WithPreviewChat +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent +import kotlinx.serialization.Serializable + +@Serializable +sealed interface GiveawayResults : WithPreviewChat, ChatEvent, PublicChatEvent { + val unclaimedCount: Int +} 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 43f928f24a..5d50d272d4 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 @@ -9,6 +9,10 @@ import dev.inmo.tgbotapi.types.dice.Dice import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.games.RawGame +import dev.inmo.tgbotapi.types.giveaway.Giveaway +import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated +import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults +import dev.inmo.tgbotapi.types.giveaway.GiveawayResults import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -130,7 +134,13 @@ internal data class RawMessage( private val link_preview_options: LinkPreviewOptions? = null, - private val reply_markup: InlineKeyboardMarkup? = null + private val reply_markup: InlineKeyboardMarkup? = null, + + // Giveaways + private val giveaway_created: GiveawayCreated? = null, + private val giveaway: Giveaway? = null, + private val giveaway_winners: GiveawayResults? = null, + private val giveaway_completed: GiveawayPrivateResults? = null, ) { private val content: MessageContent? by lazy { val adaptedCaptionEntities = caption ?.let { @@ -268,6 +278,10 @@ internal data class RawMessage( web_app_data != null -> web_app_data users_shared != null -> users_shared chat_shared != null -> chat_shared + giveaway_created != null -> giveaway_created + giveaway != null -> giveaway + giveaway_winners != null -> giveaway_winners + giveaway_completed != null -> giveaway_completed else -> null } } 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 b4fc81fc39..70b2517155 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 @@ -196,6 +196,11 @@ import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.VideoNoteFile import dev.inmo.tgbotapi.types.files.VideoSticker import dev.inmo.tgbotapi.types.files.VoiceFile +import dev.inmo.tgbotapi.types.giveaway.Giveaway +import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated +import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults +import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults +import dev.inmo.tgbotapi.types.giveaway.GiveawayResults import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.location.StaticLocation @@ -2714,6 +2719,51 @@ public inline fun TelegramMedia.titledTelegramMediaOrThrow(): TitledTelegramMedi public inline fun TelegramMedia.ifTitledTelegramMedia(block: (TitledTelegramMedia) -> T): T? = titledTelegramMediaOrNull() ?.let(block) +public inline fun ChatEvent.giveawayOrNull(): Giveaway? = this as? + dev.inmo.tgbotapi.types.giveaway.Giveaway + +public inline fun ChatEvent.giveawayOrThrow(): Giveaway = this as + dev.inmo.tgbotapi.types.giveaway.Giveaway + +public inline fun ChatEvent.ifGiveaway(block: (Giveaway) -> T): T? = giveawayOrNull() + ?.let(block) + +public inline fun ChatEvent.giveawayCreatedOrNull(): GiveawayCreated? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayCreated + +public inline fun ChatEvent.giveawayCreatedOrThrow(): GiveawayCreated = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayCreated + +public inline fun ChatEvent.ifGiveawayCreated(block: (GiveawayCreated) -> T): T? = + giveawayCreatedOrNull() ?.let(block) + +public inline fun ChatEvent.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun ChatEvent.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun ChatEvent.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = + giveawayPrivateResultsOrNull() ?.let(block) + +public inline fun ChatEvent.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun ChatEvent.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun ChatEvent.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): T? = + giveawayPublicResultsOrNull() ?.let(block) + +public inline fun ChatEvent.giveawayResultsOrNull(): GiveawayResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayResults + +public inline fun ChatEvent.giveawayResultsOrThrow(): GiveawayResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayResults + +public inline fun ChatEvent.ifGiveawayResults(block: (GiveawayResults) -> T): T? = + giveawayResultsOrNull() ?.let(block) + public inline fun ChatEvent.channelChatCreatedOrNull(): ChannelChatCreated? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated From cb11532b5885c389c8553e7bd6c0abdd64231b2a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 13:13:21 +0600 Subject: [PATCH 15/65] update ClassCastsIncluded --- .../types/giveaway/GiveawayResults.kt | 2 + .../extensions/utils/ClassCastsNew.kt | 110 ++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt index fc193537e6..721b8236b9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt @@ -3,9 +3,11 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.tgbotapi.abstracts.WithPreviewChat import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import kotlinx.serialization.Serializable @Serializable +@ClassCastsIncluded sealed interface GiveawayResults : WithPreviewChat, ChatEvent, PublicChatEvent { val unclaimedCount: Int } 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 70b2517155..7c915ba49e 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 @@ -2562,6 +2562,43 @@ public inline fun TelegramMediaFile.voiceFileOrThrow(): VoiceFile = this as public inline fun TelegramMediaFile.ifVoiceFile(block: (VoiceFile) -> T): T? = voiceFileOrNull() ?.let(block) +public inline fun GiveawayResults.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun GiveawayResults.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun + GiveawayResults.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = + giveawayPrivateResultsOrNull() ?.let(block) + +public inline fun GiveawayResults.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun GiveawayResults.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun GiveawayResults.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): + T? = giveawayPublicResultsOrNull() ?.let(block) + +public inline fun GiveawayResults.refundedOrNull(): GiveawayPublicResults.Refunded? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded + +public inline fun GiveawayResults.refundedOrThrow(): GiveawayPublicResults.Refunded = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded + +public inline fun GiveawayResults.ifRefunded(block: (GiveawayPublicResults.Refunded) -> T): T? = + refundedOrNull() ?.let(block) + +public inline fun GiveawayResults.winnersOrNull(): GiveawayPublicResults.Winners? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners + +public inline fun GiveawayResults.winnersOrThrow(): GiveawayPublicResults.Winners = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners + +public inline fun GiveawayResults.ifWinners(block: (GiveawayPublicResults.Winners) -> T): T? = + winnersOrNull() ?.let(block) + public inline fun Location.staticLocationOrNull(): StaticLocation? = this as? dev.inmo.tgbotapi.types.location.StaticLocation @@ -2764,6 +2801,79 @@ public inline fun ChatEvent.giveawayResultsOrThrow(): GiveawayResults = this as public inline fun ChatEvent.ifGiveawayResults(block: (GiveawayResults) -> T): T? = giveawayResultsOrNull() ?.let(block) +public inline fun ChatEvent.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun ChatEvent.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun ChatEvent.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = + giveawayPrivateResultsOrNull() ?.let(block) + +public inline fun GiveawayResults.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun GiveawayResults.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults + +public inline fun + GiveawayResults.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = + giveawayPrivateResultsOrNull() ?.let(block) + +public inline fun ChatEvent.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun ChatEvent.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun ChatEvent.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): T? = + giveawayPublicResultsOrNull() ?.let(block) + +public inline fun GiveawayResults.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun GiveawayResults.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults + +public inline fun GiveawayResults.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): + T? = giveawayPublicResultsOrNull() ?.let(block) + +public inline fun ChatEvent.refundedOrNull(): GiveawayPublicResults.Refunded? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded + +public inline fun ChatEvent.refundedOrThrow(): GiveawayPublicResults.Refunded = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded + +public inline fun ChatEvent.ifRefunded(block: (GiveawayPublicResults.Refunded) -> T): T? = + refundedOrNull() ?.let(block) + +public inline fun GiveawayResults.refundedOrNull(): GiveawayPublicResults.Refunded? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded + +public inline fun GiveawayResults.refundedOrThrow(): GiveawayPublicResults.Refunded = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded + +public inline fun GiveawayResults.ifRefunded(block: (GiveawayPublicResults.Refunded) -> T): T? = + refundedOrNull() ?.let(block) + +public inline fun ChatEvent.winnersOrNull(): GiveawayPublicResults.Winners? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners + +public inline fun ChatEvent.winnersOrThrow(): GiveawayPublicResults.Winners = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners + +public inline fun ChatEvent.ifWinners(block: (GiveawayPublicResults.Winners) -> T): T? = + winnersOrNull() ?.let(block) + +public inline fun GiveawayResults.winnersOrNull(): GiveawayPublicResults.Winners? = this as? + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners + +public inline fun GiveawayResults.winnersOrThrow(): GiveawayPublicResults.Winners = this as + dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners + +public inline fun GiveawayResults.ifWinners(block: (GiveawayPublicResults.Winners) -> T): T? = + winnersOrNull() ?.let(block) + public inline fun ChatEvent.channelChatCreatedOrNull(): ChannelChatCreated? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated From 52fd55eea594cc83a96750f9a832f937dd2c498c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 14:39:32 +0600 Subject: [PATCH 16/65] fix of overloads conflict in ClassCastsNew --- .../types/giveaway/GiveawayResults.kt | 2 - .../extensions/utils/ClassCastsNew.kt | 110 ------------------ 2 files changed, 112 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt index 721b8236b9..fc193537e6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt @@ -3,11 +3,9 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.tgbotapi.abstracts.WithPreviewChat import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent -import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import kotlinx.serialization.Serializable @Serializable -@ClassCastsIncluded sealed interface GiveawayResults : WithPreviewChat, ChatEvent, PublicChatEvent { val unclaimedCount: Int } 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 7c915ba49e..70b2517155 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 @@ -2562,43 +2562,6 @@ public inline fun TelegramMediaFile.voiceFileOrThrow(): VoiceFile = this as public inline fun TelegramMediaFile.ifVoiceFile(block: (VoiceFile) -> T): T? = voiceFileOrNull() ?.let(block) -public inline fun GiveawayResults.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults - -public inline fun GiveawayResults.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults - -public inline fun - GiveawayResults.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = - giveawayPrivateResultsOrNull() ?.let(block) - -public inline fun GiveawayResults.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun GiveawayResults.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun GiveawayResults.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): - T? = giveawayPublicResultsOrNull() ?.let(block) - -public inline fun GiveawayResults.refundedOrNull(): GiveawayPublicResults.Refunded? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded - -public inline fun GiveawayResults.refundedOrThrow(): GiveawayPublicResults.Refunded = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded - -public inline fun GiveawayResults.ifRefunded(block: (GiveawayPublicResults.Refunded) -> T): T? = - refundedOrNull() ?.let(block) - -public inline fun GiveawayResults.winnersOrNull(): GiveawayPublicResults.Winners? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners - -public inline fun GiveawayResults.winnersOrThrow(): GiveawayPublicResults.Winners = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners - -public inline fun GiveawayResults.ifWinners(block: (GiveawayPublicResults.Winners) -> T): T? = - winnersOrNull() ?.let(block) - public inline fun Location.staticLocationOrNull(): StaticLocation? = this as? dev.inmo.tgbotapi.types.location.StaticLocation @@ -2801,79 +2764,6 @@ public inline fun ChatEvent.giveawayResultsOrThrow(): GiveawayResults = this as public inline fun ChatEvent.ifGiveawayResults(block: (GiveawayResults) -> T): T? = giveawayResultsOrNull() ?.let(block) -public inline fun ChatEvent.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults - -public inline fun ChatEvent.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults - -public inline fun ChatEvent.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = - giveawayPrivateResultsOrNull() ?.let(block) - -public inline fun GiveawayResults.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults - -public inline fun GiveawayResults.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults - -public inline fun - GiveawayResults.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = - giveawayPrivateResultsOrNull() ?.let(block) - -public inline fun ChatEvent.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun ChatEvent.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun ChatEvent.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): T? = - giveawayPublicResultsOrNull() ?.let(block) - -public inline fun GiveawayResults.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun GiveawayResults.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun GiveawayResults.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): - T? = giveawayPublicResultsOrNull() ?.let(block) - -public inline fun ChatEvent.refundedOrNull(): GiveawayPublicResults.Refunded? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded - -public inline fun ChatEvent.refundedOrThrow(): GiveawayPublicResults.Refunded = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded - -public inline fun ChatEvent.ifRefunded(block: (GiveawayPublicResults.Refunded) -> T): T? = - refundedOrNull() ?.let(block) - -public inline fun GiveawayResults.refundedOrNull(): GiveawayPublicResults.Refunded? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded - -public inline fun GiveawayResults.refundedOrThrow(): GiveawayPublicResults.Refunded = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Refunded - -public inline fun GiveawayResults.ifRefunded(block: (GiveawayPublicResults.Refunded) -> T): T? = - refundedOrNull() ?.let(block) - -public inline fun ChatEvent.winnersOrNull(): GiveawayPublicResults.Winners? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners - -public inline fun ChatEvent.winnersOrThrow(): GiveawayPublicResults.Winners = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners - -public inline fun ChatEvent.ifWinners(block: (GiveawayPublicResults.Winners) -> T): T? = - winnersOrNull() ?.let(block) - -public inline fun GiveawayResults.winnersOrNull(): GiveawayPublicResults.Winners? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners - -public inline fun GiveawayResults.winnersOrThrow(): GiveawayPublicResults.Winners = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults.Winners - -public inline fun GiveawayResults.ifWinners(block: (GiveawayPublicResults.Winners) -> T): T? = - winnersOrNull() ?.let(block) - public inline fun ChatEvent.channelChatCreatedOrNull(): ChannelChatCreated? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated From d9c39d7a26a8c41ce396d537e5d341024a629944 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 17:31:47 +0600 Subject: [PATCH 17/65] fixes of build --- .../CallbackQueryTriggersUnhandled.kt | 2 +- .../tgbotapi/types/giveaway/GiveawayPublicResults.kt | 5 ++--- .../kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt | 1 + .../message/ChatEvents/MigratedToSupergroupTest.kt | 10 ++++------ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggersUnhandled.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggersUnhandled.kt index ef0c85a334..22f4fd4bdb 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggersUnhandled.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggersUnhandled.kt @@ -55,7 +55,7 @@ suspend fun BC.onUnhandledInlineMessageIdDataCallbackQue markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery ( - initialFilter * !SimpleFilter { triggersHolder.handleableCallbackQueriesDataHolder.isHandled(it) }, + initialFilter * !SimpleFilter { triggersHolder.handleableCallbackQueriesDataHolder.isHandled(it) }, subcontextUpdatesFilter, markerFactory, scenarioReceiver diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt index b908d2e314..85e9b9a5f6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt @@ -20,7 +20,7 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi val publicWinners: Boolean val refunded: Boolean - @Serializable(GiveawayPublicResults.Companion::class) + @Serializable data class Refunded( @SerialName(chatsField) override val chat: PreviewChat, @@ -50,7 +50,7 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi override val premiumMonths: Int? = null } - @Serializable(GiveawayPublicResults.Companion::class) + @Serializable data class Winners ( @SerialName(chatsField) override val chat: PreviewChat, @@ -157,6 +157,5 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi Surrogate.serializer().serialize(encoder, surrogate) } - } } \ 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 c7894c973c..8b1e3fe515 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 @@ -48,6 +48,7 @@ internal data class RawUpdate constructor( private val chat_boost: ChatBoostUpdated? = null, private val removed_chat_boost: ChatBoostRemoved? = null ) { + @Transient private var initedUpdate: Update? = null /** * @return One of children of [Update] interface or null in case of unknown type of update diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt index e771587cfc..d610b9cb28 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt @@ -1,9 +1,7 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.TestsJsonFormat -import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate -import dev.inmo.tgbotapi.extensions.utils.asMigratedToSupergroup -import dev.inmo.tgbotapi.extensions.utils.asSupergroupEventMessage +import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.update.abstracts.UpdateDeserializationStrategy import kotlin.test.Test @@ -41,9 +39,9 @@ class MigratedToSupergroupTest { } """.trimIndent() val update = TestsJsonFormat.decodeFromString(UpdateDeserializationStrategy, payload) - val message = update.asMessageUpdate() ?: fail("update should be of MessageUpdate subtype") - val data = message.data.asSupergroupEventMessage() ?: fail("message should be of SupergroupEventMessage subtype") - val event = data.chatEvent.asMigratedToSupergroup() ?: fail("event should be of SupergroupChatCreated subtype") + val message = update.messageUpdateOrThrow() + val data = message.data.supergroupEventMessageOrThrow() + val event = data.chatEvent.migratedToSupergroupOrThrow() assertEquals(IdChatIdentifier(57005), event.migratedFrom) } From 860e35258ce881d112113e33c51ebba4c859fed8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 17:52:57 +0600 Subject: [PATCH 18/65] update webapp part --- .../dev/inmo/tgbotapi/webapps/SettingsButton.kt | 11 +++++++++++ .../dev/inmo/tgbotapi/webapps/ThemeParams.kt | 13 +++++++++++++ .../kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt | 17 +++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/SettingsButton.kt diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/SettingsButton.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/SettingsButton.kt new file mode 100644 index 0000000000..7ea0c0bd97 --- /dev/null +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/SettingsButton.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.webapps + +external interface SettingsButton { + val isVisible: Boolean + + fun onClick(callback: () -> Unit) + fun offClick(callback: () -> Unit) + + fun show() + fun hide() +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/ThemeParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/ThemeParams.kt index b72c7b5f40..e9d19c273a 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/ThemeParams.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/ThemeParams.kt @@ -30,4 +30,17 @@ external interface ThemeParams { val buttonColorHex: Color.Hex? @JsName("button_text_color") val buttonTextColorHex: Color.Hex? + + @JsName("header_bg_color") + val headerBgColor: Color.Hex? + @JsName("accent_text_color") + val accentTextColor: Color.Hex? + @JsName("section_bg_color") + val sectionBgColor: Color.Hex? + @JsName("section_header_text_color") + val sectionHeaderTextColor: Color.Hex? + @JsName("subtitle_text_color") + val subtitleTextColor: Color.Hex? + @JsName("destructive_text_color") + val destructiveTextColor: Color.Hex? } diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt index af395cd420..d6f4fe7f4e 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/WebApp.kt @@ -54,6 +54,9 @@ external class WebApp { @JsName("CloudStorage") val cloudStorage: CloudStorage + @JsName("SettingsButton") + val settingsButton: SettingsButton + internal fun onEvent(type: String, callback: () -> Unit) @JsName("onEvent") internal fun onEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit) @@ -69,6 +72,8 @@ external class WebApp { internal fun onEventWithWriteAccessRequested(type: String, callback: (RequestStatus) -> Unit) @JsName("onEvent") internal fun onEventWithContactRequested(type: String, callback: (RequestStatus) -> Unit) + @JsName("onEvent") + internal fun onEventWithSettingsButtonClicked(type: String, callback: () -> Unit) fun offEvent(type: String, callback: () -> Unit) @JsName("offEvent") @@ -194,6 +199,18 @@ fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactReques ) } +/** + * @return The callback which should be used in case you want to turn off events handling + */ +fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = { + eventHandler(js("this").unsafeCast()) +}.also { + onEventWithSettingsButtonClicked( + type.typeName, + callback = it + ) +} + /** * @return The callback which should be used in case you want to turn off events handling */ From 430240a6ad24ee3b1d4ce3543731e0230c3b94bd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 18:06:40 +0600 Subject: [PATCH 19/65] add emoji status in the most extended chats --- .../dev/inmo/tgbotapi/types/chat/Extended.kt | 24 +++++++++++++++---- .../tgbotapi/types/chat/ExtendedAbstracts.kt | 22 ++++++++++------- 2 files changed, 33 insertions(+), 13 deletions(-) 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 017e3be087..aba9e0e404 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 @@ -35,7 +35,11 @@ data class ExtendedChannelChatImpl( @SerialName(hasHiddenMembersField) override val membersHidden: Boolean = false, @SerialName(availableReactionsField) - override val availableReactions: List? = null + override val availableReactions: List? = null, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + override val statusEmojiExpiration: TelegramDate? = null ) : ExtendedChannelChat @Serializable @@ -59,7 +63,11 @@ data class ExtendedGroupChatImpl( @SerialName(hasHiddenMembersField) override val membersHidden: Boolean = false, @SerialName(availableReactionsField) - override val availableReactions: List? = null + override val availableReactions: List? = null, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + override val statusEmojiExpiration: TelegramDate? = null ) : ExtendedGroupChat @Serializable @@ -132,7 +140,11 @@ data class ExtendedSupergroupChatImpl( @SerialName(hasHiddenMembersField) override val membersHidden: Boolean = false, @SerialName(availableReactionsField) - override val availableReactions: List? = null + override val availableReactions: List? = null, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + override val statusEmojiExpiration: TelegramDate? = null ) : ExtendedSupergroupChat @Serializable @@ -176,7 +188,11 @@ data class ExtendedForumChatImpl( @SerialName(hasHiddenMembersField) override val membersHidden: Boolean = false, @SerialName(availableReactionsField) - override val availableReactions: List? = null + override val availableReactions: List? = null, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + override val statusEmojiExpiration: TelegramDate? = null ) : ExtendedForumChat @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 36092957be..16be3e7ee4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -7,6 +7,17 @@ import dev.inmo.tgbotapi.types.reactions.Reaction import korlibs.time.DateTime import kotlinx.serialization.Serializable +@Serializable(ExtendedChatSerializer.Companion::class) +sealed interface ExtendedChat : Chat { + val chatPhoto: ChatPhoto? +} + +@Serializable(ExtendedChatSerializer.Companion::class) +sealed interface ExtendedNonBotChat : ExtendedChat { + val statusEmojiId: CustomEmojiId? + val statusEmojiExpiration: TelegramDate? +} + @Serializable(ExtendedChatSerializer.Companion::class) sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername { val linkedGroupChatId: IdChatIdentifier? @@ -18,18 +29,16 @@ sealed interface ExtendedGroupChat : GroupChat, ExtendedPublicChat { } @Serializable(ExtendedChatSerializer.Companion::class) -sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername { +sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername, ExtendedNonBotChat { val bio: String val hasPrivateForwards: Boolean val hasRestrictedVoiceAndVideoMessages: Boolean - val statusEmojiId: CustomEmojiId? - val statusEmojiExpiration: TelegramDate? val allowCreateUserIdLink: Boolean get() = hasPrivateForwards } -sealed interface ExtendedPublicChat : ExtendedChat, PublicChat { +sealed interface ExtendedPublicChat : ExtendedChat, PublicChat, ExtendedNonBotChat { val description: String val inviteLink: String? @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) @@ -65,11 +74,6 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext @Serializable(ExtendedChatSerializer.Companion::class) sealed interface ExtendedForumChat : ExtendedSupergroupChat, ForumChat -@Serializable(ExtendedChatSerializer.Companion::class) -sealed interface ExtendedChat : Chat { - val chatPhoto: ChatPhoto? -} - @Serializable(ExtendedChatSerializer.Companion::class) sealed interface ExtendedChatWithUsername : UsernameChat, ExtendedChat { val activeUsernames: List From 05bfbfe3811dbfd060ddb9e38921bdb03bd69213 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Jan 2024 13:32:08 +0600 Subject: [PATCH 20/65] start adding of colors work --- gradle/libs.versions.toml | 9 +++++---- tgbotapi.core/build.gradle | 1 + .../dev/inmo/tgbotapi/types/colors/ColorId.kt | 17 +++++++++++++++++ .../tgbotapi/webapps/{Colors.kt => Color.kt} | 0 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt rename tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/{Colors.kt => Color.kt} (100%) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8befa9eaa5..c27a805358 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,14 +6,14 @@ kotlin-coroutines = "1.7.3" javax-activation = "1.1.1" -korlibs = "4.0.10" +korlibs = "5.3.0" uuid = "0.8.2" ktor = "2.3.7" ksp = "1.9.22-1.0.16" kotlin-poet = "1.15.3" -microutils = "0.20.23" +microutils = "0.20.25" kslog = "1.3.1" versions = "0.50.0" @@ -41,11 +41,12 @@ ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version. javax-activation = { module = "javax.activation:activation", version.ref = "javax-activation" } -korlibs-klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "korlibs" } -korlibs-krypto = { module = "com.soywiz.korlibs.krypto:krypto", version.ref = "korlibs" } +korlibs-klock = { module = "com.soywiz.korge:korlibs-time", version.ref = "korlibs" } +korlibs-krypto = { module = "com.soywiz.korge:korlibs-crypto", version.ref = "korlibs" } uuid = { module = "com.benasher44:uuid", version.ref = "uuid" } +microutils-colors-common = { module = "dev.inmo:micro_utils.colors.common", version.ref = "microutils" } microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.ref = "microutils" } microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" } microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" } diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index f0e60eaf0e..51ee82808d 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -22,6 +22,7 @@ kotlin { api libs.korlibs.krypto api libs.uuid + api libs.microutils.colors.common api libs.microutils.coroutines api libs.microutils.serialization.base64 api libs.microutils.serialization.encapsulator diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt new file mode 100644 index 0000000000..7f882e7491 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.types.colors + +import dev.inmo.micro_utils.colors.common.HEXAColor +import kotlinx.serialization.Serializable +import kotlin.jvm.JvmInline + +@Serializable +@JvmInline +value class ColorId( + val int: Int +) { + companion object { + val defaultAccentColors = mapOf( + ColorId(0) to HEXAColor(0xff0000ffu), + ) + } +} \ No newline at end of file diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/Colors.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/Color.kt similarity index 100% rename from tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/Colors.kt rename to tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/Color.kt From 825ecc1d73ed7de8536c7ea5e2f72089f0009da4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Jan 2024 13:45:30 +0600 Subject: [PATCH 21/65] fixes and note in CHANGELOG --- CHANGELOG.md | 4 +++ .../extensions/api/LiveLocationProvider.kt | 1 + .../tgbotapi/requests/send/polls/SendPoll.kt | 2 ++ .../requests/stickers/CreateNewStickerSet.kt | 4 +-- .../requests/stickers/InputSticker.kt | 4 +-- .../dev/inmo/tgbotapi/types/colors/ColorId.kt | 2 +- .../ChatEvents/voice/VideoChatEnded.kt | 1 + .../dev/inmo/tgbotapi/types/polls/Poll.kt | 1 + .../extensions/utils/ClassCastsNew.kt | 28 +++++++++++++------ .../extensions/utils/extensions/raw/Poll.kt | 1 + 10 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d474e4617..d4891f3983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 10.0.0 +**IN THIS UPDATE KLOCK DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-time` UP TO 5.3.0 VERSION** + +**IN THIS UPDATE KRYPTO DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-crypto` UP TO 5.3.0 VERSION** + ## 9.4.3 **IetfLanguageCode has been renamed to IetfLang in MicroUtils** diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt index 4222a29c89..7d2d93b6d0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt @@ -24,6 +24,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.LocationContent import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull import io.ktor.utils.io.core.Closeable +import korlibs.time.millisecondsLong import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.currentCoroutineContext diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt index 2b16aaac31..1d63f7a816 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt @@ -16,6 +16,8 @@ import dev.inmo.tgbotapi.types.message.content.PollContent import dev.inmo.tgbotapi.types.message.toRawMessageEntities import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.utils.extensions.makeString +import korlibs.time.millisecondsLong +import korlibs.time.seconds import kotlinx.serialization.* private val commonResultDeserializer: DeserializationStrategy> = TelegramBotAPIMessageDeserializationStrategyClass() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt index 5cf4afa885..9bcaee8730 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/CreateNewStickerSet.kt @@ -145,7 +145,7 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction { object CreateNewStickerSetSerializer : KSerializer, MapperSerializer( CreateNewStickerSet.SurrogateCreateNewSticker.serializer(), - { + { it -> CreateNewStickerSet.SurrogateCreateNewSticker( it.userId, it.name, @@ -156,7 +156,7 @@ object CreateNewStickerSetSerializer : KSerializer, (it as? CreateNewStickerSet.CustomEmoji)?.needsRepainting ) }, - { + { it -> when (it.stickerType) { StickerType.CustomEmoji -> CreateNewStickerSet.CustomEmoji( it.userId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt index 874fff6676..b0a9cd4591 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/stickers/InputSticker.kt @@ -57,7 +57,7 @@ sealed interface InputSticker { object InputStickerSerializer : KSerializer, MapperSerializer( SurrogateInputSticker.serializer(), - { + { it -> when (it) { is InputSticker.Mask -> SurrogateInputSticker( it.sticker, @@ -82,7 +82,7 @@ object InputStickerSerializer : KSerializer, MapperSerializer when (it.internalType) { StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji( it.sticker, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt index 7f882e7491..1e8e3e6e26 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt @@ -11,7 +11,7 @@ value class ColorId( ) { companion object { val defaultAccentColors = mapOf( - ColorId(0) to HEXAColor(0xff0000ffu), + ColorId(0) to setOf(HEXAColor(0xff0000ffu)), ) } } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt index a9805c8d60..ded85cf7c9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VideoChatEnded.kt @@ -5,6 +5,7 @@ import korlibs.time.seconds import dev.inmo.tgbotapi.types.Seconds import dev.inmo.tgbotapi.types.durationField import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent +import korlibs.time.milliseconds import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt index 07110b525a..bb07e64c16 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.toRawMessageEntities import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat +import korlibs.time.seconds import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder 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 70b2517155..67d1718676 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 @@ -122,6 +122,7 @@ import dev.inmo.tgbotapi.types.chat.ExtendedChat import dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername import dev.inmo.tgbotapi.types.chat.ExtendedForumChat import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat +import dev.inmo.tgbotapi.types.chat.ExtendedNonBotChat import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat @@ -1980,6 +1981,24 @@ public inline fun Chat.unknownExtendedChatOrThrow(): UnknownExtendedChat = this public inline fun Chat.ifUnknownExtendedChat(block: (UnknownExtendedChat) -> T): T? = unknownExtendedChatOrNull() ?.let(block) +public inline fun Chat.extendedChatOrNull(): ExtendedChat? = this as? + dev.inmo.tgbotapi.types.chat.ExtendedChat + +public inline fun Chat.extendedChatOrThrow(): ExtendedChat = this as + dev.inmo.tgbotapi.types.chat.ExtendedChat + +public inline fun Chat.ifExtendedChat(block: (ExtendedChat) -> T): T? = extendedChatOrNull() + ?.let(block) + +public inline fun Chat.extendedNonBotChatOrNull(): ExtendedNonBotChat? = this as? + dev.inmo.tgbotapi.types.chat.ExtendedNonBotChat + +public inline fun Chat.extendedNonBotChatOrThrow(): ExtendedNonBotChat = this as + dev.inmo.tgbotapi.types.chat.ExtendedNonBotChat + +public inline fun Chat.ifExtendedNonBotChat(block: (ExtendedNonBotChat) -> T): T? = + extendedNonBotChatOrNull() ?.let(block) + public inline fun Chat.extendedChannelChatOrNull(): ExtendedChannelChat? = this as? dev.inmo.tgbotapi.types.chat.ExtendedChannelChat @@ -2034,15 +2053,6 @@ public inline fun Chat.extendedForumChatOrThrow(): ExtendedForumChat = this as public inline fun Chat.ifExtendedForumChat(block: (ExtendedForumChat) -> T): T? = extendedForumChatOrNull() ?.let(block) -public inline fun Chat.extendedChatOrNull(): ExtendedChat? = this as? - dev.inmo.tgbotapi.types.chat.ExtendedChat - -public inline fun Chat.extendedChatOrThrow(): ExtendedChat = this as - dev.inmo.tgbotapi.types.chat.ExtendedChat - -public inline fun Chat.ifExtendedChat(block: (ExtendedChat) -> T): T? = extendedChatOrNull() - ?.let(block) - public inline fun Chat.extendedChatWithUsernameOrNull(): ExtendedChatWithUsername? = this as? dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Poll.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Poll.kt index c4ede211b5..97ece7e16b 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Poll.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Poll.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.utils.RiskFeature +import korlibs.time.seconds import kotlinx.serialization.json.jsonPrimitive @RiskFeature(RawFieldsUsageWarning) From e66537ee32fdf33246c140a562c56fb3653365af Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 5 Jan 2024 20:30:07 +0600 Subject: [PATCH 22/65] fixes --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 4 ++ .../dev/inmo/tgbotapi/types/chat/Extended.kt | 69 +++++++++++++++++-- .../tgbotapi/types/chat/ExtendedAbstracts.kt | 5 ++ .../dev/inmo/tgbotapi/types/colors/ColorId.kt | 8 +-- 4 files changed, 73 insertions(+), 13 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 77fe66ed95..f4482e3fec 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -232,6 +232,10 @@ const val hasPrivateForwardsField = "has_private_forwards" const val hasRestrictedVoiceAndVideoMessagesField = "has_restricted_voice_and_video_messages" const val emojiStatusCustomEmojiIdField = "emoji_status_custom_emoji_id" const val emojiStatusExpirationDateField = "emoji_status_expiration_date" +const val accentColorIdField = "accent_color_id" +const val profileAccentColorIdField = "profile_accent_color_id" +const val backgroundCustomEmojiIdField = "background_custom_emoji_id" +const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id" const val iconCustomEmojiIdField = "icon_custom_emoji_id" const val canJoinGroupsField = "can_join_groups" const val canReadAllGroupMessagesField = "can_read_all_group_messages" 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 aba9e0e404..4478b120ca 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 @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.chat import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.colors.ColorId import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer import dev.inmo.tgbotapi.types.reactions.Reaction @@ -39,7 +40,15 @@ data class ExtendedChannelChatImpl( @SerialName(emojiStatusCustomEmojiIdField) override val statusEmojiId: CustomEmojiId? = null, @SerialName(emojiStatusExpirationDateField) - override val statusEmojiExpiration: TelegramDate? = null + override val statusEmojiExpiration: TelegramDate? = null, + @SerialName(accentColorIdField) + override val accentColorId: ColorId = ColorId(0), + @SerialName(profileAccentColorIdField) + override val profileAccentColorId: ColorId? = null, + @SerialName(backgroundCustomEmojiIdField) + override val backgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(profileBackgroundCustomEmojiIdField) + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, ) : ExtendedChannelChat @Serializable @@ -67,7 +76,15 @@ data class ExtendedGroupChatImpl( @SerialName(emojiStatusCustomEmojiIdField) override val statusEmojiId: CustomEmojiId? = null, @SerialName(emojiStatusExpirationDateField) - override val statusEmojiExpiration: TelegramDate? = null + override val statusEmojiExpiration: TelegramDate? = null, + @SerialName(accentColorIdField) + override val accentColorId: ColorId = ColorId(0), + @SerialName(profileAccentColorIdField) + override val profileAccentColorId: ColorId? = null, + @SerialName(backgroundCustomEmojiIdField) + override val backgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(profileBackgroundCustomEmojiIdField) + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, ) : ExtendedGroupChat @Serializable @@ -94,7 +111,15 @@ data class ExtendedPrivateChatImpl( @SerialName(emojiStatusCustomEmojiIdField) override val statusEmojiId: CustomEmojiId? = null, @SerialName(emojiStatusExpirationDateField) - override val statusEmojiExpiration: TelegramDate? = null + override val statusEmojiExpiration: TelegramDate? = null, + @SerialName(accentColorIdField) + override val accentColorId: ColorId = ColorId(0), + @SerialName(profileAccentColorIdField) + override val profileAccentColorId: ColorId? = null, + @SerialName(backgroundCustomEmojiIdField) + override val backgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(profileBackgroundCustomEmojiIdField) + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, ) : ExtendedPrivateChat typealias ExtendedUser = ExtendedPrivateChatImpl @@ -144,7 +169,15 @@ data class ExtendedSupergroupChatImpl( @SerialName(emojiStatusCustomEmojiIdField) override val statusEmojiId: CustomEmojiId? = null, @SerialName(emojiStatusExpirationDateField) - override val statusEmojiExpiration: TelegramDate? = null + override val statusEmojiExpiration: TelegramDate? = null, + @SerialName(accentColorIdField) + override val accentColorId: ColorId = ColorId(0), + @SerialName(profileAccentColorIdField) + override val profileAccentColorId: ColorId? = null, + @SerialName(backgroundCustomEmojiIdField) + override val backgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(profileBackgroundCustomEmojiIdField) + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, ) : ExtendedSupergroupChat @Serializable @@ -192,7 +225,15 @@ data class ExtendedForumChatImpl( @SerialName(emojiStatusCustomEmojiIdField) override val statusEmojiId: CustomEmojiId? = null, @SerialName(emojiStatusExpirationDateField) - override val statusEmojiExpiration: TelegramDate? = null + override val statusEmojiExpiration: TelegramDate? = null, + @SerialName(accentColorIdField) + override val accentColorId: ColorId = ColorId(0), + @SerialName(profileAccentColorIdField) + override val profileAccentColorId: ColorId? = null, + @SerialName(backgroundCustomEmojiIdField) + override val backgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(profileBackgroundCustomEmojiIdField) + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, ) : ExtendedForumChat @Serializable @@ -211,7 +252,15 @@ data class ExtendedBot( @SerialName(supportInlineQueriesField) val supportsInlineQueries: Boolean = false, @SerialName(photoField) - override val chatPhoto: ChatPhoto? = null + override val chatPhoto: ChatPhoto? = null, + @SerialName(accentColorIdField) + override val accentColorId: ColorId = ColorId(0), + @SerialName(profileAccentColorIdField) + override val profileAccentColorId: ColorId? = null, + @SerialName(backgroundCustomEmojiIdField) + override val backgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(profileBackgroundCustomEmojiIdField) + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, ) : Bot(), ExtendedChat { @SerialName(isBotField) private val isBot = true @@ -223,4 +272,12 @@ data class UnknownExtendedChat( val rawJson: JsonObject ) : ExtendedChat { override val chatPhoto: ChatPhoto? = null + @SerialName(accentColorIdField) + override val accentColorId: ColorId = ColorId(0) + @SerialName(profileAccentColorIdField) + override val profileAccentColorId: ColorId? = null + @SerialName(backgroundCustomEmojiIdField) + override val backgroundCustomEmojiId: CustomEmojiId? = null + @SerialName(profileBackgroundCustomEmojiIdField) + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,\ } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 16be3e7ee4..7df107fade 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.chat import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.colors.ColorId import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer import dev.inmo.tgbotapi.types.reactions.Reaction @@ -10,6 +11,10 @@ import kotlinx.serialization.Serializable @Serializable(ExtendedChatSerializer.Companion::class) sealed interface ExtendedChat : Chat { val chatPhoto: ChatPhoto? + val accentColorId: ColorId + val profileAccentColorId: ColorId? + val backgroundCustomEmojiId: CustomEmojiId? + val profileBackgroundCustomEmojiId: CustomEmojiId? } @Serializable(ExtendedChatSerializer.Companion::class) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt index 1e8e3e6e26..c53bb5410f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt @@ -8,10 +8,4 @@ import kotlin.jvm.JvmInline @JvmInline value class ColorId( val int: Int -) { - companion object { - val defaultAccentColors = mapOf( - ColorId(0) to setOf(HEXAColor(0xff0000ffu)), - ) - } -} \ No newline at end of file +) \ No newline at end of file From 14756fd6e8cba9720dbbce3b67c89578ed02c3e7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 15:16:33 +0600 Subject: [PATCH 23/65] add support of has_visible_history field --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt | 10 +++++++++- .../dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index f4482e3fec..29e4b67754 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -236,6 +236,7 @@ const val accentColorIdField = "accent_color_id" const val profileAccentColorIdField = "profile_accent_color_id" const val backgroundCustomEmojiIdField = "background_custom_emoji_id" const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id" +const val hasVisibleHistoryField = "has_visible_history" const val iconCustomEmojiIdField = "icon_custom_emoji_id" const val canJoinGroupsField = "can_join_groups" const val canReadAllGroupMessagesField = "can_read_all_group_messages" 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 4478b120ca..0041828a48 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 @@ -49,6 +49,8 @@ data class ExtendedChannelChatImpl( override val backgroundCustomEmojiId: CustomEmojiId? = null, @SerialName(profileBackgroundCustomEmojiIdField) override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false ) : ExtendedChannelChat @Serializable @@ -85,6 +87,8 @@ data class ExtendedGroupChatImpl( override val backgroundCustomEmojiId: CustomEmojiId? = null, @SerialName(profileBackgroundCustomEmojiIdField) override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false, ) : ExtendedGroupChat @Serializable @@ -178,6 +182,8 @@ data class ExtendedSupergroupChatImpl( override val backgroundCustomEmojiId: CustomEmojiId? = null, @SerialName(profileBackgroundCustomEmojiIdField) override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false, ) : ExtendedSupergroupChat @Serializable @@ -234,6 +240,8 @@ data class ExtendedForumChatImpl( override val backgroundCustomEmojiId: CustomEmojiId? = null, @SerialName(profileBackgroundCustomEmojiIdField) override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false, ) : ExtendedForumChat @Serializable @@ -279,5 +287,5 @@ data class UnknownExtendedChat( @SerialName(backgroundCustomEmojiIdField) override val backgroundCustomEmojiId: CustomEmojiId? = null @SerialName(profileBackgroundCustomEmojiIdField) - override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,\ + override val profileBackgroundCustomEmojiId: CustomEmojiId? = null } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 7df107fade..1b044a5b59 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -50,6 +50,7 @@ sealed interface ExtendedPublicChat : ExtendedChat, PublicChat, ExtendedNonBotCh val pinnedMessage: Message? val membersHidden: Boolean val availableReactions: List? + val newMembersSeeHistory: Boolean } @Serializable(ExtendedChatSerializer.Companion::class) From 5190f7b856f1b548d6021d0bb46b759f25edeb3b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 15:21:32 +0600 Subject: [PATCH 24/65] add support of inaccessible message --- .../kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt | 7 +++++++ .../dev/inmo/tgbotapi/types/message/abstracts/Message.kt | 9 +++++++++ 2 files changed, 16 insertions(+) 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 5d50d272d4..59b2fb6061 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 @@ -287,6 +287,13 @@ internal data class RawMessage( } val asMessage: Message by lazy { + if (date.date == 0L) { + return@lazy InaccessibleMessage( + chat, + messageId + ) + } + try { chatEvent?.let { chatEvent -> when (chat) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt index 5e1fcba29c..6d01402657 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt @@ -19,6 +19,15 @@ interface Message : WithPreviewChatAndMessageId { val date: DateTime } +@Serializable +data class InaccessibleMessage( + override val chat: PreviewChat, + override val messageId: MessageId, +) : Message { + override val date: DateTime + get() = DateTime.invoke(0L) +} + data class UnknownMessageType( override val messageId: MessageId, override val chat: PreviewChat, From b5f4219635073eac5b7e4babaf47907f02c3e89b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 15:52:49 +0600 Subject: [PATCH 25/65] fixes in inaccessible message support --- .../tgbotapi/extensions/api/DeleteMessage.kt | 9 +- .../tgbotapi/extensions/api/DeleteMessages.kt | 8 +- .../tgbotapi/extensions/api/ForwardMessage.kt | 6 +- .../extensions/api/ForwardMessages.kt | 6 +- .../extensions/api/LiveLocationProvider.kt | 21 +- .../inmo/tgbotapi/extensions/api/StopPoll.kt | 6 +- .../api/chat/modify/PinChatMessage.kt | 4 +- .../api/chat/modify/UnpinChatMessage.kt | 4 +- .../tgbotapi/extensions/api/edit/Edits.kt | 4 +- .../edit/caption/EditChatMessageCaption.kt | 4 +- .../EditChatMessageReplyMarkup.kt | 4 +- .../api/edit/text/EditChatMessageText.kt | 8 +- .../extensions/api/send/CopyMessage.kt | 10 +- .../extensions/api/send/CopyMessages.kt | 4 +- .../tgbotapi/extensions/api/send/Replies.kt | 143 +++++++------- .../api/send/RepliesWithChatsAndMessages.kt | 4 +- .../api/send/SetMessageReactions.kt | 10 +- .../filters/MessageFilterByChat.kt | 10 +- .../MessageFilterExcludingMediaGroups.kt | 4 +- .../filters/MessageFilterForums.kt | 2 +- .../MessageMarkerFactories.kt | 8 +- .../dev/inmo/tgbotapi/requests/GetUpdates.kt | 3 +- .../tgbotapi/types/chat/ExtendedAbstracts.kt | 2 +- .../types/giveaway/GiveawayPrivateResults.kt | 6 +- .../message/ChannelContentMessageImpl.kt | 3 +- .../types/message/ChatEvents/PinnedMessage.kt | 1 + .../tgbotapi/types/message/GroupMessages.kt | 14 +- .../tgbotapi/types/message/PassportMessage.kt | 5 +- .../message/PrivateContentMessageImpl.kt | 4 +- .../inmo/tgbotapi/types/message/RawMessage.kt | 2 +- .../message/abstracts/ChatEventMessage.kt | 2 +- .../types/message/abstracts/CommonMessage.kt | 2 +- .../types/message/abstracts/ContentMessage.kt | 2 +- .../message/abstracts/FromUserMessage.kt | 2 +- .../types/message/abstracts/Message.kt | 9 +- .../abstracts/PossiblyEditedMessage.kt | 2 +- .../abstracts/PossiblyForwardedMessage.kt | 2 +- .../abstracts/PossiblyPaymentMessage.kt | 2 +- .../message/abstracts/PossiblyReplyMessage.kt | 2 +- .../message/abstracts/PossiblyTopicMessage.kt | 2 +- .../types/message/abstracts/SignedMessage.kt | 2 +- .../types/message/content/Abstracts.kt | 2 +- .../message/content/MediaGroupContent.kt | 1 - .../types/message/content/StoryContent.kt | 2 - .../callback/AbstractMessageCallbackQuery.kt | 9 + .../InaccessibleMessageCallbackQuery.kt | 7 + .../InaccessibleMessageDataCallbackQuery.kt | 16 ++ ...ssibleMessageGameShortNameCallbackQuery.kt | 16 ++ .../queries/callback/MessageCallbackQuery.kt | 4 +- .../queries/callback/RawCallbackQuery.kt | 24 ++- .../types/update/ChannelPostUpdate.kt | 6 +- .../tgbotapi/types/update/MessageUpdate.kt | 6 +- .../inmo/tgbotapi/types/update/RawUpdate.kt | 4 +- .../update/abstracts/BaseMessageUpdate.kt | 4 +- .../update/abstracts/BaseSentMessageUpdate.kt | 4 +- .../utils/extensions/OptionalThreadId.kt | 4 +- .../tgbotapi/extensions/utils/ClassCasts.kt | 186 +++++++++--------- .../extensions/utils/ClassCastsNew.kt | 70 +++++++ .../extensions/utils/extensions/Same.kt | 40 ++-- .../utils/extensions/UpdateChatRetriever.kt | 3 +- .../utils/extensions/raw/Message.kt | 111 +++++------ .../utils/formatting/LinksFormatting.kt | 6 +- .../utils/updates/MessageFilters.kt | 10 +- 63 files changed, 493 insertions(+), 390 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/AbstractMessageCallbackQuery.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageCallbackQuery.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageDataCallbackQuery.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageGameShortNameCallbackQuery.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt index 90c7f00b35..ab2c648790 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt @@ -6,9 +6,8 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent suspend fun TelegramBot.deleteMessage( chatId: ChatIdentifier, @@ -23,7 +22,7 @@ suspend fun TelegramBot.deleteMessage( ) = deleteMessage(chat.id, messageId) suspend fun TelegramBot.deleteMessage( - message: Message + message: AccessibleMessage ): Boolean { val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>) if (mediaGroupContent == null) { @@ -46,9 +45,9 @@ suspend fun TelegramBot.delete( ) = deleteMessage(chat, messageId) suspend fun TelegramBot.delete( - message: Message + message: AccessibleMessage ) = deleteMessage(message) -suspend fun Message.delete( +suspend fun AccessibleMessage.delete( requestsExecutor: TelegramBot ) = requestsExecutor.deleteMessage(this) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt index 406af2bae1..c44d86a107 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt @@ -1,11 +1,9 @@ package dev.inmo.tgbotapi.extensions.api import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.DeleteMessage import dev.inmo.tgbotapi.requests.DeleteMessages -import dev.inmo.tgbotapi.requests.ForwardMessages import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage suspend fun TelegramBot.deleteMessages( chatId: ChatIdentifier, @@ -37,7 +35,7 @@ suspend fun TelegramBot.deleteMessages( ) suspend fun TelegramBot.deleteMessages( - messages: List + messages: List ) = messages.groupBy { it.chat }.map { (chat, messages) -> deleteMessages( chatId = chat.id, @@ -63,5 +61,5 @@ suspend fun TelegramBot.delete( ) = deleteMessages(chatId = chatId, messageIds = (listOf(firstMessageId, secondMessageId) + messageIds.toList())) suspend fun TelegramBot.delete( - messages: List + messages: List ) = deleteMessages(messages) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt index 4893eb13c8..8bdde19ab8 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.threadId suspend fun TelegramBot.forwardMessage( @@ -49,7 +49,7 @@ suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage( toChatId: ChatIdentifier, - message: Message, + message: AccessibleMessage, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false @@ -57,7 +57,7 @@ suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage( toChat: Chat, - message: Message, + message: AccessibleMessage, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt index 894b2ca1da..edbb1bd4c0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.ForwardMessages import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage suspend fun TelegramBot.forwardMessages( toChatId: ChatIdentifier, @@ -66,7 +66,7 @@ suspend fun TelegramBot.forwardMessages( suspend fun TelegramBot.forwardMessages( toChatId: ChatIdentifier, - messages: List, + messages: List, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -141,7 +141,7 @@ suspend fun TelegramBot.forward( suspend fun TelegramBot.forward( toChatId: ChatIdentifier, - messages: List, + messages: List, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt index 7d2d93b6d0..de3551c5a2 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt @@ -2,39 +2,24 @@ package dev.inmo.tgbotapi.extensions.api import korlibs.time.DateTime import korlibs.time.TimeSpan -import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob -import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions -import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.edit.edit import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation -import dev.inmo.tgbotapi.extensions.api.send.send -import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation import dev.inmo.tgbotapi.requests.send.SendLiveLocation import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.location.LiveLocation -import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.location.StaticLocation import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.LocationContent import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull import io.ktor.utils.io.core.Closeable import korlibs.time.millisecondsLong import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.CoroutineStart -import kotlinx.coroutines.currentCoroutineContext -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import kotlin.js.JsName -import kotlin.jvm.JvmName import kotlin.math.ceil val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L @@ -253,7 +238,7 @@ suspend fun TelegramBot.startLiveLocation( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.replyWithLiveLocation( - to: Message, + to: AccessibleMessage, scope: CoroutineScope, latitude: Double, longitude: Double, @@ -288,7 +273,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.replyWithLiveLocation( - to: Message, + to: AccessibleMessage, scope: CoroutineScope, location: StaticLocation, liveTimeMillis: Long = defaultLivePeriodDelayMillis, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt index 5bfd721463..3bb90f8cbe 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.StopPoll import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -35,7 +35,7 @@ suspend fun TelegramBot.stopPoll( */ suspend fun TelegramBot.stopPoll( chatId: IdChatIdentifier, - message: Message, + message: AccessibleMessage, replyMarkup: InlineKeyboardMarkup? = null ) = stopPoll(chatId, message.messageId, replyMarkup) @@ -45,6 +45,6 @@ suspend fun TelegramBot.stopPoll( */ suspend fun TelegramBot.stopPoll( chat: Chat, - message: Message, + message: AccessibleMessage, replyMarkup: InlineKeyboardMarkup? = null ) = stopPoll(chat.id, message.messageId, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt index af33a946db..01a66130c5 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage suspend fun TelegramBot.pinChatMessage( chatId: ChatIdentifier, @@ -20,6 +20,6 @@ suspend fun TelegramBot.pinChatMessage( ) = pinChatMessage(chat.id, messageId, disableNotification) suspend fun TelegramBot.pinChatMessage( - message: Message, + message: AccessibleMessage, disableNotification: Boolean = false ) = pinChatMessage(message.chat.id, message.messageId, disableNotification) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt index b902698c38..2d9c5cc53c 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt @@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage suspend fun TelegramBot.unpinChatMessage( chatId: ChatIdentifier, @@ -18,5 +18,5 @@ suspend fun TelegramBot.unpinChatMessage( ) = unpinChatMessage(chat.id, messageId) suspend fun TelegramBot.unpinChatMessage( - message: Message + message: AccessibleMessage ) = unpinChatMessage(message.chat.id, message.messageId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt index f7f9690a67..c08d54d625 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt @@ -14,7 +14,7 @@ import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList @@ -181,7 +181,7 @@ suspend fun TelegramBot.edit( * as a builder for that */ suspend fun TelegramBot.edit( - message: Message, + message: AccessibleMessage, replyMarkup: InlineKeyboardMarkup? = null ) = editMessageReplyMarkup(message, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt index e1ded4811e..f7992ccd8b 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.MediaContent import dev.inmo.tgbotapi.utils.RiskFeature @@ -98,7 +98,7 @@ suspend fun TelegramBot.editMessageCaption( */ @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not media message this method will throw an exception") suspend fun TelegramBot.editMessageCaption( - message: Message, + message: AccessibleMessage, entities: List, replyMarkup: InlineKeyboardMarkup? = null ): ContentMessage where T : TextedWithTextSources, T : MediaContent { diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/reply_markup/EditChatMessageReplyMarkup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/reply_markup/EditChatMessageReplyMarkup.kt index dedb5f38b7..86756fd27b 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/reply_markup/EditChatMessageReplyMarkup.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/reply_markup/EditChatMessageReplyMarkup.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -35,7 +35,7 @@ suspend fun TelegramBot.editMessageReplyMarkup( * as a builder for that */ suspend fun TelegramBot.editMessageReplyMarkup( - message: Message, + message: AccessibleMessage, replyMarkup: InlineKeyboardMarkup? = null ) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt index 1cda2d3fd7..3d00e4074c 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt @@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.utils.* @@ -174,7 +174,7 @@ suspend fun TelegramBot.editMessageText( */ @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") suspend fun TelegramBot.editMessageText( - message: Message, + message: AccessibleMessage, entities: TextSourcesList, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null @@ -186,7 +186,7 @@ suspend fun TelegramBot.editMessageText( */ @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") suspend fun TelegramBot.editMessageText( - message: Message, + message: AccessibleMessage, separator: TextSource? = null, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, @@ -199,7 +199,7 @@ suspend fun TelegramBot.editMessageText( */ @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") suspend fun TelegramBot.editMessageText( - message: Message, + message: AccessibleMessage, separator: String, linkPreviewOptions: LinkPreviewOptions? = null, replyMarkup: InlineKeyboardMarkup? = null, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt index 40ee1f326d..fe539e90ab 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt @@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.threadId /** @@ -186,7 +186,7 @@ suspend inline fun TelegramBot.copyMessage( */ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, - message: Message, + message: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, threadId: MessageThreadId? = toChatId.threadId, @@ -203,7 +203,7 @@ suspend inline fun TelegramBot.copyMessage( */ suspend inline fun TelegramBot.copyMessage( toChat: Chat, - message: Message, + message: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, threadId: MessageThreadId? = toChat.id.threadId, @@ -220,7 +220,7 @@ suspend inline fun TelegramBot.copyMessage( */ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, - message: Message, + message: AccessibleMessage, entities: TextSourcesList, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, @@ -236,7 +236,7 @@ suspend inline fun TelegramBot.copyMessage( */ suspend inline fun TelegramBot.copyMessage( toChat: Chat, - message: Message, + message: AccessibleMessage, entities: TextSourcesList, threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt index cfca65c3ff..3fabdeb877 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.CopyMessages import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage suspend fun TelegramBot.copyMessages( toChatId: ChatIdentifier, @@ -66,7 +66,7 @@ suspend fun TelegramBot.copyMessages( suspend fun TelegramBot.copyMessages( toChatId: ChatIdentifier, - messages: List, + messages: List, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 8552f54aae..09b3cd0ea3 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -22,8 +22,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.location.* -import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.payments.LabeledPrice @@ -44,7 +43,7 @@ import kotlin.jvm.JvmName * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, phoneNumber: String, firstName: String, lastName: String? = null, @@ -70,7 +69,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, contact: Contact, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -95,7 +94,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.replyWithDice( - to: Message, + to: AccessibleMessage, animationType: DiceAnimationType? = null, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -108,7 +107,7 @@ suspend inline fun TelegramBot.replyWithDice( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, animationType: DiceAnimationType, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -124,7 +123,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, latitude: Double, longitude: Double, disableNotification: Boolean = false, @@ -148,7 +147,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, location: StaticLocation, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -173,7 +172,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, text: String, parseMode: ParseMode? = null, linkPreviewOptions: LinkPreviewOptions? = null, @@ -199,7 +198,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, entities: TextSourcesList, linkPreviewOptions: LinkPreviewOptions? = null, disableNotification: Boolean = false, @@ -223,7 +222,7 @@ suspend inline fun TelegramBot.reply( * as a builder for that */ suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, separator: TextSource? = null, linkPreviewOptions: LinkPreviewOptions? = null, disableNotification: Boolean = false, @@ -238,7 +237,7 @@ suspend fun TelegramBot.reply( * as a builder for that */ suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, separator: String, linkPreviewOptions: LinkPreviewOptions? = null, disableNotification: Boolean = false, @@ -256,7 +255,7 @@ suspend fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, latitude: Double, longitude: Double, title: String, @@ -288,7 +287,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, location: StaticLocation, title: String, address: String, @@ -319,7 +318,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, venue: Venue, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -340,7 +339,7 @@ suspend inline fun TelegramBot.reply( // Game suspend inline fun TelegramBot.replyWithGame( - to: Message, + to: AccessibleMessage, gameShortName: String, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -351,7 +350,7 @@ suspend inline fun TelegramBot.replyWithGame( ) suspend inline fun TelegramBot.replyWithGame( - to: Message, + to: AccessibleMessage, game: Game, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -362,7 +361,7 @@ suspend inline fun TelegramBot.replyWithGame( ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, game: Game, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -374,7 +373,7 @@ suspend inline fun TelegramBot.reply( // Animation suspend inline fun TelegramBot.replyWithAnimation( - to: Message, + to: AccessibleMessage, animation: InputFile, thumb: InputFile? = null, text: String? = null, @@ -406,7 +405,7 @@ suspend inline fun TelegramBot.replyWithAnimation( ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, @@ -421,7 +420,7 @@ suspend inline fun TelegramBot.reply( ) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( - to: Message, + to: AccessibleMessage, animation: InputFile, entities: TextSourcesList, spoilered: Boolean = false, @@ -451,7 +450,7 @@ suspend inline fun TelegramBot.replyWithAnimation( ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, animation: AnimationFile, entities: TextSourcesList, spoilered: Boolean = false, @@ -468,7 +467,7 @@ suspend inline fun TelegramBot.reply( // Audio suspend inline fun TelegramBot.replyWithAudio( - to: Message, + to: AccessibleMessage, audio: InputFile, thumb: InputFile? = null, text: String? = null, @@ -483,7 +482,7 @@ suspend inline fun TelegramBot.replyWithAudio( ) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, audio: AudioFile, text: String? = null, parseMode: ParseMode? = null, @@ -495,7 +494,7 @@ suspend inline fun TelegramBot.reply( ) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAudio( - to: Message, + to: AccessibleMessage, audio: InputFile, thumb: InputFile? = null, entities: TextSourcesList, @@ -509,7 +508,7 @@ suspend inline fun TelegramBot.replyWithAudio( ) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, audio: AudioFile, entities: TextSourcesList, title: String? = null, @@ -523,7 +522,7 @@ suspend inline fun TelegramBot.reply( // Documents suspend inline fun TelegramBot.replyWithDocument( - to: Message, + to: AccessibleMessage, document: InputFile, thumb: InputFile? = null, text: String? = null, @@ -536,7 +535,7 @@ suspend inline fun TelegramBot.replyWithDocument( ) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, @@ -548,7 +547,7 @@ suspend inline fun TelegramBot.reply( ) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( - to: Message, + to: AccessibleMessage, document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, @@ -560,7 +559,7 @@ suspend inline fun TelegramBot.replyWithDocument( ) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, document: DocumentFile, entities: TextSourcesList, disableNotification: Boolean = false, @@ -575,7 +574,7 @@ suspend inline fun TelegramBot.reply( @RiskFeature(rawSendingMediaGroupsWarning) suspend inline fun TelegramBot.replyWithMediaGroup( - to: Message, + to: AccessibleMessage, media: List, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -583,7 +582,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( ) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithPlaylist( - to: Message, + to: AccessibleMessage, media: List, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -591,7 +590,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( ) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithDocuments( - to: Message, + to: AccessibleMessage, media: List, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -599,7 +598,7 @@ suspend inline fun TelegramBot.replyWithDocuments( ) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithGallery( - to: Message, + to: AccessibleMessage, media: List, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -610,7 +609,7 @@ suspend inline fun TelegramBot.replyWithGallery( // Photo suspend inline fun TelegramBot.replyWithPhoto( - to: Message, + to: AccessibleMessage, fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, @@ -622,7 +621,7 @@ suspend inline fun TelegramBot.replyWithPhoto( ) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photo: Photo, text: String? = null, parseMode: ParseMode? = null, @@ -634,7 +633,7 @@ suspend inline fun TelegramBot.reply( ) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, @@ -647,7 +646,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithPhoto( - to: Message, + to: AccessibleMessage, fileId: InputFile, entities: TextSourcesList, spoilered: Boolean = false, @@ -658,7 +657,7 @@ suspend inline fun TelegramBot.replyWithPhoto( ) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photo: Photo, entities: TextSourcesList, spoilered: Boolean = false, @@ -669,7 +668,7 @@ suspend inline fun TelegramBot.reply( ) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photoSize: PhotoSize, entities: TextSourcesList, spoilered: Boolean = false, @@ -683,7 +682,7 @@ suspend inline fun TelegramBot.reply( // Sticker suspend inline fun TelegramBot.replyWithSticker( - to: Message, + to: AccessibleMessage, sticker: InputFile, emoji: String? = null, disableNotification: Boolean = false, @@ -693,7 +692,7 @@ suspend inline fun TelegramBot.replyWithSticker( ) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, sticker: Sticker, emoji: String? = null, disableNotification: Boolean = false, @@ -706,7 +705,7 @@ suspend inline fun TelegramBot.reply( // Videos suspend inline fun TelegramBot.replyWithVideo( - to: Message, + to: AccessibleMessage, video: InputFile, thumb: InputFile? = null, text: String? = null, @@ -722,7 +721,7 @@ suspend inline fun TelegramBot.replyWithVideo( ) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, video: VideoFile, text: String? = null, parseMode: ParseMode? = null, @@ -734,7 +733,7 @@ suspend inline fun TelegramBot.reply( ) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVideo( - to: Message, + to: AccessibleMessage, video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, @@ -749,7 +748,7 @@ suspend inline fun TelegramBot.replyWithVideo( ) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, video: VideoFile, entities: TextSourcesList, spoilered: Boolean = false, @@ -763,7 +762,7 @@ suspend inline fun TelegramBot.reply( // VideoNotes suspend inline fun TelegramBot.replyWithVideoNote( - to: Message, + to: AccessibleMessage, videoNote: InputFile, thumb: InputFile? = null, duration: Long? = null, @@ -775,7 +774,7 @@ suspend inline fun TelegramBot.replyWithVideoNote( ) = sendVideoNote(to.chat, videoNote, thumb, duration, size, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, videoNote: VideoNoteFile, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -787,7 +786,7 @@ suspend inline fun TelegramBot.reply( // Voice suspend inline fun TelegramBot.replyWithVoice( - to: Message, + to: AccessibleMessage, voice: InputFile, text: String? = null, parseMode: ParseMode? = null, @@ -799,7 +798,7 @@ suspend inline fun TelegramBot.replyWithVoice( ) = sendVoice(to.chat, voice, text, parseMode, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, @@ -811,7 +810,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithVoice( - to: Message, + to: AccessibleMessage, voice: InputFile, entities: TextSourcesList, duration: Long? = null, @@ -822,7 +821,7 @@ suspend inline fun TelegramBot.replyWithVoice( ) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, voice: VoiceFile, entities: TextSourcesList, disableNotification: Boolean = false, @@ -839,7 +838,7 @@ suspend inline fun TelegramBot.reply( * as a builder for that */ suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, title: String, description: String, payload: String, @@ -867,7 +866,7 @@ suspend inline fun TelegramBot.reply( // Polls suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, question: String, options: List, isAnonymous: Boolean = true, @@ -881,7 +880,7 @@ suspend inline fun TelegramBot.reply( ) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, poll: RegularPoll, isClosed: Boolean = false, question: String = poll.question, @@ -896,7 +895,7 @@ suspend inline fun TelegramBot.reply( ) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, question: String, options: List, correctOptionId: Int, @@ -912,7 +911,7 @@ suspend inline fun TelegramBot.reply( ) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, quizPoll: QuizPoll, isClosed: Boolean = false, question: String = quizPoll.question, @@ -929,7 +928,7 @@ suspend inline fun TelegramBot.reply( ) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, question: String, options: List, correctOptionId: Int, @@ -944,7 +943,7 @@ suspend inline fun TelegramBot.reply( ) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, quizPoll: QuizPoll, entities: TextSourcesList, isClosed: Boolean = false, @@ -961,7 +960,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, poll: Poll, isClosed: Boolean = false, question: String = poll.question, @@ -1006,7 +1005,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, fromChatId: ChatIdentifier, messageId: MessageId, text: String? = null, @@ -1030,7 +1029,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, fromChat: Chat, messageId: MessageId, text: String? = null, @@ -1042,8 +1041,8 @@ suspend inline fun TelegramBot.reply( ) = reply(to, fromChat.id, messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, - copy: Message, + to: AccessibleMessage, + copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, @@ -1053,13 +1052,13 @@ suspend inline fun TelegramBot.reply( ) = reply(to, copy.chat.id, copy.messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, content: MessageContent, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -): Message = execute( +): AccessibleMessage = execute( content.createResend( to.chat.id, to.threadIdOrNull, @@ -1077,7 +1076,7 @@ suspend fun TelegramBot.reply( * @see handleLiveLocation */ suspend fun TelegramBot.reply( - message: Message, + message: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, @@ -1102,7 +1101,7 @@ suspend fun TelegramBot.reply( @JvmName("replyLiveLocationWithLocation") @JsName("replyLiveLocationWithLocation") suspend fun TelegramBot.reply( - message: Message, + message: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, @@ -1129,7 +1128,7 @@ suspend fun TelegramBot.reply( @JvmName("replyLiveLocationWithLatLong") @JsName("replyLiveLocationWithLatLong") suspend fun TelegramBot.reply( - message: Message, + message: AccessibleMessage, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, @@ -1149,7 +1148,7 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, mediaFile: TelegramMediaFile, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -1233,7 +1232,7 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, @@ -1307,7 +1306,7 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, content: TextedMediaContent, entities: TextSourcesList, disableNotification: Boolean = false, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index a81151755e..60197a66e0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -23,7 +23,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.location.* -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency @@ -1166,7 +1166,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, - copy: Message, + copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, threadId: MessageThreadId? = toChatId.threadId, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt index c94fdeff1f..5abec35c55 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt @@ -1,16 +1,12 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.send.SendAction import dev.inmo.tgbotapi.requests.send.SetMessageReactions import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId -import dev.inmo.tgbotapi.types.actions.* import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.reactions.Reaction -import dev.inmo.tgbotapi.types.threadId suspend fun TelegramBot.setMessageReactions( chatId: ChatIdentifier, @@ -43,13 +39,13 @@ suspend fun TelegramBot.setMessageReaction( ) = setMessageReaction(chat.id, messageId, reaction, big) suspend fun TelegramBot.setMessageReactions( - message: Message, + message: AccessibleMessage, reactions: List, big: Boolean = false ) = setMessageReactions(message.chat, message.messageId, reactions, big) suspend fun TelegramBot.setMessageReaction( - message: Message, + message: AccessibleMessage, reaction: Reaction?, big: Boolean = false ) = setMessageReaction(message.chat, message.messageId, reaction, big) 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 85bbad10ba..fd7820f464 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 @@ -6,24 +6,24 @@ 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.chat.member.ChatMemberUpdated -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery import dev.inmo.tgbotapi.types.payments.ShippingQuery import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery import dev.inmo.tgbotapi.types.update.abstracts.Update /** - * Allow only events from the same chat as base [Message] + * Allow only events from the same chat as base [AccessibleMessage] */ -val MessageFilterByChat: BehaviourContextAndTwoTypesReceiver = { message, update -> +val MessageFilterByChat: BehaviourContextAndTwoTypesReceiver = { message, update -> update.sourceChat() ?.let { it.id == message.chat.id } != false } /** - * Allow only events from the same chat as base [List] of [Message] + * Allow only events from the same chat as base [List] of [AccessibleMessage] */ -val MessagesFilterByChat: BehaviourContextAndTwoTypesReceiver, Update> = { messages, update -> +val MessagesFilterByChat: BehaviourContextAndTwoTypesReceiver, Update> = { messages, update -> val sourceChatId = update.sourceChat() ?.id sourceChatId != null && messages.all { sourceChatId == it.chat.id } } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt index f6d4fc2b76..469ab1954e 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt @@ -1,15 +1,13 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters -import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.content.MediaGroupContent import dev.inmo.tgbotapi.types.message.content.MediaGroupMessage -import dev.inmo.tgbotapi.types.update.abstracts.Update /** * Allow only messages which are not [MediaGroupMessage] */ -val CommonMessageFilterExcludeMediaGroups = SimpleFilter { +val CommonMessageFilterExcludeMediaGroups = SimpleFilter { it !is CommonMessage<*> || it.content !is MediaGroupContent<*> } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterForums.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterForums.kt index c108b48867..293b6ad20f 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterForums.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterForums.kt @@ -7,6 +7,6 @@ import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull /** * Allow only messages which are not in some forum */ -val MessageFilterForums = SimpleFilter { +val MessageFilterForums = SimpleFilter { it.threadIdOrNull == null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt index 1beb82c59d..8570f545af 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt @@ -2,12 +2,12 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories import dev.inmo.tgbotapi.types.message.abstracts.* -object ByChatMessageMarkerFactory : MarkerFactory { - override suspend fun invoke(data: Message) = data.chat +object ByChatMessageMarkerFactory : MarkerFactory { + override suspend fun invoke(data: AccessibleMessage) = data.chat } -object ByUserMessageMarkerFactory : MarkerFactory { - override suspend fun invoke(data: Message) = when (data) { +object ByUserMessageMarkerFactory : MarkerFactory { + override suspend fun invoke(data: AccessibleMessage) = when (data) { is FromUserMessage -> data.user is FromChannelGroupContentMessage<*> -> data.channel else -> data.chat // including anonymous diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/GetUpdates.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/GetUpdates.kt index f75ba755c3..c19f91aba2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/GetUpdates.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/GetUpdates.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests -import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.UpdateSerializerWithoutSerialization @@ -15,7 +14,7 @@ private val updatesListSerializer = ListSerializer( * Request updates from Telegram Bot API system. It is important, that the result updates WILL NOT include * [dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate] objects due to the fact, * that it is internal abstraction and in fact any [dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage] - * is just a common [dev.inmo.tgbotapi.types.message.abstracts.Message] + * is just a common [dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage] * * @see dev.inmo.tgbotapi.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation * @see dev.inmo.tgbotapi.utils.convertWithMediaGroupUpdates diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 1b044a5b59..b3887e7579 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -2,10 +2,10 @@ package dev.inmo.tgbotapi.types.chat import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.colors.ColorId +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer import dev.inmo.tgbotapi.types.reactions.Reaction -import korlibs.time.DateTime import kotlinx.serialization.Serializable @Serializable(ExtendedChatSerializer.Companion::class) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt index 63e3fb7f4b..8fbbf42bc2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt @@ -1,9 +1,7 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.tgbotapi.types.chat.PreviewChat -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import kotlinx.serialization.Serializable import kotlinx.serialization.Transient @@ -12,5 +10,5 @@ data class GiveawayPrivateResults( override val chat: PreviewChat, override val unclaimedCount: Int, @Transient // TODO::Add message serializer - val message: Message? = null + val message: AccessibleMessage? = null ) : GiveawayResults diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt index e3e5f0dcb4..eaab4dc3ad 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt @@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.types.message import korlibs.time.DateTime import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.chat.ChannelChat import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.PreviewChannelChat import dev.inmo.tgbotapi.types.message.abstracts.* @@ -17,7 +16,7 @@ data class ChannelContentMessageImpl( override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val forwardInfo: ForwardInfo?, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/PinnedMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/PinnedMessage.kt index 7f62ac4b23..11306bc6d1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/PinnedMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/PinnedMessage.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message data class PinnedMessage( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt index 73bd4a4174..78d90720e1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt @@ -17,7 +17,7 @@ data class ConnectedFromChannelGroupContentMessageImpl( override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -33,7 +33,7 @@ data class UnconnectedFromChannelGroupContentMessageImpl( override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -48,7 +48,7 @@ data class AnonymousGroupContentMessageImpl( override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -64,7 +64,7 @@ data class CommonGroupContentMessageImpl( override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -80,7 +80,7 @@ data class FromChannelForumContentMessageImpl( override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -96,7 +96,7 @@ data class AnonymousForumContentMessageImpl( override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -113,7 +113,7 @@ data class CommonForumContentMessageImpl( override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt index fd2945c430..2cc79c38d8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt @@ -3,10 +3,9 @@ package dev.inmo.tgbotapi.types.message import korlibs.time.DateTime import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.chat.User -import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.passport.PassportData data class PassportMessage( @@ -15,4 +14,4 @@ data class PassportMessage( override val from: User, override val date: DateTime, val passportData: PassportData -) : Message, FromUserMessage +) : AccessibleMessage, FromUserMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt index a9b4ae9c96..74f5ea3797 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.User -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage import dev.inmo.tgbotapi.types.message.content.MessageContent @@ -19,7 +19,7 @@ data class PrivateContentMessageImpl( override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val forwardInfo: ForwardInfo?, - override val replyTo: Message?, + override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupIdentifier?, 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 59b2fb6061..325aed76af 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 @@ -286,7 +286,7 @@ internal data class RawMessage( } } - val asMessage: Message by lazy { + val asMessage: AccessibleMessage by lazy { if (date.date == 0L) { return@lazy InaccessibleMessage( chat, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt index c409d53a0e..9b4999bf0d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent -interface ChatEventMessage : Message { +interface ChatEventMessage : AccessibleMessage { val chatEvent: T } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/CommonMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/CommonMessage.kt index a5bc9b83aa..31acc87740 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/CommonMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/CommonMessage.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.content.MessageContent -sealed interface CommonMessage : Message, +sealed interface CommonMessage : AccessibleMessage, PossiblyForwardedMessage, PossiblyEditedMessage, PossiblyReplyMessage, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ContentMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ContentMessage.kt index cfed7358dc..b39d110079 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ContentMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ContentMessage.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.content.MessageContent -interface ContentMessage: Message { +interface ContentMessage: AccessibleMessage { val hasProtectedContent: Boolean val content: T diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/FromUserMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/FromUserMessage.kt index 234b125ccf..4c568b1c50 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/FromUserMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/FromUserMessage.kt @@ -2,4 +2,4 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.abstracts.FromUser -interface FromUserMessage : FromUser, Message +interface FromUserMessage : FromUser, AccessibleMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt index 6d01402657..7290ebb58e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt @@ -1,12 +1,9 @@ package dev.inmo.tgbotapi.types.message.abstracts -import dev.inmo.tgbotapi.abstracts.WithMessageId import korlibs.time.DateTime -import dev.inmo.tgbotapi.abstracts.WithPreviewChat import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.message.RawMessage import kotlinx.serialization.* @@ -19,11 +16,13 @@ interface Message : WithPreviewChatAndMessageId { val date: DateTime } +interface AccessibleMessage : Message + @Serializable data class InaccessibleMessage( override val chat: PreviewChat, override val messageId: MessageId, -) : Message { +) : AccessibleMessage { override val date: DateTime get() = DateTime.invoke(0L) } @@ -33,7 +32,7 @@ data class UnknownMessageType( override val chat: PreviewChat, override val date: DateTime, val insideException: Exception -) : Message +) : AccessibleMessage internal class TelegramBotAPIMessageDeserializationStrategyClass : DeserializationStrategy { @OptIn(InternalSerializationApi::class) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyEditedMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyEditedMessage.kt index ac61856938..17353e32ce 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyEditedMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyEditedMessage.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import korlibs.time.DateTime -interface PossiblyEditedMessage : Message { +interface PossiblyEditedMessage : AccessibleMessage { val editDate: DateTime? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt index be8258d616..41b8938f74 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.ForwardInfo -interface PossiblyForwardedMessage : Message { +interface PossiblyForwardedMessage : AccessibleMessage { val forwardInfo: ForwardInfo? } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyPaymentMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyPaymentMessage.kt index 4989f3b7f1..cb8a07bb0d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyPaymentMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyPaymentMessage.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.payments.abstracts.PaymentInfo -interface PossiblyPaymentMessage : Message { +interface PossiblyPaymentMessage : AccessibleMessage { val paymentInfo: PaymentInfo? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt index ef6905c0b1..d796c09520 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.types.message.abstracts interface PossiblyReplyMessage { - val replyTo: Message? + val replyTo: AccessibleMessage? } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage.kt index 8027809031..ba19d01b83 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.MessageThreadId -interface PossiblyTopicMessage : Message { +interface PossiblyTopicMessage : AccessibleMessage { val threadId: MessageThreadId? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SignedMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SignedMessage.kt index 18aabe8616..04d4a85dd3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SignedMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SignedMessage.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.AuthorSignature -interface SignedMessage : Message { +interface SignedMessage : AccessibleMessage { val authorSignature: AuthorSignature? } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index dd346d6403..32e0299a2e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -165,5 +165,5 @@ sealed interface ResendableContent { replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null - ): Request + ): Request } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt index 1b0c05cb53..b582f493cd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt @@ -10,7 +10,6 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.textsources.TextSource import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt index 920e6a8699..187a155a10 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt @@ -7,8 +7,6 @@ import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage import dev.inmo.tgbotapi.types.stories.Story import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/AbstractMessageCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/AbstractMessageCallbackQuery.kt new file mode 100644 index 0000000000..2c71db3314 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/AbstractMessageCallbackQuery.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.types.queries.callback + +import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.content.MessageContent + +sealed interface AbstractMessageCallbackQuery : CallbackQuery { + val message: Message +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageCallbackQuery.kt new file mode 100644 index 0000000000..12b965df5a --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageCallbackQuery.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.queries.callback + +import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage + +sealed interface InaccessibleMessageCallbackQuery : AbstractMessageCallbackQuery { + override val message: InaccessibleMessage +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageDataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageDataCallbackQuery.kt new file mode 100644 index 0000000000..0ac9245eae --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageDataCallbackQuery.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.queries.callback + +import dev.inmo.tgbotapi.types.CallbackQueryIdentifier +import dev.inmo.tgbotapi.types.chat.CommonUser +import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage +import dev.inmo.tgbotapi.types.message.content.MessageContent + +data class InaccessibleMessageDataCallbackQuery( + override val id: CallbackQueryIdentifier, + override val from: CommonUser, + override val chatInstance: String, + override val message: InaccessibleMessage, + override val data: String +) : DataCallbackQuery, InaccessibleMessageCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageGameShortNameCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageGameShortNameCallbackQuery.kt new file mode 100644 index 0000000000..bfdd364e56 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/InaccessibleMessageGameShortNameCallbackQuery.kt @@ -0,0 +1,16 @@ +package dev.inmo.tgbotapi.types.queries.callback + +import dev.inmo.tgbotapi.types.CallbackQueryIdentifier +import dev.inmo.tgbotapi.types.chat.CommonUser +import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage +import dev.inmo.tgbotapi.types.message.content.MessageContent + +data class InaccessibleMessageGameShortNameCallbackQuery( + override val id: CallbackQueryIdentifier, + override val from: CommonUser, + override val chatInstance: String, + override val message: InaccessibleMessage, + override val gameShortName: String +) : GameShortNameCallbackQuery, InaccessibleMessageCallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/MessageCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/MessageCallbackQuery.kt index c1e15e4f28..22658fc513 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/MessageCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/MessageCallbackQuery.kt @@ -3,6 +3,6 @@ package dev.inmo.tgbotapi.types.queries.callback import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.MessageContent -sealed interface MessageCallbackQuery : CallbackQuery { - val message: ContentMessage +sealed interface MessageCallbackQuery : AbstractMessageCallbackQuery { + override val message: ContentMessage } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/RawCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/RawCallbackQuery.kt index 804a0a54a8..4e42298fda 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/RawCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/queries/callback/RawCallbackQuery.kt @@ -16,7 +16,7 @@ internal data class RawCallbackQuery( @SerialName(fromField) val from: CommonUser, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) - val message: ContentMessage? = null, + val message: Message? = null, @SerialName(inlineMessageIdField) val inlineMessageId: InlineMessageIdentifier? = null, @SerialName("chat_instance") @@ -28,8 +28,26 @@ internal data class RawCallbackQuery( private var inited: CallbackQuery? = null fun asCallbackQuery(raw: String): CallbackQuery { return inited ?: when { - message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data) - message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName) + message != null && data != null -> when { + message is ContentMessage<*> -> MessageDataCallbackQuery(id, from, chatInstance, message, data) + message is InaccessibleMessage -> InaccessibleMessageDataCallbackQuery(id, from, chatInstance, message, data) + else -> UnknownCallbackQueryType( + id, + from, + chatInstance, + raw + ) + } + message != null && gameShortName != null -> when { + message is ContentMessage<*> -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName) + message is InaccessibleMessage -> InaccessibleMessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName) + else -> UnknownCallbackQueryType( + id, + from, + chatInstance, + raw + ) + } inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data) inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName) else -> UnknownCallbackQueryType( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChannelPostUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChannelPostUpdate.kt index b5cbaa55b8..eeb5ad2cb7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChannelPostUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/ChannelPostUpdate.kt @@ -1,12 +1,12 @@ package dev.inmo.tgbotapi.types.update import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate data class ChannelPostUpdate( override val updateId: UpdateIdentifier, - override val data: Message + override val data: AccessibleMessage ) : BaseSentMessageUpdate { - override fun copy(newData: Message): BaseSentMessageUpdate = copy(updateId, newData) + override fun copy(newData: AccessibleMessage): BaseSentMessageUpdate = copy(updateId, newData) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MessageUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MessageUpdate.kt index 9585386627..babf6dfc31 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MessageUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MessageUpdate.kt @@ -1,12 +1,12 @@ package dev.inmo.tgbotapi.types.update import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate data class MessageUpdate( override val updateId: UpdateIdentifier, - override val data: Message + override val data: AccessibleMessage ) : BaseSentMessageUpdate { - override fun copy(newData: Message) = copy(updateId, newData) + override fun copy(newData: AccessibleMessage) = copy(updateId, newData) } 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 8b1e3fe515..7eec35e1ee 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 @@ -28,11 +28,11 @@ internal data class RawUpdate constructor( @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) private val edited_message: CommonMessage<*>? = null, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) - private val message: Message? = null, + private val message: AccessibleMessage? = null, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) private val edited_channel_post: CommonMessage<*>? = null, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) - private val channel_post: Message? = null, + private val channel_post: AccessibleMessage? = null, private val inline_query: RawInlineQuery? = null, private val chosen_inline_result: RawChosenInlineResult? = null, private val callback_query: RawCallbackQuery? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseMessageUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseMessageUpdate.kt index 5db71be2ea..8601a56f6a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseMessageUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseMessageUpdate.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.update.abstracts -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage interface BaseMessageUpdate : Update { - override val data: Message + override val data: AccessibleMessage } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseSentMessageUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseSentMessageUpdate.kt index 65efc5e9eb..7816e42a59 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseSentMessageUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/BaseSentMessageUpdate.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.update.abstracts -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage interface BaseSentMessageUpdate : BaseMessageUpdate { - fun copy(newData: Message): BaseSentMessageUpdate + fun copy(newData: AccessibleMessage): BaseSentMessageUpdate } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt index 2369d24ba4..bab83ae2e4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.utils.extensions -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage -val Message.threadIdOrNull +val AccessibleMessage.threadIdOrNull get() = (this as? PossiblyTopicMessage) ?.threadId 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 ccb25f7023..f78dbe92bf 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 @@ -978,346 +978,346 @@ inline fun SecureValue.requireSecureValueWithTranslations(): SecureValueWithTran this as SecureValueWithTranslations @PreviewFeature -inline fun Message.whenAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl) -> T) = +inline fun AccessibleMessage.whenAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl) -> T) = asAnonymousGroupContentMessageImpl()?.let(block) @PreviewFeature -inline fun Message.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl? = +inline fun AccessibleMessage.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl? = this as? AnonymousGroupContentMessageImpl @PreviewFeature -inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl = +inline fun AccessibleMessage.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl = this as AnonymousGroupContentMessageImpl @PreviewFeature -inline fun Message.whenChannelContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl) -> T) = +inline fun AccessibleMessage.whenChannelContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl) -> T) = asChannelContentMessageImpl()?.let(block) @PreviewFeature -inline fun Message.asChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl? = +inline fun AccessibleMessage.asChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl? = this as? UnconnectedFromChannelGroupContentMessageImpl @PreviewFeature -inline fun Message.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl = +inline fun AccessibleMessage.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl = this as UnconnectedFromChannelGroupContentMessageImpl @PreviewFeature -inline fun Message.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage()?.let(block) +inline fun AccessibleMessage.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage()?.let(block) @PreviewFeature -inline fun Message.asPassportMessage(): PassportMessage? = this as? PassportMessage +inline fun AccessibleMessage.asPassportMessage(): PassportMessage? = this as? PassportMessage @PreviewFeature -inline fun Message.requirePassportMessage(): PassportMessage = this as PassportMessage +inline fun AccessibleMessage.requirePassportMessage(): PassportMessage = this as PassportMessage @PreviewFeature -inline fun Message.whenPrivateContentMessageImpl(block: (PrivateContentMessageImpl) -> T) = +inline fun AccessibleMessage.whenPrivateContentMessageImpl(block: (PrivateContentMessageImpl) -> T) = asPrivateContentMessageImpl()?.let(block) @PreviewFeature -inline fun Message.asPrivateContentMessageImpl(): PrivateContentMessageImpl? = +inline fun AccessibleMessage.asPrivateContentMessageImpl(): PrivateContentMessageImpl? = this as? PrivateContentMessageImpl @PreviewFeature -inline fun Message.requirePrivateContentMessageImpl(): PrivateContentMessageImpl = +inline fun AccessibleMessage.requirePrivateContentMessageImpl(): PrivateContentMessageImpl = this as PrivateContentMessageImpl @PreviewFeature -inline fun Message.whenChannelEventMessage(block: (ChannelEventMessage) -> T) = +inline fun AccessibleMessage.whenChannelEventMessage(block: (ChannelEventMessage) -> T) = asChannelEventMessage()?.let(block) @PreviewFeature -inline fun Message.asChannelEventMessage(): ChannelEventMessage? = +inline fun AccessibleMessage.asChannelEventMessage(): ChannelEventMessage? = this as? ChannelEventMessage @PreviewFeature -inline fun Message.requireChannelEventMessage(): ChannelEventMessage = +inline fun AccessibleMessage.requireChannelEventMessage(): ChannelEventMessage = this as ChannelEventMessage @PreviewFeature -inline fun Message.whenCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T) = +inline fun AccessibleMessage.whenCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T) = asCommonGroupEventMessage()?.let(block) @PreviewFeature -inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = +inline fun AccessibleMessage.asCommonGroupEventMessage(): CommonGroupEventMessage? = this as? CommonGroupEventMessage @PreviewFeature -inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage = +inline fun AccessibleMessage.requireCommonGroupEventMessage(): CommonGroupEventMessage = this as CommonGroupEventMessage @PreviewFeature -inline fun Message.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T) = +inline fun AccessibleMessage.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T) = asCommonSupergroupEventMessage()?.let(block) @PreviewFeature -inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = +inline fun AccessibleMessage.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = this as? CommonSupergroupEventMessage @PreviewFeature -inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = +inline fun AccessibleMessage.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = this as CommonSupergroupEventMessage @PreviewFeature -inline fun Message.whenAnonymousGroupContentMessage(block: (AnonymousGroupContentMessage) -> T) = +inline fun AccessibleMessage.whenAnonymousGroupContentMessage(block: (AnonymousGroupContentMessage) -> T) = asAnonymousGroupContentMessage()?.let(block) @PreviewFeature -inline fun Message.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage? = +inline fun AccessibleMessage.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage? = this as? AnonymousGroupContentMessage @PreviewFeature -inline fun Message.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage = +inline fun AccessibleMessage.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage = this as AnonymousGroupContentMessage @PreviewFeature -inline fun Message.whenChannelContentMessage(block: (ChannelContentMessage) -> T) = +inline fun AccessibleMessage.whenChannelContentMessage(block: (ChannelContentMessage) -> T) = asChannelContentMessage()?.let(block) @PreviewFeature -inline fun Message.asChannelContentMessage(): ChannelContentMessage? = +inline fun AccessibleMessage.asChannelContentMessage(): ChannelContentMessage? = this as? ChannelContentMessage @PreviewFeature -inline fun Message.requireChannelContentMessage(): ChannelContentMessage = +inline fun AccessibleMessage.requireChannelContentMessage(): ChannelContentMessage = this as ChannelContentMessage @PreviewFeature -inline fun Message.whenConnectedFromChannelGroupContentMessage(block: (ConnectedFromChannelGroupContentMessage) -> T) = +inline fun AccessibleMessage.whenConnectedFromChannelGroupContentMessage(block: (ConnectedFromChannelGroupContentMessage) -> T) = asConnectedFromChannelGroupContentMessage()?.let(block) @PreviewFeature -inline fun Message.asConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage? = +inline fun AccessibleMessage.asConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage? = this as? ConnectedFromChannelGroupContentMessage @PreviewFeature -inline fun Message.requireConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage = +inline fun AccessibleMessage.requireConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage = this as ConnectedFromChannelGroupContentMessage @PreviewFeature -inline fun Message.whenUnconnectedFromChannelGroupContentMessage(block: (UnconnectedFromChannelGroupContentMessage) -> T) = +inline fun AccessibleMessage.whenUnconnectedFromChannelGroupContentMessage(block: (UnconnectedFromChannelGroupContentMessage) -> T) = asUnconnectedFromChannelGroupContentMessage()?.let(block) @PreviewFeature -inline fun Message.asUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage? = +inline fun AccessibleMessage.asUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage? = this as? UnconnectedFromChannelGroupContentMessage @PreviewFeature -inline fun Message.requireUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage = +inline fun AccessibleMessage.requireUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage = this as UnconnectedFromChannelGroupContentMessage @PreviewFeature -inline fun Message.whenChatEventMessage(block: (ChatEventMessage) -> T) = +inline fun AccessibleMessage.whenChatEventMessage(block: (ChatEventMessage) -> T) = asChatEventMessage()?.let(block) @PreviewFeature -inline fun Message.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage +inline fun AccessibleMessage.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage @PreviewFeature -inline fun Message.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage +inline fun AccessibleMessage.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage @PreviewFeature -inline fun Message.whenCommonGroupContentMessage(block: (CommonGroupContentMessage) -> T) = +inline fun AccessibleMessage.whenCommonGroupContentMessage(block: (CommonGroupContentMessage) -> T) = asCommonGroupContentMessage()?.let(block) @PreviewFeature -inline fun Message.asCommonGroupContentMessage(): CommonGroupContentMessage? = +inline fun AccessibleMessage.asCommonGroupContentMessage(): CommonGroupContentMessage? = this as? CommonGroupContentMessage @PreviewFeature -inline fun Message.requireCommonGroupContentMessage(): CommonGroupContentMessage = +inline fun AccessibleMessage.requireCommonGroupContentMessage(): CommonGroupContentMessage = this as CommonGroupContentMessage @PreviewFeature -inline fun Message.whenCommonMessage(block: (CommonMessage) -> T) = asCommonMessage()?.let(block) +inline fun AccessibleMessage.whenCommonMessage(block: (CommonMessage) -> T) = asCommonMessage()?.let(block) @PreviewFeature -inline fun Message.asCommonMessage(): CommonMessage? = this as? CommonMessage +inline fun AccessibleMessage.asCommonMessage(): CommonMessage? = this as? CommonMessage @PreviewFeature -inline fun Message.requireCommonMessage(): CommonMessage = this as CommonMessage +inline fun AccessibleMessage.requireCommonMessage(): CommonMessage = this as CommonMessage @PreviewFeature -inline fun Message.whenContentMessage(block: (ContentMessage) -> T) = asContentMessage()?.let(block) +inline fun AccessibleMessage.whenContentMessage(block: (ContentMessage) -> T) = asContentMessage()?.let(block) @PreviewFeature -inline fun Message.asContentMessage(): ContentMessage? = this as? ContentMessage +inline fun AccessibleMessage.asContentMessage(): ContentMessage? = this as? ContentMessage @PreviewFeature -inline fun Message.requireContentMessage(): ContentMessage = this as ContentMessage +inline fun AccessibleMessage.requireContentMessage(): ContentMessage = this as ContentMessage @PreviewFeature -inline fun Message.whenFromChannelGroupContentMessage(block: (FromChannelGroupContentMessage) -> T) = +inline fun AccessibleMessage.whenFromChannelGroupContentMessage(block: (FromChannelGroupContentMessage) -> T) = asFromChannelGroupContentMessage()?.let(block) @PreviewFeature -inline fun Message.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage? = +inline fun AccessibleMessage.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage? = this as? FromChannelGroupContentMessage @PreviewFeature -inline fun Message.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage = +inline fun AccessibleMessage.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage = this as FromChannelGroupContentMessage @PreviewFeature -inline fun Message.whenGroupEventMessage(block: (GroupEventMessage) -> T) = +inline fun AccessibleMessage.whenGroupEventMessage(block: (GroupEventMessage) -> T) = asGroupEventMessage()?.let(block) @PreviewFeature -inline fun Message.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage +inline fun AccessibleMessage.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage @PreviewFeature -inline fun Message.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage +inline fun AccessibleMessage.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage @PreviewFeature -inline fun Message.whenPrivateEventMessage(block: (PrivateEventMessage) -> T) = +inline fun AccessibleMessage.whenPrivateEventMessage(block: (PrivateEventMessage) -> T) = asPrivateEventMessage()?.let(block) @PreviewFeature -inline fun Message.asPrivateEventMessage(): PrivateEventMessage? = +inline fun AccessibleMessage.asPrivateEventMessage(): PrivateEventMessage? = this as? PrivateEventMessage @PreviewFeature -inline fun Message.requirePrivateEventMessage(): PrivateEventMessage = +inline fun AccessibleMessage.requirePrivateEventMessage(): PrivateEventMessage = this as PrivateEventMessage @PreviewFeature -inline fun Message.whenGroupContentMessage(block: (GroupContentMessage) -> T) = +inline fun AccessibleMessage.whenGroupContentMessage(block: (GroupContentMessage) -> T) = asGroupContentMessage()?.let(block) @PreviewFeature -inline fun Message.asGroupContentMessage(): GroupContentMessage? = +inline fun AccessibleMessage.asGroupContentMessage(): GroupContentMessage? = this as? GroupContentMessage @PreviewFeature -inline fun Message.requireGroupContentMessage(): GroupContentMessage = +inline fun AccessibleMessage.requireGroupContentMessage(): GroupContentMessage = this as GroupContentMessage @PreviewFeature -inline fun Message.whenMediaGroupMessage(block: (MediaGroupMessage) -> T) = +inline fun AccessibleMessage.whenMediaGroupMessage(block: (MediaGroupMessage) -> T) = asMediaGroupMessage()?.let(block) @PreviewFeature -inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = +inline fun AccessibleMessage.asMediaGroupMessage(): MediaGroupMessage? = this as? MediaGroupMessage @PreviewFeature -inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = +inline fun AccessibleMessage.requireMediaGroupMessage(): MediaGroupMessage = this as MediaGroupMessage @PreviewFeature -inline fun Message.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) = +inline fun AccessibleMessage.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) = asPossiblyEditedMessage()?.let(block) @PreviewFeature -inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage +inline fun AccessibleMessage.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage @PreviewFeature -inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage +inline fun AccessibleMessage.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage @PreviewFeature -inline fun Message.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) = +inline fun AccessibleMessage.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) = asPossiblyReplyMessage()?.let(block) @PreviewFeature -inline fun Message.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage +inline fun AccessibleMessage.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage @PreviewFeature -inline fun Message.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage +inline fun AccessibleMessage.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage @PreviewFeature -inline fun Message.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) = +inline fun AccessibleMessage.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) = asPossiblyForwardedMessage()?.let(block) @PreviewFeature -inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage +inline fun AccessibleMessage.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage @PreviewFeature -inline fun Message.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage +inline fun AccessibleMessage.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage @PreviewFeature -inline fun Message.whenPossiblyPaymentMessage(block: (PossiblyPaymentMessage) -> T) = +inline fun AccessibleMessage.whenPossiblyPaymentMessage(block: (PossiblyPaymentMessage) -> T) = asPossiblyPaymentMessage()?.let(block) @PreviewFeature -inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage +inline fun AccessibleMessage.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage @PreviewFeature -inline fun Message.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage +inline fun AccessibleMessage.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage @PreviewFeature -inline fun Message.whenPrivateContentMessage(block: (PrivateContentMessage) -> T) = +inline fun AccessibleMessage.whenPrivateContentMessage(block: (PrivateContentMessage) -> T) = asPrivateContentMessage()?.let(block) @PreviewFeature -inline fun Message.asPrivateContentMessage(): PrivateContentMessage? = +inline fun AccessibleMessage.asPrivateContentMessage(): PrivateContentMessage? = this as? PrivateContentMessage @PreviewFeature -inline fun Message.requirePrivateContentMessage(): PrivateContentMessage = +inline fun AccessibleMessage.requirePrivateContentMessage(): PrivateContentMessage = this as PrivateContentMessage @PreviewFeature -inline fun Message.whenPublicContentMessage(block: (PublicContentMessage) -> T) = +inline fun AccessibleMessage.whenPublicContentMessage(block: (PublicContentMessage) -> T) = asPublicContentMessage()?.let(block) @PreviewFeature -inline fun Message.asPublicContentMessage(): PublicContentMessage? = +inline fun AccessibleMessage.asPublicContentMessage(): PublicContentMessage? = this as? PublicContentMessage @PreviewFeature -inline fun Message.requirePublicContentMessage(): PublicContentMessage = +inline fun AccessibleMessage.requirePublicContentMessage(): PublicContentMessage = this as PublicContentMessage @PreviewFeature -inline fun Message.whenSignedMessage(block: (SignedMessage) -> T) = asSignedMessage()?.let(block) +inline fun AccessibleMessage.whenSignedMessage(block: (SignedMessage) -> T) = asSignedMessage()?.let(block) @PreviewFeature -inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage +inline fun AccessibleMessage.asSignedMessage(): SignedMessage? = this as? SignedMessage @PreviewFeature -inline fun Message.requireSignedMessage(): SignedMessage = this as SignedMessage +inline fun AccessibleMessage.requireSignedMessage(): SignedMessage = this as SignedMessage @PreviewFeature -inline fun Message.whenSupergroupEventMessage(block: (SupergroupEventMessage) -> T) = +inline fun AccessibleMessage.whenSupergroupEventMessage(block: (SupergroupEventMessage) -> T) = asSupergroupEventMessage()?.let(block) @PreviewFeature -inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = +inline fun AccessibleMessage.asSupergroupEventMessage(): SupergroupEventMessage? = this as? SupergroupEventMessage @PreviewFeature -inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage = +inline fun AccessibleMessage.requireSupergroupEventMessage(): SupergroupEventMessage = this as SupergroupEventMessage @PreviewFeature -inline fun Message.whenUnknownMessageType(block: (UnknownMessageType) -> T) = asUnknownMessageType()?.let(block) +inline fun AccessibleMessage.whenUnknownMessageType(block: (UnknownMessageType) -> T) = asUnknownMessageType()?.let(block) @PreviewFeature -inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType +inline fun AccessibleMessage.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType @PreviewFeature -inline fun Message.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType +inline fun AccessibleMessage.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType @PreviewFeature -inline fun Message.whenPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage) -> T) = +inline fun AccessibleMessage.whenPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage) -> T) = asPossiblySentViaBotCommonMessage()?.let(block) @PreviewFeature -inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = +inline fun AccessibleMessage.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = this as? PossiblySentViaBotCommonMessage @PreviewFeature -inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = +inline fun AccessibleMessage.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = this as PossiblySentViaBotCommonMessage @PreviewFeature -inline fun Message.whenFromUserMessage(block: (FromUserMessage) -> T) = asFromUserMessage()?.let(block) +inline fun AccessibleMessage.whenFromUserMessage(block: (FromUserMessage) -> T) = asFromUserMessage()?.let(block) @PreviewFeature -inline fun Message.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage +inline fun AccessibleMessage.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage @PreviewFeature -inline fun Message.requireFromUserMessage(): FromUserMessage = this as FromUserMessage +inline fun AccessibleMessage.requireFromUserMessage(): FromUserMessage = this as FromUserMessage @PreviewFeature inline fun BotAction.whenFindLocationAction(block: (FindLocationAction) -> T) = asFindLocationAction()?.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 67d1718676..fd267c4c88 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 @@ -260,6 +260,7 @@ import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage import dev.inmo.tgbotapi.types.message.ForwardInfo import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.message.PrivateEventMessage +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage @@ -275,6 +276,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage import dev.inmo.tgbotapi.types.message.abstracts.GroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage +import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage @@ -414,9 +416,13 @@ import dev.inmo.tgbotapi.types.polls.QuizPoll import dev.inmo.tgbotapi.types.polls.RegularPoll import dev.inmo.tgbotapi.types.polls.ScheduledCloseInfo import dev.inmo.tgbotapi.types.polls.UnknownPollType +import dev.inmo.tgbotapi.types.queries.callback.AbstractMessageCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery import dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.GameShortNameCallbackQuery +import dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageCallbackQuery +import dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageDataCallbackQuery +import dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageGameShortNameCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdDataCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdGameShortNameCallbackQuery @@ -841,6 +847,16 @@ public inline fun WithUser.pollAnswerOrThrow(): PollAnswer = this as public inline fun WithUser.ifPollAnswer(block: (PollAnswer) -> T): T? = pollAnswerOrNull() ?.let(block) +public inline fun WithUser.abstractMessageCallbackQueryOrNull(): AbstractMessageCallbackQuery? = + this as? dev.inmo.tgbotapi.types.queries.callback.AbstractMessageCallbackQuery + +public inline fun WithUser.abstractMessageCallbackQueryOrThrow(): AbstractMessageCallbackQuery = + this as dev.inmo.tgbotapi.types.queries.callback.AbstractMessageCallbackQuery + +public inline fun + WithUser.ifAbstractMessageCallbackQuery(block: (AbstractMessageCallbackQuery) -> T): T? = + abstractMessageCallbackQueryOrNull() ?.let(block) + public inline fun WithUser.callbackQueryOrNull(): CallbackQuery? = this as? dev.inmo.tgbotapi.types.queries.callback.CallbackQuery @@ -878,6 +894,42 @@ public inline fun WithUser.ifGameShortNameCallbackQuery(block: (GameShortNameCallbackQuery) -> T): T? = gameShortNameCallbackQueryOrNull() ?.let(block) +public inline fun WithUser.inaccessibleMessageCallbackQueryOrNull(): + InaccessibleMessageCallbackQuery? = this as? + dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageCallbackQuery + +public inline fun WithUser.inaccessibleMessageCallbackQueryOrThrow(): + InaccessibleMessageCallbackQuery = this as + dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageCallbackQuery + +public inline fun + WithUser.ifInaccessibleMessageCallbackQuery(block: (InaccessibleMessageCallbackQuery) -> T): T? + = inaccessibleMessageCallbackQueryOrNull() ?.let(block) + +public inline fun WithUser.inaccessibleMessageDataCallbackQueryOrNull(): + InaccessibleMessageDataCallbackQuery? = this as? + dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageDataCallbackQuery + +public inline fun WithUser.inaccessibleMessageDataCallbackQueryOrThrow(): + InaccessibleMessageDataCallbackQuery = this as + dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageDataCallbackQuery + +public inline fun + WithUser.ifInaccessibleMessageDataCallbackQuery(block: (InaccessibleMessageDataCallbackQuery) -> T): + T? = inaccessibleMessageDataCallbackQueryOrNull() ?.let(block) + +public inline fun WithUser.inaccessibleMessageGameShortNameCallbackQueryOrNull(): + InaccessibleMessageGameShortNameCallbackQuery? = this as? + dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageGameShortNameCallbackQuery + +public inline fun WithUser.inaccessibleMessageGameShortNameCallbackQueryOrThrow(): + InaccessibleMessageGameShortNameCallbackQuery = this as + dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageGameShortNameCallbackQuery + +public inline fun + WithUser.ifInaccessibleMessageGameShortNameCallbackQuery(block: (InaccessibleMessageGameShortNameCallbackQuery) -> T): + T? = inaccessibleMessageGameShortNameCallbackQueryOrNull() ?.let(block) + public inline fun WithUser.inlineMessageIdCallbackQueryOrNull(): InlineMessageIdCallbackQuery? = this as? dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery @@ -3396,6 +3448,24 @@ public inline fun Message.ifCommonForumContentMessage(block: (CommonForumContentMessage) -> T): T? = commonForumContentMessageOrNull() ?.let(block) +public inline fun Message.accessibleMessageOrNull(): AccessibleMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage + +public inline fun Message.accessibleMessageOrThrow(): AccessibleMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage + +public inline fun Message.ifAccessibleMessage(block: (AccessibleMessage) -> T): T? = + accessibleMessageOrNull() ?.let(block) + +public inline fun Message.inaccessibleMessageOrNull(): InaccessibleMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage + +public inline fun Message.inaccessibleMessageOrThrow(): InaccessibleMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage + +public inline fun Message.ifInaccessibleMessage(block: (InaccessibleMessage) -> T): T? = + inaccessibleMessageOrNull() ?.let(block) + public inline fun Message.unknownMessageTypeOrNull(): UnknownMessageType? = this as? dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt index 360d71c6f4..a8d3eb25ea 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt @@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.Username import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull @@ -32,43 +32,43 @@ inline fun WithPreviewChat.sameChat(chat: Chat) = * @return true in case if [this] message is placed in the same chat that [other] */ @Suppress("NOTHING_TO_INLINE") -inline fun WithPreviewChat.sameChat(other: Message) = sameChat(other.chat) +inline fun WithPreviewChat.sameChat(other: AccessibleMessage) = sameChat(other.chat) /** - * @return true in case if [this] message is from the same chat (with id == [chatId]) and [this] [Message.messageId] + * @return true in case if [this] message is from the same chat (with id == [chatId]) and [this] [AccessibleMessage.messageId] * equal [messageId] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameMessage( +inline fun AccessibleMessage.sameMessage( chatId: ChatIdentifier, messageId: MessageId ) = sameChat(chatId) && this.messageId == messageId /** - * @return true in case if [this] message is from the same [chat] and [this] [Message.messageId] equal [messageId] + * @return true in case if [this] message is from the same [chat] and [this] [AccessibleMessage.messageId] equal [messageId] * identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameMessage( +inline fun AccessibleMessage.sameMessage( chat: Chat, messageId: MessageId ) = sameChat(chat) && this.messageId == messageId /** * @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat - * and have equal [Message.messageId] identifier + * and have equal [AccessibleMessage.messageId] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameMessage(other: Message) = sameMessage(other.chat, other.messageId) +inline fun AccessibleMessage.sameMessage(other: AccessibleMessage) = sameMessage(other.chat, other.messageId) /** * Thread is the same thing that topic * * @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these - * messages from one chat and have equal [Message.threadIdOrNull] identifier + * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameTopic( +inline fun AccessibleMessage.sameTopic( chatId: ChatIdentifier, threadId: MessageThreadId? = chatId.threadId ) = sameChat(chatId) && threadIdOrNull == threadId @@ -77,10 +77,10 @@ inline fun Message.sameTopic( * Thread is the same thing that topic * * @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these - * messages from one chat and have equal [Message.threadIdOrNull] identifier + * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameThread( +inline fun AccessibleMessage.sameThread( chatId: ChatIdentifier, threadId: MessageThreadId? = chatId.threadId ) = sameTopic(chatId, threadId) @@ -89,10 +89,10 @@ inline fun Message.sameThread( * Thread is the same thing that topic * * @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these - * messages from one chat and have equal [Message.threadIdOrNull] identifier + * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameTopic( +inline fun AccessibleMessage.sameTopic( chat: Chat, threadId: MessageThreadId? = chat.id.threadId ) = sameTopic(chat.id, threadId) @@ -101,10 +101,10 @@ inline fun Message.sameTopic( * Thread is the same thing that topic * * @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these - * messages from one chat and have equal [Message.threadIdOrNull] identifier + * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameThread( +inline fun AccessibleMessage.sameThread( chat: Chat, threadId: MessageThreadId? = chat.id.threadId ) = sameThread(chat.id, threadId) @@ -113,16 +113,16 @@ inline fun Message.sameThread( * Thread is the same thing that topic * * @return true in case if [this] message is from the same chat and topic as [other]. The same here means that these - * messages from one chat and have equal [Message.threadIdOrNull] identifier + * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameTopic(other: Message) = sameTopic(other.chat, other.threadIdOrNull) +inline fun AccessibleMessage.sameTopic(other: AccessibleMessage) = sameTopic(other.chat, other.threadIdOrNull) /** * Thread is the same thing that topic * * @return true in case if [this] message is in the same topic as the [other]. The same here means that these messages - * from one chat and have equal [Message.threadIdOrNull] identifier + * from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun Message.sameThread(other: Message) = sameTopic(other) +inline fun AccessibleMessage.sameThread(other: AccessibleMessage) = sameTopic(other) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt index b7831999b9..dae6a94efb 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt @@ -18,9 +18,8 @@ import dev.inmo.tgbotapi.utils.PreviewFeature fun CallbackQuery.sourceChat() = when (this) { is InlineMessageIdDataCallbackQuery -> null - is MessageDataCallbackQuery -> message.chat + is AbstractMessageCallbackQuery -> message.chat is InlineMessageIdGameShortNameCallbackQuery -> null - is MessageGameShortNameCallbackQuery -> message.chat is UnknownCallbackQueryType -> null } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index ca069ef5c4..9b65ae7a90 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.ConnectedFromChannelGroupContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList @@ -22,58 +23,58 @@ import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.utils.RiskFeature @RiskFeature(RawFieldsUsageWarning) -inline val Message.from: User? +inline val AccessibleMessage.from: User? get() = asFromUser() ?.from @RiskFeature(RawFieldsUsageWarning) -inline val Message.sender_chat: PublicChat? +inline val AccessibleMessage.sender_chat: PublicChat? get() = asFromChannelGroupContentMessage() ?.senderChat @RiskFeature(RawFieldsUsageWarning) -inline val Message.forward_from: User? +inline val AccessibleMessage.forward_from: User? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asUserForwardInfo() ?.from @RiskFeature(RawFieldsUsageWarning) -inline val Message.forward_from_chat: Chat? +inline val AccessibleMessage.forward_from_chat: Chat? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromPublicChatInfo() ?.chat @RiskFeature(RawFieldsUsageWarning) -inline val Message.forward_from_message_id: MessageId? +inline val AccessibleMessage.forward_from_message_id: MessageId? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.messageId @RiskFeature(RawFieldsUsageWarning) -inline val Message.forward_signature: ForwardSignature? +inline val AccessibleMessage.forward_signature: ForwardSignature? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.signature @RiskFeature(RawFieldsUsageWarning) -inline val Message.forward_sender_name: ForwardSenderName? +inline val AccessibleMessage.forward_sender_name: ForwardSenderName? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asAnonymousForwardInfo() ?.senderName @RiskFeature(RawFieldsUsageWarning) -inline val Message.forward_date: TelegramDate? +inline val AccessibleMessage.forward_date: TelegramDate? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.dateOfOriginal @RiskFeature(RawFieldsUsageWarning) -inline val Message.is_automatic_forward: Boolean? +inline val AccessibleMessage.is_automatic_forward: Boolean? get() = this is ConnectedFromChannelGroupContentMessage<*> @RiskFeature(RawFieldsUsageWarning) -inline val Message.reply_to_message: Message? +inline val AccessibleMessage.reply_to_message: AccessibleMessage? get() = asPossiblyReplyMessage() ?.replyTo @RiskFeature(RawFieldsUsageWarning) -inline val Message.via_bot: CommonBot? +inline val AccessibleMessage.via_bot: CommonBot? get() = asPossiblySentViaBotCommonMessage() ?.senderBot @RiskFeature(RawFieldsUsageWarning) -inline val Message.edit_date: TelegramDate? +inline val AccessibleMessage.edit_date: TelegramDate? get() = asPossiblyEditedMessage() ?.editDate ?.toTelegramDate() @RiskFeature(RawFieldsUsageWarning) -inline val Message.has_protected_content: Boolean? +inline val AccessibleMessage.has_protected_content: Boolean? get() = asContentMessage() ?.hasProtectedContent @RiskFeature(RawFieldsUsageWarning) -inline val Message.media_group_id: MediaGroupIdentifier? +inline val AccessibleMessage.media_group_id: MediaGroupIdentifier? get() = asMediaGroupMessage() ?.mediaGroupId @RiskFeature(RawFieldsUsageWarning) -inline val Message.author_signature: AuthorSignature? +inline val AccessibleMessage.author_signature: AuthorSignature? get() = asSignedMessage() ?.authorSignature @RiskFeature(RawFieldsUsageWarning) -inline val Message.text: String? +inline val AccessibleMessage.text: String? get() = asContentMessage() ?.content ?.asTextContent() ?.text @RiskFeature(RawFieldsUsageWarning) -inline val Message.entities: TextSourcesList? +inline val AccessibleMessage.entities: TextSourcesList? get() = asContentMessage() ?.content ?.asTextContent() ?.textSources @RiskFeature(RawFieldsUsageWarning) -inline val Message.caption: String? +inline val AccessibleMessage.caption: String? get() = whenContentMessage { if (it.content !is TextContent) { it.content.asTextedInput() ?.text @@ -82,7 +83,7 @@ inline val Message.caption: String? } } @RiskFeature(RawFieldsUsageWarning) -inline val Message.caption_entities: TextSourcesList? +inline val AccessibleMessage.caption_entities: TextSourcesList? get() = whenContentMessage { if (it.content !is TextContent) { it.content.asTextedInput() ?.textSources @@ -91,117 +92,117 @@ inline val Message.caption_entities: TextSourcesList? } } @RiskFeature(RawFieldsUsageWarning) -inline val Message.audio: AudioFile? +inline val AccessibleMessage.audio: AudioFile? get() = asContentMessage() ?.content ?.asAudioContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val Message.document: DocumentFile? +inline val AccessibleMessage.document: DocumentFile? get() = asContentMessage() ?.content ?.asDocumentContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val Message.animation: AnimationFile? +inline val AccessibleMessage.animation: AnimationFile? get() = asContentMessage() ?.content ?.asAnimationContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val Message.game: Game? +inline val AccessibleMessage.game: Game? get() = asContentMessage() ?.content ?.asGameContent() ?.game @RiskFeature(RawFieldsUsageWarning) -inline val Message.photo: Photo? +inline val AccessibleMessage.photo: Photo? get() = asContentMessage() ?.content ?.asPhotoContent() ?.mediaCollection @RiskFeature(RawFieldsUsageWarning) -inline val Message.sticker: Sticker? +inline val AccessibleMessage.sticker: Sticker? get() = asContentMessage() ?.content ?.asStickerContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val Message.video: VideoFile? +inline val AccessibleMessage.video: VideoFile? get() = asContentMessage() ?.content ?.asVideoContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val Message.voice: VoiceFile? +inline val AccessibleMessage.voice: VoiceFile? get() = asContentMessage() ?.content ?.asVoiceContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val Message.video_note: VideoNoteFile? +inline val AccessibleMessage.video_note: VideoNoteFile? get() = asContentMessage() ?.content ?.asVideoNoteContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val Message.contact: Contact? +inline val AccessibleMessage.contact: Contact? get() = asContentMessage() ?.content ?.asContactContent() ?.contact @RiskFeature(RawFieldsUsageWarning) -inline val Message.location: Location? +inline val AccessibleMessage.location: Location? get() = asContentMessage() ?.content ?.asLocationContent() ?.location @RiskFeature(RawFieldsUsageWarning) -inline val Message.venue: Venue? +inline val AccessibleMessage.venue: Venue? get() = asContentMessage() ?.content ?.asVenueContent() ?.venue @RiskFeature(RawFieldsUsageWarning) -inline val Message.poll: Poll? +inline val AccessibleMessage.poll: Poll? get() = asContentMessage() ?.content ?.asPollContent() ?.poll @RiskFeature(RawFieldsUsageWarning) -inline val Message.invoice: Invoice? +inline val AccessibleMessage.invoice: Invoice? get() = asContentMessage() ?.content ?.asInvoiceContent() ?.invoice @RiskFeature(RawFieldsUsageWarning) -inline val Message.dice: Dice? +inline val AccessibleMessage.dice: Dice? get() = asContentMessage() ?.content ?.asDiceContent() ?.dice @RiskFeature(RawFieldsUsageWarning) -inline val Message.new_chat_members: List? +inline val AccessibleMessage.new_chat_members: List? get() = asChatEventMessage() ?.chatEvent ?.asNewChatMembers() ?.members @RiskFeature(RawFieldsUsageWarning) -inline val Message.left_chat_member: User? +inline val AccessibleMessage.left_chat_member: User? get() = asChatEventMessage() ?.chatEvent ?.asLeftChatMember() ?.user @RiskFeature(RawFieldsUsageWarning) -inline val Message.new_chat_title: String? +inline val AccessibleMessage.new_chat_title: String? get() = asChatEventMessage() ?.chatEvent ?.asNewChatTitle() ?.title @RiskFeature(RawFieldsUsageWarning) -inline val Message.new_chat_photo: Photo? +inline val AccessibleMessage.new_chat_photo: Photo? get() = asChatEventMessage() ?.chatEvent ?.asNewChatPhoto() ?.photo @RiskFeature(RawFieldsUsageWarning) -inline val Message.delete_chat_photo: Boolean +inline val AccessibleMessage.delete_chat_photo: Boolean get() = asChatEventMessage() ?.chatEvent is DeleteChatPhoto @RiskFeature(RawFieldsUsageWarning) -inline val Message.group_chat_created: Boolean +inline val AccessibleMessage.group_chat_created: Boolean get() = asChatEventMessage() ?.chatEvent is GroupChatCreated @RiskFeature(RawFieldsUsageWarning) -inline val Message.supergroup_chat_created: Boolean +inline val AccessibleMessage.supergroup_chat_created: Boolean get() = asChatEventMessage() ?.chatEvent is SupergroupChatCreated @RiskFeature(RawFieldsUsageWarning) -inline val Message.channel_chat_created: Boolean +inline val AccessibleMessage.channel_chat_created: Boolean get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated @RiskFeature(RawFieldsUsageWarning) -inline val Message.migrate_to_chat_id: IdChatIdentifier? +inline val AccessibleMessage.migrate_to_chat_id: IdChatIdentifier? get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo @RiskFeature(RawFieldsUsageWarning) -inline val Message.migrate_from_chat_id: IdChatIdentifier? +inline val AccessibleMessage.migrate_from_chat_id: IdChatIdentifier? get() = asChatEventMessage() ?.chatEvent ?.let { it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom } @RiskFeature(RawFieldsUsageWarning) -inline val Message.pinned_message: Message? +inline val AccessibleMessage.pinned_message: Message? get() = asChatEventMessage() ?.chatEvent ?.asPinnedMessage() ?.message @RiskFeature(RawFieldsUsageWarning) -inline val Message.successful_payment: SuccessfulPayment? +inline val AccessibleMessage.successful_payment: SuccessfulPayment? get() = asChatEventMessage() ?.chatEvent ?.asSuccessfulPaymentEvent() ?.payment @RiskFeature(RawFieldsUsageWarning) -inline val Message.video_chat_scheduled: VideoChatScheduled? +inline val AccessibleMessage.video_chat_scheduled: VideoChatScheduled? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatScheduled() @RiskFeature(RawFieldsUsageWarning) -inline val Message.video_chat_started: VideoChatStarted? +inline val AccessibleMessage.video_chat_started: VideoChatStarted? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatStarted() @RiskFeature(RawFieldsUsageWarning) -inline val Message.video_chat_ended: VideoChatEnded? +inline val AccessibleMessage.video_chat_ended: VideoChatEnded? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatEnded() @RiskFeature(RawFieldsUsageWarning) -inline val Message.video_chat_participants_invited: VideoChatParticipantsInvited? +inline val AccessibleMessage.video_chat_participants_invited: VideoChatParticipantsInvited? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatParticipantsInvited() @RiskFeature(RawFieldsUsageWarning) -inline val Message.message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? +inline val AccessibleMessage.message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? get() = asChatEventMessage() ?.chatEvent ?.asMessageAutoDeleteTimerChanged() @RiskFeature(RawFieldsUsageWarning) -inline val Message.connected_website: String? +inline val AccessibleMessage.connected_website: String? get() = asChatEventMessage() ?.chatEvent ?.asUserLoggedIn() ?.domain @RiskFeature(RawFieldsUsageWarning) -inline val Message.proximity_alert_triggered: ProximityAlertTriggered? +inline val AccessibleMessage.proximity_alert_triggered: ProximityAlertTriggered? get() = asChatEventMessage() ?.chatEvent ?.asProximityAlertTriggered() @RiskFeature(RawFieldsUsageWarning) -inline val Message.passport_data: PassportData? +inline val AccessibleMessage.passport_data: PassportData? get() = asPassportMessage() ?.passportData @RiskFeature(RawFieldsUsageWarning) -inline val Message.reply_markup: InlineKeyboardMarkup? +inline val AccessibleMessage.reply_markup: InlineKeyboardMarkup? get() = asCommonMessage() ?.replyMarkup diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt index 98bd0ccc5d..af8342df7a 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.formatting import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.* -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.textsources.link import io.ktor.http.encodeURLQueryComponent @@ -69,7 +69,7 @@ fun makeLinkToMessage( ): String = makeLinkToMessage(chatId.chatId, messageId, chatId.threadId) /** - * Link which can be used as by any user to get access to [Message]. Returns null in case when there are no + * Link which can be used as by any user to get access to [AccessibleMessage]. Returns null in case when there are no * known way to build link (for [PrivateChat]s, for example) */ fun makeLinkToMessage( @@ -88,7 +88,7 @@ fun makeLinkToMessage( /** * @see makeLinkToMessage */ -val Message.messageLink: String? +val AccessibleMessage.messageLink: String? get() = makeLinkToMessage( chat, messageId diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt index 03963a88f4..9461999457 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull @@ -58,10 +58,10 @@ fun CommonMessage<*>.hasNoCommands(): Boolean = !this.hasCommands() * } * ``` * - * @return true if this [Message] is from forum ([threadIdOrNull] is not null). False otherwise. + * @return true if this [AccessibleMessage] is from forum ([threadIdOrNull] is not null). False otherwise. * @see notForumMessage */ -fun Message.forumMessage(): Boolean = threadIdOrNull != null +fun AccessibleMessage.forumMessage(): Boolean = threadIdOrNull != null /** * A predicate to test that message has not been sent in the forum. @@ -76,7 +76,7 @@ fun Message.forumMessage(): Boolean = threadIdOrNull != null * } * ``` * - * @return true if this [Message] is not from forum ([threadIdOrNull] is not null). False otherwise. + * @return true if this [AccessibleMessage] is not from forum ([threadIdOrNull] is not null). False otherwise. * @see forumMessage */ -fun Message.notForumMessage(): Boolean = !forumMessage() +fun AccessibleMessage.notForumMessage(): Boolean = !forumMessage() From 6c76e1c47ad7ec7ebd85aa617c113bdfbabf8531 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 17:12:37 +0600 Subject: [PATCH 26/65] add support of MessageOrigin --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 4 + .../message/ChannelContentMessageImpl.kt | 21 ++- .../tgbotapi/types/message/ForwardInfo.kt | 52 ++++++ .../tgbotapi/types/message/GroupMessages.kt | 154 ++++++++++++++++-- .../tgbotapi/types/message/MessageOrigin.kt | 89 ++++++++++ .../message/PrivateContentMessageImpl.kt | 21 ++- .../inmo/tgbotapi/types/message/RawMessage.kt | 72 ++------ .../abstracts/PossiblyForwardedMessage.kt | 4 + .../MediaGroupContentMessageCreator.kt | 20 +-- 9 files changed, 351 insertions(+), 86 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 29e4b67754..56c7b39add 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -201,6 +201,10 @@ const val tgWebAppStartParamField = "tgWebAppStartParam" const val chatIdField = "chat_id" const val senderChatIdField = "sender_chat_id" +const val senderChatField = "sender_chat" +const val authorSignatureField = "author_signature" +const val senderUserField = "sender_user" +const val senderUserNameField = "sender_user_name" const val messageIdField = "message_id" const val giveawayMessageIdField = "giveaway_message_id" const val messageIdsField = "message_ids" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt index eaab4dc3ad..bfe6234525 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt @@ -15,10 +15,27 @@ data class ChannelContentMessageImpl( override val date: DateTime, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, override val mediaGroupId: MediaGroupIdentifier?, -) : ChannelContentMessage +) : ChannelContentMessage { + constructor( + messageId: MessageId, + chat: PreviewChannelChat, + content: T, + date: DateTime, + editDate: DateTime?, + hasProtectedContent: Boolean, + forwardInfo: ForwardInfo, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + senderBot: CommonBot?, + authorSignature: AuthorSignature?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + messageId, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo, replyMarkup, senderBot, authorSignature, mediaGroupId + ) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt index 58eb633bd6..be74e8c3db 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt @@ -57,3 +57,55 @@ sealed interface ForwardInfo { } } } + +fun MessageOrigin.forwardInfo() = when(this) { + is MessageOrigin.HiddenUser -> ForwardInfo.ByAnonymous( + date, + name + ) + is MessageOrigin.Public.Channel -> ForwardInfo.PublicChat.FromChannel( + date, + messageId, + chat, + authorSignature + ) + is MessageOrigin.Public.Sender -> when (chat) { + is ChannelChat -> ForwardInfo.PublicChat.SentByChannel( + date, + chat + ) + is SupergroupChat -> ForwardInfo.PublicChat.FromSupergroup( + date, + chat + ) + } + is MessageOrigin.User -> ForwardInfo.ByUser( + date, + user + ) +} + +fun ForwardInfo.messageOrigin() = when (this) { + is ForwardInfo.ByAnonymous -> MessageOrigin.HiddenUser( + senderName, + dateOfOriginal + ) + is ForwardInfo.ByUser -> MessageOrigin.User( + user, + dateOfOriginal + ) + is ForwardInfo.PublicChat.FromChannel -> MessageOrigin.Public.Channel( + channelChat, + messageId, + dateOfOriginal, + signature + ) + is ForwardInfo.PublicChat.FromSupergroup -> MessageOrigin.Public.Sender( + group, + dateOfOriginal + ) + is ForwardInfo.PublicChat.SentByChannel -> MessageOrigin.Public.Sender( + channelChat, + dateOfOriginal + ) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt index 78d90720e1..bfa54b8c1f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt @@ -14,7 +14,7 @@ data class ConnectedFromChannelGroupContentMessageImpl( override val channel: PreviewChannelChat, override val messageId: MessageId, override val date: DateTime, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val replyTo: AccessibleMessage?, @@ -23,14 +23,33 @@ data class ConnectedFromChannelGroupContentMessageImpl( override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, override val mediaGroupId: MediaGroupIdentifier?, -) : ConnectedFromChannelGroupContentMessage +) : ConnectedFromChannelGroupContentMessage { + + constructor( + chat: PreviewGroupChat, + channel: PreviewChannelChat, + messageId: MessageId, + date: DateTime, + forwardInfo: ForwardInfo, + editDate: DateTime?, + hasProtectedContent: Boolean, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + content: T, + senderBot: CommonBot?, + authorSignature: AuthorSignature?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + ) +} data class UnconnectedFromChannelGroupContentMessageImpl( override val chat: PreviewGroupChat, override val channel: PreviewChannelChat, override val messageId: MessageId, override val date: DateTime, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val replyTo: AccessibleMessage?, @@ -39,13 +58,31 @@ data class UnconnectedFromChannelGroupContentMessageImpl( override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, override val mediaGroupId: MediaGroupIdentifier?, -) : UnconnectedFromChannelGroupContentMessage +) : UnconnectedFromChannelGroupContentMessage { + constructor( + chat: PreviewGroupChat, + channel: PreviewChannelChat, + messageId: MessageId, + date: DateTime, + forwardInfo: ForwardInfo, + editDate: DateTime?, + hasProtectedContent: Boolean, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + content: T, + senderBot: CommonBot?, + authorSignature: AuthorSignature?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + ) +} data class AnonymousGroupContentMessageImpl( override val chat: PreviewGroupChat, override val messageId: MessageId, override val date: DateTime, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val replyTo: AccessibleMessage?, @@ -54,14 +91,31 @@ data class AnonymousGroupContentMessageImpl( override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, override val mediaGroupId: MediaGroupIdentifier?, -) : AnonymousGroupContentMessage +) : AnonymousGroupContentMessage { + constructor( + chat: PreviewGroupChat, + messageId: MessageId, + date: DateTime, + forwardInfo: ForwardInfo, + editDate: DateTime?, + hasProtectedContent: Boolean, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + content: T, + senderBot: CommonBot?, + authorSignature: AuthorSignature?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + ) +} data class CommonGroupContentMessageImpl( override val chat: PreviewGroupChat, override val messageId: MessageId, override val from: User, override val date: DateTime, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val replyTo: AccessibleMessage?, @@ -69,7 +123,24 @@ data class CommonGroupContentMessageImpl( override val content: T, override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupIdentifier?, -) : CommonGroupContentMessage +) : CommonGroupContentMessage { + constructor( + chat: PreviewGroupChat, + messageId: MessageId, + from: User, + date: DateTime, + forwardInfo: ForwardInfo, + editDate: DateTime?, + hasProtectedContent: Boolean, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + content: T, + senderBot: CommonBot?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, mediaGroupId + ) +} data class FromChannelForumContentMessageImpl( override val chat: PreviewForumChat, @@ -77,7 +148,7 @@ data class FromChannelForumContentMessageImpl( override val messageId: MessageId, override val threadId: MessageThreadId, override val date: DateTime, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val replyTo: AccessibleMessage?, @@ -86,14 +157,33 @@ data class FromChannelForumContentMessageImpl( override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, override val mediaGroupId: MediaGroupIdentifier?, -) : FromChannelForumContentMessage +) : FromChannelForumContentMessage { + constructor( + chat: PreviewForumChat, + channel: PreviewChannelChat, + messageId: MessageId, + threadId: MessageThreadId, + date: DateTime, + forwardInfo: ForwardInfo, + editDate: DateTime?, + hasProtectedContent: Boolean, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + content: T, + senderBot: CommonBot?, + authorSignature: AuthorSignature?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + ) +} data class AnonymousForumContentMessageImpl( override val chat: PreviewForumChat, override val messageId: MessageId, override val threadId: MessageThreadId, override val date: DateTime, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val replyTo: AccessibleMessage?, @@ -102,7 +192,25 @@ data class AnonymousForumContentMessageImpl( override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, override val mediaGroupId: MediaGroupIdentifier?, -) : AnonymousForumContentMessage +) : AnonymousForumContentMessage { + constructor( + chat: PreviewForumChat, + messageId: MessageId, + threadId: MessageThreadId, + date: DateTime, + forwardInfo: ForwardInfo, + editDate: DateTime?, + hasProtectedContent: Boolean, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + content: T, + senderBot: CommonBot?, + authorSignature: AuthorSignature?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + ) +} data class CommonForumContentMessageImpl( override val chat: PreviewForumChat, @@ -110,7 +218,7 @@ data class CommonForumContentMessageImpl( override val threadId: MessageThreadId, override val from: User, override val date: DateTime, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val replyTo: AccessibleMessage?, @@ -118,4 +226,22 @@ data class CommonForumContentMessageImpl( override val content: T, override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupIdentifier?, -) : CommonForumContentMessage +) : CommonForumContentMessage { + constructor( + chat: PreviewForumChat, + messageId: MessageId, + threadId: MessageThreadId, + from: User, + date: DateTime, + forwardInfo: ForwardInfo, + editDate: DateTime?, + hasProtectedContent: Boolean, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + content: T, + senderBot: CommonBot?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, mediaGroupId + ) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt new file mode 100644 index 0000000000..57e162a3b6 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt @@ -0,0 +1,89 @@ +package dev.inmo.tgbotapi.types.message + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.* +import kotlinx.serialization.Required +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +sealed interface MessageOrigin { + val type: String + val date: TelegramDate + + @Serializable + data class User( + @SerialName(senderUserField) + val user: dev.inmo.tgbotapi.types.chat.User, + @SerialName(dateField) + override val date: TelegramDate + ) : MessageOrigin { + @SerialName(typeField) + @Required + override val type: String = Companion.type + + companion object { + val type: String = "user" + } + } + + @Serializable + data class HiddenUser( + @SerialName(senderUserNameField) + val name: String, + @SerialName(dateField) + override val date: TelegramDate + ) : MessageOrigin { + @SerialName(typeField) + @Required + override val type: String = Companion.type + + companion object { + val type: String = "hidden_user" + } + } + + @Serializable + sealed interface Public : MessageOrigin { + val chat: PublicChat + val authorSignature: AuthorSignature? + + @Serializable + data class Sender( + @SerialName(senderChatField) + override val chat: SuperPublicChat, + @SerialName(dateField) + override val date: TelegramDate, + @SerialName(authorSignatureField) + override val authorSignature: AuthorSignature? = null + ) : Public { + @SerialName(typeField) + @Required + override val type: String = Companion.type + + companion object { + val type: String = "chat" + } + } + + @Serializable + data class Channel( + @SerialName(chatField) + override val chat: ChannelChat, + @SerialName(messageIdField) + val messageId: MessageId, + @SerialName(dateField) + override val date: TelegramDate, + @SerialName(authorSignatureField) + override val authorSignature: AuthorSignature? = null + ) : Public { + @SerialName(typeField) + @Required + override val type: String = Companion.type + + companion object { + val type: String = "channel" + } + } + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt index 74f5ea3797..21438aea84 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt @@ -18,9 +18,26 @@ data class PrivateContentMessageImpl( override val date: DateTime, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val forwardInfo: ForwardInfo?, + override val forwardOrigin: MessageOrigin?, override val replyTo: AccessibleMessage?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupIdentifier?, -) : PrivateContentMessage +) : PrivateContentMessage { + constructor( + messageId: MessageId, + from: User, + chat: PreviewPrivateChat, + content: T, + date: DateTime, + editDate: DateTime?, + hasProtectedContent: Boolean, + forwardInfo: ForwardInfo, + replyTo: AccessibleMessage?, + replyMarkup: InlineKeyboardMarkup?, + senderBot: CommonBot?, + mediaGroupId: MediaGroupIdentifier?, + ) : this( + messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo, replyMarkup, senderBot, mediaGroupId + ) +} 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 325aed76af..f876f18ed6 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 @@ -52,12 +52,8 @@ internal data class RawMessage( private val messageThreadId: MessageThreadId? = null, private val from: User? = null, private val sender_chat: PreviewPublicChat? = null, - private val forward_from: User? = null, - private val forward_from_chat: Chat? = null, - private val forward_from_message_id: MessageId? = null, - private val forward_signature: ForwardSignature? = null, - private val forward_sender_name: ForwardSenderName? = null, - private val forward_date: TelegramDate? = null, + private val forward_origin: MessageOrigin? = null, + private val is_topic_message: Boolean? = null, private val is_automatic_forward: Boolean? = null, private val reply_to_message: RawMessage? = null, private val via_bot: CommonBot? = null, @@ -201,44 +197,6 @@ internal data class RawMessage( } } - private val forwarded: ForwardInfo? by lazy { - forward_date - ?: return@lazy null // According to the documentation, now any forwarded message contains this field - when { - forward_sender_name != null -> ForwardInfo.ByAnonymous( - forward_date, - forward_sender_name - ) - - forward_from_chat is ChannelChat -> if (forward_from_message_id == null) { - ForwardInfo.PublicChat.SentByChannel( - forward_date, - forward_from_chat, - forward_signature - ) - } else { - ForwardInfo.PublicChat.FromChannel( - forward_date, - forward_from_message_id, - forward_from_chat, - forward_signature - ) - } - - forward_from_chat is SupergroupChat -> ForwardInfo.PublicChat.FromSupergroup( - forward_date, - forward_from_chat - ) - - forward_from != null -> ForwardInfo.ByUser( - forward_date, - forward_from - ) - - else -> null - } - } - private val chatEvent: ChatEvent? by lazy { when { new_chat_members != null -> NewChatMembers(new_chat_members.toList()) @@ -334,7 +292,7 @@ internal data class RawMessage( date.asDate, edit_date?.asDate, has_protected_content == true, - forwarded, + forward_origin, reply_to_message?.asMessage, reply_markup, via_bot, @@ -356,7 +314,7 @@ internal data class RawMessage( messageId, messageThreadId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -371,7 +329,7 @@ internal data class RawMessage( messageId, messageThreadId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -387,7 +345,7 @@ internal data class RawMessage( messageThreadId, from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -405,7 +363,7 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -421,7 +379,7 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -436,7 +394,7 @@ internal data class RawMessage( chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -451,7 +409,7 @@ internal data class RawMessage( messageId, from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -469,7 +427,7 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -485,7 +443,7 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -500,7 +458,7 @@ internal data class RawMessage( chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -515,7 +473,7 @@ internal data class RawMessage( messageId, from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, reply_to_message ?.asMessage, @@ -534,7 +492,7 @@ internal data class RawMessage( date.asDate, edit_date?.asDate, has_protected_content == true, - forwarded, + forward_origin, reply_to_message?.asMessage, reply_markup, via_bot, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt index 41b8938f74..6c6e13b608 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyForwardedMessage.kt @@ -1,7 +1,11 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.ForwardInfo +import dev.inmo.tgbotapi.types.message.MessageOrigin +import dev.inmo.tgbotapi.types.message.forwardInfo interface PossiblyForwardedMessage : AccessibleMessage { + val forwardOrigin: MessageOrigin? val forwardInfo: ForwardInfo? + get() = forwardOrigin ?.forwardInfo() } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt index dcf3b4d3eb..5ed0e6f3af 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.utils.extensions -import dev.inmo.tgbotapi.types.MediaGroupIdentifier import dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl import dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl import dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl @@ -15,7 +14,6 @@ import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage import dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.CommonGroupContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.ConnectedFromChannelGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage @@ -41,7 +39,7 @@ fun List>.asMedia sourceMessage.date, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.replyTo, sourceMessage.replyMarkup, sourceMessage.senderBot, @@ -56,7 +54,7 @@ fun List>.asMedia sourceMessage.date, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.replyTo, sourceMessage.replyMarkup, sourceMessage.senderBot, @@ -66,7 +64,7 @@ fun List>.asMedia sourceMessage.chat, sourceMessage.messageId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.replyTo, @@ -81,7 +79,7 @@ fun List>.asMedia sourceMessage.messageId, sourceMessage.user, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.replyTo, @@ -95,7 +93,7 @@ fun List>.asMedia sourceMessage.channel, sourceMessage.messageId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.replyTo, @@ -110,7 +108,7 @@ fun List>.asMedia sourceMessage.channel, sourceMessage.messageId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.replyTo, @@ -125,7 +123,7 @@ fun List>.asMedia sourceMessage.messageId, sourceMessage.threadId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.replyTo, @@ -141,7 +139,7 @@ fun List>.asMedia sourceMessage.threadId, sourceMessage.user, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.replyTo, @@ -156,7 +154,7 @@ fun List>.asMedia sourceMessage.messageId, sourceMessage.threadId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.replyTo, From f760e600895300013cbb04a3cc6e01e52921a8af Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 17:40:41 +0600 Subject: [PATCH 27/65] fixes in typing of giveaways --- .../expectations/WaitContent.kt | 10 ++++ .../expectations/WaitContentMessage.kt | 10 ++++ .../expectations/WaitEditedContent.kt | 11 ++++ .../expectations/WaitEditedContentMessage.kt | 11 ++++ .../triggers_handling/ContentTriggers.kt | 49 +++++++++++++++++ .../types/giveaway/GiveawayPrivateResults.kt | 4 +- .../types/giveaway/GiveawayResults.kt | 2 +- .../{Giveaway.kt => ScheduledGiveaway.kt} | 9 ++-- .../inmo/tgbotapi/types/message/RawMessage.kt | 13 +++-- .../content/GiveawayPublicResultsContent.kt | 25 +++++++++ .../content/ScheduledGiveawayContent.kt | 29 ++++++++++ .../types/message/content/Typealiases.kt | 2 + .../extensions/utils/ClassCastsNew.kt | 54 +++++++++---------- 13 files changed, 187 insertions(+), 42 deletions(-) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/{Giveaway.kt => ScheduledGiveaway.kt} (79%) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 6bafc17182..2fe2743266 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -138,3 +138,13 @@ suspend fun BehaviourContext.waitMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory).mapContent() + +suspend fun BehaviourContext.waitScheduledGiveawayContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory).mapContent() + +suspend fun BehaviourContext.waitGiveawayPublicResultsContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory).mapContent() diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt index d0e151480a..7ff93f2931 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt @@ -152,3 +152,13 @@ suspend fun BehaviourContext.waitMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory).mapWithContent() + +suspend fun BehaviourContext.waitScheduledGiveawayContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory).mapWithContent() + +suspend fun BehaviourContext.waitGiveawayPublicResultsContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory).mapWithContent() diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index c78ab0452a..d3761f4097 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -130,3 +130,14 @@ suspend fun BehaviourContext.waitEditedInvoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContent(initRequest, false, errorFactory) + +suspend fun BehaviourContext.waitEditedScheduledGiveawayContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) + +suspend fun BehaviourContext.waitEditedGiveawayPublicResultsContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) + diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt index 99d14d8d0b..4790f8ac71 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt @@ -136,3 +136,14 @@ suspend fun BehaviourContext.waitEditedInvoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContentMessage(initRequest, errorFactory) + +suspend fun BehaviourContext.waitEditedScheduledGiveawayContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) + +suspend fun BehaviourContext.waitEditedGiveawayPublicResultsContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) + diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index a2b1a002b4..0b3e5ec1eb 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -703,3 +703,52 @@ suspend fun BC.onMediaContent( markerFactory, scenarioReceiver ) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onScheduledGiveawayContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + markerFactory: MarkerFactory = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onContentMessageWithType( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onScheduledGiveawayContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + markerFactory: MarkerFactory = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onContentMessageWithType( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt index 8fbbf42bc2..81cbc2ce03 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt @@ -1,6 +1,8 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import kotlinx.serialization.Serializable import kotlinx.serialization.Transient @@ -11,4 +13,4 @@ data class GiveawayPrivateResults( override val unclaimedCount: Int, @Transient // TODO::Add message serializer val message: AccessibleMessage? = null -) : GiveawayResults +) : GiveawayResults, ChatEvent, PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt index fc193537e6..90628b1ee3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt @@ -6,6 +6,6 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent import kotlinx.serialization.Serializable @Serializable -sealed interface GiveawayResults : WithPreviewChat, ChatEvent, PublicChatEvent { +sealed interface GiveawayResults : WithPreviewChat { val unclaimedCount: Int } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt similarity index 79% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt index cbae4c2740..d0642619f0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt @@ -1,16 +1,19 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.micro_utils.language_codes.IetfLang +import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.PreviewChat -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.giveaway.GiveawayInfo import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class Giveaway( +data class ScheduledGiveaway( @SerialName(chatsField) val chats: List, @SerialName(winnersSelectionDateField) @@ -27,4 +30,4 @@ data class Giveaway( val countries: List? = null, @SerialName(premiumSubscriptionMonthCountField) override val premiumMonths: Int? = null -) : GiveawayInfo, ChatEvent, PublicChatEvent \ No newline at end of file +) : GiveawayInfo \ No newline at end of file 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 f876f18ed6..e8758b9045 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 @@ -9,10 +9,8 @@ import dev.inmo.tgbotapi.types.dice.Dice import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.games.RawGame -import dev.inmo.tgbotapi.types.giveaway.Giveaway -import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated -import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults -import dev.inmo.tgbotapi.types.giveaway.GiveawayResults +import dev.inmo.tgbotapi.types.giveaway.* +import dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -134,7 +132,7 @@ internal data class RawMessage( // Giveaways private val giveaway_created: GiveawayCreated? = null, - private val giveaway: Giveaway? = null, + private val giveaway: ScheduledGiveaway? = null, private val giveaway_winners: GiveawayResults? = null, private val giveaway_completed: GiveawayPrivateResults? = null, ) { @@ -193,6 +191,8 @@ internal data class RawMessage( venue != null -> VenueContent(venue) poll != null -> PollContent(poll) invoice != null -> InvoiceContent(invoice) + giveaway != null -> ScheduledGiveawayContent(giveaway) + giveaway_winners is GiveawayPublicResults -> GiveawayPublicResultsContent(giveaway_winners) else -> null } } @@ -237,8 +237,7 @@ internal data class RawMessage( users_shared != null -> users_shared chat_shared != null -> chat_shared giveaway_created != null -> giveaway_created - giveaway != null -> giveaway - giveaway_winners != null -> giveaway_winners + giveaway_winners is GiveawayPrivateResults -> giveaway_winners giveaway_completed != null -> giveaway_completed else -> null } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt new file mode 100644 index 0000000000..3d4a5e4ded --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt @@ -0,0 +1,25 @@ +package dev.inmo.tgbotapi.types.message.content + +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import kotlinx.serialization.Serializable + +@Serializable +data class GiveawayPublicResultsContent( + val giveaway: GiveawayPublicResults +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, + disableNotification: Boolean, + protectContent: Boolean, + replyToMessageId: MessageId?, + allowSendingWithoutReply: Boolean?, + replyMarkup: KeyboardMarkup? + ): Request { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt new file mode 100644 index 0000000000..47386da9ef --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt @@ -0,0 +1,29 @@ +package dev.inmo.tgbotapi.types.message.content + +import dev.inmo.micro_utils.language_codes.IetfLang +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.giveaway.GiveawayInfo +import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ScheduledGiveawayContent( + val giveaway: ScheduledGiveaway +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, + disableNotification: Boolean, + protectContent: Boolean, + replyToMessageId: MessageId?, + allowSendingWithoutReply: Boolean?, + replyMarkup: KeyboardMarkup? + ): Request { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt index 9e9a865f9f..399ef34cd8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt @@ -32,5 +32,7 @@ typealias VisualMediaGroupMessage = CommonMessage typealias VideoMessage = CommonMessage typealias PhotoMessage = CommonMessage typealias AnimationMessage = CommonMessage +typealias ScheduledGiveawayContentMessage = CommonMessage +typealias GiveawayPublicResultsContentMessage = CommonMessage 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 fd267c4c88..6942deb6ef 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 @@ -197,11 +197,8 @@ import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.VideoNoteFile import dev.inmo.tgbotapi.types.files.VideoSticker import dev.inmo.tgbotapi.types.files.VoiceFile -import dev.inmo.tgbotapi.types.giveaway.Giveaway import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults -import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults -import dev.inmo.tgbotapi.types.giveaway.GiveawayResults import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.location.StaticLocation @@ -298,6 +295,7 @@ import dev.inmo.tgbotapi.types.message.content.DiceContent import dev.inmo.tgbotapi.types.message.content.DocumentContent import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.GameContent +import dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.message.content.LiveLocationContent import dev.inmo.tgbotapi.types.message.content.LocationContent @@ -310,6 +308,7 @@ import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.PhotoContent import dev.inmo.tgbotapi.types.message.content.PollContent import dev.inmo.tgbotapi.types.message.content.ResendableContent +import dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent import dev.inmo.tgbotapi.types.message.content.StaticLocationContent import dev.inmo.tgbotapi.types.message.content.StickerContent @@ -2781,15 +2780,6 @@ public inline fun TelegramMedia.titledTelegramMediaOrThrow(): TitledTelegramMedi public inline fun TelegramMedia.ifTitledTelegramMedia(block: (TitledTelegramMedia) -> T): T? = titledTelegramMediaOrNull() ?.let(block) -public inline fun ChatEvent.giveawayOrNull(): Giveaway? = this as? - dev.inmo.tgbotapi.types.giveaway.Giveaway - -public inline fun ChatEvent.giveawayOrThrow(): Giveaway = this as - dev.inmo.tgbotapi.types.giveaway.Giveaway - -public inline fun ChatEvent.ifGiveaway(block: (Giveaway) -> T): T? = giveawayOrNull() - ?.let(block) - public inline fun ChatEvent.giveawayCreatedOrNull(): GiveawayCreated? = this as? dev.inmo.tgbotapi.types.giveaway.GiveawayCreated @@ -2808,24 +2798,6 @@ public inline fun ChatEvent.giveawayPrivateResultsOrThrow(): GiveawayPrivateResu public inline fun ChatEvent.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = giveawayPrivateResultsOrNull() ?.let(block) -public inline fun ChatEvent.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun ChatEvent.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun ChatEvent.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): T? = - giveawayPublicResultsOrNull() ?.let(block) - -public inline fun ChatEvent.giveawayResultsOrNull(): GiveawayResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayResults - -public inline fun ChatEvent.giveawayResultsOrThrow(): GiveawayResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayResults - -public inline fun ChatEvent.ifGiveawayResults(block: (GiveawayResults) -> T): T? = - giveawayResultsOrNull() ?.let(block) - public inline fun ChatEvent.channelChatCreatedOrNull(): ChannelChatCreated? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated @@ -3748,6 +3720,18 @@ public inline fun ResendableContent.gameContentOrThrow(): GameContent = this as public inline fun ResendableContent.ifGameContent(block: (GameContent) -> T): T? = gameContentOrNull() ?.let(block) +public inline fun ResendableContent.giveawayPublicResultsContentOrNull(): + GiveawayPublicResultsContent? = this as? + dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent + +public inline fun ResendableContent.giveawayPublicResultsContentOrThrow(): + GiveawayPublicResultsContent = this as + dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent + +public inline fun + ResendableContent.ifGiveawayPublicResultsContent(block: (GiveawayPublicResultsContent) -> T): T? + = giveawayPublicResultsContentOrNull() ?.let(block) + public inline fun ResendableContent.invoiceContentOrNull(): InvoiceContent? = this as? dev.inmo.tgbotapi.types.message.content.InvoiceContent @@ -3815,6 +3799,16 @@ public inline fun ResendableContent.pollContentOrThrow(): PollContent = this as public inline fun ResendableContent.ifPollContent(block: (PollContent) -> T): T? = pollContentOrNull() ?.let(block) +public inline fun ResendableContent.scheduledGiveawayContentOrNull(): ScheduledGiveawayContent? = + this as? dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent + +public inline fun ResendableContent.scheduledGiveawayContentOrThrow(): ScheduledGiveawayContent = + this as dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent + +public inline fun + ResendableContent.ifScheduledGiveawayContent(block: (ScheduledGiveawayContent) -> T): T? = + scheduledGiveawayContentOrNull() ?.let(block) + public inline fun ResendableContent.stickerContentOrNull(): StickerContent? = this as? dev.inmo.tgbotapi.types.message.content.StickerContent From cad0bf8a951282293ade02e7614cbdc6feb06233 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 19:04:23 +0600 Subject: [PATCH 28/65] add ExternalReplyInfo --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/Contact.kt | 2 +- .../inmo/tgbotapi/types/ExternalReplyInfo.kt | 166 ++++++++++++++++++ .../dev/inmo/tgbotapi/types/dice/Dice.kt | 2 +- .../tgbotapi/types/files/AnimationFile.kt | 3 +- .../inmo/tgbotapi/types/files/AudioFile.kt | 2 +- .../inmo/tgbotapi/types/files/DocumentFile.kt | 2 +- .../inmo/tgbotapi/types/files/PhotoSize.kt | 11 +- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 2 +- .../inmo/tgbotapi/types/files/VideoFile.kt | 3 +- .../tgbotapi/types/files/VideoNoteFile.kt | 2 +- .../inmo/tgbotapi/types/files/VoiceFile.kt | 2 +- .../dev/inmo/tgbotapi/types/games/Game.kt | 3 +- .../types/giveaway/GiveawayPublicResults.kt | 3 +- .../types/giveaway/ScheduledGiveaway.kt | 2 +- .../inmo/tgbotapi/types/location/Location.kt | 2 +- .../inmo/tgbotapi/types/message/RawMessage.kt | 10 +- .../types/message/abstracts/Message.kt | 27 +++ .../types/message/content/Abstracts.kt | 14 +- .../content/GiveawayPublicResultsContent.kt | 10 +- .../content/ScheduledGiveawayContent.kt | 13 +- .../inmo/tgbotapi/types/payments/Invoice.kt | 2 +- .../dev/inmo/tgbotapi/types/polls/Poll.kt | 2 +- .../dev/inmo/tgbotapi/types/stories/Story.kt | 3 +- .../dev/inmo/tgbotapi/types/venue/Venue.kt | 2 +- 25 files changed, 251 insertions(+), 40 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 56c7b39add..cf884c0b4b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -491,6 +491,7 @@ const val isBigField = "is_big" const val oldReactionField = "old_reaction" const val newReactionField = "new_reaction" const val chatField = "chat" +const val originField = "origin" const val chatsField = "chats" const val usernameField = "username" const val bioField = "bio" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt index 1e11d16ad3..b84d4ed72a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt @@ -16,4 +16,4 @@ data class Contact( val userId: UserId? = null, @SerialName(vcardField) override val vcard: String? = null -) : CommonContactData +) : CommonContactData, ExternalReplyInfo.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt new file mode 100644 index 0000000000..7bf46b0d48 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt @@ -0,0 +1,166 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.abstracts.SpoilerableData +import dev.inmo.tgbotapi.types.chat.SuperPublicChat +import dev.inmo.tgbotapi.types.dice.Dice +import dev.inmo.tgbotapi.types.files.* +import dev.inmo.tgbotapi.types.games.Game +import dev.inmo.tgbotapi.types.games.RawGame +import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults +import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway +import dev.inmo.tgbotapi.types.location.Location +import dev.inmo.tgbotapi.types.message.MessageOrigin +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.payments.Invoice +import dev.inmo.tgbotapi.types.polls.Poll +import dev.inmo.tgbotapi.types.stories.Story +import dev.inmo.tgbotapi.types.venue.Venue +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded +import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +@Serializable(ExternalReplyInfo.Companion::class) +@ClassCastsIncluded +sealed interface ExternalReplyInfo { + val origin: MessageOrigin + val chat: SuperPublicChat? + val messageMeta: Message.MetaInfo? + + interface ContentVariant + + @Serializable + data class Text( + override val origin: MessageOrigin, + override val chat: SuperPublicChat?, + override val messageMeta: Message.MetaInfo?, + val linkPreviewOptions: LinkPreviewOptions? + ) : ExternalReplyInfo + + @Serializable(ExternalReplyInfo.Companion::class) + sealed interface Content : ExternalReplyInfo { + val content: ContentVariant + + + @Serializable + data class Simple( + override val origin: MessageOrigin, + override val chat: SuperPublicChat?, + override val messageMeta: Message.MetaInfo?, + override val content: ContentVariant + ) : Content + + @Serializable + data class Media( + override val origin: MessageOrigin, + override val chat: SuperPublicChat?, + override val messageMeta: Message.MetaInfo?, + override val spoilered: Boolean, + override val content: T + ) : Content, SpoilerableData where T: ContentVariant, T : TelegramMediaFile + } + + @Serializable + private data class Surrogate( + val origin: MessageOrigin, + val chat: SuperPublicChat? = null, + val message_id: MessageId? = null, + val link_preview_options: LinkPreviewOptions? = null, + val has_media_spoiler: Boolean? = null, + private val story: Story? = null, + private val audio: AudioFile? = null, + private val document: DocumentFile? = null, + private val animation: AnimationFile? = null, + private val game: RawGame? = null, + @Serializable(PhotoSerializer::class) + private val photo: Photo? = null, + private val sticker: Sticker? = null, + private val video: VideoFile? = null, + private val voice: VoiceFile? = null, + private val video_note: VideoNoteFile? = null, + private val contact: Contact? = null, + private val location: Location? = null, + private val venue: Venue? = null, + private val poll: Poll? = null, + private val invoice: Invoice? = null, + private val dice: Dice? = null, + private val giveaway: ScheduledGiveaway? = null, + private val giveaway_winners: GiveawayPublicResults? = null, + ) { + val asExternalReplyInfo: ExternalReplyInfo + get() { + val messageMeta = chat ?.let { + message_id ?.let { + Message.MetaInfo( + chat.id, + message_id + ) + } + } + val content: ContentVariant? = when { + story != null -> story + audio != null -> audio + video != null -> video + video_note != null -> video_note + animation != null -> animation + document != null -> document + voice != null -> voice + photo != null -> photo + sticker != null -> sticker + dice != null -> dice + game != null -> game.asGame + contact != null -> contact + location != null -> location + venue != null -> venue + poll != null -> poll + invoice != null -> invoice + giveaway != null -> giveaway + giveaway_winners != null -> giveaway_winners + else -> null + } + + return content ?.let { + when (it) { + is TelegramMediaFile -> { + Content.Media( + origin, + chat, + messageMeta, + has_media_spoiler == true, + it + ) + } + else -> Content.Simple( + origin, + chat, + messageMeta, + it + ) + } + } ?: Text( + origin, + chat, + messageMeta, + link_preview_options + ) + } + } + + @RiskFeature("This serializer currently support only deserialization, but not serialization") + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): ExternalReplyInfo { + return Surrogate.serializer().deserialize(decoder).asExternalReplyInfo + } + + override fun serialize(encoder: Encoder, value: ExternalReplyInfo) { + + } + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt index 834df0c729..c5a70ff3f3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt @@ -10,4 +10,4 @@ data class Dice( val value: DiceResult, @SerialName(emojiField) val animationType: DiceAnimationType -) +) : ExternalReplyInfo.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt index 6492f43f39..d09fbcbe79 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt @@ -23,4 +23,5 @@ data class AnimationFile( override val mimeType: MimeType? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, CustomNamedMediaFile, SizedMediaFile +) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, CustomNamedMediaFile, SizedMediaFile, + ExternalReplyInfo.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt index e8a85ac00b..c83351dc25 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt @@ -28,6 +28,6 @@ data class AudioFile( @SerialName(thumbnailField) override val thumbnail: PhotoSize? = null ) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, - Performerable + Performerable, ExternalReplyInfo.ContentVariant fun AudioFile.asVoiceFile() = VoiceFile(fileId, fileUniqueId, duration, mimeType, fileSize) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt index f2b57fe6a7..73df323628 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt @@ -20,7 +20,7 @@ data class DocumentFile( override val mimeType: MimeType? = null, @SerialName(fileNameField) override val fileName: String? = null -) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile +) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile, ExternalReplyInfo.ContentVariant @Suppress("NOTHING_TO_INLINE") inline fun TelegramMediaFile.asDocumentFile() = if (this is DocumentFile) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt index 707eed7e2d..39bd5c42cf 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt @@ -6,17 +6,20 @@ import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer +import kotlin.jvm.JvmInline -typealias Photo = List +@Serializable +@JvmInline +value class Photo( + val photos: List +) : List by photos, ExternalReplyInfo.ContentVariant fun Photo.biggest(): PhotoSize? = maxByOrNull { it.resolution } @RiskFeature -object PhotoSerializer : KSerializer by ListSerializer( - PhotoSize.serializer() -) +object PhotoSerializer : KSerializer by Photo.serializer() @Serializable data class PhotoSize( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt index b05bb06971..4355de3241 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt @@ -34,7 +34,7 @@ data class StickerSurrogate( // TODO:: Serializer @Serializable(StickerSerializer::class) -sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile { +sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile, ExternalReplyInfo.ContentVariant { val emoji: String? val stickerSetName: StickerSetName? val stickerFormat: StickerFormat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 3fbc99a402..5eec4d48a7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -29,7 +29,8 @@ data class VideoFile( override val mimeType: MimeType? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile +) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, + ExternalReplyInfo.ContentVariant @Suppress("NOTHING_TO_INLINE") inline fun VideoFile.toTelegramMediaVideo( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt index d98d872261..49b5ec8889 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt @@ -18,7 +18,7 @@ data class VideoNoteFile( override val thumbnail: PhotoSize? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile { +) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, ExternalReplyInfo.ContentVariant { override val height: Int get() = width } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt index f3a88b1e66..725a52a0ed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt @@ -19,7 +19,7 @@ data class VoiceFile( override val mimeType: MimeType? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile +) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, ExternalReplyInfo.ContentVariant fun VoiceFile.asAudioFile( performer: String? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt index bf908d161f..60027bc169 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.games import dev.inmo.tgbotapi.abstracts.TextedInput import dev.inmo.tgbotapi.abstracts.Titled +import dev.inmo.tgbotapi.types.ExternalReplyInfo import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.Photo @@ -15,4 +16,4 @@ data class Game( override val text: String? = null, override val textSources: TextSourcesList = emptyList(), val animation: AnimationFile? = null -) : Titled, TextedInput +) : Titled, TextedInput, ExternalReplyInfo.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt index 85e9b9a5f6..83fe74fa2f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt @@ -13,7 +13,8 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @Serializable(GiveawayPublicResults.Companion::class) -sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId { +sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId, + ExternalReplyInfo.ContentVariant { val count: Int val winners: List val additionalChats: Int diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt index d0642619f0..317a83287e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt @@ -30,4 +30,4 @@ data class ScheduledGiveaway( val countries: List? = null, @SerialName(premiumSubscriptionMonthCountField) override val premiumMonths: Int? = null -) : GiveawayInfo \ No newline at end of file +) : GiveawayInfo, ExternalReplyInfo.ContentVariant \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt index 423c208121..149f04c533 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt @@ -20,7 +20,7 @@ import kotlinx.serialization.json.JsonObject */ @Serializable(LocationSerializer::class) @ClassCastsIncluded -sealed interface Location : Locationed, HorizontallyAccured +sealed interface Location : Locationed, HorizontallyAccured, ExternalReplyInfo.ContentVariant @Serializable data class StaticLocation( 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 e8758b9045..087df83da7 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 @@ -94,6 +94,8 @@ internal data class RawMessage( private val invoice: Invoice? = null, private val dice: Dice? = null, private val successful_payment: SuccessfulPayment? = null, + private val giveaway: ScheduledGiveaway? = null, + private val giveaway_winners: GiveawayResults? = null, private val users_shared: UsersShared? = null, private val chat_shared: ChatShared? = null, @@ -132,8 +134,6 @@ internal data class RawMessage( // Giveaways private val giveaway_created: GiveawayCreated? = null, - private val giveaway: ScheduledGiveaway? = null, - private val giveaway_winners: GiveawayResults? = null, private val giveaway_completed: GiveawayPrivateResults? = null, ) { private val content: MessageContent? by lazy { @@ -177,7 +177,7 @@ internal data class RawMessage( adaptedCaptionEntities ) photo != null -> PhotoContent( - photo.toList(), + photo, caption, adaptedCaptionEntities, has_media_spoiler ?: false @@ -191,7 +191,7 @@ internal data class RawMessage( venue != null -> VenueContent(venue) poll != null -> PollContent(poll) invoice != null -> InvoiceContent(invoice) - giveaway != null -> ScheduledGiveawayContent(giveaway) + giveaway != null -> ScheduledGiveawayContent(chat, messageId, giveaway) giveaway_winners is GiveawayPublicResults -> GiveawayPublicResultsContent(giveaway_winners) else -> null } @@ -202,7 +202,7 @@ internal data class RawMessage( new_chat_members != null -> NewChatMembers(new_chat_members.toList()) left_chat_member != null -> LeftChatMemberEvent(left_chat_member) new_chat_title != null -> NewChatTitle(new_chat_title) - new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList()) + new_chat_photo != null -> NewChatPhoto(new_chat_photo) video_chat_started != null -> video_chat_started video_chat_scheduled != null -> video_chat_scheduled message_auto_delete_timer_changed != null -> message_auto_delete_timer_changed diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt index 7290ebb58e..69a1906a3c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt @@ -1,19 +1,46 @@ package dev.inmo.tgbotapi.types.message.abstracts +import dev.inmo.tgbotapi.abstracts.WithMessageId import korlibs.time.DateTime import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId +import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.types.MessageId +import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.message.RawMessage +import dev.inmo.tgbotapi.types.threadId import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import kotlin.jvm.JvmInline @ClassCastsIncluded(excludeRegex = ".*Impl") interface Message : WithPreviewChatAndMessageId { val date: DateTime + val metaInfo: MetaInfo + get() = MetaInfo(chat.id, messageId) + + @Serializable + @JvmInline + value class MetaInfo( + val chatIdMessageIdThreadId: Triple + ) : WithMessageId { + val chatId: ChatIdentifier + get() = chatIdMessageIdThreadId.first + override val messageId: MessageId + get() = chatIdMessageIdThreadId.second + val threadId: MessageThreadId? + get() = chatIdMessageIdThreadId.third + + constructor(chatId: ChatIdentifier, messageId: MessageId, threadId: MessageThreadId? = chatId.threadId) : this(Triple(chatId, messageId, threadId)) + constructor(chatIdMessageId: Pair, threadId: MessageThreadId? = chatIdMessageId.first.threadId) : this(Triple(chatIdMessageId.first, chatIdMessageId.second, threadId)) + + fun copy( + chatId: ChatIdentifier = this.chatId, messageId: MessageId = this.messageId, threadId: MessageThreadId? = chatId.threadId + ) = MetaInfo(chatId, messageId, threadId) + } } interface AccessibleMessage : Message diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index 32e0299a2e..4f25de4ed1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -52,6 +52,8 @@ sealed interface MessageContent: ResendableContent { subclass(StickerContent::class) subclass(InvoiceContent::class) subclass(StoryContent::class) + subclass(GiveawayPublicResultsContent::class) + subclass(ScheduledGiveawayContent::class) additionalBuilder() } @@ -139,18 +141,6 @@ sealed interface TextedContent : MessageContent, TextedInput sealed interface MediaContent: MessageContent { val media: TelegramMediaFile fun asTelegramMedia(): TelegramMedia - - override fun createResend( - chatId: ChatIdentifier, - messageThreadId: MessageThreadId?, - disableNotification: Boolean, - protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, - replyMarkup: KeyboardMarkup? - ): Request> { - TODO("Not yet implemented") - } } sealed interface SpoilerableMediaContent : MediaContent, SpoilerableData diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt index 3d4a5e4ded..29e9e0b348 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.message.content +import dev.inmo.tgbotapi.requests.ForwardMessage import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -20,6 +21,13 @@ data class GiveawayPublicResultsContent( allowSendingWithoutReply: Boolean?, replyMarkup: KeyboardMarkup? ): Request { - TODO("Not yet implemented") + return ForwardMessage( + giveaway.chat.id, + toChatId = chatId, + messageId = giveaway.messageId, + threadId = messageThreadId, + disableNotification = disableNotification, + protectContent = protectContent + ) } } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt index 47386da9ef..f3b4125a44 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt @@ -1,9 +1,11 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.micro_utils.language_codes.IetfLang +import dev.inmo.tgbotapi.requests.ForwardMessage import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.giveaway.GiveawayInfo import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway @@ -13,6 +15,8 @@ import kotlinx.serialization.Serializable @Serializable data class ScheduledGiveawayContent( + private val chat: Chat, + private val messageId: MessageId, val giveaway: ScheduledGiveaway ) : MessageContent { override fun createResend( @@ -24,6 +28,13 @@ data class ScheduledGiveawayContent( allowSendingWithoutReply: Boolean?, replyMarkup: KeyboardMarkup? ): Request { - TODO("Not yet implemented") + return ForwardMessage( + chat.id, + toChatId = chatId, + messageId = messageId, + threadId = messageThreadId, + disableNotification = disableNotification, + protectContent = protectContent + ) } } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt index 03d3c10b64..cd10c9f0f1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt @@ -17,4 +17,4 @@ data class Invoice( override val currency: Currency, @SerialName(totalAmountField) override val amount: Long -) : Amounted, Currencied +) : Amounted, Currencied, ExternalReplyInfo.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt index bb07e64c16..183a65abdc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt @@ -49,7 +49,7 @@ val LongSeconds.asExactScheduledCloseInfo @Serializable(PollSerializer::class) @ClassCastsIncluded -sealed interface Poll { +sealed interface Poll : ExternalReplyInfo.ContentVariant { val id: PollIdentifier val question: String val options: List diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt index 592188a196..c17452cf3a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.types.stories +import dev.inmo.tgbotapi.types.ExternalReplyInfo import kotlinx.serialization.Serializable @Serializable -class Story +class Story : ExternalReplyInfo.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt index f96a1f26bf..5dc5b71a3e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt @@ -23,4 +23,4 @@ data class Venue( override val googlePlaceId: GooglePlaceId? = null, @SerialName(googlePlaceTypeField) override val googlePlaceType: GooglePlaceType? = null -) : CommonVenueData, Locationed by location +) : CommonVenueData, Locationed by location, ExternalReplyInfo.ContentVariant From 95011e2b3ea2f36bfce4b3412e867691ab9d3003 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 19:19:59 +0600 Subject: [PATCH 29/65] add MessageOrigin serializer --- .../tgbotapi/types/message/MessageOrigin.kt | 96 ++++++++++++++++++- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt index 57e162a3b6..1ab6d6e542 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt @@ -2,11 +2,18 @@ package dev.inmo.tgbotapi.types.message import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.* +import kotlinx.serialization.KSerializer import kotlinx.serialization.Required import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.JsonDecoder +import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.decodeFromJsonElement -@Serializable +@Serializable(MessageOrigin.Companion::class) sealed interface MessageOrigin { val type: String val date: TelegramDate @@ -14,7 +21,7 @@ sealed interface MessageOrigin { @Serializable data class User( @SerialName(senderUserField) - val user: dev.inmo.tgbotapi.types.chat.User, + val user: PreviewUser, @SerialName(dateField) override val date: TelegramDate ) : MessageOrigin { @@ -43,7 +50,7 @@ sealed interface MessageOrigin { } } - @Serializable + @Serializable(MessageOrigin.Companion::class) sealed interface Public : MessageOrigin { val chat: PublicChat val authorSignature: AuthorSignature? @@ -86,4 +93,87 @@ sealed interface MessageOrigin { } } } + + @Serializable + data class Unknown internal constructor( + override val type: String, + override val date: TelegramDate, + val source: JsonElement? + ) : MessageOrigin + + @Serializable + private data class Surrogate( + @SerialName(typeField) + @Required + val type: String, + @SerialName(senderChatField) + val senderChat: PreviewChat? = null, + @SerialName(chatField) + val chat: PreviewChat? = null, + @SerialName(dateField) + val date: TelegramDate, + @SerialName(authorSignatureField) + val authorSignature: AuthorSignature? = null, + @SerialName(messageIdField) + val messageId: MessageId? = null, + @SerialName(senderUserNameField) + val name: String? = null, + @SerialName(senderUserField) + val user: PreviewUser? = null + ) + + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): MessageOrigin { + val (surrogate, json) = if (decoder is JsonDecoder) { + val json = decoder.decodeJsonElement() + val surrogate = decoder.json.decodeFromJsonElement(Surrogate.serializer(), json) + surrogate to json + } else { + Surrogate.serializer().deserialize(decoder) to null + } + + return let { + when (surrogate.type) { + HiddenUser.type -> HiddenUser( + surrogate.name ?: return@let null, + surrogate.date + ) + Public.Channel.type -> Public.Channel( + surrogate.chat as? ChannelChat ?: return@let null, + surrogate.messageId ?: return@let null, + surrogate.date, + surrogate.authorSignature + ) + Public.Sender.type -> Public.Sender( + surrogate.senderChat as? ChannelChat ?: return@let null, + surrogate.date, + surrogate.authorSignature + ) + User.type -> User( + surrogate.user ?: return@let null, + surrogate.date + ) + else -> null + } + } ?: Unknown( + surrogate.type, + surrogate.date, + json + ) + } + + override fun serialize(encoder: Encoder, value: MessageOrigin) { + when (value) { + is HiddenUser -> HiddenUser.serializer().serialize(encoder, value) + is Public.Channel -> Public.Channel.serializer().serialize(encoder, value) + is Public.Sender -> Public.Sender.serializer().serialize(encoder, value) + is Unknown -> value.source ?.let { JsonElement.serializer().serialize(encoder, it) } ?: Unknown.serializer().serialize(encoder, value) + is User -> User.serializer().serialize(encoder, value) + } + } + + } } \ No newline at end of file From f3b05bbffd59f7c7c5f037065cdf459e2bdab52a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 19:38:22 +0600 Subject: [PATCH 30/65] add support of external_reply in RawMessage --- .../kotlin/dev/inmo/tgbotapi/types/Contact.kt | 2 +- .../inmo/tgbotapi/types/ExternalReplyInfo.kt | 166 ----------------- .../dev/inmo/tgbotapi/types/ReplyInfo.kt | 175 ++++++++++++++++++ .../dev/inmo/tgbotapi/types/dice/Dice.kt | 2 +- .../tgbotapi/types/files/AnimationFile.kt | 2 +- .../inmo/tgbotapi/types/files/AudioFile.kt | 2 +- .../inmo/tgbotapi/types/files/DocumentFile.kt | 2 +- .../inmo/tgbotapi/types/files/PhotoSize.kt | 2 +- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 2 +- .../inmo/tgbotapi/types/files/VideoFile.kt | 2 +- .../tgbotapi/types/files/VideoNoteFile.kt | 2 +- .../inmo/tgbotapi/types/files/VoiceFile.kt | 2 +- .../dev/inmo/tgbotapi/types/games/Game.kt | 4 +- .../types/giveaway/GiveawayPublicResults.kt | 2 +- .../types/giveaway/ScheduledGiveaway.kt | 2 +- .../inmo/tgbotapi/types/location/Location.kt | 2 +- .../message/ChannelContentMessageImpl.kt | 2 +- .../tgbotapi/types/message/GroupMessages.kt | 14 +- .../message/PrivateContentMessageImpl.kt | 2 +- .../inmo/tgbotapi/types/message/RawMessage.kt | 37 ++-- .../message/abstracts/PossiblyReplyMessage.kt | 4 + .../inmo/tgbotapi/types/payments/Invoice.kt | 2 +- .../dev/inmo/tgbotapi/types/polls/Poll.kt | 2 +- .../dev/inmo/tgbotapi/types/stories/Story.kt | 4 +- .../dev/inmo/tgbotapi/types/venue/Venue.kt | 2 +- .../MediaGroupContentMessageCreator.kt | 18 +- .../utils/extensions/raw/Message.kt | 2 +- 27 files changed, 241 insertions(+), 219 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt index b84d4ed72a..8eaf9dfb84 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Contact.kt @@ -16,4 +16,4 @@ data class Contact( val userId: UserId? = null, @SerialName(vcardField) override val vcard: String? = null -) : CommonContactData, ExternalReplyInfo.ContentVariant +) : CommonContactData, ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt deleted file mode 100644 index 7bf46b0d48..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ExternalReplyInfo.kt +++ /dev/null @@ -1,166 +0,0 @@ -package dev.inmo.tgbotapi.types - -import dev.inmo.tgbotapi.abstracts.SpoilerableData -import dev.inmo.tgbotapi.types.chat.SuperPublicChat -import dev.inmo.tgbotapi.types.dice.Dice -import dev.inmo.tgbotapi.types.files.* -import dev.inmo.tgbotapi.types.games.Game -import dev.inmo.tgbotapi.types.games.RawGame -import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults -import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway -import dev.inmo.tgbotapi.types.location.Location -import dev.inmo.tgbotapi.types.message.MessageOrigin -import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.types.payments.Invoice -import dev.inmo.tgbotapi.types.polls.Poll -import dev.inmo.tgbotapi.types.stories.Story -import dev.inmo.tgbotapi.types.venue.Venue -import dev.inmo.tgbotapi.utils.RiskFeature -import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded -import kotlinx.serialization.KSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -@Serializable(ExternalReplyInfo.Companion::class) -@ClassCastsIncluded -sealed interface ExternalReplyInfo { - val origin: MessageOrigin - val chat: SuperPublicChat? - val messageMeta: Message.MetaInfo? - - interface ContentVariant - - @Serializable - data class Text( - override val origin: MessageOrigin, - override val chat: SuperPublicChat?, - override val messageMeta: Message.MetaInfo?, - val linkPreviewOptions: LinkPreviewOptions? - ) : ExternalReplyInfo - - @Serializable(ExternalReplyInfo.Companion::class) - sealed interface Content : ExternalReplyInfo { - val content: ContentVariant - - - @Serializable - data class Simple( - override val origin: MessageOrigin, - override val chat: SuperPublicChat?, - override val messageMeta: Message.MetaInfo?, - override val content: ContentVariant - ) : Content - - @Serializable - data class Media( - override val origin: MessageOrigin, - override val chat: SuperPublicChat?, - override val messageMeta: Message.MetaInfo?, - override val spoilered: Boolean, - override val content: T - ) : Content, SpoilerableData where T: ContentVariant, T : TelegramMediaFile - } - - @Serializable - private data class Surrogate( - val origin: MessageOrigin, - val chat: SuperPublicChat? = null, - val message_id: MessageId? = null, - val link_preview_options: LinkPreviewOptions? = null, - val has_media_spoiler: Boolean? = null, - private val story: Story? = null, - private val audio: AudioFile? = null, - private val document: DocumentFile? = null, - private val animation: AnimationFile? = null, - private val game: RawGame? = null, - @Serializable(PhotoSerializer::class) - private val photo: Photo? = null, - private val sticker: Sticker? = null, - private val video: VideoFile? = null, - private val voice: VoiceFile? = null, - private val video_note: VideoNoteFile? = null, - private val contact: Contact? = null, - private val location: Location? = null, - private val venue: Venue? = null, - private val poll: Poll? = null, - private val invoice: Invoice? = null, - private val dice: Dice? = null, - private val giveaway: ScheduledGiveaway? = null, - private val giveaway_winners: GiveawayPublicResults? = null, - ) { - val asExternalReplyInfo: ExternalReplyInfo - get() { - val messageMeta = chat ?.let { - message_id ?.let { - Message.MetaInfo( - chat.id, - message_id - ) - } - } - val content: ContentVariant? = when { - story != null -> story - audio != null -> audio - video != null -> video - video_note != null -> video_note - animation != null -> animation - document != null -> document - voice != null -> voice - photo != null -> photo - sticker != null -> sticker - dice != null -> dice - game != null -> game.asGame - contact != null -> contact - location != null -> location - venue != null -> venue - poll != null -> poll - invoice != null -> invoice - giveaway != null -> giveaway - giveaway_winners != null -> giveaway_winners - else -> null - } - - return content ?.let { - when (it) { - is TelegramMediaFile -> { - Content.Media( - origin, - chat, - messageMeta, - has_media_spoiler == true, - it - ) - } - else -> Content.Simple( - origin, - chat, - messageMeta, - it - ) - } - } ?: Text( - origin, - chat, - messageMeta, - link_preview_options - ) - } - } - - @RiskFeature("This serializer currently support only deserialization, but not serialization") - companion object : KSerializer { - override val descriptor: SerialDescriptor - get() = Surrogate.serializer().descriptor - - override fun deserialize(decoder: Decoder): ExternalReplyInfo { - return Surrogate.serializer().deserialize(decoder).asExternalReplyInfo - } - - override fun serialize(encoder: Encoder, value: ExternalReplyInfo) { - - } - } -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt new file mode 100644 index 0000000000..4045b5117a --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt @@ -0,0 +1,175 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.abstracts.SpoilerableData +import dev.inmo.tgbotapi.types.chat.SuperPublicChat +import dev.inmo.tgbotapi.types.dice.Dice +import dev.inmo.tgbotapi.types.files.* +import dev.inmo.tgbotapi.types.games.RawGame +import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults +import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway +import dev.inmo.tgbotapi.types.location.Location +import dev.inmo.tgbotapi.types.message.MessageOrigin +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.payments.Invoice +import dev.inmo.tgbotapi.types.polls.Poll +import dev.inmo.tgbotapi.types.stories.Story +import dev.inmo.tgbotapi.types.venue.Venue +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +@ClassCastsIncluded +sealed interface ReplyInfo { + val messageMeta: Message.MetaInfo? + + data class Internal( + val message: AccessibleMessage + ): ReplyInfo { + override val messageMeta: Message.MetaInfo + get() = message.metaInfo + } + + @Serializable(External.Companion::class) + sealed interface External : ReplyInfo { + val origin: MessageOrigin + val chat: SuperPublicChat? + + interface ContentVariant + + @Serializable + data class Text( + override val origin: MessageOrigin, + override val chat: SuperPublicChat?, + override val messageMeta: Message.MetaInfo?, + val linkPreviewOptions: LinkPreviewOptions? + ) : External + + @Serializable(External.Companion::class) + sealed interface Content : External { + val content: ContentVariant + + + @Serializable + data class Simple( + override val origin: MessageOrigin, + override val chat: SuperPublicChat?, + override val messageMeta: Message.MetaInfo?, + override val content: ContentVariant + ) : Content + + @Serializable + data class Media( + override val origin: MessageOrigin, + override val chat: SuperPublicChat?, + override val messageMeta: Message.MetaInfo?, + override val spoilered: Boolean, + override val content: T + ) : Content, SpoilerableData where T: ContentVariant, T : TelegramMediaFile + } + + @Serializable + private data class Surrogate( + val origin: MessageOrigin, + val chat: SuperPublicChat? = null, + val message_id: MessageId? = null, + val link_preview_options: LinkPreviewOptions? = null, + val has_media_spoiler: Boolean? = null, + private val story: Story? = null, + private val audio: AudioFile? = null, + private val document: DocumentFile? = null, + private val animation: AnimationFile? = null, + private val game: RawGame? = null, + @Serializable(PhotoSerializer::class) + private val photo: Photo? = null, + private val sticker: Sticker? = null, + private val video: VideoFile? = null, + private val voice: VoiceFile? = null, + private val video_note: VideoNoteFile? = null, + private val contact: Contact? = null, + private val location: Location? = null, + private val venue: Venue? = null, + private val poll: Poll? = null, + private val invoice: Invoice? = null, + private val dice: Dice? = null, + private val giveaway: ScheduledGiveaway? = null, + private val giveaway_winners: GiveawayPublicResults? = null, + ) { + val asExternalReplyInfo: External + get() { + val messageMeta = chat ?.let { + message_id ?.let { + Message.MetaInfo( + chat.id, + message_id + ) + } + } + val content: ContentVariant? = when { + story != null -> story + audio != null -> audio + video != null -> video + video_note != null -> video_note + animation != null -> animation + document != null -> document + voice != null -> voice + photo != null -> photo + sticker != null -> sticker + dice != null -> dice + game != null -> game.asGame + contact != null -> contact + location != null -> location + venue != null -> venue + poll != null -> poll + invoice != null -> invoice + giveaway != null -> giveaway + giveaway_winners != null -> giveaway_winners + else -> null + } + + return content ?.let { + when (it) { + is TelegramMediaFile -> { + Content.Media( + origin, + chat, + messageMeta, + has_media_spoiler == true, + it + ) + } + else -> Content.Simple( + origin, + chat, + messageMeta, + it + ) + } + } ?: Text( + origin, + chat, + messageMeta, + link_preview_options + ) + } + } + + @RiskFeature("This serializer currently support only deserialization, but not serialization") + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): External { + return Surrogate.serializer().deserialize(decoder).asExternalReplyInfo + } + + override fun serialize(encoder: Encoder, value: External) { + + } + } + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt index c5a70ff3f3..719e7a3337 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt @@ -10,4 +10,4 @@ data class Dice( val value: DiceResult, @SerialName(emojiField) val animationType: DiceAnimationType -) : ExternalReplyInfo.ContentVariant +) : ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt index d09fbcbe79..cff7534719 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt @@ -24,4 +24,4 @@ data class AnimationFile( @SerialName(fileSizeField) override val fileSize: Long? = null ) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, CustomNamedMediaFile, SizedMediaFile, - ExternalReplyInfo.ContentVariant + ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt index c83351dc25..5996f41bb3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt @@ -28,6 +28,6 @@ data class AudioFile( @SerialName(thumbnailField) override val thumbnail: PhotoSize? = null ) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, - Performerable, ExternalReplyInfo.ContentVariant + Performerable, ReplyInfo.External.ContentVariant fun AudioFile.asVoiceFile() = VoiceFile(fileId, fileUniqueId, duration, mimeType, fileSize) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt index 73df323628..a5a0676543 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt @@ -20,7 +20,7 @@ data class DocumentFile( override val mimeType: MimeType? = null, @SerialName(fileNameField) override val fileName: String? = null -) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile, ExternalReplyInfo.ContentVariant +) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile, ReplyInfo.External.ContentVariant @Suppress("NOTHING_TO_INLINE") inline fun TelegramMediaFile.asDocumentFile() = if (this is DocumentFile) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt index 39bd5c42cf..fdac2d0e5f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt @@ -12,7 +12,7 @@ import kotlin.jvm.JvmInline @JvmInline value class Photo( val photos: List -) : List by photos, ExternalReplyInfo.ContentVariant +) : List by photos, ReplyInfo.External.ContentVariant fun Photo.biggest(): PhotoSize? = maxByOrNull { it.resolution diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt index 4355de3241..199bae6c9b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt @@ -34,7 +34,7 @@ data class StickerSurrogate( // TODO:: Serializer @Serializable(StickerSerializer::class) -sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile, ExternalReplyInfo.ContentVariant { +sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile, ReplyInfo.External.ContentVariant { val emoji: String? val stickerSetName: StickerSetName? val stickerFormat: StickerFormat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 5eec4d48a7..5ab993cb56 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -30,7 +30,7 @@ data class VideoFile( @SerialName(fileSizeField) override val fileSize: Long? = null ) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, - ExternalReplyInfo.ContentVariant + ReplyInfo.External.ContentVariant @Suppress("NOTHING_TO_INLINE") inline fun VideoFile.toTelegramMediaVideo( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt index 49b5ec8889..f93debfb83 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt @@ -18,7 +18,7 @@ data class VideoNoteFile( override val thumbnail: PhotoSize? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, ExternalReplyInfo.ContentVariant { +) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, ReplyInfo.External.ContentVariant { override val height: Int get() = width } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt index 725a52a0ed..b26631c800 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt @@ -19,7 +19,7 @@ data class VoiceFile( override val mimeType: MimeType? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, ExternalReplyInfo.ContentVariant +) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, ReplyInfo.External.ContentVariant fun VoiceFile.asAudioFile( performer: String? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt index 60027bc169..c2e9d15275 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/games/Game.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.games import dev.inmo.tgbotapi.abstracts.TextedInput import dev.inmo.tgbotapi.abstracts.Titled -import dev.inmo.tgbotapi.types.ExternalReplyInfo +import dev.inmo.tgbotapi.types.ReplyInfo import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.Photo @@ -16,4 +16,4 @@ data class Game( override val text: String? = null, override val textSources: TextSourcesList = emptyList(), val animation: AnimationFile? = null -) : Titled, TextedInput, ExternalReplyInfo.ContentVariant +) : Titled, TextedInput, ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt index 83fe74fa2f..192e2521b1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.encoding.Encoder @Serializable(GiveawayPublicResults.Companion::class) sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId, - ExternalReplyInfo.ContentVariant { + ReplyInfo.External.ContentVariant { val count: Int val winners: List val additionalChats: Int diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt index 317a83287e..ce7c3430bd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt @@ -30,4 +30,4 @@ data class ScheduledGiveaway( val countries: List? = null, @SerialName(premiumSubscriptionMonthCountField) override val premiumMonths: Int? = null -) : GiveawayInfo, ExternalReplyInfo.ContentVariant \ No newline at end of file +) : GiveawayInfo, ReplyInfo.External.ContentVariant \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt index 149f04c533..37fed8e9a6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/Location.kt @@ -20,7 +20,7 @@ import kotlinx.serialization.json.JsonObject */ @Serializable(LocationSerializer::class) @ClassCastsIncluded -sealed interface Location : Locationed, HorizontallyAccured, ExternalReplyInfo.ContentVariant +sealed interface Location : Locationed, HorizontallyAccured, ReplyInfo.External.ContentVariant @Serializable data class StaticLocation( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt index bfe6234525..f76af91f66 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt @@ -16,7 +16,7 @@ data class ChannelContentMessageImpl( override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val forwardOrigin: MessageOrigin?, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, override val authorSignature: AuthorSignature?, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt index bfa54b8c1f..967f87d4df 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt @@ -17,7 +17,7 @@ data class ConnectedFromChannelGroupContentMessageImpl( override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -52,7 +52,7 @@ data class UnconnectedFromChannelGroupContentMessageImpl( override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -85,7 +85,7 @@ data class AnonymousGroupContentMessageImpl( override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -118,7 +118,7 @@ data class CommonGroupContentMessageImpl( override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -151,7 +151,7 @@ data class FromChannelForumContentMessageImpl( override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -186,7 +186,7 @@ data class AnonymousForumContentMessageImpl( override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, @@ -221,7 +221,7 @@ data class CommonForumContentMessageImpl( override val forwardOrigin: MessageOrigin?, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt index 21438aea84..a2482308df 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt @@ -19,7 +19,7 @@ data class PrivateContentMessageImpl( override val editDate: DateTime?, override val hasProtectedContent: Boolean, override val forwardOrigin: MessageOrigin?, - override val replyTo: AccessibleMessage?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupIdentifier?, 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 087df83da7..dd05df6535 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 @@ -54,6 +54,7 @@ internal data class RawMessage( private val is_topic_message: Boolean? = null, private val is_automatic_forward: Boolean? = null, private val reply_to_message: RawMessage? = null, + private val external_reply: ReplyInfo.External? = null, private val via_bot: CommonBot? = null, private val edit_date: TelegramDate? = null, private val has_protected_content: Boolean? = null, @@ -282,7 +283,15 @@ internal data class RawMessage( ) else -> error("Expected one of the public chats, but was $chat (in extracting of chat event message)") } - } ?: content?.let { content -> when (chat) { + } ?: content?.let { content -> + val replyInfo: ReplyInfo? = when { + reply_to_message != null -> ReplyInfo.Internal( + reply_to_message.asMessage + ) + external_reply != null -> external_reply + else -> null + } + when (chat) { is PreviewPublicChat -> when (chat) { is PreviewChannelChat -> ChannelContentMessageImpl( messageId, @@ -292,7 +301,7 @@ internal data class RawMessage( edit_date?.asDate, has_protected_content == true, forward_origin, - reply_to_message?.asMessage, + replyInfo, reply_markup, via_bot, author_signature, @@ -316,7 +325,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -331,7 +340,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -347,7 +356,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -365,7 +374,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -381,7 +390,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -396,7 +405,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -411,7 +420,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -429,7 +438,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -445,7 +454,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -460,7 +469,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -475,7 +484,7 @@ internal data class RawMessage( forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -492,7 +501,7 @@ internal data class RawMessage( edit_date?.asDate, has_protected_content == true, forward_origin, - reply_to_message?.asMessage, + replyInfo, reply_markup, via_bot, media_group_id diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt index d796c09520..7a59546392 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt @@ -1,5 +1,9 @@ package dev.inmo.tgbotapi.types.message.abstracts +import dev.inmo.tgbotapi.types.ReplyInfo + interface PossiblyReplyMessage { + val replyInfo: ReplyInfo? val replyTo: AccessibleMessage? + get() = (replyInfo as? ReplyInfo.Internal) ?.message } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt index cd10c9f0f1..3d1e848337 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/Invoice.kt @@ -17,4 +17,4 @@ data class Invoice( override val currency: Currency, @SerialName(totalAmountField) override val amount: Long -) : Amounted, Currencied, ExternalReplyInfo.ContentVariant +) : Amounted, Currencied, ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt index 183a65abdc..182e379dd9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/Poll.kt @@ -49,7 +49,7 @@ val LongSeconds.asExactScheduledCloseInfo @Serializable(PollSerializer::class) @ClassCastsIncluded -sealed interface Poll : ExternalReplyInfo.ContentVariant { +sealed interface Poll : ReplyInfo.External.ContentVariant { val id: PollIdentifier val question: String val options: List diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt index c17452cf3a..35154fd101 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.stories -import dev.inmo.tgbotapi.types.ExternalReplyInfo +import dev.inmo.tgbotapi.types.ReplyInfo import kotlinx.serialization.Serializable @Serializable -class Story : ExternalReplyInfo.ContentVariant +class Story : ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt index 5dc5b71a3e..0a109e51a4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt @@ -23,4 +23,4 @@ data class Venue( override val googlePlaceId: GooglePlaceId? = null, @SerialName(googlePlaceTypeField) override val googlePlaceType: GooglePlaceType? = null -) : CommonVenueData, Locationed by location, ExternalReplyInfo.ContentVariant +) : CommonVenueData, Locationed by location, ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt index 5ed0e6f3af..f8764c212f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt @@ -40,7 +40,7 @@ fun List>.asMedia sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.forwardOrigin, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, sourceMessage.senderBot, sourceMessage.authorSignature, @@ -55,7 +55,7 @@ fun List>.asMedia sourceMessage.editDate, sourceMessage.hasProtectedContent, sourceMessage.forwardOrigin, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, sourceMessage.senderBot, sourceMessage.mediaGroupId @@ -67,7 +67,7 @@ fun List>.asMedia sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -82,7 +82,7 @@ fun List>.asMedia sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -96,7 +96,7 @@ fun List>.asMedia sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -111,7 +111,7 @@ fun List>.asMedia sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -126,7 +126,7 @@ fun List>.asMedia sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -142,7 +142,7 @@ fun List>.asMedia sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -157,7 +157,7 @@ fun List>.asMedia sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index 9b65ae7a90..0874d13255 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -51,7 +51,7 @@ inline val AccessibleMessage.is_automatic_forward: Boolean? get() = this is ConnectedFromChannelGroupContentMessage<*> @RiskFeature(RawFieldsUsageWarning) inline val AccessibleMessage.reply_to_message: AccessibleMessage? - get() = asPossiblyReplyMessage() ?.replyTo + get() = asPossiblyReplyMessage() ?.replyInfo @RiskFeature(RawFieldsUsageWarning) inline val AccessibleMessage.via_bot: CommonBot? get() = asPossiblySentViaBotCommonMessage() ?.senderBot From 8df72edd524773e54cff6bbd0a8e3163954d33c0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 20:00:07 +0600 Subject: [PATCH 31/65] fixes of build --- .../triggers_handling/ContentTriggers.kt | 2 +- .../dev/inmo/tgbotapi/types/ReplyInfo.kt | 8 +- .../tgbotapi/types/files/AnimationFile.kt | 2 +- .../inmo/tgbotapi/types/files/AudioFile.kt | 2 +- .../inmo/tgbotapi/types/files/DocumentFile.kt | 2 +- .../types/files/MediaContentVariant.kt | 5 ++ .../inmo/tgbotapi/types/files/PhotoSize.kt | 17 ++++- .../dev/inmo/tgbotapi/types/files/Sticker.kt | 2 +- .../inmo/tgbotapi/types/files/VideoFile.kt | 2 +- .../tgbotapi/types/files/VideoNoteFile.kt | 2 +- .../inmo/tgbotapi/types/files/VoiceFile.kt | 2 +- .../message/ChannelContentMessageImpl.kt | 2 +- .../tgbotapi/types/message/ForwardInfo.kt | 1 + .../tgbotapi/types/message/GroupMessages.kt | 14 ++-- .../tgbotapi/types/message/MessageOrigin.kt | 2 +- .../message/PrivateContentMessageImpl.kt | 2 +- .../dev/inmo/tgbotapi/SimpleInputFilesTest.kt | 7 +- .../extensions/utils/ClassCastsNew.kt | 75 +++++++++++++++++++ .../utils/extensions/raw/Message.kt | 2 +- 19 files changed, 125 insertions(+), 26 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/MediaContentVariant.kt diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index 0b3e5ec1eb..1bec1193e7 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -741,7 +741,7 @@ suspend fun BC.onScheduledGiveawayContent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BC.onScheduledGiveawayContent( +suspend fun BC.onGiveawayPublicResultsContent( initialFilter: CommonMessageFilter? = null, subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt index 4045b5117a..d2c832927d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt @@ -63,13 +63,13 @@ sealed interface ReplyInfo { ) : Content @Serializable - data class Media( + data class Media( override val origin: MessageOrigin, override val chat: SuperPublicChat?, override val messageMeta: Message.MetaInfo?, override val spoilered: Boolean, - override val content: T - ) : Content, SpoilerableData where T: ContentVariant, T : TelegramMediaFile + override val content: MediaContentVariant + ) : Content, SpoilerableData } @Serializable @@ -133,7 +133,7 @@ sealed interface ReplyInfo { return content ?.let { when (it) { - is TelegramMediaFile -> { + is MediaContentVariant -> { Content.Media( origin, chat, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt index cff7534719..466a418c79 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AnimationFile.kt @@ -24,4 +24,4 @@ data class AnimationFile( @SerialName(fileSizeField) override val fileSize: Long? = null ) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, CustomNamedMediaFile, SizedMediaFile, - ReplyInfo.External.ContentVariant + MediaContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt index 5996f41bb3..4edfc7d3e6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt @@ -28,6 +28,6 @@ data class AudioFile( @SerialName(thumbnailField) override val thumbnail: PhotoSize? = null ) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, - Performerable, ReplyInfo.External.ContentVariant + Performerable, MediaContentVariant fun AudioFile.asVoiceFile() = VoiceFile(fileId, fileUniqueId, duration, mimeType, fileSize) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt index a5a0676543..9adfe6f7b5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/DocumentFile.kt @@ -20,7 +20,7 @@ data class DocumentFile( override val mimeType: MimeType? = null, @SerialName(fileNameField) override val fileName: String? = null -) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile, ReplyInfo.External.ContentVariant +) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile, MediaContentVariant @Suppress("NOTHING_TO_INLINE") inline fun TelegramMediaFile.asDocumentFile() = if (this is DocumentFile) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/MediaContentVariant.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/MediaContentVariant.kt new file mode 100644 index 0000000000..2eec7aae08 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/MediaContentVariant.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.types.files + +import dev.inmo.tgbotapi.types.ReplyInfo + +interface MediaContentVariant : ReplyInfo.External.ContentVariant, TelegramMediaFile \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt index fdac2d0e5f..62561c1a89 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PhotoSize.kt @@ -12,7 +12,22 @@ import kotlin.jvm.JvmInline @JvmInline value class Photo( val photos: List -) : List by photos, ReplyInfo.External.ContentVariant +) : List by photos, MediaContentVariant { + val biggest: PhotoSize + get() = biggest()!! + override val fileId: FileId + get() = biggest.fileId + override val fileUniqueId: FileUniqueId + get() = biggest.fileUniqueId + override val fileSize: Long? + get() = biggest.fileSize + + init { + require(photos.isNotEmpty()) { + "Photos collection must not be empty" + } + } +} fun Photo.biggest(): PhotoSize? = maxByOrNull { it.resolution diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt index 199bae6c9b..06f4704306 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt @@ -34,7 +34,7 @@ data class StickerSurrogate( // TODO:: Serializer @Serializable(StickerSerializer::class) -sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile, ReplyInfo.External.ContentVariant { +sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile, MediaContentVariant { val emoji: String? val stickerSetName: StickerSetName? val stickerFormat: StickerFormat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt index 5ab993cb56..7665e712f2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoFile.kt @@ -30,7 +30,7 @@ data class VideoFile( @SerialName(fileSizeField) override val fileSize: Long? = null ) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, - ReplyInfo.External.ContentVariant + MediaContentVariant @Suppress("NOTHING_TO_INLINE") inline fun VideoFile.toTelegramMediaVideo( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt index f93debfb83..a8e0623961 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VideoNoteFile.kt @@ -18,7 +18,7 @@ data class VideoNoteFile( override val thumbnail: PhotoSize? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, ReplyInfo.External.ContentVariant { +) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, MediaContentVariant { override val height: Int get() = width } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt index b26631c800..b21524b630 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt @@ -19,7 +19,7 @@ data class VoiceFile( override val mimeType: MimeType? = null, @SerialName(fileSizeField) override val fileSize: Long? = null -) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, ReplyInfo.External.ContentVariant +) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, MediaContentVariant fun VoiceFile.asAudioFile( performer: String? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt index f76af91f66..26602f901b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelContentMessageImpl.kt @@ -36,6 +36,6 @@ data class ChannelContentMessageImpl( authorSignature: AuthorSignature?, mediaGroupId: MediaGroupIdentifier?, ) : this( - messageId, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo, replyMarkup, senderBot, authorSignature, mediaGroupId + messageId, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, authorSignature, mediaGroupId ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt index be74e8c3db..287cc2b757 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt @@ -83,6 +83,7 @@ fun MessageOrigin.forwardInfo() = when(this) { date, user ) + is MessageOrigin.Unknown -> null } fun ForwardInfo.messageOrigin() = when (this) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt index 967f87d4df..c9d42f2bf6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt @@ -40,7 +40,7 @@ data class ConnectedFromChannelGroupContentMessageImpl( authorSignature: AuthorSignature?, mediaGroupId: MediaGroupIdentifier?, ) : this( - chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId ) } @@ -74,7 +74,7 @@ data class UnconnectedFromChannelGroupContentMessageImpl( authorSignature: AuthorSignature?, mediaGroupId: MediaGroupIdentifier?, ) : this( - chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId ) } @@ -106,7 +106,7 @@ data class AnonymousGroupContentMessageImpl( authorSignature: AuthorSignature?, mediaGroupId: MediaGroupIdentifier?, ) : this( - chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId ) } @@ -138,7 +138,7 @@ data class CommonGroupContentMessageImpl( senderBot: CommonBot?, mediaGroupId: MediaGroupIdentifier?, ) : this( - chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, mediaGroupId + chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId ) } @@ -174,7 +174,7 @@ data class FromChannelForumContentMessageImpl( authorSignature: AuthorSignature?, mediaGroupId: MediaGroupIdentifier?, ) : this( - chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId ) } @@ -208,7 +208,7 @@ data class AnonymousForumContentMessageImpl( authorSignature: AuthorSignature?, mediaGroupId: MediaGroupIdentifier?, ) : this( - chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, authorSignature, mediaGroupId + chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId ) } @@ -242,6 +242,6 @@ data class CommonForumContentMessageImpl( senderBot: CommonBot?, mediaGroupId: MediaGroupIdentifier?, ) : this( - chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo, replyMarkup, content, senderBot, mediaGroupId + chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt index 1ab6d6e542..f6b886b4de 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt @@ -21,7 +21,7 @@ sealed interface MessageOrigin { @Serializable data class User( @SerialName(senderUserField) - val user: PreviewUser, + val user: dev.inmo.tgbotapi.types.chat.User, @SerialName(dateField) override val date: TelegramDate ) : MessageOrigin { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt index a2482308df..01fbf50758 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt @@ -38,6 +38,6 @@ data class PrivateContentMessageImpl( senderBot: CommonBot?, mediaGroupId: MediaGroupIdentifier?, ) : this( - messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo, replyMarkup, senderBot, mediaGroupId + messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, mediaGroupId ) } diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt index a0facdfb88..520b27f950 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/SimpleInputFilesTest.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi import dev.inmo.tgbotapi.requests.abstracts.toInputFile +import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMediaSerializer import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.message.content.PhotoContent @@ -20,8 +21,10 @@ class SimpleInputFilesTest { @Test fun test_that_creating_of_photo_and_converting_to_input_media_working_correctly() { val photoContent = PhotoContent( - listOf( - PhotoSize("example_file_id".toInputFile(), "example_unique_file_id", 100, 100, 100) + Photo( + listOf( + PhotoSize("example_file_id".toInputFile(), "example_unique_file_id", 100, 100, 100) + ) ) ) val inputMedia = photoContent.toMediaGroupMemberTelegramMedia() 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 6942deb6ef..313b784543 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 @@ -75,6 +75,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery import dev.inmo.tgbotapi.types.PrimaryInviteLink +import dev.inmo.tgbotapi.types.ReplyInfo import dev.inmo.tgbotapi.types.SecondaryChatInviteLink import dev.inmo.tgbotapi.types.Username import dev.inmo.tgbotapi.types.actions.BotAction @@ -179,9 +180,11 @@ import dev.inmo.tgbotapi.types.files.MaskAnimatedSticker import dev.inmo.tgbotapi.types.files.MaskSimpleSticker import dev.inmo.tgbotapi.types.files.MaskSticker import dev.inmo.tgbotapi.types.files.MaskVideoSticker +import dev.inmo.tgbotapi.types.files.MediaContentVariant import dev.inmo.tgbotapi.types.files.MimedMediaFile import dev.inmo.tgbotapi.types.files.PassportFile import dev.inmo.tgbotapi.types.files.PathedFile +import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.files.PlayableMediaFile import dev.inmo.tgbotapi.types.files.RegularAnimatedSticker @@ -1572,6 +1575,60 @@ public inline fun InputMessageContent.ifInputVenueMessageContent(block: (InputVenueMessageContent) -> T): T? = inputVenueMessageContentOrNull() ?.let(block) +public inline fun ReplyInfo.externalOrNull(): ReplyInfo.External? = this as? + dev.inmo.tgbotapi.types.ReplyInfo.External + +public inline fun ReplyInfo.externalOrThrow(): ReplyInfo.External = this as + dev.inmo.tgbotapi.types.ReplyInfo.External + +public inline fun ReplyInfo.ifExternal(block: (ReplyInfo.External) -> T): T? = externalOrNull() + ?.let(block) + +public inline fun ReplyInfo.contentOrNull(): ReplyInfo.External.Content? = this as? + dev.inmo.tgbotapi.types.ReplyInfo.External.Content + +public inline fun ReplyInfo.contentOrThrow(): ReplyInfo.External.Content = this as + dev.inmo.tgbotapi.types.ReplyInfo.External.Content + +public inline fun ReplyInfo.ifContent(block: (ReplyInfo.External.Content) -> T): T? = + contentOrNull() ?.let(block) + +public inline fun ReplyInfo.mediaOrNull(): ReplyInfo.External.Content.Media? = this as? + dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Media + +public inline fun ReplyInfo.mediaOrThrow(): ReplyInfo.External.Content.Media = this as + dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Media + +public inline fun ReplyInfo.ifMedia(block: (ReplyInfo.External.Content.Media) -> T): T? = + mediaOrNull() ?.let(block) + +public inline fun ReplyInfo.simpleOrNull(): ReplyInfo.External.Content.Simple? = this as? + dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Simple + +public inline fun ReplyInfo.simpleOrThrow(): ReplyInfo.External.Content.Simple = this as + dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Simple + +public inline fun ReplyInfo.ifSimple(block: (ReplyInfo.External.Content.Simple) -> T): T? = + simpleOrNull() ?.let(block) + +public inline fun ReplyInfo.textOrNull(): ReplyInfo.External.Text? = this as? + dev.inmo.tgbotapi.types.ReplyInfo.External.Text + +public inline fun ReplyInfo.textOrThrow(): ReplyInfo.External.Text = this as + dev.inmo.tgbotapi.types.ReplyInfo.External.Text + +public inline fun ReplyInfo.ifText(block: (ReplyInfo.External.Text) -> T): T? = textOrNull() + ?.let(block) + +public inline fun ReplyInfo.internalOrNull(): ReplyInfo.Internal? = this as? + dev.inmo.tgbotapi.types.ReplyInfo.Internal + +public inline fun ReplyInfo.internalOrThrow(): ReplyInfo.Internal = this as + dev.inmo.tgbotapi.types.ReplyInfo.Internal + +public inline fun ReplyInfo.ifInternal(block: (ReplyInfo.Internal) -> T): T? = internalOrNull() + ?.let(block) + public inline fun BotAction.typingActionOrNull(): TypingAction? = this as? dev.inmo.tgbotapi.types.actions.TypingAction @@ -2385,6 +2442,15 @@ public inline fun TelegramMediaFile.fileOrThrow(): File = this as dev.inmo.tgbot public inline fun TelegramMediaFile.ifFile(block: (File) -> T): T? = fileOrNull() ?.let(block) +public inline fun TelegramMediaFile.mediaContentVariantOrNull(): MediaContentVariant? = this as? + dev.inmo.tgbotapi.types.files.MediaContentVariant + +public inline fun TelegramMediaFile.mediaContentVariantOrThrow(): MediaContentVariant = this as + dev.inmo.tgbotapi.types.files.MediaContentVariant + +public inline fun TelegramMediaFile.ifMediaContentVariant(block: (MediaContentVariant) -> T): T? + = mediaContentVariantOrNull() ?.let(block) + public inline fun TelegramMediaFile.mimedMediaFileOrNull(): MimedMediaFile? = this as? dev.inmo.tgbotapi.types.files.MimedMediaFile @@ -2412,6 +2478,15 @@ public inline fun TelegramMediaFile.pathedFileOrThrow(): PathedFile = this as public inline fun TelegramMediaFile.ifPathedFile(block: (PathedFile) -> T): T? = pathedFileOrNull() ?.let(block) +public inline fun TelegramMediaFile.photoOrNull(): Photo? = this as? + dev.inmo.tgbotapi.types.files.Photo + +public inline fun TelegramMediaFile.photoOrThrow(): Photo = this as + dev.inmo.tgbotapi.types.files.Photo + +public inline fun TelegramMediaFile.ifPhoto(block: (Photo) -> T): T? = photoOrNull() + ?.let(block) + public inline fun TelegramMediaFile.photoSizeOrNull(): PhotoSize? = this as? dev.inmo.tgbotapi.types.files.PhotoSize diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index 0874d13255..9b65ae7a90 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -51,7 +51,7 @@ inline val AccessibleMessage.is_automatic_forward: Boolean? get() = this is ConnectedFromChannelGroupContentMessage<*> @RiskFeature(RawFieldsUsageWarning) inline val AccessibleMessage.reply_to_message: AccessibleMessage? - get() = asPossiblyReplyMessage() ?.replyInfo + get() = asPossiblyReplyMessage() ?.replyTo @RiskFeature(RawFieldsUsageWarning) inline val AccessibleMessage.via_bot: CommonBot? get() = asPossiblySentViaBotCommonMessage() ?.senderBot From 955e9ca871f23c82deba880f6e6a8056effa5247 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 20:05:05 +0600 Subject: [PATCH 32/65] fix of #816 --- .../kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 96881e086b..79537d5231 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 @@ -85,17 +85,24 @@ fun Int.toChatId(): IdChatIdentifier = toLong().toChatId() fun Byte.toChatId(): IdChatIdentifier = toLong().toChatId() @Serializable(ChatIdentifierSerializer::class) -data class Username( +@JvmInline +value class Username( val username: String ) : ChatIdentifier { val usernameWithoutAt get() = username.dropWhile { it == '@' } + val full: String + get() = username init { if (!username.startsWith("@")) { throw IllegalArgumentException("Username must starts with `@`") } } + + override fun toString(): String { + return full + } } fun String.toUsername(): Username = Username(this) From f637b480b1562da1c9f8166d0d180c88a959ba26 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 20:51:29 +0600 Subject: [PATCH 33/65] add TextQuote --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../dev/inmo/tgbotapi/types/TextQuote.kt | 38 +++++++++++++++++++ .../types/abstracts/WithOptionalQuoteInfo.kt | 7 ++++ .../inmo/tgbotapi/types/message/RawMessage.kt | 21 ++++++---- .../types/message/RawMessageEntity.kt | 3 ++ .../types/message/content/AbstractsMedia.kt | 3 +- .../types/message/content/AnimationContent.kt | 4 +- .../types/message/content/AudioContent.kt | 4 +- .../types/message/content/DocumentContent.kt | 8 +++- .../message/content/MediaGroupContent.kt | 12 +++--- .../types/message/content/PhotoContent.kt | 7 +++- .../types/message/content/TextContent.kt | 11 +++--- .../types/message/content/VideoContent.kt | 4 +- .../types/message/content/VoiceContent.kt | 9 ++--- 14 files changed, 100 insertions(+), 32 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/abstracts/WithOptionalQuoteInfo.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index cf884c0b4b..27231c67b9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -665,3 +665,4 @@ const val winnersField = "winners" const val additionalChatCountField = "additional_chat_count" const val unclaimedPrizeCountField = "unclaimed_prize_count" const val wasRefundedField = "was_refunded" +const val isManualField = "is_manual" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt new file mode 100644 index 0000000000..48745d5816 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt @@ -0,0 +1,38 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.abstracts.TextedInput +import dev.inmo.tgbotapi.types.message.RawMessageEntities +import dev.inmo.tgbotapi.types.message.asTextSources +import dev.inmo.tgbotapi.types.message.textsources.TextSource +import dev.inmo.tgbotapi.types.message.toRawMessageEntities +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlin.jvm.JvmName + +@Serializable +data class TextQuote private constructor( + @SerialName(textField) + override val text: String, + @SerialName(positionField) + val position: Int, + @SerialName(entitiesField) + private val entities: RawMessageEntities? = null, + @SerialName(isManualField) + val isManual: Boolean = false +) : TextedInput { + override val textSources: List by lazy { + entities ?.asTextSources(text) ?: emptyList() + } + + companion object { + @JvmName("PublicConstructor") + operator fun invoke( + text: String, + position: Int, + textSources: List = emptyList(), + isManual: Boolean = false + ) = TextQuote( + text, position, textSources.toRawMessageEntities(position), isManual + ) + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/abstracts/WithOptionalQuoteInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/abstracts/WithOptionalQuoteInfo.kt new file mode 100644 index 0000000000..1ca3764b1e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/abstracts/WithOptionalQuoteInfo.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.abstracts + +import dev.inmo.tgbotapi.types.TextQuote + +interface WithOptionalQuoteInfo { + val quote: TextQuote? +} 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 dd05df6535..97aab2991d 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 @@ -55,6 +55,7 @@ internal data class RawMessage( private val is_automatic_forward: Boolean? = null, private val reply_to_message: RawMessage? = null, private val external_reply: ReplyInfo.External? = null, + private val quote: TextQuote? = null, private val via_bot: CommonBot? = null, private val edit_date: TelegramDate? = null, private val has_protected_content: Boolean? = null, @@ -148,40 +149,46 @@ internal data class RawMessage( messageId, story ) - text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text), link_preview_options) + text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text), link_preview_options, quote) audio != null -> AudioContent( audio, caption, - adaptedCaptionEntities + adaptedCaptionEntities, + quote ) video != null -> VideoContent( video, caption, adaptedCaptionEntities, - has_media_spoiler ?: false + has_media_spoiler ?: false, + quote ) animation != null -> AnimationContent( animation, document, caption, adaptedCaptionEntities, - has_media_spoiler ?: false + has_media_spoiler ?: false, + quote ) document != null -> DocumentContent( document, caption, - adaptedCaptionEntities + adaptedCaptionEntities, + quote ) voice != null -> VoiceContent( voice, caption, - adaptedCaptionEntities + adaptedCaptionEntities, + quote ) photo != null -> PhotoContent( photo, caption, adaptedCaptionEntities, - has_media_spoiler ?: false + has_media_spoiler ?: false, + quote ) sticker != null -> StickerContent(sticker) dice != null -> DiceContent(dice) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt index dde5a1fdb7..38058eb101 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessageEntity.kt @@ -1,9 +1,12 @@ package dev.inmo.tgbotapi.types.message +import dev.inmo.micro_utils.serialization.mapper.MapperSerializer import dev.inmo.tgbotapi.types.CustomEmojiId import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.message.textsources.* +import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable +import kotlinx.serialization.builtins.ListSerializer @Serializable internal data class RawMessageEntity( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt index 2b7cd80eaf..6a1ec0c5a2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AbstractsMedia.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.abstracts.TextedInput import dev.inmo.tgbotapi.types.MediaGroupIdentifier import dev.inmo.tgbotapi.types.MessageId +import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.files.AudioFile import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.media.* @@ -22,7 +23,7 @@ sealed interface DocumentMediaGroupPartContent : MediaGroupPartContent { override fun toMediaGroupMemberTelegramMedia(): DocumentMediaGroupMemberTelegramMedia } -sealed interface TextedMediaContent : TextedContent, MediaContent +sealed interface TextedMediaContent : TextedContent, MediaContent, WithOptionalQuoteInfo sealed interface MediaGroupCollectionContent : TextedMediaContent { @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt index 1552b97f54..5b77469bee 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.types.media.TelegramMediaAnimation import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.DocumentFile @@ -19,7 +20,8 @@ data class AnimationContent( val includedDocument: DocumentFile?, override val text: String?, override val textSources: TextSourcesList = emptyList(), - override val spoilered: Boolean = false + override val spoilered: Boolean = false, + override val quote: TextQuote? = null ) : TextedMediaContent, SpoilerableMediaContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt index 0b56455154..5051492406 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt @@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.types.media.toTelegramMediaAudio import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AudioFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -17,7 +18,8 @@ import kotlinx.serialization.Serializable data class AudioContent( override val media: AudioFile, override val text: String? = null, - override val textSources: TextSourcesList = emptyList() + override val textSources: TextSourcesList = emptyList(), + override val quote: TextQuote? = null ) : AudioMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt index 1b2720bcc8..7030286acb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt @@ -9,6 +9,8 @@ import dev.inmo.tgbotapi.types.media.toTelegramMediaDocument import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.TextQuote +import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.files.asDocumentFile @@ -19,7 +21,8 @@ import kotlinx.serialization.Serializable data class DocumentContent( override val media: DocumentFile, override val text: String? = null, - override val textSources: TextSourcesList = emptyList() + override val textSources: TextSourcesList = emptyList(), + override val quote: TextQuote? = null ) : DocumentMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier, @@ -52,7 +55,8 @@ inline fun MediaContent.asDocumentContent() = when (this) { is TextedInput -> DocumentContent( media.asDocumentFile(), text, - textSources + textSources, + (this as? WithOptionalQuoteInfo) ?.quote ) else -> DocumentContent( media.asDocumentFile() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt index b582f493cd..d0c0f729b7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt @@ -2,10 +2,8 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendMediaGroup -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MediaGroupIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.media.TelegramMedia @@ -16,10 +14,12 @@ import kotlinx.serialization.Serializable @Serializable data class MediaGroupContent( override val group: List>, - override val mediaGroupId: MediaGroupIdentifier -) : MediaGroupCollectionContent { + override val mediaGroupId: MediaGroupIdentifier, +) : MediaGroupCollectionContent, WithOptionalQuoteInfo { val mainContent: MediaGroupPartContent get() = group.first().content + override val quote: TextQuote? + get() = mainContent.quote override val media: TelegramMediaFile get() = mainContent.media diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt index 8b3e98c1ee..bbcc0453fd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt @@ -8,6 +8,8 @@ import dev.inmo.tgbotapi.types.media.toTelegramMediaPhoto import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.TextQuote +import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -18,8 +20,9 @@ data class PhotoContent( override val mediaCollection: Photo, override val text: String? = null, override val textSources: TextSourcesList = emptyList(), - override val spoilered: Boolean = false -) : MediaCollectionContent, VisualMediaGroupPartContent { + override val spoilered: Boolean = false, + override val quote: TextQuote? = null +) : MediaCollectionContent, VisualMediaGroupPartContent, WithOptionalQuoteInfo { override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") override fun createResend( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index 567841dd0c..26c4fd2f14 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -3,11 +3,9 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.abstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.SendTextMessage -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.LinkPreviewOptions +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import kotlinx.serialization.Serializable @@ -16,8 +14,9 @@ import kotlinx.serialization.Serializable data class TextContent( override val text: String, override val textSources: TextSourcesList = emptyList(), - val linkPreviewOptions: LinkPreviewOptions? = null -) : TextedContent { + val linkPreviewOptions: LinkPreviewOptions? = null, + override val quote: TextQuote? = null +) : TextedContent, WithOptionalQuoteInfo { override fun createResend( chatId: ChatIdentifier, messageThreadId: MessageThreadId?, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt index 7b8ed78713..96ebc2b2d3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.types.media.TelegramMediaVideo import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.toTelegramMediaVideo @@ -18,7 +19,8 @@ data class VideoContent( override val media: VideoFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList(), - override val spoilered: Boolean = false + override val spoilered: Boolean = false, + override val quote: TextQuote? = null ) : VisualMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt index 7e7deceea8..b2cc4fe154 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt @@ -2,22 +2,21 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendVoice -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.TelegramMediaAudio import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VoiceFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage -import dev.inmo.tgbotapi.types.threadId import kotlinx.serialization.Serializable @Serializable data class VoiceContent( override val media: VoiceFile, override val text: String? = null, - override val textSources: TextSourcesList = emptyList() + override val textSources: TextSourcesList = emptyList(), + override val quote: TextQuote? = null ) : TextedMediaContent { override fun createResend( chatId: ChatIdentifier, From e28f3492efa054c89620518e70a8094b0a5f3453 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 21:54:56 +0600 Subject: [PATCH 34/65] add ReplyParameters --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 4 + .../inmo/tgbotapi/types/ReplyParameters.kt | 121 ++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 27231c67b9..03529ac168 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -220,6 +220,10 @@ const val protectContentField = "protect_content" const val removeCaptionField = "remove_caption" const val replyToMessageIdField = "reply_to_message_id" const val allowSendingWithoutReplyField = "allow_sending_without_reply" +const val quoteField = "quote" +const val quoteParseModeField = "quote_parse_mode" +const val quoteEntitiesField = "quote_entities" +const val quotePositionField = "quote_position" const val replyMarkupField = "reply_markup" const val disableContentTypeDetectionField = "disable_content_type_detection" const val supportStreamingField = "support_streaming" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt new file mode 100644 index 0000000000..fe20f54db0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt @@ -0,0 +1,121 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.abstracts.TextedInput +import dev.inmo.tgbotapi.abstracts.TextedWithTextSources +import dev.inmo.tgbotapi.abstracts.WithMessageId +import dev.inmo.tgbotapi.types.message.ParseMode +import dev.inmo.tgbotapi.types.message.RawMessageEntity +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.asTextSources +import dev.inmo.tgbotapi.types.message.textsources.TextSource +import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.message.toRawMessageEntities +import dev.inmo.tgbotapi.utils.extensions.makeSourceString +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ReplyParameters internal constructor( + @SerialName(chatIdField) + val chatIdentifier: ChatIdentifier, + @SerialName(messageIdField) + override val messageId: MessageId, + @SerialName(allowSendingWithoutReplyField) + val allowSendingWithoutReply: Boolean = false, + @SerialName(quoteField) + val quote: String? = null, + @SerialName(quoteParseModeField) + val quoteParseMode: ParseMode? = null, + @SerialName(quoteEntitiesField) + private val quoteEntities: List? = null, + @SerialName(quotePositionField) + val quotePosition: Int? +) : WithMessageId, TextedInput { + override val text: String? + get() = quote + override val textSources: List by lazy { + quoteEntities ?.asTextSources(quote ?: return@lazy emptyList()) ?: emptyList() + } + + constructor( + chatIdentifier: ChatIdentifier, + messageId: MessageId, + entities: TextSourcesList, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + chatIdentifier, + messageId, + allowSendingWithoutReply, + entities.makeSourceString(), + null, + entities.toRawMessageEntities(), + quotePosition + ) + constructor( + metaInfo: Message.MetaInfo, + entities: TextSourcesList, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + metaInfo.chatId, + metaInfo.messageId, + entities, + allowSendingWithoutReply, + quotePosition + ) + constructor( + chatIdentifier: ChatIdentifier, + messageId: MessageId, + quote: String, + quoteParseMode: ParseMode, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + chatIdentifier, + messageId, + allowSendingWithoutReply, + quote, + quoteParseMode, + null, + quotePosition + ) + constructor( + metaInfo: Message.MetaInfo, + quote: String, + quoteParseMode: ParseMode, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + metaInfo.chatId, + metaInfo.messageId, + quote, + quoteParseMode, + allowSendingWithoutReply, + quotePosition + ) + constructor( + chatIdentifier: ChatIdentifier, + messageId: MessageId, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + chatIdentifier, + messageId, + allowSendingWithoutReply, + null, + null, + null, + quotePosition + ) + constructor( + metaInfo: Message.MetaInfo, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + metaInfo.chatId, + metaInfo.messageId, + allowSendingWithoutReply, + quotePosition + ) +} From 60e50f94928f82e6818f6de6d5e19dd32125010d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 21:56:31 +0600 Subject: [PATCH 35/65] improvements in Username --- .../dev/inmo/tgbotapi/types/ChatIdentifier.kt | 8 ++++++-- .../utils/formatting/LinksFormatting.kt | 16 ++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) 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 79537d5231..30270966cd 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 @@ -87,12 +87,16 @@ fun Byte.toChatId(): IdChatIdentifier = toLong().toChatId() @Serializable(ChatIdentifierSerializer::class) @JvmInline value class Username( + @Deprecated("Renamed", ReplaceWith("full")) val username: String ) : ChatIdentifier { - val usernameWithoutAt - get() = username.dropWhile { it == '@' } val full: String get() = username + val withoutAt + get() = full.dropWhile { it == '@' } + @Deprecated("Renamed", ReplaceWith("withoutAt")) + val usernameWithoutAt + get() = withoutAt init { if (!username.startsWith("@")) { diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt index af8342df7a..5364f4cdda 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt @@ -21,24 +21,24 @@ fun makeInternalTgUsernameDeepLinkPrefix(username: String) = "${makeInternalTgUs fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$username?startattach" fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}" inline val Username.usernameLink - get() = makeUsernameLink(usernameWithoutAt) + get() = makeUsernameLink(withoutAt) val IdChatIdentifier.chatLink: String get() = makeChatLink(chatId, threadId) fun ChatId.link(threadId: MessageThreadId?) = makeChatLink(chatId, threadId) -inline fun Username.link(threadId: MessageThreadId?) = makeUsernameLink(usernameWithoutAt, threadId) +inline fun Username.link(threadId: MessageThreadId?) = makeUsernameLink(withoutAt, threadId) inline val Username.deepLinkPrefix - get() = makeUsernameDeepLinkPrefix(usernameWithoutAt) + get() = makeUsernameDeepLinkPrefix(withoutAt) inline val Username.startattachPrefix - get() = makeUsernameStartattachPrefix(usernameWithoutAt) + get() = makeUsernameStartattachPrefix(withoutAt) inline fun makeLink(username: Username, threadId: MessageThreadId? = null) = username.link(threadId) inline fun makeTelegramDeepLink(username: String, startParameter: String) = "${makeUsernameDeepLinkPrefix(username)}$startParameter".encodeURLQueryComponent() inline fun makeInternalTgDeepLink(username: String, startParameter: String) = "${makeInternalTgUsernameDeepLinkPrefix(username)}$startParameter".encodeURLQueryComponent() inline fun makeInternalTgDeepLink(username: Username, startParameter: String) = - makeInternalTgDeepLink(username.usernameWithoutAt, startParameter) + makeInternalTgDeepLink(username.withoutAt, startParameter) inline fun makeTelegramStartattach(username: String, data: String? = null) = makeUsernameStartattachLink(username, data) -inline fun makeDeepLink(username: Username, startParameter: String) = makeTelegramDeepLink(username.usernameWithoutAt, startParameter) +inline fun makeDeepLink(username: Username, startParameter: String) = makeTelegramDeepLink(username.withoutAt, startParameter) inline fun makeTelegramDeepLink(username: Username, startParameter: String) = makeDeepLink(username, startParameter) -inline fun makeTelegramStartattach(username: Username, data: String? = null) = makeTelegramStartattach(username.usernameWithoutAt, data) +inline fun makeTelegramStartattach(username: Username, data: String? = null) = makeTelegramStartattach(username.withoutAt, data) private val linkIdRedundantPartRegex = Regex("^-100") private val usernameBeginSymbolRegex = Regex("^@") @@ -52,7 +52,7 @@ fun makeLinkToMessage( username: Username, messageId: MessageId, threadId: MessageThreadId? = null -): String = makeLinkToMessage(username.usernameWithoutAt, messageId, threadId) +): String = makeLinkToMessage(username.withoutAt, messageId, threadId) fun makeLinkToMessage( chatId: Identifier, messageId: MessageId, From a692ed65f3cc4fd67d7e07eb19eb73fecff2971a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 22:42:46 +0600 Subject: [PATCH 36/65] almost add reply parameters --- .../extensions/api/LiveFlowLocation.kt | 18 +- .../extensions/api/LiveLocationProvider.kt | 30 +- .../extensions/api/send/CopyMessage.kt | 115 ++--- .../tgbotapi/extensions/api/send/Replies.kt | 142 +++--- .../extensions/api/send/ResendMessage.kt | 29 +- .../extensions/api/send/SendContact.kt | 20 +- .../tgbotapi/extensions/api/send/SendDice.kt | 15 +- .../extensions/api/send/SendLiveLocation.kt | 44 +- .../extensions/api/send/SendMessage.kt | 81 ++- .../extensions/api/send/SendStaticLocation.kt | 49 +- .../tgbotapi/extensions/api/send/SendVenue.kt | 36 +- .../tgbotapi/extensions/api/send/Sends.kt | 461 +++++++----------- .../extensions/api/send/games/SendGame.kt | 25 +- .../api/send/media/SendAnimation.kt | 47 +- .../extensions/api/send/media/SendAudio.kt | 47 +- .../extensions/api/send/media/SendDocument.kt | 47 +- .../api/send/media/SendMediaGroup.kt | 85 ++-- .../extensions/api/send/media/SendPhoto.kt | 67 +-- .../extensions/api/send/media/SendSticker.kt | 25 +- .../extensions/api/send/media/SendVideo.kt | 47 +- .../api/send/media/SendVideoNote.kt | 26 +- .../extensions/api/send/media/SendVoice.kt | 47 +- .../api/send/payments/SendInvoice.kt | 10 +- .../extensions/api/send/polls/SendPoll.kt | 65 +-- .../abstracts/types/ReplyMessageId.kt | 8 - .../abstracts/types/WithReplyParameters.kt | 19 + .../tgbotapi/requests/send/CopyMessage.kt | 30 +- .../tgbotapi/requests/send/SendContact.kt | 18 +- .../inmo/tgbotapi/requests/send/SendDice.kt | 10 +- .../tgbotapi/requests/send/SendLocation.kt | 23 +- .../tgbotapi/requests/send/SendMessage.kt | 18 +- .../inmo/tgbotapi/requests/send/SendVenue.kt | 18 +- .../send/abstracts/SendMessageRequest.kt | 2 +- .../tgbotapi/requests/send/games/SendGame.kt | 6 +- .../requests/send/media/SendAnimation.kt | 18 +- .../tgbotapi/requests/send/media/SendAudio.kt | 18 +- .../requests/send/media/SendDocument.kt | 18 +- .../requests/send/media/SendMediaGroup.kt | 26 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 18 +- .../requests/send/media/SendSticker.kt | 18 +- .../tgbotapi/requests/send/media/SendVideo.kt | 18 +- .../requests/send/media/SendVideoNote.kt | 12 +- .../tgbotapi/requests/send/media/SendVoice.kt | 18 +- .../requests/send/payments/SendInvoice.kt | 8 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 57 +-- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../inmo/tgbotapi/types/ReplyParameters.kt | 34 +- .../types/message/content/Abstracts.kt | 31 +- .../types/message/content/AnimationContent.kt | 11 +- .../types/message/content/AudioContent.kt | 11 +- .../types/message/content/ContactContent.kt | 5 +- .../types/message/content/DiceContent.kt | 7 +- .../types/message/content/DocumentContent.kt | 11 +- .../types/message/content/GameContent.kt | 7 +- .../content/GiveawayPublicResultsContent.kt | 3 +- .../types/message/content/InvoiceContent.kt | 4 +- .../types/message/content/LocationContent.kt | 13 +- .../message/content/MediaGroupContent.kt | 6 +- .../types/message/content/PhotoContent.kt | 11 +- .../types/message/content/PollContent.kt | 7 +- .../content/ScheduledGiveawayContent.kt | 3 +- .../types/message/content/StickerContent.kt | 7 +- .../types/message/content/StoryContent.kt | 4 +- .../types/message/content/TextContent.kt | 6 +- .../types/message/content/VenueContent.kt | 6 +- .../types/message/content/VideoContent.kt | 11 +- .../types/message/content/VideoNoteContent.kt | 7 +- .../types/message/content/VoiceContent.kt | 6 +- 68 files changed, 852 insertions(+), 1319 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMessageId.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyParameters.kt diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt index 58bae30e88..46381c4430 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveFlowLocation.kt @@ -44,8 +44,7 @@ suspend fun TelegramBot.handleLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, sentMessageFlow: FlowCollector>? = null ) { var currentLiveLocationMessage: ContentMessage? = null @@ -71,8 +70,7 @@ suspend fun TelegramBot.handleLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, it.replyMarkup ).also { sentMessageFlow ?.emit(it) @@ -106,8 +104,7 @@ suspend fun TelegramBot.handleLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, sentMessageFlow: FlowCollector>? = null ) { handleLiveLocation( @@ -126,8 +123,7 @@ suspend fun TelegramBot.handleLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, sentMessageFlow ) } @@ -145,8 +141,7 @@ suspend fun TelegramBot.handleLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, sentMessageFlow: FlowCollector>? = null ) { handleLiveLocation( @@ -161,8 +156,7 @@ suspend fun TelegramBot.handleLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, sentMessageFlow ) } diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt index de3551c5a2..4f76a7923f 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt @@ -96,8 +96,7 @@ suspend fun TelegramBot.startLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): LiveLocationProvider { val liveTimeAsDouble = liveTimeMillis.toDouble() @@ -113,8 +112,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -143,8 +141,7 @@ suspend fun TelegramBot.startLiveLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): LiveLocationProvider = startLiveLocation( scope, @@ -158,8 +155,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -178,8 +174,7 @@ suspend fun TelegramBot.startLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): LiveLocationProvider = startLiveLocation( scope, @@ -193,8 +188,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -213,8 +207,7 @@ suspend fun TelegramBot.startLiveLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): LiveLocationProvider = startLiveLocation( scope, @@ -228,8 +221,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -263,8 +255,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( threadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -296,7 +287,6 @@ suspend inline fun TelegramBot.replyWithLiveLocation( threadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt index fe539e90ab..2524e2b145 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt @@ -2,15 +2,12 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.CopyMessage -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -25,8 +22,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( CopyMessage( @@ -38,8 +34,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -57,10 +52,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -75,10 +69,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -93,10 +86,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -111,8 +103,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( CopyMessage( @@ -123,8 +114,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -141,10 +131,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChatId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChatId, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -158,10 +147,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChatId, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -175,10 +163,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -192,10 +179,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -209,10 +195,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -225,10 +210,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChatId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChatId, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -241,10 +225,9 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChat, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChat, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -259,8 +242,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( CopyMessage( @@ -272,8 +254,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -291,8 +272,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( toChatId, @@ -303,8 +283,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -321,8 +300,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( toChat.id, @@ -333,8 +311,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -351,8 +328,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( toChat.id, @@ -363,8 +339,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -381,8 +356,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( CopyMessage( @@ -393,8 +367,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -411,8 +384,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( toChatId, @@ -422,8 +394,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -439,8 +410,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( toChat.id, @@ -450,8 +420,7 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -467,8 +436,7 @@ suspend inline fun TelegramBot.copyMessage( threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( toChat.id, @@ -478,7 +446,6 @@ suspend inline fun TelegramBot.copyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 09b3cd0ea3..7484c3bd20 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -59,8 +59,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -81,8 +80,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -100,7 +98,7 @@ suspend inline fun TelegramBot.replyWithDice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -188,8 +186,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -212,8 +209,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -281,8 +277,7 @@ suspend inline fun TelegramBot.reply( threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = to.messageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup = replyMarkup ) @@ -312,8 +307,7 @@ suspend inline fun TelegramBot.reply( threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = to.messageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup = replyMarkup ) @@ -330,8 +324,7 @@ suspend inline fun TelegramBot.reply( threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = to.messageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup = replyMarkup ) @@ -346,7 +339,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup + to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( @@ -357,7 +350,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup + to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) suspend inline fun TelegramBot.reply( @@ -399,8 +392,7 @@ suspend inline fun TelegramBot.replyWithAnimation( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -417,7 +409,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( to: AccessibleMessage, @@ -444,8 +436,7 @@ suspend inline fun TelegramBot.replyWithAnimation( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -461,7 +452,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Audio @@ -479,7 +470,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -491,7 +482,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( to: AccessibleMessage, @@ -505,7 +496,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -516,7 +507,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Documents @@ -532,7 +523,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -544,7 +535,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( to: AccessibleMessage, @@ -556,7 +547,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -567,7 +558,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) // Media Group @@ -618,7 +609,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -630,7 +621,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -642,7 +633,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -654,7 +645,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -665,7 +656,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -676,7 +667,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Sticker @@ -689,7 +680,7 @@ suspend inline fun TelegramBot.replyWithSticker( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -699,7 +690,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Videos @@ -718,7 +709,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -730,7 +721,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( to: AccessibleMessage, @@ -745,7 +736,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -756,7 +747,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // VideoNotes @@ -771,7 +762,7 @@ suspend inline fun TelegramBot.replyWithVideoNote( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(to.chat, videoNote, thumb, duration, size, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(to.chat, videoNote, thumb, duration, size, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -780,7 +771,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(to.chat, videoNote, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(to.chat, videoNote, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Voice @@ -795,7 +786,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, text, parseMode, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, text, parseMode, duration, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -806,7 +797,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -818,7 +809,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -828,7 +819,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Invoice @@ -860,7 +851,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Polls @@ -877,7 +868,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -892,7 +883,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -908,7 +899,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -925,7 +916,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -940,7 +931,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -956,7 +947,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( @@ -1023,8 +1014,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -1064,44 +1054,42 @@ suspend fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) ) /** - * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update + * Will use [handleLiveLocation] with replying to [to] each time new message will be sent by live location update * * @see handleLiveLocation */ suspend fun TelegramBot.reply( - message: AccessibleMessage, + to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) = handleLiveLocation( - message.chat.id, + to.chat.id, locationsFlow, liveTimeMillis, - message.threadIdOrNull, + to.threadIdOrNull, disableNotification, protectContent, - message.messageId, - allowSendingWithoutReply + ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true) ) /** - * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update + * Will use [handleLiveLocation] with replying to [to] each time new message will be sent by live location update * * @see handleLiveLocation */ @JvmName("replyLiveLocationWithLocation") @JsName("replyLiveLocationWithLocation") suspend fun TelegramBot.reply( - message: AccessibleMessage, + to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, @@ -1109,26 +1097,25 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - message.chat.id, + to.chat.id, locationsFlow, liveTimeMillis, - message.threadIdOrNull, + to.threadIdOrNull, disableNotification, protectContent, - message.messageId, - allowSendingWithoutReply + ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true) ) } /** - * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update + * Will use [handleLiveLocation] with replying to [to] each time new message will be sent by live location update * * @see handleLiveLocation */ @JvmName("replyLiveLocationWithLatLong") @JsName("replyLiveLocationWithLatLong") suspend fun TelegramBot.reply( - message: AccessibleMessage, + to: AccessibleMessage, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, @@ -1136,14 +1123,13 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - message.chat.id, + to.chat.id, locationsFlow, liveTimeMillis, - message.threadIdOrNull, + to.threadIdOrNull, disableNotification, protectContent, - message.messageId, - allowSendingWithoutReply + ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true) ) } diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/ResendMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/ResendMessage.kt index 8a68ce82f7..6d002c5bb4 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/ResendMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/ResendMessage.kt @@ -1,14 +1,11 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.MessageContent -import dev.inmo.tgbotapi.types.threadId /** * This method will send [content] to the [chatId] as is @@ -19,8 +16,7 @@ suspend inline fun TelegramBot.resend( messageThreadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( content.createResend( @@ -28,8 +24,7 @@ suspend inline fun TelegramBot.resend( messageThreadId = messageThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) ) as ContentMessage @@ -43,8 +38,7 @@ suspend inline fun TelegramBot.resend( messageThreadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = resend( chatId = chat.id, @@ -52,8 +46,7 @@ suspend inline fun TelegramBot.resend( messageThreadId = messageThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -68,8 +61,7 @@ suspend inline fun TelegramBot.resend( messageThreadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = resend( chatId = chatId, @@ -77,8 +69,7 @@ suspend inline fun TelegramBot.resend( messageThreadId = messageThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -93,8 +84,7 @@ suspend inline fun TelegramBot.resend( messageThreadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = resend( chatId = chat.id, @@ -102,7 +92,6 @@ suspend inline fun TelegramBot.resend( messageThreadId = messageThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt index adaf50afa8..a2c9904118 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt @@ -18,12 +18,11 @@ suspend fun TelegramBot.sendContact( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendContact( - chatId, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) ) @@ -37,12 +36,11 @@ suspend fun TelegramBot.sendContact( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendContact( - chatId, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, contact, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) ) @@ -58,11 +56,10 @@ suspend fun TelegramBot.sendContact( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - chat.id, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -75,9 +72,8 @@ suspend fun TelegramBot.sendContact( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - chat.id, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, contact, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt index e7094f1400..776d900f27 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt @@ -2,13 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.SendDice -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.dice.DiceAnimationType -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -20,11 +17,10 @@ suspend fun TelegramBot.sendDice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendDice(chatId, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendDice(chatId, animationType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) ) /** @@ -37,7 +33,6 @@ suspend fun TelegramBot.sendDice( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(chat.id, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(chat.id, animationType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt index 674b61d276..e33ccf8f66 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLiveLocation.kt @@ -22,8 +22,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendLiveLocation( @@ -37,8 +36,7 @@ suspend fun TelegramBot.sendLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -57,8 +55,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( chatId, @@ -71,8 +68,7 @@ suspend fun TelegramBot.sendLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -91,8 +87,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( chat.id, @@ -105,8 +100,7 @@ suspend fun TelegramBot.sendLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -124,8 +118,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( chat.id, @@ -138,8 +131,7 @@ suspend fun TelegramBot.sendLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -158,10 +150,9 @@ suspend fun TelegramBot.sendLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -177,10 +168,9 @@ suspend fun TelegramBot.sendLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -197,10 +187,9 @@ suspend fun TelegramBot.sendLiveLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -216,7 +205,6 @@ suspend fun TelegramBot.sendLiveLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt index 2c7ee237fc..36e366a727 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt @@ -23,8 +23,7 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendTextMessage( @@ -35,8 +34,7 @@ suspend fun TelegramBot.sendMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -53,11 +51,10 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -72,10 +69,9 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -90,10 +86,9 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -106,11 +101,10 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) ) /** @@ -124,11 +118,10 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -142,11 +135,10 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -159,11 +151,10 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -177,11 +168,10 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -195,11 +185,10 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -212,10 +201,9 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -228,11 +216,10 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -246,11 +233,10 @@ suspend fun TelegramBot.sendMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -264,10 +250,9 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -280,11 +265,10 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -298,8 +282,7 @@ suspend fun TelegramBot.sendTextMessage( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt index d201c7cb42..11d7c50503 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendStaticLocation.kt @@ -2,13 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.SendStaticLocation -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.location.Location -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -21,8 +18,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendStaticLocation( @@ -32,8 +28,7 @@ suspend fun TelegramBot.sendLocation( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - allowSendingWithoutReply = allowSendingWithoutReply, - replyToMessageId = replyToMessageId, + replyParameters = replyParameters, replyMarkup = replyMarkup ) ) @@ -48,8 +43,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( chatId, @@ -58,8 +52,7 @@ suspend fun TelegramBot.sendLocation( threadId, disableNotification, protectContent, - allowSendingWithoutReply, - replyToMessageId, + replyParameters, replyMarkup ) @@ -74,8 +67,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( chat.id, @@ -84,8 +76,7 @@ suspend fun TelegramBot.sendLocation( threadId, disableNotification, protectContent, - allowSendingWithoutReply, - replyToMessageId, + replyParameters, replyMarkup ) @@ -99,8 +90,7 @@ suspend fun TelegramBot.sendLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( chat.id, @@ -109,8 +99,7 @@ suspend fun TelegramBot.sendLocation( threadId, disableNotification, protectContent, - allowSendingWithoutReply, - replyToMessageId, + replyParameters, replyMarkup ) @@ -125,10 +114,9 @@ suspend fun TelegramBot.sendStaticLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -140,10 +128,9 @@ suspend fun TelegramBot.sendStaticLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, location.latitude, location.longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chatId, location.latitude, location.longitude, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -156,10 +143,9 @@ suspend fun TelegramBot.sendStaticLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chat.id, latitude, longitude, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -171,7 +157,6 @@ suspend fun TelegramBot.sendStaticLocation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, location.latitude, location.longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chat.id, location.latitude, location.longitude, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt index 1025ac993f..a33ce202a9 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt @@ -25,8 +25,7 @@ suspend fun TelegramBot.sendVenue( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendVenue( @@ -42,8 +41,7 @@ suspend fun TelegramBot.sendVenue( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) ) @@ -65,8 +63,7 @@ suspend fun TelegramBot.sendVenue( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( chatId = chat.id, @@ -81,8 +78,7 @@ suspend fun TelegramBot.sendVenue( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -102,8 +98,7 @@ suspend fun TelegramBot.sendVenue( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( chatId = chatId, @@ -118,8 +113,7 @@ suspend fun TelegramBot.sendVenue( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -139,8 +133,7 @@ suspend fun TelegramBot.sendVenue( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( chatId = chat.id, @@ -155,8 +148,7 @@ suspend fun TelegramBot.sendVenue( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -170,8 +162,7 @@ suspend fun TelegramBot.sendVenue( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendVenue( @@ -180,8 +171,7 @@ suspend fun TelegramBot.sendVenue( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) ) @@ -196,8 +186,7 @@ suspend fun TelegramBot.sendVenue( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( chatId = chat.id, @@ -205,7 +194,6 @@ suspend fun TelegramBot.sendVenue( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt index 283367d9e3..f71cf0f761 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt @@ -63,10 +63,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendAnimation] request @@ -85,10 +84,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendAnimation] request @@ -106,10 +104,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendAnimation] request @@ -127,10 +124,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendAudio] request @@ -146,10 +142,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendAudio] request @@ -165,10 +160,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendAudio] request @@ -183,10 +177,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio, entities, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio, entities, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendAudio] request @@ -201,10 +194,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat, audio, entities, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat, audio, entities, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendContact] request @@ -219,10 +211,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chatId, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chatId, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendContact] request @@ -235,10 +226,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chatId, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chatId, contact, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendContact] request @@ -253,10 +243,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chat, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chat, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendContact] request @@ -269,10 +258,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chat, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chat, contact, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendDice] request @@ -285,10 +273,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(chatId, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(chatId, animationType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendDice] request @@ -301,10 +288,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(chat, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(chat, animationType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendDocument] request @@ -319,11 +305,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chatId, document, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chatId, document, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) /** * Will execute [sendDocument] request @@ -338,11 +323,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat, document, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat, document, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) /** * Will execute [sendDocument] request @@ -356,11 +340,10 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chatId, document, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chatId, document, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) /** * Will execute [sendDocument] request @@ -374,11 +357,10 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat, document, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat, document, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) /** * Will execute [sendGame] request @@ -391,10 +373,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendGame(chatId, game, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendGame(chatId, game, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendGame] request @@ -407,10 +388,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendGame(chat, game, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendGame(chat, game, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendInvoice] request @@ -439,10 +419,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendInvoice] request @@ -470,10 +449,9 @@ suspend fun TelegramBot.send( priceDependOnShipAddress: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(user, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(user, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -487,10 +465,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -503,10 +480,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chatId, location, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chatId, location, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -520,10 +496,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chat, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chat, latitude, longitude, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -536,10 +511,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chat, location, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chat, location, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendTextMessage] request @@ -554,10 +528,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendTextMessage] request @@ -572,10 +545,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendTextMessage] request @@ -589,10 +561,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -605,11 +576,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -623,11 +593,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -642,10 +611,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -658,11 +626,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -676,11 +643,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -696,10 +662,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -715,10 +680,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -734,10 +698,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -753,10 +716,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -771,10 +733,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -789,10 +750,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photo, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -807,10 +767,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendPhoto] request @@ -825,10 +784,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -846,10 +804,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -868,10 +825,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -889,10 +845,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -911,10 +866,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -934,10 +888,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -957,10 +910,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -981,11 +933,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -1007,10 +958,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -1029,10 +979,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -1051,10 +1000,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -1074,10 +1022,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -1097,10 +1044,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendSticker] request @@ -1114,10 +1060,9 @@ suspend fun TelegramBot.send( emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendSticker] request @@ -1131,10 +1076,9 @@ suspend fun TelegramBot.send( emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat, sticker, threadId, emoji, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -1153,8 +1097,7 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLiveLocation( chatId = chatId, @@ -1167,8 +1110,7 @@ suspend fun TelegramBot.send( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -1187,11 +1129,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLiveLocation( - chatId, location, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, location, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -1210,11 +1151,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLiveLocation( - chat, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -1232,11 +1172,10 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendLiveLocation( - chat, location, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat, location, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -1257,10 +1196,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chatId, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chatId, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVenue] request @@ -1280,10 +1218,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chat, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chat, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVenue] request @@ -1302,10 +1239,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chatId, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chatId, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVenue] request @@ -1324,10 +1260,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chat, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chat, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVenue] request @@ -1340,10 +1275,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chatId, venue, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chatId, venue, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVenue] request @@ -1356,10 +1290,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chat, venue, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chat, venue, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVideo] request @@ -1375,10 +1308,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVideo] request @@ -1394,10 +1326,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVideo] request @@ -1412,10 +1343,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVideo] request @@ -1430,10 +1360,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat, video, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVideoNote] request @@ -1446,10 +1375,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chatId, videoNote, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chatId, videoNote, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVideoNote] request @@ -1462,10 +1390,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chat, videoNote, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chat, videoNote, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVoice] request @@ -1480,10 +1407,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chatId, voice, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chatId, voice, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVoice] request @@ -1498,10 +1424,9 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat, voice, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat, voice, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVoice] request @@ -1515,10 +1440,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chatId, voice, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chatId, voice, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendVoice] request @@ -1532,10 +1456,9 @@ suspend inline fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat, voice, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat, voice, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @see SendMediaGroup @@ -1548,9 +1471,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendMediaGroup @@ -1563,9 +1485,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendMediaGroup(chat, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendMediaGroup @@ -1578,9 +1499,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendMediaGroup @@ -1593,9 +1513,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendMediaGroup(chat, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendPlaylist @@ -1607,9 +1526,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendPlaylist(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendPlaylist @@ -1621,9 +1539,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendPlaylist(chat, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendPlaylist @@ -1635,9 +1552,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendPlaylist(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendPlaylist @@ -1649,9 +1565,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendPlaylist(chat, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendDocumentsGroup @@ -1663,9 +1578,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendDocumentsGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendDocumentsGroup @@ -1677,9 +1591,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendDocumentsGroup(chat, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendDocumentsGroup @@ -1691,9 +1604,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendDocumentsGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendDocumentsGroup @@ -1705,9 +1617,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendDocumentsGroup(chat, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendVisualMediaGroup @@ -1719,9 +1630,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendVisualMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendVisualMediaGroup @@ -1733,9 +1643,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendVisualMediaGroup(chat, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendVisualMediaGroup @@ -1747,9 +1656,8 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendVisualMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters) /** * @see SendVisualMediaGroup @@ -1761,6 +1669,5 @@ suspend fun TelegramBot.send( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) + replyParameters: ReplyParameters? = null +) = sendVisualMediaGroup(chat, media, threadId, disableNotification, protectContent, replyParameters) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt index 10e26f0527..71f0f495ba 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt @@ -2,13 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.send.games import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.games.SendGame -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.games.Game -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -20,12 +17,11 @@ suspend fun TelegramBot.sendGame( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendGame( - chatId, gameShortName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, gameShortName, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) ) @@ -39,11 +35,10 @@ suspend fun TelegramBot.sendGame( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - chat.id, gameShortName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, gameShortName, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -56,11 +51,10 @@ suspend fun TelegramBot.sendGame( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - chatId, game.title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, game.title, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -73,9 +67,8 @@ suspend fun TelegramBot.sendGame( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - chat.id, game.title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, game.title, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt index 22817f4192..fbb0a719fd 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt @@ -3,15 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAnimation -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.AnimationFile -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -30,8 +27,7 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendAnimation( @@ -47,8 +43,7 @@ suspend fun TelegramBot.sendAnimation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -69,11 +64,10 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumbnail ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumbnail ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -93,10 +87,9 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -114,10 +107,9 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -136,8 +128,7 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendAnimation( @@ -152,8 +143,7 @@ suspend fun TelegramBot.sendAnimation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -173,11 +163,10 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumbnail ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumbnail ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -196,10 +185,9 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -216,7 +204,6 @@ suspend fun TelegramBot.sendAnimation( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt index 355a26fa85..1266c22f98 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt @@ -3,15 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAudio -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.AudioFile -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -29,8 +26,7 @@ suspend fun TelegramBot.sendAudio( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendAudio( @@ -45,8 +41,7 @@ suspend fun TelegramBot.sendAudio( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -67,10 +62,9 @@ suspend fun TelegramBot.sendAudio( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -85,10 +79,9 @@ suspend fun TelegramBot.sendAudio( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -103,10 +96,9 @@ suspend fun TelegramBot.sendAudio( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -124,8 +116,7 @@ suspend inline fun TelegramBot.sendAudio( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendAudio( @@ -139,8 +130,7 @@ suspend inline fun TelegramBot.sendAudio( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -160,10 +150,9 @@ suspend inline fun TelegramBot.sendAudio( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -177,10 +166,9 @@ suspend inline fun TelegramBot.sendAudio( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio.fileId, audio.thumbnail ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -194,7 +182,6 @@ suspend inline fun TelegramBot.sendAudio( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, entities, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, entities, title, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt index 787e5fc7f6..8fda288589 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt @@ -3,15 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendDocument -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.DocumentFile -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -26,8 +23,7 @@ suspend fun TelegramBot.sendDocument( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = execute( @@ -40,8 +36,7 @@ suspend fun TelegramBot.sendDocument( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup, disableContentTypeDetection ) @@ -60,11 +55,10 @@ suspend fun TelegramBot.sendDocument( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, thumb, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, thumb, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -78,12 +72,11 @@ suspend fun TelegramBot.sendDocument( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = sendDocument( - chatId, document.fileId, document.thumbnail ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection + chatId, document.fileId, document.thumbnail ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection ) /** @@ -98,11 +91,10 @@ suspend fun TelegramBot.sendDocument( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -116,8 +108,7 @@ suspend inline fun TelegramBot.sendDocument( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = execute( @@ -129,8 +120,7 @@ suspend inline fun TelegramBot.sendDocument( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup, disableContentTypeDetection ) @@ -148,11 +138,10 @@ suspend inline fun TelegramBot.sendDocument( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, thumb, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, thumb, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -165,12 +154,11 @@ suspend inline fun TelegramBot.sendDocument( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = sendDocument( - chatId, document.fileId, document.thumbnail ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection + chatId, document.fileId, document.thumbnail ?.fileId, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection ) /** @@ -184,8 +172,7 @@ suspend inline fun TelegramBot.sendDocument( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup, disableContentTypeDetection) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt index 5b24700c0c..69edd1a91d 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt @@ -2,16 +2,13 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.media.* -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.* -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.AudioContent import dev.inmo.tgbotapi.types.message.content.DocumentContent -import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.utils.RiskFeature import kotlin.jvm.JvmName @@ -25,11 +22,10 @@ suspend fun TelegramBot.sendMediaGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = execute( SendMediaGroup( - chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media, threadId, disableNotification, protectContent, replyParameters ) ) @@ -43,10 +39,9 @@ suspend fun TelegramBot.sendMediaGroup( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendMediaGroup( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) /** @@ -60,10 +55,9 @@ suspend fun TelegramBot.sendMediaGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendMediaGroup( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyParameters ) /** @@ -77,10 +71,9 @@ suspend fun TelegramBot.sendMediaGroup( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendMediaGroup( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) /** @@ -92,11 +85,10 @@ suspend fun TelegramBot.sendPlaylist( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = execute( SendPlaylist( - chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media, threadId, disableNotification, protectContent, replyParameters ) ) @@ -109,10 +101,9 @@ suspend fun TelegramBot.sendPlaylist( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendPlaylist( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) /** @@ -125,10 +116,9 @@ suspend fun TelegramBot.sendPlaylist( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendPlaylist( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyParameters ) /** @@ -141,10 +131,9 @@ suspend fun TelegramBot.sendPlaylist( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendPlaylist( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) /** @@ -156,11 +145,10 @@ suspend fun TelegramBot.sendDocumentsGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = execute( SendDocumentsGroup( - chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media, threadId, disableNotification, protectContent, replyParameters ) ) @@ -173,10 +161,9 @@ suspend fun TelegramBot.sendDocumentsGroup( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendDocumentsGroup( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) /** @@ -189,10 +176,9 @@ suspend fun TelegramBot.sendDocumentsGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendDocumentsGroup( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyParameters ) /** @@ -205,10 +191,9 @@ suspend fun TelegramBot.sendDocumentsGroup( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendDocumentsGroup( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) /** @@ -220,11 +205,10 @@ suspend fun TelegramBot.sendVisualMediaGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = execute( SendVisualMediaGroup( - chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media, threadId, disableNotification, protectContent, replyParameters ) ) @@ -237,10 +221,9 @@ suspend fun TelegramBot.sendVisualMediaGroup( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendVisualMediaGroup( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) /** @@ -253,10 +236,9 @@ suspend fun TelegramBot.sendVisualMediaGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendVisualMediaGroup( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyParameters ) /** @@ -269,8 +251,7 @@ suspend fun TelegramBot.sendVisualMediaGroup( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null + replyParameters: ReplyParameters? = null ) = sendVisualMediaGroup( - chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyParameters ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt index 3626bb8f66..4141311d02 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt @@ -3,15 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendPhoto -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.* -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -26,8 +23,7 @@ suspend fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendPhoto( @@ -39,8 +35,7 @@ suspend fun TelegramBot.sendPhoto( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -58,10 +53,9 @@ suspend fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -76,10 +70,9 @@ suspend fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -94,10 +87,9 @@ suspend fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -112,10 +104,9 @@ suspend fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize.fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -130,10 +121,9 @@ suspend fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -148,8 +138,7 @@ suspend inline fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendPhoto( @@ -160,8 +149,7 @@ suspend inline fun TelegramBot.sendPhoto( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -178,10 +166,9 @@ suspend inline fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, fileId, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -195,10 +182,9 @@ suspend inline fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -212,10 +198,9 @@ suspend inline fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photo, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -229,10 +214,9 @@ suspend inline fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize.fileId, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -246,7 +230,6 @@ suspend inline fun TelegramBot.sendPhoto( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt index 26ee351e09..493fdd9b36 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt @@ -3,13 +3,10 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendSticker -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.Sticker -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -22,11 +19,10 @@ suspend fun TelegramBot.sendSticker( emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyParameters, replyMarkup) ) /** @@ -40,10 +36,9 @@ suspend fun TelegramBot.sendSticker( emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat.id, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat.id, sticker, threadId, emoji, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -56,10 +51,9 @@ suspend fun TelegramBot.sendSticker( emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chatId, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chatId, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -72,7 +66,6 @@ suspend fun TelegramBot.sendSticker( emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt index c9ad764b91..2f3a55ee08 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt @@ -3,15 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVideo -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.VideoFile -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -30,8 +27,7 @@ suspend fun TelegramBot.sendVideo( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendVideo( @@ -48,8 +44,7 @@ suspend fun TelegramBot.sendVideo( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -67,10 +62,9 @@ suspend fun TelegramBot.sendVideo( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -89,10 +83,9 @@ suspend fun TelegramBot.sendVideo( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -108,10 +101,9 @@ suspend fun TelegramBot.sendVideo( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -129,8 +121,7 @@ suspend inline fun TelegramBot.sendVideo( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendVideo( @@ -146,8 +137,7 @@ suspend inline fun TelegramBot.sendVideo( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -164,10 +154,9 @@ suspend inline fun TelegramBot.sendVideo( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumbnail ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -185,10 +174,9 @@ suspend inline fun TelegramBot.sendVideo( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -203,7 +191,6 @@ suspend inline fun TelegramBot.sendVideo( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, entities, spoilered, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt index d4c0cc11a6..51228a9949 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt @@ -3,13 +3,10 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVideoNote -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.VideoNoteFile -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -24,8 +21,7 @@ suspend fun TelegramBot.sendVideoNote( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendVideoNote( @@ -37,8 +33,7 @@ suspend fun TelegramBot.sendVideoNote( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -53,11 +48,10 @@ suspend fun TelegramBot.sendVideoNote( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendVideoNote( - chatId, videoNote.fileId, videoNote.thumbnail ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, videoNote.fileId, videoNote.thumbnail ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -73,10 +67,9 @@ suspend fun TelegramBot.sendVideoNote( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chat.id, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chat.id, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -88,7 +81,6 @@ suspend fun TelegramBot.sendVideoNote( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chat.id, videoNote, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chat.id, videoNote, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt index 3be4a2435f..44bc626484 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt @@ -3,15 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVoice -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.VoiceFile -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -26,8 +23,7 @@ suspend fun TelegramBot.sendVoice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendVoice( @@ -39,8 +35,7 @@ suspend fun TelegramBot.sendVoice( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -58,10 +53,9 @@ suspend fun TelegramBot.sendVoice( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, text, parseMode, duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, text, parseMode, duration, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -75,11 +69,10 @@ suspend fun TelegramBot.sendVoice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendVoice( - chatId, voice.fileId, text, parseMode, voice.duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, voice.fileId, text, parseMode, voice.duration, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -94,10 +87,9 @@ suspend fun TelegramBot.sendVoice( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, text, parseMode, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** @@ -112,8 +104,7 @@ suspend inline fun TelegramBot.sendVoice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendVoice( @@ -124,8 +115,7 @@ suspend inline fun TelegramBot.sendVoice( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -142,10 +132,9 @@ suspend inline fun TelegramBot.sendVoice( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, entities, duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, entities, duration, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -158,11 +147,10 @@ suspend inline fun TelegramBot.sendVoice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendVoice( - chatId, voice.fileId, entities, voice.duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, voice.fileId, entities, voice.duration, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -175,7 +163,6 @@ suspend inline fun TelegramBot.sendVoice( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, entities, threadId, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt index 6fa583d15a..eb1f7ff458 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt @@ -34,11 +34,10 @@ suspend fun TelegramBot.sendInvoice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute( - SendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, replyParameters, replyMarkup) ) /** @@ -66,7 +65,6 @@ suspend fun TelegramBot.sendInvoice( priceDependOnShipAddress: Boolean = false, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, null, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, null, disableNotification, protectContent, replyParameters, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt index e297e56394..b008e76d00 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt @@ -3,15 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.send.polls import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.polls.* -import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -28,12 +25,11 @@ suspend fun TelegramBot.sendRegularPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendRegularPoll( - chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) ) /** @@ -52,10 +48,9 @@ suspend fun TelegramBot.sendRegularPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -72,11 +67,10 @@ suspend fun TelegramBot.sendRegularPoll( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -95,11 +89,10 @@ suspend fun TelegramBot.sendRegularPoll( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) @@ -120,12 +113,11 @@ suspend fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) ) @@ -146,11 +138,10 @@ suspend fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -171,11 +162,10 @@ suspend fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -196,11 +186,10 @@ suspend fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) @@ -220,12 +209,11 @@ suspend inline fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) ) @@ -245,11 +233,10 @@ suspend inline fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -269,11 +256,10 @@ suspend inline fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -293,9 +279,8 @@ suspend inline fun TelegramBot.sendQuizPoll( threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMessageId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMessageId.kt deleted file mode 100644 index 6a076122e1..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/ReplyMessageId.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.inmo.tgbotapi.abstracts.types - -import dev.inmo.tgbotapi.types.MessageId - -interface ReplyMessageId { - val replyToMessageId: MessageId? - val allowSendingWithoutReply: Boolean? -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyParameters.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyParameters.kt new file mode 100644 index 0000000000..a51b6e54db --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/WithReplyParameters.kt @@ -0,0 +1,19 @@ +package dev.inmo.tgbotapi.abstracts.types + +import dev.inmo.tgbotapi.types.MessageId +import dev.inmo.tgbotapi.types.ReplyParameters + +@Deprecated("Renamed", ReplaceWith("WithReplyParameters", "dev.inmo.tgbotapi.abstracts.types.WithReplyParameters")) +interface ReplyMessageId { + val replyToMessageId: MessageId? + val allowSendingWithoutReply: Boolean? +} + +interface WithReplyParameters : ReplyMessageId { + val replyParameters: ReplyParameters? + + override val replyToMessageId: MessageId? + get() = replyParameters ?.messageId + override val allowSendingWithoutReply: Boolean? + get() = replyParameters ?.allowSendingWithoutReply +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt index 710d152811..c1a97db0d5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/CopyMessage.kt @@ -30,8 +30,7 @@ fun CopyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( toChatId, @@ -43,8 +42,7 @@ fun CopyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -56,8 +54,7 @@ fun CopyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( toChatId, @@ -69,8 +66,7 @@ fun CopyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -83,8 +79,7 @@ fun CopyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( toChatId, @@ -96,8 +91,7 @@ fun CopyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -109,8 +103,7 @@ fun CopyMessage( threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = CopyMessage( toChatId, @@ -122,8 +115,7 @@ fun CopyMessage( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -147,10 +139,8 @@ data class CopyMessage internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ): SimpleRequest, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt index 2d10e109df..f3ab14ef43 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt @@ -28,10 +28,8 @@ data class SendContact( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendMessageRequest>, @@ -43,8 +41,7 @@ data class SendContact( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): this( chatId, @@ -54,8 +51,7 @@ data class SendContact( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -71,8 +67,7 @@ fun Contact.toRequest( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): SendContact = SendContact( chatId, @@ -80,7 +75,6 @@ fun Contact.toRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt index 5225d3a5fe..629f29a445 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.requests.send import dev.inmo.tgbotapi.abstracts.types.DisableNotification -import dev.inmo.tgbotapi.abstracts.types.ReplyMessageId +import dev.inmo.tgbotapi.abstracts.types.WithReplyParameters import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -26,13 +26,11 @@ data class SendDice( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null -) : ReplyingMarkupSendMessageRequest>, ReplyMessageId, DisableNotification { +) : ReplyingMarkupSendMessageRequest>, WithReplyParameters, DisableNotification { override val requestSerializer: SerializationStrategy<*> get() = serializer() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt index 43d3cafa00..4aa76820fe 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt @@ -21,8 +21,7 @@ fun SendLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendLocation( chatId, @@ -35,8 +34,7 @@ fun SendLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -47,10 +45,9 @@ fun SendStaticLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = SendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = SendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, replyParameters, replyMarkup) fun SendLiveLocation( chatId: ChatIdentifier, @@ -63,8 +60,7 @@ fun SendLiveLocation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendLocation( chatId, @@ -77,8 +73,7 @@ fun SendLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -104,10 +99,8 @@ data class SendLocation internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendMessageRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt index 8cbc0e1d24..23711b9c3d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt @@ -28,8 +28,7 @@ fun SendTextMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendTextMessage( chatId, @@ -40,8 +39,7 @@ fun SendTextMessage( linkPreviewOptions, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -52,8 +50,7 @@ fun SendTextMessage( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendTextMessage( chatId, @@ -64,8 +61,7 @@ fun SendTextMessage( linkPreviewOptions, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -87,10 +83,8 @@ data class SendTextMessage internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendMessageRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt index 2a4d0af6ca..4812627536 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt @@ -38,10 +38,8 @@ data class SendVenue( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendMessageRequest>, @@ -55,8 +53,7 @@ data class SendVenue( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): this( chatId = chatId, @@ -71,8 +68,7 @@ data class SendVenue( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -88,8 +84,7 @@ fun Venue.toRequest( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): SendVenue = SendVenue( chatId, @@ -97,7 +92,6 @@ fun Venue.toRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendMessageRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendMessageRequest.kt index b3dbca83a2..e52810b8d4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendMessageRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendMessageRequest.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.requests.send.abstracts import dev.inmo.tgbotapi.abstracts.types.* interface SendMessageRequest : SendChatMessageRequest, - ReplyMessageId, + WithReplyParameters, DisableNotification, ProtectContent, OptionallyMessageThreadRequest diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt index 43769a00a3..e00b08885d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt @@ -24,10 +24,8 @@ data class SendGame ( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendMessageRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt index d1a51fed56..1a4d4816a1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt @@ -33,8 +33,7 @@ fun SendAnimation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val animationAsFile = animation as? MultipartFile @@ -54,8 +53,7 @@ fun SendAnimation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -81,8 +79,7 @@ fun SendAnimation( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val animationAsFile = animation as? MultipartFile @@ -102,8 +99,7 @@ fun SendAnimation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -148,10 +144,8 @@ data class SendAnimationData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : DataRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt index b2399f9fed..2c85f6199a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt @@ -33,8 +33,7 @@ fun SendAudio( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val audioAsFile = audio as? MultipartFile @@ -53,8 +52,7 @@ fun SendAudio( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -79,8 +77,7 @@ fun SendAudio( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val audioAsFile = audio as? MultipartFile @@ -99,8 +96,7 @@ fun SendAudio( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -143,10 +139,8 @@ data class SendAudioData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : DataRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt index 98bc374dac..b9b33cbbb4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt @@ -38,8 +38,7 @@ fun SendDocument( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ): Request> { @@ -56,8 +55,7 @@ fun SendDocument( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup, disableContentTypeDetection ) @@ -89,8 +87,7 @@ fun SendDocument( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ): Request> { @@ -107,8 +104,7 @@ fun SendDocument( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup, disableContentTypeDetection ) @@ -155,10 +151,8 @@ data class SendDocumentData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null, @SerialName(disableContentTypeDetectionField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt index ff2ace3d9e..0304856ba7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt @@ -22,10 +22,7 @@ import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonArray -import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.buildJsonArray -import kotlinx.serialization.json.jsonPrimitive const val rawSendingMediaGroupsWarning = "Media groups contains restrictions related to combinations of media" + " types. Currently it is possible to combine photo + video OR audio OR documents" @@ -37,7 +34,7 @@ fun SendMediaGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, allowSendingWithoutReply: Boolean? = null ): Request>> { if (media.size !in mediaCountInMediaGroup) { @@ -61,8 +58,7 @@ fun SendMediaGroup( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply + replyParameters ) return (if (files.isEmpty()) { @@ -87,9 +83,9 @@ inline fun SendPlaylist( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply) /** * Use this method to be sure that you are correctly sending documents media group @@ -103,9 +99,9 @@ inline fun SendDocumentsGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply) /** * Use this method to be sure that you are correctly sending visual media group @@ -120,9 +116,9 @@ inline fun SendVisualMediaGroup( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, + replyParameters: ReplyParameters? = null, allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply) private object MessagesListSerializer: KSerializer>> { private val serializer = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass>()) @@ -150,10 +146,8 @@ data class SendMediaGroupData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, ) : DataRequest>>, SendMessageRequest>> { @SerialName(mediaField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt index d030d66cba..4c16cf55c8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt @@ -28,8 +28,7 @@ fun SendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val data = SendPhotoData( @@ -42,8 +41,7 @@ fun SendPhoto( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) return if (photo is MultipartFile) { @@ -64,8 +62,7 @@ fun SendPhoto( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val data = SendPhotoData( @@ -78,8 +75,7 @@ fun SendPhoto( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -116,10 +112,8 @@ data class SendPhotoData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : DataRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt index 46897671d6..bba52d5470 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt @@ -9,13 +9,7 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import dev.inmo.tgbotapi.types.message.content.StickerContent -import dev.inmo.tgbotapi.utils.mapOfNotNull -import dev.inmo.tgbotapi.utils.toJsonWithoutNulls import kotlinx.serialization.* -import kotlinx.serialization.json.JsonObject -import kotlinx.serialization.json.JsonPrimitive -import kotlinx.serialization.json.buildJsonObject -import kotlinx.serialization.json.put fun SendSticker( chatId: ChatIdentifier, @@ -24,8 +18,7 @@ fun SendSticker( emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> = SendStickerByFileId( chatId, @@ -33,8 +26,7 @@ fun SendSticker( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ).let { when (sticker) { @@ -61,10 +53,8 @@ data class SendStickerByFileId internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendMessageRequest>, ReplyingMarkupSendMessageRequest> { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt index 815e784969..80b17f8e70 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt @@ -34,8 +34,7 @@ fun SendVideo( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val videoAsFile = video as? MultipartFile @@ -56,8 +55,7 @@ fun SendVideo( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -84,8 +82,7 @@ fun SendVideo( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val videoAsFile = video as? MultipartFile @@ -106,8 +103,7 @@ fun SendVideo( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -154,10 +150,8 @@ data class SendVideoData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : DataRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt index 0c840feed0..9eb8cab82c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt @@ -21,8 +21,7 @@ fun SendVideoNote( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val videoNoteAsFile = videoNote as? MultipartFile @@ -37,8 +36,7 @@ fun SendVideoNote( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -73,10 +71,8 @@ data class SendVideoNoteData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : DataRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt index 1bad25a36a..1193f6dfb6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt @@ -29,8 +29,7 @@ fun SendVoice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val voiceAsFile = voice as? MultipartFile @@ -45,8 +44,7 @@ fun SendVoice( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -68,8 +66,7 @@ fun SendVoice( duration: Long? = null, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val voiceAsFile = voice as? MultipartFile @@ -84,8 +81,7 @@ fun SendVoice( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -122,10 +118,8 @@ data class SendVoiceData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : DataRequest>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt index 010ef191b8..c2ead144a7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt @@ -64,16 +64,14 @@ data class SendInvoice( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: InlineKeyboardMarkup? = null ) : CommonSendInvoiceData, ChatRequest, DisableNotification, - ReplyMessageId, + WithReplyParameters, WithReplyMarkup, SendMessageRequest> { override fun method(): String = "sendInvoice" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt index 1d63f7a816..5d88eaa918 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendPoll.kt @@ -53,8 +53,7 @@ fun SendPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendRegularPoll( chatId, @@ -64,9 +63,8 @@ fun SendPoll( isClosed, threadId = threadId, protectContent = protectContent, - allowSendingWithoutReply = allowSendingWithoutReply, disableNotification = disableNotification, - replyToMessageId = replyToMessageId, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -79,8 +77,7 @@ fun Poll.createRequest( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = when (this) { is RegularPoll -> SendRegularPoll( @@ -94,8 +91,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) is QuizPoll -> correctOptionId ?.let { correctOptionId -> @@ -111,8 +107,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } ?: SendRegularPoll( @@ -126,8 +121,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) is UnknownPollType -> SendRegularPoll( @@ -141,8 +135,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } @@ -209,10 +202,8 @@ data class SendRegularPoll( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendPoll() { @@ -237,8 +228,7 @@ fun SendRegularPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendRegularPoll( chatId, @@ -252,8 +242,7 @@ fun SendRegularPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -270,8 +259,7 @@ fun SendQuizPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendQuizPoll( chatId, @@ -287,8 +275,7 @@ fun SendQuizPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -304,8 +291,7 @@ fun SendQuizPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendQuizPoll( chatId, @@ -321,8 +307,7 @@ fun SendQuizPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -340,8 +325,7 @@ internal fun SendQuizPoll( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendQuizPoll( chatId, @@ -358,8 +342,7 @@ internal fun SendQuizPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -393,10 +376,8 @@ data class SendQuizPoll internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, - @SerialName(replyToMessageIdField) - override val replyToMessageId: MessageId? = null, - @SerialName(allowSendingWithoutReplyField) - override val allowSendingWithoutReply: Boolean? = null, + @SerialName(replyParametersField) + override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null ) : SendPoll(), TextedOutput { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 03529ac168..44b0f6df67 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -219,6 +219,7 @@ const val disableNotificationField = "disable_notification" const val protectContentField = "protect_content" const val removeCaptionField = "remove_caption" const val replyToMessageIdField = "reply_to_message_id" +const val replyParametersField = "reply_parameters" const val allowSendingWithoutReplyField = "allow_sending_without_reply" const val quoteField = "quote" const val quoteParseModeField = "quote_parse_mode" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt index fe20f54db0..db6432cf69 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types import dev.inmo.tgbotapi.abstracts.TextedInput -import dev.inmo.tgbotapi.abstracts.TextedWithTextSources import dev.inmo.tgbotapi.abstracts.WithMessageId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.RawMessageEntity @@ -64,6 +63,17 @@ data class ReplyParameters internal constructor( allowSendingWithoutReply, quotePosition ) + constructor( + message: Message, + entities: TextSourcesList, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + message.metaInfo, + entities, + allowSendingWithoutReply, + quotePosition + ) constructor( chatIdentifier: ChatIdentifier, messageId: MessageId, @@ -94,6 +104,19 @@ data class ReplyParameters internal constructor( allowSendingWithoutReply, quotePosition ) + constructor( + message: Message, + quote: String, + quoteParseMode: ParseMode, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + message.metaInfo, + quote, + quoteParseMode, + allowSendingWithoutReply, + quotePosition + ) constructor( chatIdentifier: ChatIdentifier, messageId: MessageId, @@ -118,4 +141,13 @@ data class ReplyParameters internal constructor( allowSendingWithoutReply, quotePosition ) + constructor( + message: Message, + allowSendingWithoutReply: Boolean = false, + quotePosition: Int? = null + ) : this( + message.metaInfo, + allowSendingWithoutReply, + quotePosition + ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index 4f25de4ed1..4bf9d78a42 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -4,14 +4,11 @@ import dev.inmo.tgbotapi.abstracts.SpoilerableData import dev.inmo.tgbotapi.abstracts.TextedInput import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.requests.abstracts.Request -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.Serializable import kotlinx.serialization.modules.* @@ -152,8 +149,30 @@ sealed interface ResendableContent { messageThreadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request + + fun createResend( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId? = chatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId?, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null + ): Request = createResend( + chatId = chatId, + messageThreadId = messageThreadId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyToMessageId ?.let { + ReplyParameters( + chatId, + replyToMessageId, + allowSendingWithoutReply = allowSendingWithoutReply == true + ) + }, + replyMarkup = replyMarkup + ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt index 5b77469bee..6e67ad7b62 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AnimationContent.kt @@ -2,12 +2,9 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendAnimation -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.TelegramMediaAnimation import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId -import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.DocumentFile @@ -28,8 +25,7 @@ data class AnimationContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendAnimation( chatId, @@ -43,8 +39,7 @@ data class AnimationContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt index 5051492406..e6c43e6ec7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/AudioContent.kt @@ -2,13 +2,10 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendAudio -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.TelegramMediaAudio import dev.inmo.tgbotapi.types.media.toTelegramMediaAudio import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId -import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AudioFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -26,8 +23,7 @@ data class AudioContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendAudio( chatId, @@ -40,8 +36,7 @@ data class AudioContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ContactContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ContactContent.kt index 694b4ff5d5..3c91b28946 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ContactContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ContactContent.kt @@ -16,10 +16,9 @@ data class ContactContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendContact( - chatId, contact, messageThreadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, contact, messageThreadId, disableNotification, protectContent, replyParameters, replyMarkup ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DiceContent.kt index fc319a695d..8b32a07c24 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DiceContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.SendDice import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.dice.Dice import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -19,8 +20,7 @@ data class DiceContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendDice( chatId, @@ -28,8 +28,7 @@ data class DiceContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt index 7030286acb..ad43787c75 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/DocumentContent.kt @@ -3,13 +3,10 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.abstracts.TextedInput import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendDocument -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.TelegramMediaDocument import dev.inmo.tgbotapi.types.media.toTelegramMediaDocument import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId -import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.DocumentFile @@ -29,8 +26,7 @@ data class DocumentContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendDocument( chatId, @@ -40,8 +36,7 @@ data class DocumentContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GameContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GameContent.kt index e3b72c96a8..44a248cc32 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GameContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GameContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.games.SendGame import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -19,8 +20,7 @@ data class GameContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendGame( chatId, @@ -28,8 +28,7 @@ data class GameContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt index 29e9e0b348..ddaf9ebd9e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt @@ -17,8 +17,7 @@ data class GiveawayPublicResultsContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request { return ForwardMessage( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/InvoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/InvoiceContent.kt index aba78dbf89..dfe7a4e347 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/InvoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/InvoiceContent.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.payments.Invoice @@ -18,8 +19,7 @@ data class InvoiceContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> { error("Unfortunately, currently InvoiceOfPayment can not be resend due to requirement of additional parameters," + diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/LocationContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/LocationContent.kt index c90ebd31c4..00e5206545 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/LocationContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/LocationContent.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -101,8 +102,7 @@ data class LiveLocationContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendLiveLocation( chatId, @@ -115,8 +115,7 @@ data class LiveLocationContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) as SendMessageRequest> } @@ -134,8 +133,7 @@ data class StaticLocationContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendStaticLocation( chatId, @@ -144,8 +142,7 @@ data class StaticLocationContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) as SendMessageRequest> } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt index d0c0f729b7..9452611ead 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt @@ -35,8 +35,7 @@ data class MediaGroupContent( threadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request>> = SendMediaGroup( chatId, @@ -44,7 +43,6 @@ data class MediaGroupContent( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply + replyParameters, ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt index bbcc0453fd..c63148c80b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PhotoContent.kt @@ -2,13 +2,10 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendPhoto -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.TelegramMediaPhoto import dev.inmo.tgbotapi.types.media.toTelegramMediaPhoto import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId -import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.* @@ -30,8 +27,7 @@ data class PhotoContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendPhoto( chatId, @@ -41,8 +37,7 @@ data class PhotoContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PollContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PollContent.kt index 7d81ddaa60..6b17f1a1f7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PollContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/PollContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.polls.createRequest import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.polls.Poll @@ -19,16 +20,14 @@ data class PollContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = poll.createRequest( chatId, messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt index f3b4125a44..17ce374abb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt @@ -24,8 +24,7 @@ data class ScheduledGiveawayContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request { return ForwardMessage( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt index 6caeaa91ce..bae183a40a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StickerContent.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.media.TelegramMediaDocument import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -20,8 +21,7 @@ data class StickerContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendSticker( chatId, @@ -30,8 +30,7 @@ data class StickerContent( media.emoji, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt index 187a155a10..13659c8796 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/StoryContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage @@ -22,8 +23,7 @@ data class StoryContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request { return ForwardMessage( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index 26c4fd2f14..9e1b62aaba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -22,8 +22,7 @@ data class TextContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendTextMessage( chatId, @@ -32,8 +31,7 @@ data class TextContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VenueContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VenueContent.kt index 12fa337486..d61f49cc47 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VenueContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VenueContent.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.SendVenue import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.venue.Venue @@ -19,10 +20,9 @@ data class VenueContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendVenue( - chatId, venue, messageThreadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, venue, messageThreadId, disableNotification, protectContent, replyParameters, replyMarkup ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt index 96ebc2b2d3..bb00fd3ef5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoContent.kt @@ -2,12 +2,9 @@ package dev.inmo.tgbotapi.types.message.content import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.media.SendVideo -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.TelegramMediaVideo import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId -import dev.inmo.tgbotapi.types.MessageThreadId -import dev.inmo.tgbotapi.types.TextQuote import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.toTelegramMediaVideo @@ -27,8 +24,7 @@ data class VideoContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendVideo( chatId, @@ -43,8 +39,7 @@ data class VideoContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt index 8e47237fd0..3fdbc27282 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VideoNoteContent.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.media.TelegramMediaVideo import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VideoNoteFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -20,8 +21,7 @@ data class VideoNoteContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendVideoNote( chatId, @@ -32,8 +32,7 @@ data class VideoNoteContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt index b2cc4fe154..84fd8d70e1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/VoiceContent.kt @@ -23,8 +23,7 @@ data class VoiceContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendVoice( chatId = chatId, @@ -34,8 +33,7 @@ data class VoiceContent( duration = media.duration, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) From bb80eb43fd2f9a33a8b1ed5619e52ec627e99a98 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 00:42:24 +0600 Subject: [PATCH 37/65] build fixes --- .../tgbotapi/extensions/api/send/Replies.kt | 14 +- .../api/send/RepliesWithChatsAndMessages.kt | 132 ++++++++---------- 2 files changed, 64 insertions(+), 82 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 7484c3bd20..28315c6066 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -135,8 +135,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - allowSendingWithoutReply, - to.messageId, + replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -157,8 +156,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - allowSendingWithoutReply, - to.messageId, + replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -570,7 +568,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) suspend inline fun TelegramBot.replyWithPlaylist( to: AccessibleMessage, @@ -578,7 +576,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) suspend inline fun TelegramBot.replyWithDocuments( to: AccessibleMessage, @@ -586,7 +584,7 @@ suspend inline fun TelegramBot.replyWithDocuments( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) suspend inline fun TelegramBot.replyWithGallery( to: AccessibleMessage, @@ -594,7 +592,7 @@ suspend inline fun TelegramBot.replyWithGallery( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) // Photo diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 60197a66e0..29a0ecf509 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -60,8 +60,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -84,8 +83,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -105,7 +103,7 @@ suspend inline fun TelegramBot.replyWithDice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(toChatId, animationType, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(toChatId, animationType, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -146,8 +144,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - allowSendingWithoutReply, - toMessageId, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -170,8 +167,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - allowSendingWithoutReply, - toMessageId, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -201,8 +197,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -227,8 +222,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -302,8 +296,7 @@ suspend inline fun TelegramBot.reply( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = toMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup = replyMarkup ) @@ -335,8 +328,7 @@ suspend inline fun TelegramBot.reply( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = toMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup = replyMarkup ) @@ -355,8 +347,7 @@ suspend inline fun TelegramBot.reply( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = toMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup = replyMarkup ) @@ -373,7 +364,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, gameShortName, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup + toChatId, gameShortName, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( @@ -386,7 +377,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, game.title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup + toChatId, game.title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) suspend inline fun TelegramBot.reply( @@ -432,8 +423,7 @@ suspend inline fun TelegramBot.replyWithAnimation( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -452,7 +442,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( toChatId: IdChatIdentifier, @@ -481,8 +471,7 @@ suspend inline fun TelegramBot.replyWithAnimation( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -500,7 +489,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Audio @@ -520,7 +509,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -534,7 +523,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( toChatId: IdChatIdentifier, @@ -550,7 +539,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -563,7 +552,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, entities, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, entities, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Documents @@ -581,7 +570,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -595,7 +584,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( toChatId: IdChatIdentifier, @@ -609,7 +598,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -622,7 +611,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) // Media Group @@ -636,7 +625,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) suspend inline fun TelegramBot.replyWithPlaylist( toChatId: IdChatIdentifier, @@ -646,7 +635,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) suspend inline fun TelegramBot.replyWithDocuments( toChatId: IdChatIdentifier, @@ -656,7 +645,7 @@ suspend inline fun TelegramBot.replyWithDocuments( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) suspend inline fun TelegramBot.replyWithGallery( toChatId: IdChatIdentifier, @@ -666,7 +655,7 @@ suspend inline fun TelegramBot.replyWithGallery( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) // Photo @@ -683,7 +672,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -697,7 +686,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -711,7 +700,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -725,7 +714,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -738,7 +727,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -751,7 +740,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Sticker @@ -766,7 +755,7 @@ suspend inline fun TelegramBot.replyWithSticker( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -778,7 +767,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Videos @@ -799,7 +788,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -813,7 +802,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( toChatId: IdChatIdentifier, @@ -830,7 +819,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -843,7 +832,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // VideoNotes @@ -860,7 +849,7 @@ suspend inline fun TelegramBot.replyWithVideoNote( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -871,7 +860,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(toChatId, videoNote, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Voice @@ -888,7 +877,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -901,7 +890,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -915,7 +904,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -927,7 +916,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Invoice @@ -961,7 +950,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(toChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(toChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Polls @@ -980,7 +969,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -997,7 +986,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1015,7 +1004,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1034,7 +1023,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1051,7 +1040,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1069,7 +1058,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( @@ -1144,8 +1133,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) @@ -1192,8 +1180,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) ) @@ -1220,8 +1207,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true) ) /** @@ -1248,8 +1234,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true) ) } @@ -1277,8 +1262,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true) ) } From 86bb87bb37e21b36701dc1da69c2e5c5cec77da4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 10:05:41 +0600 Subject: [PATCH 38/65] make allowSendingWithoutReply nullable --- .../extensions/api/LiveLocationProvider.kt | 4 +- .../tgbotapi/extensions/api/send/Replies.kt | 78 ++++++------ .../api/send/RepliesWithChatsAndMessages.kt | 116 +++++++++--------- .../inmo/tgbotapi/types/ReplyParameters.kt | 20 +-- .../types/message/content/Abstracts.kt | 2 +- 5 files changed, 110 insertions(+), 110 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt index 4f76a7923f..301ac72e65 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt @@ -255,7 +255,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( threadId, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -287,6 +287,6 @@ suspend inline fun TelegramBot.replyWithLiveLocation( threadId, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 28315c6066..cb05bb8b98 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -59,7 +59,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -80,7 +80,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -98,7 +98,7 @@ suspend inline fun TelegramBot.replyWithDice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -135,7 +135,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -156,7 +156,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -184,7 +184,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -207,7 +207,7 @@ suspend inline fun TelegramBot.reply( to.threadIdOrNull, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -275,7 +275,7 @@ suspend inline fun TelegramBot.reply( threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, - replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -305,7 +305,7 @@ suspend inline fun TelegramBot.reply( threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, - replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -322,7 +322,7 @@ suspend inline fun TelegramBot.reply( threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, - replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -337,7 +337,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup + to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( @@ -348,7 +348,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup + to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( @@ -390,7 +390,7 @@ suspend inline fun TelegramBot.replyWithAnimation( to.threadIdOrNull, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -407,7 +407,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( to: AccessibleMessage, @@ -434,7 +434,7 @@ suspend inline fun TelegramBot.replyWithAnimation( to.threadIdOrNull, disableNotification, protectContent, - ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -450,7 +450,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio @@ -468,7 +468,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -480,7 +480,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( to: AccessibleMessage, @@ -494,7 +494,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -505,7 +505,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents @@ -521,7 +521,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -533,7 +533,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( to: AccessibleMessage, @@ -545,7 +545,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -556,7 +556,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @@ -568,7 +568,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( to: AccessibleMessage, @@ -576,7 +576,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( to: AccessibleMessage, @@ -584,7 +584,7 @@ suspend inline fun TelegramBot.replyWithDocuments( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( to: AccessibleMessage, @@ -592,7 +592,7 @@ suspend inline fun TelegramBot.replyWithGallery( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo @@ -607,7 +607,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -619,7 +619,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -631,7 +631,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -643,7 +643,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -654,7 +654,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -665,7 +665,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker @@ -678,7 +678,7 @@ suspend inline fun TelegramBot.replyWithSticker( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -688,7 +688,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos @@ -707,7 +707,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -719,7 +719,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( to: AccessibleMessage, @@ -734,7 +734,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 29a0ecf509..663608d1dd 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -60,7 +60,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -83,7 +83,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -103,7 +103,7 @@ suspend inline fun TelegramBot.replyWithDice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(toChatId, animationType, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendDice(toChatId, animationType, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -144,7 +144,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -167,7 +167,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -197,7 +197,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -222,7 +222,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -296,7 +296,7 @@ suspend inline fun TelegramBot.reply( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -328,7 +328,7 @@ suspend inline fun TelegramBot.reply( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -347,7 +347,7 @@ suspend inline fun TelegramBot.reply( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, - replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -364,7 +364,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, gameShortName, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup + toChatId, gameShortName, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( @@ -377,7 +377,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, game.title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup + toChatId, game.title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( @@ -423,7 +423,7 @@ suspend inline fun TelegramBot.replyWithAnimation( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -442,7 +442,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( toChatId: IdChatIdentifier, @@ -471,7 +471,7 @@ suspend inline fun TelegramBot.replyWithAnimation( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -489,7 +489,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio @@ -509,7 +509,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -523,7 +523,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( toChatId: IdChatIdentifier, @@ -539,7 +539,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -552,7 +552,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, entities, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendAudio(toChatId, audio, entities, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents @@ -570,7 +570,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -584,7 +584,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( toChatId: IdChatIdentifier, @@ -598,7 +598,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -611,7 +611,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @@ -625,7 +625,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( toChatId: IdChatIdentifier, @@ -635,7 +635,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( toChatId: IdChatIdentifier, @@ -645,7 +645,7 @@ suspend inline fun TelegramBot.replyWithDocuments( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( toChatId: IdChatIdentifier, @@ -655,7 +655,7 @@ suspend inline fun TelegramBot.replyWithGallery( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true)) +) = sendVisualMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo @@ -672,7 +672,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -686,7 +686,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -700,7 +700,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -714,7 +714,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -727,7 +727,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -740,7 +740,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker @@ -755,7 +755,7 @@ suspend inline fun TelegramBot.replyWithSticker( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -767,7 +767,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos @@ -788,7 +788,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -802,7 +802,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( toChatId: IdChatIdentifier, @@ -819,7 +819,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -832,7 +832,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // VideoNotes @@ -849,7 +849,7 @@ suspend inline fun TelegramBot.replyWithVideoNote( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -860,7 +860,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideoNote(toChatId, videoNote, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Voice @@ -877,7 +877,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -890,7 +890,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(toChatId, voice, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -904,7 +904,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -916,7 +916,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(toChatId, voice, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Invoice @@ -950,7 +950,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(toChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendInvoice(toChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Polls @@ -969,7 +969,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -986,7 +986,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1004,7 +1004,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1023,7 +1023,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1040,7 +1040,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1058,7 +1058,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( @@ -1133,7 +1133,7 @@ suspend inline fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -1180,7 +1180,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true), + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) ) @@ -1207,7 +1207,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true) + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) ) /** @@ -1234,7 +1234,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true) + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) ) } @@ -1262,7 +1262,7 @@ suspend fun TelegramBot.reply( threadId, disableNotification, protectContent, - ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply == true) + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt index db6432cf69..cd3d451474 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt @@ -20,7 +20,7 @@ data class ReplyParameters internal constructor( @SerialName(messageIdField) override val messageId: MessageId, @SerialName(allowSendingWithoutReplyField) - val allowSendingWithoutReply: Boolean = false, + val allowSendingWithoutReply: Boolean? = null, @SerialName(quoteField) val quote: String? = null, @SerialName(quoteParseModeField) @@ -40,7 +40,7 @@ data class ReplyParameters internal constructor( chatIdentifier: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( chatIdentifier, @@ -54,7 +54,7 @@ data class ReplyParameters internal constructor( constructor( metaInfo: Message.MetaInfo, entities: TextSourcesList, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( metaInfo.chatId, @@ -66,7 +66,7 @@ data class ReplyParameters internal constructor( constructor( message: Message, entities: TextSourcesList, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( message.metaInfo, @@ -79,7 +79,7 @@ data class ReplyParameters internal constructor( messageId: MessageId, quote: String, quoteParseMode: ParseMode, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( chatIdentifier, @@ -94,7 +94,7 @@ data class ReplyParameters internal constructor( metaInfo: Message.MetaInfo, quote: String, quoteParseMode: ParseMode, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( metaInfo.chatId, @@ -108,7 +108,7 @@ data class ReplyParameters internal constructor( message: Message, quote: String, quoteParseMode: ParseMode, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( message.metaInfo, @@ -120,7 +120,7 @@ data class ReplyParameters internal constructor( constructor( chatIdentifier: ChatIdentifier, messageId: MessageId, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( chatIdentifier, @@ -133,7 +133,7 @@ data class ReplyParameters internal constructor( ) constructor( metaInfo: Message.MetaInfo, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( metaInfo.chatId, @@ -143,7 +143,7 @@ data class ReplyParameters internal constructor( ) constructor( message: Message, - allowSendingWithoutReply: Boolean = false, + allowSendingWithoutReply: Boolean? = null, quotePosition: Int? = null ) : this( message.metaInfo, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index 4bf9d78a42..59e02ffbef 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -170,7 +170,7 @@ sealed interface ResendableContent { ReplyParameters( chatId, replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply == true + allowSendingWithoutReply = allowSendingWithoutReply ) }, replyMarkup = replyMarkup From f2f370e40ed8d81b78757cda77ca0fdee290e6a5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 10:11:39 +0600 Subject: [PATCH 39/65] update all updates list --- .../dev/inmo/tgbotapi/types/UpdateTypes.kt | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) 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 b7fbeaea86..4de7c92bad 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 @@ -16,14 +16,16 @@ const val UPDATE_CHAT_MEMBER = "chat_member" const val UPDATE_CHAT_JOIN_REQUEST = "chat_join_request" const val UPDATE_MESSAGE_REACTION = "message_reaction" const val UPDATE_MESSAGE_REACTION_COUNT = "message_reaction_count" +const val UPDATE_CHAT_BOOST = "chat_boost" +const val UPDATE_REMOVE_CHAT_BOOST = "removed_chat_boost" -val ALL_UPDATES_LIST = listOf( +val ALL_UPDATES_LIST_WITHOUT_REACTIONS = listOf( UPDATE_MESSAGE, UPDATE_EDITED_MESSAGE, UPDATE_CHANNEL_POST, UPDATE_EDITED_CHANNEL_POST, - UPDATE_CHOSEN_INLINE_RESULT, UPDATE_INLINE_QUERY, + UPDATE_CHOSEN_INLINE_RESULT, UPDATE_CALLBACK_QUERY, UPDATE_SHIPPING_QUERY, UPDATE_PRE_CHECKOUT_QUERY, @@ -32,23 +34,11 @@ val ALL_UPDATES_LIST = listOf( UPDATE_MY_CHAT_MEMBER, UPDATE_CHAT_MEMBER, UPDATE_CHAT_JOIN_REQUEST, + UPDATE_CHAT_BOOST, + UPDATE_REMOVE_CHAT_BOOST +) + +val ALL_UPDATES_LIST = ALL_UPDATES_LIST_WITHOUT_REACTIONS + listOf( UPDATE_MESSAGE_REACTION, UPDATE_MESSAGE_REACTION_COUNT ) - -val ALL_UPDATES_LIST_WITHOUT_REACTIONS = listOf( - UPDATE_MESSAGE, - UPDATE_EDITED_MESSAGE, - UPDATE_CHANNEL_POST, - UPDATE_EDITED_CHANNEL_POST, - UPDATE_CHOSEN_INLINE_RESULT, - UPDATE_INLINE_QUERY, - UPDATE_CALLBACK_QUERY, - UPDATE_SHIPPING_QUERY, - UPDATE_PRE_CHECKOUT_QUERY, - UPDATE_POLL, - UPDATE_POLL_ANSWER, - UPDATE_MY_CHAT_MEMBER, - UPDATE_CHAT_MEMBER, - UPDATE_CHAT_JOIN_REQUEST -) From adede330fb4cafecf2a404c2d1ab89492b29d15b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 13:55:41 +0600 Subject: [PATCH 40/65] fix of testSources in TextQuote --- .../src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt index 48745d5816..2d2f639d16 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/TextQuote.kt @@ -21,7 +21,7 @@ data class TextQuote private constructor( val isManual: Boolean = false ) : TextedInput { override val textSources: List by lazy { - entities ?.asTextSources(text) ?: emptyList() + (entities ?: emptyList()).asTextSources(text) } companion object { From d55253a81b98c281aa3274146e9e332033338765 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 15:02:39 +0600 Subject: [PATCH 41/65] improvements in replies --- .../tgbotapi/extensions/api/send/Replies.kt | 342 ++++++++++--- .../api/send/RepliesWithChatsAndMessages.kt | 456 ++++++++++-------- 2 files changed, 524 insertions(+), 274 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index cb05bb8b98..a05460af2c 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -47,16 +47,18 @@ suspend inline fun TelegramBot.reply( phoneNumber: String, firstName: String, lastName: String? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - to.chat, + replyInChat, phoneNumber, firstName, lastName, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -70,14 +72,16 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( to: AccessibleMessage, contact: Contact, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - to.chat, + replyInChat, contact, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -94,11 +98,13 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithDice( to: AccessibleMessage, animationType: DiceAnimationType? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendDice(replyInChat, animationType, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -107,11 +113,13 @@ suspend inline fun TelegramBot.replyWithDice( suspend inline fun TelegramBot.reply( to: AccessibleMessage, animationType: DiceAnimationType, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(to, animationType, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(to, animationType, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -124,15 +132,17 @@ suspend inline fun TelegramBot.reply( to: AccessibleMessage, latitude: Double, longitude: Double, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - to.chat, + replyInChat, latitude, longitude, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -146,14 +156,16 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( to: AccessibleMessage, location: StaticLocation, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - to.chat, + replyInChat, location, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -172,16 +184,18 @@ suspend inline fun TelegramBot.reply( text: String, parseMode: ParseMode? = null, linkPreviewOptions: LinkPreviewOptions? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - to.chat, + replyInChat, text, parseMode, linkPreviewOptions, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -196,15 +210,17 @@ suspend inline fun TelegramBot.reply( to: AccessibleMessage, entities: TextSourcesList, linkPreviewOptions: LinkPreviewOptions? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - to.chat, + replyInChat, entities, linkPreviewOptions, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -219,12 +235,14 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, separator: TextSource? = null, linkPreviewOptions: LinkPreviewOptions? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -234,12 +252,14 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, separator: String, linkPreviewOptions: LinkPreviewOptions? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -258,12 +278,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chat = to.chat, + chatId = replyInChat, latitude = latitude, longitude = longitude, title = title, @@ -272,7 +294,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = to.threadIdOrNull, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), @@ -288,12 +310,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chat = to.chat, + chatId = replyInChat, latitude = location.latitude, longitude = location.longitude, title = title, @@ -302,7 +326,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = to.threadIdOrNull, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), @@ -312,14 +336,16 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( to: AccessibleMessage, venue: Venue, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chat = to.chat, + chatId = replyInChat, venue = venue, - threadId = to.threadIdOrNull, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), @@ -332,33 +358,39 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithGame( to: AccessibleMessage, gameShortName: String, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChat, gameShortName, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( to: AccessibleMessage, game: Game, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChat, game.title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( to: AccessibleMessage, game: Game, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(to, game, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(to, game, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation @@ -373,12 +405,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - to.chat, + replyInChat, animation, thumb, text, @@ -387,7 +421,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -403,11 +437,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChat, animation, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( to: AccessibleMessage, @@ -418,12 +454,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - to.chat, + replyInChat, animation, thumb, entities, @@ -431,7 +469,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), @@ -446,11 +484,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChat, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio @@ -464,11 +504,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, thumb, text, parseMode, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -476,11 +518,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, title: String? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( to: AccessibleMessage, @@ -490,22 +534,26 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, thumb, entities, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, audio: AudioFile, entities: TextSourcesList, title: String? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents @@ -516,47 +564,55 @@ suspend inline fun TelegramBot.replyWithDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, thumb, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( to: AccessibleMessage, document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, thumb, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, document: DocumentFile, entities: TextSourcesList, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @@ -565,34 +621,42 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithMediaGroup( to: AccessibleMessage, media: List, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( to: AccessibleMessage, media: List, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendPlaylist(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( to: AccessibleMessage, media: List, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendDocumentsGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( to: AccessibleMessage, media: List, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendVisualMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo @@ -603,11 +667,13 @@ suspend inline fun TelegramBot.replyWithPhoto( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -615,11 +681,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -627,11 +695,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -639,33 +709,39 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, entities: TextSourcesList, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, photo: Photo, entities: TextSourcesList, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, photoSize: PhotoSize, entities: TextSourcesList, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker @@ -674,21 +750,25 @@ suspend inline fun TelegramBot.replyWithSticker( to: AccessibleMessage, sticker: InputFile, emoji: String? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, sticker: Sticker, emoji: String? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos @@ -703,11 +783,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChat, video, thumb, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -715,11 +797,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChat, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( to: AccessibleMessage, @@ -730,22 +814,26 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChat, video, thumb, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, video: VideoFile, entities: TextSourcesList, spoilered: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(replyInChat, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // VideoNotes @@ -756,20 +844,24 @@ suspend inline fun TelegramBot.replyWithVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(to.chat, videoNote, thumb, duration, size, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideoNote(replyInChat, videoNote, thumb, duration, size, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, videoNote: VideoNoteFile, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(to.chat, videoNote, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideoNote(replyInChat, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Voice @@ -780,22 +872,26 @@ suspend inline fun TelegramBot.replyWithVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, text, parseMode, duration, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChat, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChat, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -803,21 +899,25 @@ suspend inline fun TelegramBot.replyWithVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChat, voice, entities, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, voice: VoiceFile, entities: TextSourcesList, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChat, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Invoice @@ -845,11 +945,13 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendInvoice(replyInChat, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Polls @@ -862,11 +964,13 @@ suspend inline fun TelegramBot.reply( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendRegularPoll(replyInChat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -877,11 +981,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendRegularPoll(replyInChat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -893,11 +999,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -910,11 +1018,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -925,11 +1035,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -941,11 +1053,13 @@ suspend inline fun TelegramBot.reply( correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), isAnonymous: Boolean = quizPoll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( @@ -956,6 +1070,8 @@ suspend inline fun TelegramBot.reply( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -970,6 +1086,8 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -985,6 +1103,8 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -999,17 +1119,19 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( - to.chat.id, + replyInChat, fromChatId, messageId, text, parseMode, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), @@ -1022,34 +1144,40 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(to, fromChat.id, messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, fromChat.id, messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(to, copy.chat.id, copy.messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, copy.chat.id, copy.messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( to: AccessibleMessage, content: MessageContent, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): AccessibleMessage = execute( content.createResend( - to.chat.id, - to.threadIdOrNull, + replyInChat, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), @@ -1066,14 +1194,16 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) = handleLiveLocation( - to.chat.id, + replyInChat, locationsFlow, liveTimeMillis, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true) @@ -1090,15 +1220,17 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - to.chat.id, + replyInChat, locationsFlow, liveTimeMillis, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true) @@ -1116,15 +1248,17 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - to.chat.id, + replyInChat, locationsFlow, liveTimeMillis, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true) @@ -1134,6 +1268,8 @@ suspend fun TelegramBot.reply( suspend fun TelegramBot.reply( to: AccessibleMessage, mediaFile: TelegramMediaFile, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1143,6 +1279,8 @@ suspend fun TelegramBot.reply( is AudioFile -> reply( to = to, audio = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1151,6 +1289,8 @@ suspend fun TelegramBot.reply( is AnimationFile -> reply( to = to, animation = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1159,6 +1299,8 @@ suspend fun TelegramBot.reply( is VoiceFile -> reply( to = to, voice = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1167,6 +1309,8 @@ suspend fun TelegramBot.reply( is VideoFile -> reply( to = to, video = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1175,6 +1319,8 @@ suspend fun TelegramBot.reply( is VideoNoteFile -> reply( to = to, videoNote = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1183,6 +1329,8 @@ suspend fun TelegramBot.reply( is DocumentFile -> reply( to = to, document = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1191,6 +1339,8 @@ suspend fun TelegramBot.reply( is Sticker -> reply( to = to, sticker = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1199,6 +1349,8 @@ suspend fun TelegramBot.reply( is PhotoSize -> reply( to = to, photoSize = mediaFile, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1207,6 +1359,8 @@ suspend fun TelegramBot.reply( else -> reply( to = to, document = mediaFile.asDocumentFile(), + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1220,6 +1374,8 @@ suspend fun TelegramBot.reply( content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1231,6 +1387,8 @@ suspend fun TelegramBot.reply( voice = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1241,6 +1399,8 @@ suspend fun TelegramBot.reply( audio = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1251,6 +1411,8 @@ suspend fun TelegramBot.reply( photoSize = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1261,6 +1423,8 @@ suspend fun TelegramBot.reply( video = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1271,6 +1435,8 @@ suspend fun TelegramBot.reply( animation = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1281,6 +1447,8 @@ suspend fun TelegramBot.reply( document = content.media.asDocumentFile(), text = text, parseMode = parseMode, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1293,6 +1461,8 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, content: TextedMediaContent, entities: TextSourcesList, + replyInChat: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1303,6 +1473,8 @@ suspend fun TelegramBot.reply( to = to, voice = content.media, entities = entities, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1312,6 +1484,8 @@ suspend fun TelegramBot.reply( to = to, audio = content.media, entities = entities, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1321,6 +1495,8 @@ suspend fun TelegramBot.reply( to = to, photoSize = content.media, entities = entities, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1330,6 +1506,8 @@ suspend fun TelegramBot.reply( to = to, video = content.media, entities = entities, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1339,6 +1517,8 @@ suspend fun TelegramBot.reply( to = to, animation = content.media, entities = entities, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1348,6 +1528,8 @@ suspend fun TelegramBot.reply( to = to, document = content.media.asDocumentFile(), entities = entities, + replyInChat = replyInChat, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 663608d1dd..933dd258eb 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -47,17 +47,18 @@ suspend inline fun TelegramBot.reply( phoneNumber: String, firstName: String, lastName: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - toChatId, + replyInChat, phoneNumber, firstName, lastName, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -72,15 +73,16 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, contact: Contact, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - toChatId, + replyInChat, contact, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -98,12 +100,13 @@ suspend inline fun TelegramBot.replyWithDice( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(toChatId, animationType, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendDice(replyInChat, animationType, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -113,12 +116,13 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(toChatId, toMessageId, animationType, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(replyInChat, toMessageId, animationType, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -132,16 +136,17 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, latitude: Double, longitude: Double, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - toChatId, + replyInChat, latitude, longitude, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -156,15 +161,16 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, location: StaticLocation, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - toChatId, + replyInChat, location, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -184,17 +190,18 @@ suspend inline fun TelegramBot.reply( text: String, parseMode: ParseMode? = null, linkPreviewOptions: LinkPreviewOptions? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - toChatId, + replyInChat, text, parseMode, linkPreviewOptions, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -210,16 +217,17 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, entities: TextSourcesList, linkPreviewOptions: LinkPreviewOptions? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - toChatId, + replyInChat, entities, linkPreviewOptions, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -235,13 +243,14 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: TextSource? = null, linkPreviewOptions: LinkPreviewOptions? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(replyInChat, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -252,13 +261,14 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: String, linkPreviewOptions: LinkPreviewOptions? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(replyInChat, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -278,13 +288,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = toChatId, + chatId = replyInChat, latitude = latitude, longitude = longitude, title = title, @@ -293,7 +304,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = threadId, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -310,13 +321,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = toChatId, + chatId = replyInChat, latitude = location.latitude, longitude = location.longitude, title = title, @@ -325,7 +337,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = threadId, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -336,15 +348,16 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, venue: Venue, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = toChatId, + chatId = replyInChat, venue = venue, - threadId = threadId, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -358,38 +371,41 @@ suspend inline fun TelegramBot.replyWithGame( toChatId: IdChatIdentifier, toMessageId: MessageId, gameShortName: String, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, gameShortName, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChat, gameShortName, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, game.title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChat, game.title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(toChatId, toMessageId, game, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(replyInChat, toMessageId, game, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation @@ -405,13 +421,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - toChatId, + replyInChat, animation, thumb, text, @@ -420,7 +437,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -437,12 +454,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChat, animation, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( toChatId: IdChatIdentifier, @@ -454,13 +472,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - toChatId, + replyInChat, animation, thumb, entities, @@ -468,7 +487,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -484,12 +503,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChat, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio @@ -504,12 +524,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, thumb, text, parseMode, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -518,12 +539,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( toChatId: IdChatIdentifier, @@ -534,12 +556,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, thumb, entities, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -547,12 +570,13 @@ suspend inline fun TelegramBot.reply( audio: AudioFile, entities: TextSourcesList, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, entities, title, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChat, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents @@ -564,13 +588,14 @@ suspend inline fun TelegramBot.replyWithDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, thumb, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -578,13 +603,14 @@ suspend inline fun TelegramBot.reply( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( toChatId: IdChatIdentifier, @@ -592,26 +618,28 @@ suspend inline fun TelegramBot.replyWithDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, thumb, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, document: DocumentFile, entities: TextSourcesList, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChat, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @@ -621,41 +649,45 @@ suspend inline fun TelegramBot.replyWithMediaGroup( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendPlaylist(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendDocumentsGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(toChatId, media, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendVisualMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo @@ -667,12 +699,13 @@ suspend inline fun TelegramBot.replyWithPhoto( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -681,12 +714,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -695,12 +729,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -709,12 +744,13 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -722,12 +758,13 @@ suspend inline fun TelegramBot.reply( photo: Photo, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -735,12 +772,13 @@ suspend inline fun TelegramBot.reply( photoSize: PhotoSize, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChat, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker @@ -749,25 +787,27 @@ suspend inline fun TelegramBot.replyWithSticker( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: InputFile, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: Sticker, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos @@ -783,12 +823,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChat, video, thumb, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -797,12 +838,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChat, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( toChatId: IdChatIdentifier, @@ -814,12 +856,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChat, video, thumb, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -827,12 +870,13 @@ suspend inline fun TelegramBot.reply( video: VideoFile, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChat, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // VideoNotes @@ -844,23 +888,25 @@ suspend inline fun TelegramBot.replyWithVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideoNote(replyInChat, videoNote, thumb, duration, size, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, videoNote: VideoNoteFile, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideoNote(replyInChat, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Voice @@ -872,12 +918,13 @@ suspend inline fun TelegramBot.replyWithVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChat, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -885,12 +932,13 @@ suspend inline fun TelegramBot.reply( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChat, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -899,24 +947,26 @@ suspend inline fun TelegramBot.replyWithVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChat, voice, entities, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, voice: VoiceFile, entities: TextSourcesList, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChat, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Invoice @@ -945,12 +995,13 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(toChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendInvoice(replyInChat, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Polls @@ -964,12 +1015,13 @@ suspend inline fun TelegramBot.reply( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendRegularPoll(replyInChat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -981,12 +1033,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendRegularPoll(replyInChat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -999,12 +1052,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1018,12 +1072,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1035,12 +1090,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1053,12 +1109,13 @@ suspend inline fun TelegramBot.reply( correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), isAnonymous: Boolean = quizPoll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( @@ -1070,14 +1127,15 @@ suspend inline fun TelegramBot.reply( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = when (poll) { is RegularPoll -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, poll = poll, isClosed = isClosed, @@ -1086,7 +1144,7 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1094,7 +1152,7 @@ suspend inline fun TelegramBot.reply( ) is UnknownPollType -> error("Unable to send poll with unknown type ($poll)") is QuizPoll -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, quizPoll = poll, entities = poll.textSources, @@ -1103,7 +1161,7 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1119,18 +1177,19 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( - toChatId, + replyInChat, fromChatId, messageId, text, parseMode, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -1144,12 +1203,13 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(replyInChat, toMessageId, fromChat.id, messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1157,18 +1217,20 @@ suspend inline fun TelegramBot.reply( copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(replyInChat, toMessageId, copy.chat.id, copy.messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, content: MessageContent, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1176,8 +1238,8 @@ suspend fun TelegramBot.reply( ) { execute( content.createResend( - toChatId, - threadId, + replyInChat, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), @@ -1196,15 +1258,16 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) = handleLiveLocation( - toChatId, + replyInChat, locationsFlow, liveTimeMillis, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) @@ -1222,16 +1285,17 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - toChatId, + replyInChat, locationsFlow, liveTimeMillis, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) @@ -1250,16 +1314,17 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - toChatId, + replyInChat, locationsFlow, liveTimeMillis, - threadId, + replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) @@ -1270,7 +1335,8 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, mediaFile: TelegramMediaFile, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1278,90 +1344,90 @@ suspend fun TelegramBot.reply( ) { when (mediaFile) { is AudioFile -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, audio = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is AnimationFile -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, animation = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is VoiceFile -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, voice = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is VideoFile -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, video = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is VideoNoteFile -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, videoNote = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is DocumentFile -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, document = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is Sticker -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, sticker = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is PhotoSize -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, photoSize = mediaFile, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) else -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, document = mediaFile.asDocumentFile(), - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1376,7 +1442,8 @@ suspend fun TelegramBot.reply( content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1384,72 +1451,72 @@ suspend fun TelegramBot.reply( ) { when (content) { is VoiceContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, voice = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is AudioMediaGroupPartContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, audio = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is PhotoContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, photoSize = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is VideoContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, video = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is AnimationContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, animation = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) else -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, document = content.media.asDocumentFile(), text = text, parseMode = parseMode, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1463,7 +1530,8 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, content: TextedMediaContent, entities: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChat: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChat.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1471,66 +1539,66 @@ suspend fun TelegramBot.reply( ) { when (content) { is VoiceContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, voice = content.media, entities = entities, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is AudioMediaGroupPartContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, audio = content.media, entities = entities, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is PhotoContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, photoSize = content.media, entities = entities, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is VideoContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, video = content.media, entities = entities, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) is AnimationContent -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, animation = content.media, entities = entities, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) else -> reply( - toChatId = toChatId, + toChatId = replyInChat, toMessageId = toMessageId, document = content.media.asDocumentFile(), entities = entities, - threadId = threadId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, From a106068af4321aeac8f99ef7a1c1c79415747ad5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 15:13:51 +0600 Subject: [PATCH 42/65] fixes in reactions --- .../inmo/tgbotapi/types/reactions/Reaction.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt index 3cb993ed28..a325317115 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.reactions import dev.inmo.tgbotapi.types.CustomEmojiId -import dev.inmo.tgbotapi.types.customEmojiField +import dev.inmo.tgbotapi.types.customEmojiIdField import dev.inmo.tgbotapi.types.emojiField import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import kotlinx.serialization.KSerializer @@ -12,6 +12,7 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.JsonDecoder import kotlinx.serialization.json.JsonElement +import kotlin.jvm.JvmInline @Serializable(Reaction.Companion::class) @ClassCastsIncluded @@ -19,7 +20,8 @@ sealed interface Reaction { val type: String @Serializable(Reaction.Companion::class) - data class Emoji( + @JvmInline + value class Emoji( val emoji: String ) : Reaction { override val type: String @@ -30,8 +32,9 @@ sealed interface Reaction { } @Serializable(Reaction.Companion::class) - data class CustomEmoji( - val customEmoji: CustomEmojiId + @JvmInline + value class CustomEmoji( + val customEmojiId: CustomEmojiId ) : Reaction { override val type: String get() = Companion.type @@ -51,8 +54,8 @@ sealed interface Reaction { val type: String, @SerialName(emojiField) val emoji: String? = null, - @SerialName(customEmojiField) - val customEmoji: CustomEmojiId? = null + @SerialName(customEmojiIdField) + val customEmojiId: CustomEmojiId? = null ) companion object : KSerializer { @@ -69,7 +72,7 @@ sealed interface Reaction { return when { surrogate.emoji != null -> Emoji(surrogate.emoji) - surrogate.customEmoji != null -> CustomEmoji(surrogate.customEmoji) + surrogate.customEmojiId != null -> CustomEmoji(surrogate.customEmojiId) else -> Unknown(surrogate.type, json) } } @@ -83,7 +86,7 @@ sealed interface Reaction { Surrogate( type = value.type, emoji = (value as? Emoji) ?.emoji, - customEmoji = (value as? CustomEmoji) ?.customEmoji, + customEmojiId = (value as? CustomEmoji) ?.customEmojiId, ) ) } From d480c9efd6f3393b60952daf1c1bc54215b644cb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 15:43:11 +0600 Subject: [PATCH 43/65] fixes in replies with chats and messages --- .../api/send/RepliesWithChatsAndMessages.kt | 81 ++++++++++++------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 933dd258eb..eec896e704 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -122,7 +122,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(replyInChat, toMessageId, animationType, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(toChatId, toMessageId, animationType, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -250,7 +250,7 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(replyInChat, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -268,7 +268,7 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(replyInChat, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -405,7 +405,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(replyInChat, toMessageId, game, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(toChatId, toMessageId, game, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation @@ -1135,7 +1135,7 @@ suspend inline fun TelegramBot.reply( replyMarkup: KeyboardMarkup? = null ) = when (poll) { is RegularPoll -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, poll = poll, isClosed = isClosed, @@ -1144,6 +1144,7 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1152,7 +1153,7 @@ suspend inline fun TelegramBot.reply( ) is UnknownPollType -> error("Unable to send poll with unknown type ($poll)") is QuizPoll -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, quizPoll = poll, entities = poll.textSources, @@ -1161,6 +1162,7 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1209,7 +1211,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(replyInChat, toMessageId, fromChat.id, messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1223,7 +1225,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(replyInChat, toMessageId, copy.chat.id, copy.messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1344,9 +1346,10 @@ suspend fun TelegramBot.reply( ) { when (mediaFile) { is AudioFile -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, audio = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1354,9 +1357,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is AnimationFile -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, animation = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1364,9 +1368,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is VoiceFile -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, voice = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1374,9 +1379,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is VideoFile -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, video = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1384,9 +1390,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is VideoNoteFile -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, videoNote = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1394,9 +1401,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is DocumentFile -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, document = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1404,9 +1412,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is Sticker -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, sticker = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1414,9 +1423,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is PhotoSize -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, photoSize = mediaFile, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1424,9 +1434,10 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) else -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, document = mediaFile.asDocumentFile(), + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1451,11 +1462,12 @@ suspend fun TelegramBot.reply( ) { when (content) { is VoiceContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, voice = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1463,11 +1475,12 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is AudioMediaGroupPartContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, audio = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1475,11 +1488,12 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is PhotoContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, photoSize = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1487,11 +1501,12 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is VideoContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, video = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1499,11 +1514,12 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is AnimationContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, animation = content.media, text = text, parseMode = parseMode, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1511,11 +1527,12 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) else -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, document = content.media.asDocumentFile(), text = text, parseMode = parseMode, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1539,10 +1556,11 @@ suspend fun TelegramBot.reply( ) { when (content) { is VoiceContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, voice = content.media, entities = entities, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1550,10 +1568,11 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is AudioMediaGroupPartContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, audio = content.media, entities = entities, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1561,10 +1580,11 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is PhotoContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, photoSize = content.media, entities = entities, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1572,10 +1592,11 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is VideoContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, video = content.media, entities = entities, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1583,10 +1604,11 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) is AnimationContent -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, animation = content.media, entities = entities, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1594,10 +1616,11 @@ suspend fun TelegramBot.reply( replyMarkup = replyMarkup ) else -> reply( - toChatId = replyInChat, + toChatId = toChatId, toMessageId = toMessageId, document = content.media.asDocumentFile(), entities = entities, + replyInChat = replyInChat, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, From f2308f0312951ea2b05fddfde8e79ebf332205e6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 18:49:04 +0600 Subject: [PATCH 44/65] update setMessageReaction --- .../api/send/SetMessageReactions.kt | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt index 5abec35c55..3247ba03b3 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt @@ -6,7 +6,10 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.reactions.Reaction +import kotlin.js.JsName +import kotlin.jvm.JvmName suspend fun TelegramBot.setMessageReactions( chatId: ChatIdentifier, @@ -38,14 +41,82 @@ suspend fun TelegramBot.setMessageReaction( big: Boolean = false ) = setMessageReaction(chat.id, messageId, reaction, big) +suspend fun TelegramBot.setMessageReactions( + meta: Message.MetaInfo, + reactions: List, + big: Boolean = false +) = setMessageReactions(meta.chatId, meta.messageId, reactions, big) + +suspend fun TelegramBot.setMessageReaction( + meta: Message.MetaInfo, + reaction: Reaction?, + big: Boolean = false +) = setMessageReaction(meta.chatId, meta.messageId, reaction, big) + suspend fun TelegramBot.setMessageReactions( message: AccessibleMessage, reactions: List, big: Boolean = false -) = setMessageReactions(message.chat, message.messageId, reactions, big) +) = setMessageReactions(message.metaInfo, reactions, big) suspend fun TelegramBot.setMessageReaction( message: AccessibleMessage, reaction: Reaction?, big: Boolean = false -) = setMessageReaction(message.chat, message.messageId, reaction, big) +) = setMessageReaction(message.metaInfo, reaction, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + chatId: ChatIdentifier, + messageId: MessageId, + reactions: List, + big: Boolean = false +) = setMessageReactions(chatId, messageId, reactions.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + reaction: String?, + big: Boolean = false +) = setMessageReaction(chatId, messageId, reaction ?.let { Reaction.Emoji(it) }, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + chat: Chat, + messageId: MessageId, + reactions: List, + big: Boolean = false +) = setMessageReactions(chat, messageId, reactions.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + chat: Chat, + messageId: MessageId, + reaction: String?, + big: Boolean = false +) = setMessageReaction(chat, messageId, reaction ?.let { Reaction.Emoji(it) }, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + meta: Message.MetaInfo, + reactions: List, + big: Boolean = false +) = setMessageReactions(meta, reactions.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + meta: Message.MetaInfo, + reaction: String?, + big: Boolean = false +) = setMessageReaction(meta, reaction ?.let { Reaction.Emoji(it) }, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + message: AccessibleMessage, + reactions: List, + big: Boolean = false +) = setMessageReactions(message, reactions.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + message: AccessibleMessage, + reaction: String?, + big: Boolean = false +) = setMessageReaction(message, reaction ?.let { Reaction.Emoji(it) }, big) From f0448485c849cac54a73037910b19497fd9f7d55 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 18:56:21 +0600 Subject: [PATCH 45/65] add defaults to setMessageReaction --- .../api/send/SetMessageReactions.kt | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt index 3247ba03b3..9b0931e842 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt @@ -14,7 +14,7 @@ import kotlin.jvm.JvmName suspend fun TelegramBot.setMessageReactions( chatId: ChatIdentifier, messageId: MessageId, - reactions: List, + reactions: List = emptyList(), big: Boolean = false ) = execute( SetMessageReactions(chatId, messageId, reactions, big) @@ -23,45 +23,45 @@ suspend fun TelegramBot.setMessageReactions( suspend fun TelegramBot.setMessageReaction( chatId: ChatIdentifier, messageId: MessageId, - reaction: Reaction?, + reaction: Reaction? = null, big: Boolean = false ) = setMessageReactions(chatId, messageId, listOfNotNull(reaction), big) suspend fun TelegramBot.setMessageReactions( chat: Chat, messageId: MessageId, - reactions: List, + reactions: List = emptyList(), big: Boolean = false ) = setMessageReactions(chat.id, messageId, reactions, big) suspend fun TelegramBot.setMessageReaction( chat: Chat, messageId: MessageId, - reaction: Reaction?, + reaction: Reaction? = null, big: Boolean = false ) = setMessageReaction(chat.id, messageId, reaction, big) suspend fun TelegramBot.setMessageReactions( meta: Message.MetaInfo, - reactions: List, + reactions: List = emptyList(), big: Boolean = false ) = setMessageReactions(meta.chatId, meta.messageId, reactions, big) suspend fun TelegramBot.setMessageReaction( meta: Message.MetaInfo, - reaction: Reaction?, + reaction: Reaction? = null, big: Boolean = false ) = setMessageReaction(meta.chatId, meta.messageId, reaction, big) suspend fun TelegramBot.setMessageReactions( message: AccessibleMessage, - reactions: List, + reactions: List = emptyList(), big: Boolean = false ) = setMessageReactions(message.metaInfo, reactions, big) suspend fun TelegramBot.setMessageReaction( message: AccessibleMessage, - reaction: Reaction?, + reaction: Reaction? = null, big: Boolean = false ) = setMessageReaction(message.metaInfo, reaction, big) @@ -69,54 +69,54 @@ suspend fun TelegramBot.setMessageReaction( suspend fun TelegramBot.setMessageReactions( chatId: ChatIdentifier, messageId: MessageId, - reactions: List, + emojis: List, big: Boolean = false -) = setMessageReactions(chatId, messageId, reactions.map { Reaction.Emoji(it) }, big) +) = setMessageReactions(chatId, messageId, emojis.map { Reaction.Emoji(it) }, big) suspend fun TelegramBot.setMessageReaction( chatId: ChatIdentifier, messageId: MessageId, - reaction: String?, + emoji: String?, big: Boolean = false -) = setMessageReaction(chatId, messageId, reaction ?.let { Reaction.Emoji(it) }, big) +) = setMessageReaction(chatId, messageId, emoji ?.let { Reaction.Emoji(it) }, big) @JvmName("setMessageReactionsStrings") suspend fun TelegramBot.setMessageReactions( chat: Chat, messageId: MessageId, - reactions: List, + emojis: List, big: Boolean = false -) = setMessageReactions(chat, messageId, reactions.map { Reaction.Emoji(it) }, big) +) = setMessageReactions(chat, messageId, emojis.map { Reaction.Emoji(it) }, big) suspend fun TelegramBot.setMessageReaction( chat: Chat, messageId: MessageId, - reaction: String?, + emoji: String?, big: Boolean = false -) = setMessageReaction(chat, messageId, reaction ?.let { Reaction.Emoji(it) }, big) +) = setMessageReaction(chat, messageId, emoji ?.let { Reaction.Emoji(it) }, big) @JvmName("setMessageReactionsStrings") suspend fun TelegramBot.setMessageReactions( meta: Message.MetaInfo, - reactions: List, + emojis: List, big: Boolean = false -) = setMessageReactions(meta, reactions.map { Reaction.Emoji(it) }, big) +) = setMessageReactions(meta, emojis.map { Reaction.Emoji(it) }, big) suspend fun TelegramBot.setMessageReaction( meta: Message.MetaInfo, - reaction: String?, + emoji: String?, big: Boolean = false -) = setMessageReaction(meta, reaction ?.let { Reaction.Emoji(it) }, big) +) = setMessageReaction(meta, emoji ?.let { Reaction.Emoji(it) }, big) @JvmName("setMessageReactionsStrings") suspend fun TelegramBot.setMessageReactions( message: AccessibleMessage, - reactions: List, + emojis: List, big: Boolean = false -) = setMessageReactions(message, reactions.map { Reaction.Emoji(it) }, big) +) = setMessageReactions(message, emojis.map { Reaction.Emoji(it) }, big) suspend fun TelegramBot.setMessageReaction( message: AccessibleMessage, - reaction: String?, + emoji: String?, big: Boolean = false -) = setMessageReaction(message, reaction ?.let { Reaction.Emoji(it) }, big) +) = setMessageReaction(message, emoji ?.let { Reaction.Emoji(it) }, big) From eac45b86a6ec3a7656d9861ac13732765bb37104 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 19:16:17 +0600 Subject: [PATCH 46/65] fixes in LinkPreviewOptions --- .../inmo/tgbotapi/types/LinkPreviewOptions.kt | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt index 3db380420b..d553b676e6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -1,10 +1,14 @@ package dev.inmo.tgbotapi.types +import kotlinx.serialization.KSerializer import kotlinx.serialization.Required import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder -@Serializable +@Serializable(LinkPreviewOptions.Companion::class) sealed interface LinkPreviewOptions { val isDisabled: Boolean val url: String? @@ -76,4 +80,47 @@ sealed interface LinkPreviewOptions { override val preferLargeMedia: Boolean get() = false } + + @Serializable + private data class Surrogate( + @Required + @SerialName(isDisabledField) + val isDisabled: Boolean = true, + @SerialName(urlField) + val url: String? = null, + @SerialName(preferSmallMediaField) + val preferSmallMedia: Boolean = false, + @SerialName(preferLargeMediaField) + val preferLargeMedia: Boolean = false, + @SerialName(showAboveTextField) + val showAboveText: Boolean = false, + ) { + + } + + companion object : KSerializer { + override val descriptor: SerialDescriptor + get() = Surrogate.serializer().descriptor + + override fun deserialize(decoder: Decoder): LinkPreviewOptions { + val surrogate = Surrogate.serializer().deserialize(decoder) + + return when { + surrogate.isDisabled -> Disabled + surrogate.preferLargeMedia -> Large(surrogate.url, surrogate.showAboveText) + surrogate.preferSmallMedia -> Small(surrogate.url, surrogate.showAboveText) + else -> Medium(surrogate.url, surrogate.showAboveText) + } + } + + override fun serialize(encoder: Encoder, value: LinkPreviewOptions) { + when (value) { + is Disabled -> Disabled.serializer().serialize(encoder, value) + is Large -> Large.serializer().serialize(encoder, value) + is Medium -> Medium.serializer().serialize(encoder, value) + is Small -> Small.serializer().serialize(encoder, value) + } + } + + } } \ No newline at end of file From 7e5064ba3c5f50bc275bfcefc88bf796d24a3c1c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Jan 2024 19:22:26 +0600 Subject: [PATCH 47/65] fix in LinkPreviewOptions surrogate --- .../kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt index d553b676e6..c50374524d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -83,7 +83,6 @@ sealed interface LinkPreviewOptions { @Serializable private data class Surrogate( - @Required @SerialName(isDisabledField) val isDisabled: Boolean = true, @SerialName(urlField) From a4064a15ec04afbe4d293fe16ac1f36af4b995f2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 11:33:07 +0600 Subject: [PATCH 48/65] add trigger for ChatMessageReactionsCountUpdated --- ...sageReactionCountUpdatedUpdatesTriggers.kt | 38 +++++++++++++++++++ ...ageReactionsCountUpdatedMarkerFactories.kt | 8 ++++ 2 files changed, 46 insertions(+) create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionCountUpdatedUpdatesTriggers.kt create mode 100644 tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionsCountUpdatedMarkerFactories.kt diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionCountUpdatedUpdatesTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionCountUpdatedUpdatesTriggers.kt new file mode 100644 index 0000000000..9db5e94a07 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMessageReactionCountUpdatedUpdatesTriggers.kt @@ -0,0 +1,38 @@ +@file:Suppress("unused") + +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatIdChatMessageReactionUpdatedMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatIdChatMessageReactionsCountUpdatedMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull +import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionsCountUpdatedUpdateOrNull +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated +import dev.inmo.tgbotapi.types.polls.* +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] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onChatMessageReactionsCountUpdated( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByChatIdChatMessageReactionsCountUpdatedMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.chatMessageReactionsCountUpdatedUpdateOrNull() ?.data) ?.let(::listOfNotNull) +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionsCountUpdatedMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionsCountUpdatedMarkerFactories.kt new file mode 100644 index 0000000000..875af973ac --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMessageReactionsCountUpdatedMarkerFactories.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated +import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated + +object ByChatIdChatMessageReactionsCountUpdatedMarkerFactory : MarkerFactory { + override suspend fun invoke(data: ChatMessageReactionsCountUpdated) = data.chat.id +} From 294f80032c883f8b437580eadebd37315170d566 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 11:43:04 +0600 Subject: [PATCH 49/65] rename ScheduledGiveaway -> Giveaway --- .../expectations/WaitContent.kt | 4 ++-- .../expectations/WaitContentMessage.kt | 7 ++----- .../expectations/WaitEditedContent.kt | 4 ++-- .../expectations/WaitEditedContentMessage.kt | 5 ++--- .../triggers_handling/ContentTriggers.kt | 4 ++-- .../dev/inmo/tgbotapi/types/ReplyInfo.kt | 4 ++-- .../{ScheduledGiveaway.kt => Giveaway.kt} | 8 +------ .../inmo/tgbotapi/types/message/RawMessage.kt | 6 +++--- .../types/message/content/Abstracts.kt | 2 +- ...dGiveawayContent.kt => GiveawayContent.kt} | 10 +++------ .../types/message/content/Typealiases.kt | 2 +- .../extensions/utils/ClassCastsNew.kt | 21 +++++++++---------- 12 files changed, 31 insertions(+), 46 deletions(-) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/{ScheduledGiveaway.kt => Giveaway.kt} (66%) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/{ScheduledGiveawayContent.kt => GiveawayContent.kt} (76%) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 2fe2743266..4ec872744d 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -139,10 +139,10 @@ suspend fun BehaviourContext.waitMediaContent( errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory).mapContent() -suspend fun BehaviourContext.waitScheduledGiveawayContent( +suspend fun BehaviourContext.waitGiveawayContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, errorFactory).mapContent() +) = waitContent(initRequest, errorFactory).mapContent() suspend fun BehaviourContext.waitGiveawayPublicResultsContent( initRequest: Request<*>? = null, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt index 7ff93f2931..7d55775f0e 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt @@ -2,9 +2,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations -import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.withContent import dev.inmo.tgbotapi.extensions.utils.withContentOrNull import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage @@ -13,7 +11,6 @@ import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.mapNotNull typealias CommonMessageToCommonMessageMapper = suspend CommonMessage.() -> CommonMessage? @@ -153,10 +150,10 @@ suspend fun BehaviourContext.waitMediaContentMessage( errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory).mapWithContent() -suspend fun BehaviourContext.waitScheduledGiveawayContentMessage( +suspend fun BehaviourContext.waitGiveawayContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, errorFactory).mapWithContent() +) = waitContentMessage(initRequest, errorFactory).mapWithContent() suspend fun BehaviourContext.waitGiveawayPublicResultsContentMessage( initRequest: Request<*>? = null, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index d3761f4097..6a4d06aecb 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -131,10 +131,10 @@ suspend fun BehaviourContext.waitEditedInvoice( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContent(initRequest, false, errorFactory) -suspend fun BehaviourContext.waitEditedScheduledGiveawayContent( +suspend fun BehaviourContext.waitEditedGiveawayContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContent(initRequest, false, errorFactory) +) = waitEditedContent(initRequest, false, errorFactory) suspend fun BehaviourContext.waitEditedGiveawayPublicResultsContent( initRequest: Request<*>? = null, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt index 4790f8ac71..fa53f15138 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt @@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.baseEditMessageUpdateOrNull import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull import dev.inmo.tgbotapi.extensions.utils.withContent import dev.inmo.tgbotapi.requests.abstracts.Request @@ -137,10 +136,10 @@ suspend fun BehaviourContext.waitEditedInvoiceMessage( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContentMessage(initRequest, errorFactory) -suspend fun BehaviourContext.waitEditedScheduledGiveawayContentMessage( +suspend fun BehaviourContext.waitEditedGiveawayContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedGiveawayPublicResultsContentMessage( initRequest: Request<*>? = null, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index 1bec1193e7..5d66a1ed66 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -716,8 +716,8 @@ suspend fun BC.onMediaContent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BC.onScheduledGiveawayContent( - initialFilter: CommonMessageFilter? = null, +suspend fun BC.onGiveawayContent( + initialFilter: CommonMessageFilter? = null, subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt index d2c832927d..21b5244bde 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.dice.Dice import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.games.RawGame import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults -import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway +import dev.inmo.tgbotapi.types.giveaway.Giveaway import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.MessageOrigin import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage @@ -96,7 +96,7 @@ sealed interface ReplyInfo { private val poll: Poll? = null, private val invoice: Invoice? = null, private val dice: Dice? = null, - private val giveaway: ScheduledGiveaway? = null, + private val giveaway: Giveaway? = null, private val giveaway_winners: GiveawayPublicResults? = null, ) { val asExternalReplyInfo: External diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt similarity index 66% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt index ce7c3430bd..d8bea8ad5c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt @@ -1,19 +1,13 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.micro_utils.language_codes.IetfLang -import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.PreviewChat -import dev.inmo.tgbotapi.types.giveaway.GiveawayInfo -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ScheduledGiveaway( +data class Giveaway( @SerialName(chatsField) val chats: List, @SerialName(winnersSelectionDateField) 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 97aab2991d..e28264eda0 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 @@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.games.RawGame import dev.inmo.tgbotapi.types.giveaway.* -import dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent +import dev.inmo.tgbotapi.types.message.content.GiveawayContent import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -96,7 +96,7 @@ internal data class RawMessage( private val invoice: Invoice? = null, private val dice: Dice? = null, private val successful_payment: SuccessfulPayment? = null, - private val giveaway: ScheduledGiveaway? = null, + private val giveaway: Giveaway? = null, private val giveaway_winners: GiveawayResults? = null, private val users_shared: UsersShared? = null, @@ -199,7 +199,7 @@ internal data class RawMessage( venue != null -> VenueContent(venue) poll != null -> PollContent(poll) invoice != null -> InvoiceContent(invoice) - giveaway != null -> ScheduledGiveawayContent(chat, messageId, giveaway) + giveaway != null -> GiveawayContent(chat, messageId, giveaway) giveaway_winners is GiveawayPublicResults -> GiveawayPublicResultsContent(giveaway_winners) else -> null } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt index 59e02ffbef..536e7b87cd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Abstracts.kt @@ -50,7 +50,7 @@ sealed interface MessageContent: ResendableContent { subclass(InvoiceContent::class) subclass(StoryContent::class) subclass(GiveawayPublicResultsContent::class) - subclass(ScheduledGiveawayContent::class) + subclass(GiveawayContent::class) additionalBuilder() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayContent.kt similarity index 76% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayContent.kt index 17ce374abb..db4cedf9ae 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayContent.kt @@ -1,23 +1,19 @@ package dev.inmo.tgbotapi.types.message.content -import dev.inmo.micro_utils.language_codes.IetfLang import dev.inmo.tgbotapi.requests.ForwardMessage import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.chat.PreviewChat -import dev.inmo.tgbotapi.types.giveaway.GiveawayInfo -import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway +import dev.inmo.tgbotapi.types.giveaway.Giveaway import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage -import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ScheduledGiveawayContent( +data class GiveawayContent( private val chat: Chat, private val messageId: MessageId, - val giveaway: ScheduledGiveaway + val giveaway: Giveaway ) : MessageContent { override fun createResend( chatId: ChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt index 399ef34cd8..7d92ddff43 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt @@ -32,7 +32,7 @@ typealias VisualMediaGroupMessage = CommonMessage typealias VideoMessage = CommonMessage typealias PhotoMessage = CommonMessage typealias AnimationMessage = CommonMessage -typealias ScheduledGiveawayContentMessage = CommonMessage +typealias ScheduledGiveawayContentMessage = CommonMessage typealias GiveawayPublicResultsContentMessage = CommonMessage 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 313b784543..e73520d8cd 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 @@ -298,6 +298,7 @@ import dev.inmo.tgbotapi.types.message.content.DiceContent import dev.inmo.tgbotapi.types.message.content.DocumentContent import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.GameContent +import dev.inmo.tgbotapi.types.message.content.GiveawayContent import dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.message.content.LiveLocationContent @@ -311,7 +312,6 @@ import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.PhotoContent import dev.inmo.tgbotapi.types.message.content.PollContent import dev.inmo.tgbotapi.types.message.content.ResendableContent -import dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent import dev.inmo.tgbotapi.types.message.content.StaticLocationContent import dev.inmo.tgbotapi.types.message.content.StickerContent @@ -3795,6 +3795,15 @@ public inline fun ResendableContent.gameContentOrThrow(): GameContent = this as public inline fun ResendableContent.ifGameContent(block: (GameContent) -> T): T? = gameContentOrNull() ?.let(block) +public inline fun ResendableContent.giveawayContentOrNull(): GiveawayContent? = this as? + dev.inmo.tgbotapi.types.message.content.GiveawayContent + +public inline fun ResendableContent.giveawayContentOrThrow(): GiveawayContent = this as + dev.inmo.tgbotapi.types.message.content.GiveawayContent + +public inline fun ResendableContent.ifGiveawayContent(block: (GiveawayContent) -> T): T? = + giveawayContentOrNull() ?.let(block) + public inline fun ResendableContent.giveawayPublicResultsContentOrNull(): GiveawayPublicResultsContent? = this as? dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent @@ -3874,16 +3883,6 @@ public inline fun ResendableContent.pollContentOrThrow(): PollContent = this as public inline fun ResendableContent.ifPollContent(block: (PollContent) -> T): T? = pollContentOrNull() ?.let(block) -public inline fun ResendableContent.scheduledGiveawayContentOrNull(): ScheduledGiveawayContent? = - this as? dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent - -public inline fun ResendableContent.scheduledGiveawayContentOrThrow(): ScheduledGiveawayContent = - this as dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent - -public inline fun - ResendableContent.ifScheduledGiveawayContent(block: (ScheduledGiveawayContent) -> T): T? = - scheduledGiveawayContentOrNull() ?.let(block) - public inline fun ResendableContent.stickerContentOrNull(): StickerContent? = this as? dev.inmo.tgbotapi.types.message.content.StickerContent From 0f5bce592b80262f3cf77edf47d18614f5e0db3c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 11:45:12 +0600 Subject: [PATCH 50/65] replace username to full --- .../kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt | 6 +++--- .../tgbotapi/types/message/textsources/MentionTextSource.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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 30270966cd..e065b7ba2e 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 @@ -99,7 +99,7 @@ value class Username( get() = withoutAt init { - if (!username.startsWith("@")) { + if (!full.startsWith("@")) { throw IllegalArgumentException("Username must starts with `@`") } } @@ -132,7 +132,7 @@ object ChatIdentifierSerializer : KSerializer { override fun serialize(encoder: Encoder, value: ChatIdentifier) { when (value) { is IdChatIdentifier -> encoder.encodeLong(value.chatId) - is Username -> encoder.encodeString(value.username) + is Username -> encoder.encodeString(value.full) } } } @@ -170,7 +170,7 @@ object FullChatIdentifierSerializer : KSerializer { when (value) { is ChatId -> encoder.encodeLong(value.chatId) is ChatIdWithThreadId -> encoder.encodeString("${value.chatId}/${value.threadId}") - is Username -> encoder.encodeString(value.username) + is Username -> encoder.encodeString(value.full) } } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/MentionTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/MentionTextSource.kt index e8f49ecb44..933293694d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/MentionTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/textsources/MentionTextSource.kt @@ -45,5 +45,5 @@ inline fun mention(vararg parts: TextSource) = mention(parts.toList()) inline fun mention(whoToMention: String) = mention(regular(whoToMention)) @Suppress("NOTHING_TO_INLINE") -inline fun mention(whoToMention: Username) = mention(whoToMention.username.dropWhile { it == '@' }) +inline fun mention(whoToMention: Username) = mention(whoToMention.full.dropWhile { it == '@' }) diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt index 004de4dc0f..98fd148b1e 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/ChatIdentifierTests.kt @@ -33,10 +33,10 @@ class ChatIdentifierTests { @Test fun `Cast_from_String_to_Username_is_working_correctly`() { - assertEquals(testUsername, testUsername.toUsername().username) + assertEquals(testUsername, testUsername.toUsername().full) assertFails("Username creating must fail when trying to create from string which is not starting from @ symbol") { - testUsername.replace("@", "").toUsername().username + testUsername.replace("@", "").toUsername().full } } From 94253800029cc7a9d831fda9e990f5a37cabc3c6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 17:03:47 +0600 Subject: [PATCH 51/65] imrovements in copy/delete/forward messages --- .../tgbotapi/extensions/api/DeleteMessages.kt | 16 ++- .../extensions/api/ForwardMessages.kt | 40 ++++++- .../extensions/api/send/CopyMessages.kt | 111 +++++++++++++++++- 3 files changed, 158 insertions(+), 9 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt index c44d86a107..5ce39e0d10 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.DeleteMessages import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message suspend fun TelegramBot.deleteMessages( chatId: ChatIdentifier, @@ -35,14 +36,18 @@ suspend fun TelegramBot.deleteMessages( ) suspend fun TelegramBot.deleteMessages( - messages: List -) = messages.groupBy { it.chat }.map { (chat, messages) -> + messagesMetas: List +) = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) -> deleteMessages( - chatId = chat.id, + chatId = chatId, messageIds = messages.map { it.messageId } ) }.all { it } +suspend fun TelegramBot.deleteMessages( + messages: List +) = deleteMessages(messages.map { it.metaInfo }) + suspend fun TelegramBot.delete( chatId: ChatIdentifier, messageIds: List @@ -60,6 +65,11 @@ suspend fun TelegramBot.delete( vararg messageIds: MessageId ) = deleteMessages(chatId = chatId, messageIds = (listOf(firstMessageId, secondMessageId) + messageIds.toList())) + +suspend fun TelegramBot.delete( + messagesMetas: List +) = deleteMessages(messagesMetas) + suspend fun TelegramBot.delete( messages: List ) = deleteMessages(messages) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt index edbb1bd4c0..1bbbd5a966 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt @@ -1,9 +1,11 @@ package dev.inmo.tgbotapi.extensions.api import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.extensions.api.send.copyMessages import dev.inmo.tgbotapi.requests.ForwardMessages import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message suspend fun TelegramBot.forwardMessages( toChatId: ChatIdentifier, @@ -66,15 +68,15 @@ suspend fun TelegramBot.forwardMessages( suspend fun TelegramBot.forwardMessages( toChatId: ChatIdentifier, - messages: List, + messagesMetas: List, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, removeCaption: Boolean = false -) = messages.groupBy { it.chat }.flatMap { (chat, messages) -> +) = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) -> forwardMessages( toChatId = toChatId, - fromChatId = chat.id, + fromChatId = chatId, messageIds = messages.map { it.messageId }, threadId = threadId, disableNotification = disableNotification, @@ -83,6 +85,22 @@ suspend fun TelegramBot.forwardMessages( ) } +suspend fun TelegramBot.forwardMessages( + toChatId: ChatIdentifier, + messages: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + messagesMetas = messages.map { it.metaInfo }, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + suspend fun TelegramBot.forward( toChatId: ChatIdentifier, fromChatId: ChatIdentifier, @@ -139,6 +157,22 @@ suspend fun TelegramBot.forward( removeCaption = removeCaption ) +suspend fun TelegramBot.forward( + toChatId: ChatIdentifier, + messagesMetas: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = forwardMessages( + toChatId = toChatId, + messagesMetas = messagesMetas, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + suspend fun TelegramBot.forward( toChatId: ChatIdentifier, messages: List, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt index 3fabdeb877..7dbdc51103 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.CopyMessages import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message suspend fun TelegramBot.copyMessages( toChatId: ChatIdentifier, @@ -66,15 +67,15 @@ suspend fun TelegramBot.copyMessages( suspend fun TelegramBot.copyMessages( toChatId: ChatIdentifier, - messages: List, + messagesMetas: List, threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, removeCaption: Boolean = false -) = messages.groupBy { it.chat }.flatMap { (chat, messages) -> +) = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) -> copyMessages( toChatId = toChatId, - fromChatId = chat.id, + fromChatId = chatId, messageIds = messages.map { it.messageId }, threadId = threadId, disableNotification = disableNotification, @@ -82,3 +83,107 @@ suspend fun TelegramBot.copyMessages( removeCaption = removeCaption ) } + +suspend fun TelegramBot.copyMessages( + toChatId: ChatIdentifier, + messages: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + messagesMetas = messages.map { it.metaInfo }, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.copy( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.copy( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + messageIds: Array, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + messageIds = messageIds, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.copy( + toChatId: ChatIdentifier, + fromChatId: ChatIdentifier, + firstMessageId: MessageId, + vararg messageIds: MessageId, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + fromChatId = fromChatId, + firstMessageId = firstMessageId, + messageIds = messageIds, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.copy( + toChatId: ChatIdentifier, + messagesMetas: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + messagesMetas = messagesMetas, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) + +suspend fun TelegramBot.copy( + toChatId: ChatIdentifier, + messages: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = copyMessages( + toChatId = toChatId, + messages = messages, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption +) From aa315f6fecb3cb9b4e5994349d122028e043c1be Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 17:34:07 +0600 Subject: [PATCH 52/65] rename LinkPreviewOptions.Medium to LinkPreviewOptions.Default --- .../kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt index c50374524d..cccec5e8c8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -66,7 +66,7 @@ sealed interface LinkPreviewOptions { } @Serializable - data class Medium( + data class Default( @SerialName(urlField) override val url: String?, @SerialName(showAboveTextField) @@ -108,7 +108,7 @@ sealed interface LinkPreviewOptions { surrogate.isDisabled -> Disabled surrogate.preferLargeMedia -> Large(surrogate.url, surrogate.showAboveText) surrogate.preferSmallMedia -> Small(surrogate.url, surrogate.showAboveText) - else -> Medium(surrogate.url, surrogate.showAboveText) + else -> Default(surrogate.url, surrogate.showAboveText) } } @@ -116,7 +116,7 @@ sealed interface LinkPreviewOptions { when (value) { is Disabled -> Disabled.serializer().serialize(encoder, value) is Large -> Large.serializer().serialize(encoder, value) - is Medium -> Medium.serializer().serialize(encoder, value) + is Default -> Default.serializer().serialize(encoder, value) is Small -> Small.serializer().serialize(encoder, value) } } From 0013e91f6ee07acd3605f2ab8906f30c5c36f2b3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 17:52:13 +0600 Subject: [PATCH 53/65] fix of build and add annotation to all fields with one --- tgbotapi.api/build.gradle | 3 +++ .../inmo/tgbotapi/extensions/api/DeleteMessages.kt | 3 +++ .../inmo/tgbotapi/extensions/api/ForwardMessages.kt | 3 +++ .../tgbotapi/extensions/api/send/CopyMessages.kt | 3 +++ .../inmo/tgbotapi/requests/abstracts/InputFile.kt | 1 + .../chat/invite_links/CreateChatInviteLink.kt | 1 + .../requests/chat/invite_links/EditChatInviteLink.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/MenuButton.kt | 6 +++++- .../inmo/tgbotapi/types/boosts/ChatBoostSource.kt | 12 ++++++++---- .../inmo/tgbotapi/types/buttons/KeyboardButton.kt | 1 + .../dev/inmo/tgbotapi/types/buttons/ReplyForce.kt | 1 + .../tgbotapi/types/buttons/ReplyKeyboardRemove.kt | 1 + .../types/chat/member/AdministratorChatMemberImpl.kt | 1 + .../tgbotapi/types/chat/member/KickedChatMember.kt | 1 + .../tgbotapi/types/chat/member/LeftChatMemberImpl.kt | 1 + .../types/chat/member/MemberChatMemberImpl.kt | 1 + .../tgbotapi/types/chat/member/OwnerChatMember.kt | 1 + .../types/chat/member/RestrictedChatMember.kt | 1 + .../inmo/tgbotapi/types/commands/BotCommandScope.kt | 7 +++++++ .../tgbotapi/types/giveaway/GiveawayPublicResults.kt | 7 +++---- .../dev/inmo/tgbotapi/types/message/MessageOrigin.kt | 10 ++++++---- .../tgbotapi/types/passport/PassportElementError.kt | 9 +++++++++ 22 files changed, 62 insertions(+), 13 deletions(-) diff --git a/tgbotapi.api/build.gradle b/tgbotapi.api/build.gradle index 6c3723a5ed..20b3969dc6 100644 --- a/tgbotapi.api/build.gradle +++ b/tgbotapi.api/build.gradle @@ -16,6 +16,9 @@ kotlin { api project(":tgbotapi.core") } } + configureEach { + languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi") + } } } diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt index 5ce39e0d10..ee392340b9 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.DeleteMessages import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message +import kotlin.jvm.JvmName suspend fun TelegramBot.deleteMessages( chatId: ChatIdentifier, @@ -44,6 +45,7 @@ suspend fun TelegramBot.deleteMessages( ) }.all { it } +@JvmName("deleteMessagesWithMessages") suspend fun TelegramBot.deleteMessages( messages: List ) = deleteMessages(messages.map { it.metaInfo }) @@ -70,6 +72,7 @@ suspend fun TelegramBot.delete( messagesMetas: List ) = deleteMessages(messagesMetas) +@JvmName("deleteWithMessages") suspend fun TelegramBot.delete( messages: List ) = deleteMessages(messages) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt index 1bbbd5a966..d30b499ad4 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.ForwardMessages import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message +import kotlin.jvm.JvmName suspend fun TelegramBot.forwardMessages( toChatId: ChatIdentifier, @@ -85,6 +86,7 @@ suspend fun TelegramBot.forwardMessages( ) } +@JvmName("forwardMessagesWithMessages") suspend fun TelegramBot.forwardMessages( toChatId: ChatIdentifier, messages: List, @@ -173,6 +175,7 @@ suspend fun TelegramBot.forward( removeCaption = removeCaption ) +@JvmName("forwardWithMessages") suspend fun TelegramBot.forward( toChatId: ChatIdentifier, messages: List, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt index 7dbdc51103..f9d2265c6b 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.CopyMessages import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message +import kotlin.jvm.JvmName suspend fun TelegramBot.copyMessages( toChatId: ChatIdentifier, @@ -84,6 +85,7 @@ suspend fun TelegramBot.copyMessages( ) } +@JvmName("copyMessagesWithMessages") suspend fun TelegramBot.copyMessages( toChatId: ChatIdentifier, messages: List, @@ -172,6 +174,7 @@ suspend fun TelegramBot.copy( removeCaption = removeCaption ) +@JvmName("copyWithMessages") suspend fun TelegramBot.copy( toChatId: ChatIdentifier, messages: List, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt index 8aeebbfd18..b382b40c95 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt @@ -98,6 +98,7 @@ data class MultipartFile ( private val inputSource: () -> Input ) : InputFile() { @Required + @EncodeDefault override val fileId: String = "${uuid4()}.${filename.fileExtension}" val input: Input get() = inputSource() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt index 10d4e8b026..18a375ba8b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt @@ -112,6 +112,7 @@ data class CreateChatInviteLinkWithJoinRequest( override val expirationUnixTimeStamp: TelegramDate? = null, ) : CreateChatInviteLink, WithJoinRequestChatInviteLinkRequest { @Required + @EncodeDefault @SerialName(createsJoinRequestField) private val createsJoinRequest: Boolean = true diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt index 4872196740..7ef53689d7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt @@ -126,6 +126,7 @@ data class EditChatInviteLinkWithJoinRequest( ) : EditChatInviteLink, WithJoinRequestChatInviteLinkRequest { @Required + @EncodeDefault @SerialName(createsJoinRequestField) private val createsJoinRequest: Boolean = true diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MenuButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MenuButton.kt index 25b9f71159..d7395598e2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MenuButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MenuButton.kt @@ -9,13 +9,15 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.* @Serializable(MenuButtonSerializer::class) +@OptIn(ExperimentalSerializationApi::class) sealed interface MenuButton { - @Required + @EncodeDefault val type: String @Serializable object Commands : MenuButton { @Required + @EncodeDefault override val type: String get() = "commands" } @@ -27,6 +29,7 @@ sealed interface MenuButton { val webApp: WebAppInfo ) : MenuButton { @Required + @EncodeDefault override val type: String get() = Companion.type @@ -39,6 +42,7 @@ sealed interface MenuButton { @Serializable object Default : MenuButton { @Required + @EncodeDefault override val type: String get() = "default" } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt index 1fc74ec9c8..a4cb6d9fe8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt @@ -4,10 +4,7 @@ import dev.inmo.tgbotapi.abstracts.WithMessageId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.PreviewUser import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Required -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -31,6 +28,7 @@ sealed interface ChatBoostSource { override val user: PreviewUser ) : ByUser { @Required + @EncodeDefault @SerialName(sourceField) override val sourceName: String = sourceCode @@ -45,6 +43,7 @@ sealed interface ChatBoostSource { override val user: PreviewUser ) : ByUser { @Required + @EncodeDefault @SerialName(sourceField) override val sourceName: String = sourceCode @@ -67,9 +66,11 @@ sealed interface ChatBoostSource { override val user: PreviewUser ) : Giveaway, ByUser { @Required + @EncodeDefault @SerialName(sourceField) override val sourceName: String = Giveaway.sourceCode @Required + @EncodeDefault @SerialName(isUnclaimedField) override val unclaimed: Boolean = false } @@ -80,9 +81,11 @@ sealed interface ChatBoostSource { override val messageId: MessageId ) : Giveaway { @Required + @EncodeDefault @SerialName(sourceField) override val sourceName: String = Giveaway.sourceCode @Required + @EncodeDefault @SerialName(isUnclaimedField) override val unclaimed: Boolean = true @SerialName(userField) @@ -104,6 +107,7 @@ sealed interface ChatBoostSource { @Serializable private data class Surrogate( @Required + @EncodeDefault @SerialName(sourceField) val sourceName: String, @SerialName(userField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt index c7b2aaaa37..a51385927b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt @@ -65,6 +65,7 @@ data class RequestLocationKeyboardButton( ) : KeyboardButton { @SerialName(requestLocationField) @Required + @EncodeDefault val requestLocation: Boolean = true } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt index 51368f2594..e5c970e7d2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt @@ -11,6 +11,7 @@ data class ReplyForce( ) : KeyboardMarkup { @SerialName(forceReplyField) @Required + @EncodeDefault val forceReply: Boolean = true companion object { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt index 16bbce7dad..aa79b820f8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove.kt @@ -8,5 +8,6 @@ data class ReplyKeyboardRemove( ) : KeyboardMarkup { @SerialName("remove_keyboard") @Required + @EncodeDefault val removeKeyboard: Boolean = true } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt index 928fdf8ae6..757cacf244 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt @@ -45,5 +45,6 @@ data class AdministratorChatMemberImpl( ) : AdministratorChatMember { @SerialName(statusField) @Required + @EncodeDefault override val status: ChatMember.Status = ChatMember.Status.Administrator } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt index 3da3b37c53..2ae0b29ae0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt @@ -13,5 +13,6 @@ data class KickedChatMember( ) : BannedChatMember { @SerialName(statusField) @Required + @EncodeDefault override val status: ChatMember.Status = ChatMember.Status.Kicked } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt index aae25344e3..1060213cd0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt @@ -11,5 +11,6 @@ data class LeftChatMemberImpl( ) : LeftChatMember { @SerialName(statusField) @Required + @EncodeDefault override val status: ChatMember.Status = ChatMember.Status.Left } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt index 9edd84d50c..43f9ad4b54 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt @@ -11,5 +11,6 @@ data class MemberChatMemberImpl( ) : MemberChatMember { @SerialName(statusField) @Required + @EncodeDefault override val status: ChatMember.Status = ChatMember.Status.Member } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt index 9be0119f5f..666fa2b8b5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt @@ -45,5 +45,6 @@ data class OwnerChatMember( @SerialName(statusField) @Required + @EncodeDefault override val status: ChatMember.Status = ChatMember.Status.Creator } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt index 1d1b3b9e6c..0167262e1a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt @@ -44,5 +44,6 @@ data class RestrictedChatMember( ) : BannedChatMember, SpecialRightsChatMember, ChatPermissions { @SerialName(statusField) @Required + @EncodeDefault override val status: ChatMember.Status = ChatMember.Status.Restricted } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/commands/BotCommandScope.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/commands/BotCommandScope.kt index ce1aa93bee..9102d43a0a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/commands/BotCommandScope.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/commands/BotCommandScope.kt @@ -71,24 +71,28 @@ data class UnknownBotCommandScope internal constructor( @Serializable object BotCommandScopeDefault : BotCommandScope { @Required + @EncodeDefault override val type: String = "default" } @Serializable object BotCommandScopeAllPrivateChats : BotCommandScope { @Required + @EncodeDefault override val type: String = "all_private_chats" } @Serializable object BotCommandScopeAllGroupChats : BotCommandScope { @Required + @EncodeDefault override val type: String = "all_group_chats" } @Serializable object BotCommandScopeAllChatAdministrators : BotCommandScope { @Required + @EncodeDefault override val type: String = "all_chat_administrators" } @@ -102,6 +106,7 @@ data class BotCommandScopeChatAdministrators( override val chatId: ChatIdentifier ) : ChatBotCommandScope { @Required + @EncodeDefault override val type: String = BotCommandScopeChatAdministrators.type companion object { const val type = "chat_administrators" @@ -113,6 +118,7 @@ data class BotCommandScopeChat( override val chatId: ChatIdentifier ) : ChatBotCommandScope { @Required + @EncodeDefault override val type: String = BotCommandScopeChat.type companion object { const val type = "chat" @@ -125,6 +131,7 @@ data class BotCommandScopeChatMember( val userId: UserId ) : ChatBotCommandScope { @Required + @EncodeDefault override val type: String = BotCommandScopeChatMember.type companion object { const val type = "chat_member" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt index 192e2521b1..850c0122e4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt @@ -4,10 +4,7 @@ import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.chat.PreviewUser -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Required -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -32,6 +29,7 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi ) : GiveawayPublicResults { @SerialName(wasRefundedField) @Required + @EncodeDefault override val refunded: Boolean = true @SerialName(winnersCountField) override val count: Int = 0 @@ -78,6 +76,7 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi ) : GiveawayPublicResults { @SerialName(wasRefundedField) @Required + @EncodeDefault override val refunded: Boolean = false } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt index f6b886b4de..e2ff425a35 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt @@ -2,10 +2,7 @@ package dev.inmo.tgbotapi.types.message import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.* -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Required -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -27,6 +24,7 @@ sealed interface MessageOrigin { ) : MessageOrigin { @SerialName(typeField) @Required + @EncodeDefault override val type: String = Companion.type companion object { @@ -43,6 +41,7 @@ sealed interface MessageOrigin { ) : MessageOrigin { @SerialName(typeField) @Required + @EncodeDefault override val type: String = Companion.type companion object { @@ -66,6 +65,7 @@ sealed interface MessageOrigin { ) : Public { @SerialName(typeField) @Required + @EncodeDefault override val type: String = Companion.type companion object { @@ -86,6 +86,7 @@ sealed interface MessageOrigin { ) : Public { @SerialName(typeField) @Required + @EncodeDefault override val type: String = Companion.type companion object { @@ -105,6 +106,7 @@ sealed interface MessageOrigin { private data class Surrogate( @SerialName(typeField) @Required + @EncodeDefault val type: String, @SerialName(senderChatField) val senderChat: PreviewChat? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt index 214cf39c52..7d4c929e1f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/passport/PassportElementError.kt @@ -100,6 +100,7 @@ data class PassportElementErrorDataField( ) : PassportSingleElementError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = dataField } fun EncryptedPassportElementWithData.createDataError(field: String, message: String) = PassportElementErrorDataField( @@ -121,6 +122,7 @@ data class PassportElementErrorFrontSide( ) : PassportElementFileError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = frontSideField } fun EncryptedPassportElementWithFrontSide.createFrontSideError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorFrontSide( @@ -141,6 +143,7 @@ data class PassportElementErrorReverseSide( ) : PassportElementFileError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = reverseSideField } fun EncryptedPassportElementWithReverseSide.createReverseSideError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorReverseSide( @@ -160,6 +163,7 @@ data class PassportElementErrorSelfie( ) : PassportElementFileError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = selfieField } fun EncryptedPassportElementWithSelfie.createSelfieError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorSelfie( @@ -181,6 +185,7 @@ data class PassportElementErrorFile( ) : PassportElementFileError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = fileField } fun EncryptedPassportElementWithFilesCollection.createFileError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorFile( @@ -200,6 +205,7 @@ data class PassportElementErrorFiles( ) : PassportElementFilesError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = filesField } fun EncryptedPassportElementWithFilesCollection.createFilesError(message: String, unencryptedFileHashes: List) = PassportElementErrorFiles( @@ -221,6 +227,7 @@ data class PassportElementErrorTranslationFile( ) : PassportElementFileError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = translationFileField } fun EncryptedPassportElementTranslatable.createFileError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorTranslationFile( @@ -239,6 +246,7 @@ data class PassportElementErrorTranslationFiles( ) : PassportElementFilesError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = translationFilesField } fun EncryptedPassportElementTranslatable.createFilesError(message: String, unencryptedFileHashes: List) = PassportElementErrorTranslationFiles( @@ -259,6 +267,7 @@ data class PassportElementErrorUnspecified( ) : PassportElementFileError() { @SerialName(sourceField) @Required + @EncodeDefault override val source: String = unspecifiedField } fun EncryptedPassportElement.createUnspecifiedError(message: String, elementHash: PassportElementHash) = PassportElementErrorUnspecified( From f14885a5412fbd56fb4b838a9c8dfd3940e9f491 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 18:05:03 +0600 Subject: [PATCH 54/65] fix in LinkPreviewOptions.Surrogate --- .../kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt index cccec5e8c8..89b067ef93 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -84,7 +84,7 @@ sealed interface LinkPreviewOptions { @Serializable private data class Surrogate( @SerialName(isDisabledField) - val isDisabled: Boolean = true, + val isDisabled: Boolean = false, @SerialName(urlField) val url: String? = null, @SerialName(preferSmallMediaField) From d70c7fdbdff2e51ae3f8b8e73306ffc171c4db19 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jan 2024 18:21:20 +0600 Subject: [PATCH 55/65] fixes related to UsersShared --- .../expectations/WaitEventAction.kt | 8 ++- .../expectations/WaitEventActionMessages.kt | 8 ++- .../triggers_handling/EventTriggers.kt | 23 +++++- .../types/buttons/ReplyKeyboardBuilder.kt | 72 +++++++++++++++++-- 4 files changed, 101 insertions(+), 10 deletions(-) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index d65419b704..286e2f3c88 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -23,6 +23,7 @@ import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.filter typealias EventMessageToEventMapper = suspend ChatEventMessage.() -> T? @@ -199,11 +200,16 @@ suspend fun BehaviourContext.waitChatSharedRequest( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEvents(initRequest, errorFactory) -suspend fun BehaviourContext.waitUserShared( +suspend fun BehaviourContext.waitUsersShared( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEvents(initRequest, errorFactory) +suspend fun BehaviourContext.waitUserShared( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitUsersShared(initRequest, errorFactory).filter { it.userIds.size == 1 } + suspend fun BehaviourContext.waitChatShared( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt index 9143f2bca6..55d89bbc75 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt @@ -23,6 +23,7 @@ import dev.inmo.tgbotapi.types.request.UsersShared import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.filter @RiskFeature(lowLevelRiskFeatureMessage) suspend inline fun BehaviourContext.waitEventsMessages( @@ -193,11 +194,16 @@ suspend fun BehaviourContext.waitChatSharedRequestEventsMessages( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEventsMessages(initRequest, errorFactory) -suspend fun BehaviourContext.waitUserSharedEventsMessages( +suspend fun BehaviourContext.waitUsersSharedEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitUserSharedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitUsersSharedEventsMessages(initRequest, errorFactory).filter { it.chatEvent.userIds.size == 1 } + suspend fun BehaviourContext.waitChatSharedEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 5826757feb..6fe38413da 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByCha import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull import dev.inmo.tgbotapi.extensions.utils.chatEventMessageOrNull import dev.inmo.tgbotapi.types.message.ChatEvents.* @@ -775,7 +776,7 @@ suspend fun BC.onChatSharedRequest( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BC.onUserShared( +suspend fun BC.onUsersShared( initialFilter: SimpleFilter>? = null, subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, @@ -783,6 +784,26 @@ suspend fun BC.onUserShared( ) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onUserShared( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onUsersShared(initialFilter * { it.chatEvent.userIds.size == 1 }, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + + /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt index 6af5aa3a24..5cf259e63a 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.reply.requestChatReplyButton import dev.inmo.tgbotapi.types.buttons.reply.requestUserReplyButton import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights +import dev.inmo.tgbotapi.types.keyboardButtonRequestUserLimit import dev.inmo.tgbotapi.types.request.RequestId import dev.inmo.tgbotapi.types.webapps.WebAppInfo import dev.inmo.tgbotapi.utils.* @@ -137,7 +138,7 @@ inline fun ReplyKeyboardRowBuilder.webAppButton( * @see replyKeyboard * @see ReplyKeyboardBuilder.row */ -inline fun ReplyKeyboardRowBuilder.requestUserButton( +inline fun ReplyKeyboardRowBuilder.requestUsersButton( text: String, requestUser: KeyboardButtonRequestUsers ) = add( @@ -147,6 +148,33 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( ) ) +/** + * Creates and put [RequestUserKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +@Deprecated("Renamed", ReplaceWith("requestUsersButton(text, requestUser)", "dev.inmo.tgbotapi.extensions.utils.types.buttons")) +inline fun ReplyKeyboardRowBuilder.requestUserButton( + text: String, + requestUser: KeyboardButtonRequestUsers +) = requestUsersButton(text, requestUser) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestBotsButton( + text: String, + requestId: RequestId, + maxCount: Int +) = requestUsersButton( + text, + KeyboardButtonRequestUsers.Bot(requestId, maxCount) +) + /** * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] * @@ -156,9 +184,26 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( inline fun ReplyKeyboardRowBuilder.requestBotButton( text: String, requestId: RequestId -) = requestUserButton( +) = requestBotsButton( text, - KeyboardButtonRequestUsers.Bot(requestId) + requestId, + maxCount = keyboardButtonRequestUserLimit.first +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestUsersButton( + text: String, + requestId: RequestId, + premiumUser: Boolean? = null, + maxCount: Int +) = requestUsersButton( + text, + KeyboardButtonRequestUsers.Common(requestId, premiumUser, maxCount) ) /** @@ -171,9 +216,21 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( text: String, requestId: RequestId, premiumUser: Boolean? = null -) = requestUserButton( +) = requestUsersButton(text, requestId, premiumUser, maxCount = keyboardButtonRequestUserLimit.first) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestUsersOrBotsButton( + text: String, + requestId: RequestId, + maxCount: Int +) = requestUsersButton( text, - KeyboardButtonRequestUsers.Common(requestId, premiumUser) + KeyboardButtonRequestUsers.Any(requestId, maxCount) ) /** @@ -185,9 +242,10 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( inline fun ReplyKeyboardRowBuilder.requestUserOrBotButton( text: String, requestId: RequestId -) = requestUserButton( +) = requestUsersOrBotsButton( text, - KeyboardButtonRequestUsers.Any(requestId) + requestId, + maxCount = keyboardButtonRequestUserLimit.first ) From bdae774c6210d8b171140c372f7f630900fe622a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 10 Jan 2024 14:59:41 +0600 Subject: [PATCH 56/65] add EncodeDefault for required fields in LinkPreviewOptions --- .../dev/inmo/tgbotapi/types/LinkPreviewOptions.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt index 89b067ef93..c998468b48 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -1,9 +1,6 @@ package dev.inmo.tgbotapi.types -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Required -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -19,6 +16,7 @@ sealed interface LinkPreviewOptions { @Serializable data object Disabled : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = true override val url: String? @@ -39,9 +37,11 @@ sealed interface LinkPreviewOptions { override val showAboveText: Boolean ) : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = false @Required + @EncodeDefault @SerialName(preferLargeMediaField) override val preferLargeMedia: Boolean = true override val preferSmallMedia: Boolean @@ -56,9 +56,11 @@ sealed interface LinkPreviewOptions { override val showAboveText: Boolean ) : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = false @Required + @EncodeDefault @SerialName(preferSmallMediaField) override val preferSmallMedia: Boolean = true override val preferLargeMedia: Boolean @@ -73,6 +75,7 @@ sealed interface LinkPreviewOptions { override val showAboveText: Boolean ) : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = false override val preferSmallMedia: Boolean From 86c86dfb8addc4e2f1e1d8354f1fcaae4f7e237b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 10 Jan 2024 16:46:36 +0600 Subject: [PATCH 57/65] fixes in LinkPreviewOptions --- .../ktor/base/AbstractRequestCallFactory.kt | 11 ++++++- .../inmo/tgbotapi/types/LinkPreviewOptions.kt | 29 ++++++++++--------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt index f950f30e5b..9a633f38a5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory.kt @@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.bot.exceptions.newRequestException import dev.inmo.tgbotapi.requests.GetUpdatesRequest import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.Response +import dev.inmo.tgbotapi.types.message.textsources.pre import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import io.ktor.client.HttpClient @@ -16,6 +17,7 @@ import io.ktor.client.plugins.timeout import io.ktor.client.request.* import io.ktor.client.statement.bodyAsText import io.ktor.http.ContentType +import io.ktor.http.content.* import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import kotlin.collections.set @@ -33,7 +35,14 @@ abstract class AbstractRequestCallFactory( jsonFormatter: Json ): T? { val preparedBody = prepareCallBody(client, urlsKeeper, request) ?: return null - logger.v { "Prepared body for $request: $preparedBody" } + logger.v { + val bodyValue = if (preparedBody is TextContent) { + preparedBody.text + } else { + preparedBody.toString() + } + "Prepared body for $request: $bodyValue" + } client.post { url( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt index c998468b48..5890f7d686 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -13,7 +13,7 @@ sealed interface LinkPreviewOptions { val preferLargeMedia: Boolean val showAboveText: Boolean - @Serializable + @Serializable(LinkPreviewOptions.Companion::class) data object Disabled : LinkPreviewOptions { @Required @EncodeDefault @@ -29,7 +29,7 @@ sealed interface LinkPreviewOptions { get() = false } - @Serializable + @Serializable(LinkPreviewOptions.Companion::class) data class Large( @SerialName(urlField) override val url: String?, @@ -48,7 +48,7 @@ sealed interface LinkPreviewOptions { get() = false } - @Serializable + @Serializable(LinkPreviewOptions.Companion::class) data class Small( @SerialName(urlField) override val url: String?, @@ -67,7 +67,7 @@ sealed interface LinkPreviewOptions { get() = false } - @Serializable + @Serializable(LinkPreviewOptions.Companion::class) data class Default( @SerialName(urlField) override val url: String?, @@ -96,9 +96,7 @@ sealed interface LinkPreviewOptions { val preferLargeMedia: Boolean = false, @SerialName(showAboveTextField) val showAboveText: Boolean = false, - ) { - - } + ) companion object : KSerializer { override val descriptor: SerialDescriptor @@ -116,13 +114,16 @@ sealed interface LinkPreviewOptions { } override fun serialize(encoder: Encoder, value: LinkPreviewOptions) { - when (value) { - is Disabled -> Disabled.serializer().serialize(encoder, value) - is Large -> Large.serializer().serialize(encoder, value) - is Default -> Default.serializer().serialize(encoder, value) - is Small -> Small.serializer().serialize(encoder, value) - } + Surrogate.serializer().serialize( + encoder, + Surrogate( + isDisabled = value.isDisabled, + url = value.url, + preferSmallMedia = value.preferSmallMedia, + preferLargeMedia = value.preferLargeMedia, + showAboveText = value.showAboveText + ) + ) } - } } \ No newline at end of file From 89524290c5f40ad522af1e1b759854478221f2c8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 10 Jan 2024 23:05:44 +0600 Subject: [PATCH 58/65] improve users shared DSLs --- .../buttons/KeyboardButtonRequestUsers.kt | 9 ++- .../reply/ReplyKeyboardButtonsShortcuts.kt | 68 +++++++++++++++++-- .../types/buttons/ReplyKeyboardBuilder.kt | 12 ++-- 3 files changed, 75 insertions(+), 14 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUsers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUsers.kt index 152284564b..6d5cd42911 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUsers.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonRequestUsers.kt @@ -17,12 +17,15 @@ import kotlinx.serialization.encoding.Encoder sealed interface KeyboardButtonRequestUsers { val requestId: RequestId val isBot: Boolean? + val isPremium: Boolean? val maxCount: Int @Serializable data class Any( @SerialName(requestIdField) override val requestId: RequestId, + @SerialName(userIsPremiumField) + override val isPremium: Boolean? = null, @SerialName(maxQuantityField) override val maxCount: Int = keyboardButtonRequestUserLimit.first ) : KeyboardButtonRequestUsers { @@ -36,7 +39,7 @@ sealed interface KeyboardButtonRequestUsers { @SerialName(requestIdField) override val requestId: RequestId, @SerialName(userIsPremiumField) - val isPremium: Boolean? = null, + override val isPremium: Boolean? = null, @SerialName(maxQuantityField) override val maxCount: Int = keyboardButtonRequestUserLimit.first ) : KeyboardButtonRequestUsers { @@ -55,6 +58,8 @@ sealed interface KeyboardButtonRequestUsers { @SerialName(userIsBotField) @EncodeDefault override val isBot: Boolean = true + override val isPremium: Boolean? + get() = null } @Serializer(KeyboardButtonRequestUsers::class) @@ -80,7 +85,7 @@ sealed interface KeyboardButtonRequestUsers { return when (surrogate.userIsBot) { true -> Bot(surrogate.requestId, surrogate.maxCount) false -> Common(surrogate.requestId, surrogate.userIsPremium, surrogate.maxCount) - null -> Any(surrogate.requestId, surrogate.maxCount) + null -> Any(surrogate.requestId, surrogate.userIsPremium, surrogate.maxCount) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt index 87bed43fa4..ad759efec4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt @@ -2,8 +2,10 @@ package dev.inmo.tgbotapi.types.buttons.reply import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights +import dev.inmo.tgbotapi.types.keyboardButtonRequestUserLimit import dev.inmo.tgbotapi.types.request.RequestId import dev.inmo.tgbotapi.types.webapps.WebAppInfo +import kotlin.math.max /** @@ -55,7 +57,7 @@ inline fun webAppReplyButton( /** * Creates [RequestUserKeyboardButton] */ -inline fun requestUserReplyButton( +inline fun requestUsersReplyButton( text: String, requestUser: KeyboardButtonRequestUsers ) = RequestUserKeyboardButton( @@ -63,15 +65,51 @@ inline fun requestUserReplyButton( requestUser ) + +/** + * Creates [RequestUserKeyboardButton] + */ +@Deprecated("Renamed", ReplaceWith("requestUsersReplyButton(text, requestUser)", "dev.inmo.tgbotapi.types.buttons.reply.requestUsersReplyButton")) +inline fun requestUserReplyButton( + text: String, + requestUser: KeyboardButtonRequestUsers +) = requestUsersReplyButton(text, requestUser) + /** * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] */ +inline fun requestBotsReplyButton( + text: String, + requestId: RequestId, + maxCount: Int = keyboardButtonRequestUserLimit.first +) = requestUsersReplyButton( + text, + KeyboardButtonRequestUsers.Bot(requestId, maxCount) +) + +/** + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] + */ +@Deprecated("Renamed", ReplaceWith("requestBotsReplyButton(text, requestId)", "dev.inmo.tgbotapi.types.buttons.reply.requestBotsReplyButton")) inline fun requestBotReplyButton( text: String, - requestId: RequestId -) = requestUserReplyButton( + requestId: RequestId, +) = requestBotsReplyButton( text, - KeyboardButtonRequestUsers.Bot(requestId) + requestId, +) + +/** + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common] + */ +inline fun requestUsersReplyButton( + text: String, + requestId: RequestId, + premiumUser: Boolean? = null, + maxCount: Int = keyboardButtonRequestUserLimit.first +) = requestUsersReplyButton( + text, + KeyboardButtonRequestUsers.Common(requestId, premiumUser, maxCount) ) /** @@ -80,10 +118,26 @@ inline fun requestBotReplyButton( inline fun requestUserReplyButton( text: String, requestId: RequestId, - premiumUser: Boolean? = null -) = requestUserReplyButton( + premiumUser: Boolean? = null, + maxCount: Int = keyboardButtonRequestUserLimit.first +) = requestUsersReplyButton( text, - KeyboardButtonRequestUsers.Common(requestId, premiumUser) + requestId, + premiumUser, + maxCount +) + +/** + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any] + */ +inline fun requestUsersOrBotsReplyButton( + text: String, + requestId: RequestId, + premiumUser: Boolean? = null, + maxCount: Int = keyboardButtonRequestUserLimit.first +) = requestUsersReplyButton( + text, + KeyboardButtonRequestUsers.Any(requestId, premiumUser, maxCount) ) /** diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt index 5cf259e63a..0468a17939 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.utils.types.buttons import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.reply.requestChatReplyButton import dev.inmo.tgbotapi.types.buttons.reply.requestUserReplyButton +import dev.inmo.tgbotapi.types.buttons.reply.requestUsersReplyButton import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights import dev.inmo.tgbotapi.types.keyboardButtonRequestUserLimit import dev.inmo.tgbotapi.types.request.RequestId @@ -142,7 +143,7 @@ inline fun ReplyKeyboardRowBuilder.requestUsersButton( text: String, requestUser: KeyboardButtonRequestUsers ) = add( - requestUserReplyButton( + requestUsersReplyButton( text, requestUser ) @@ -169,7 +170,7 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( inline fun ReplyKeyboardRowBuilder.requestBotsButton( text: String, requestId: RequestId, - maxCount: Int + maxCount: Int = keyboardButtonRequestUserLimit.first ) = requestUsersButton( text, KeyboardButtonRequestUsers.Bot(requestId, maxCount) @@ -200,7 +201,7 @@ inline fun ReplyKeyboardRowBuilder.requestUsersButton( text: String, requestId: RequestId, premiumUser: Boolean? = null, - maxCount: Int + maxCount: Int = keyboardButtonRequestUserLimit.first ) = requestUsersButton( text, KeyboardButtonRequestUsers.Common(requestId, premiumUser, maxCount) @@ -227,10 +228,11 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( inline fun ReplyKeyboardRowBuilder.requestUsersOrBotsButton( text: String, requestId: RequestId, - maxCount: Int + premiumUser: Boolean? = null, + maxCount: Int = keyboardButtonRequestUserLimit.first ) = requestUsersButton( text, - KeyboardButtonRequestUsers.Any(requestId, maxCount) + KeyboardButtonRequestUsers.Any(requestId, premiumUser, maxCount) ) /** From 4d92588390613d41c4d6034f38102bacf6c138e9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Jan 2024 01:11:57 +0600 Subject: [PATCH 59/65] update changelog --- CHANGELOG.md | 11 +++++++++++ gradle/libs.versions.toml | 2 +- .../kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt | 2 +- .../dev/inmo/tgbotapi/types/message/RawMessage.kt | 2 +- .../inmo/tgbotapi/types/message/abstracts/Message.kt | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4891f3983..6eda7f1847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ **IN THIS UPDATE KRYPTO DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-crypto` UP TO 5.3.0 VERSION** +* `Version`: + * `MicroUtils`: `0.20.23` -> `0.20.26` + * `Korlibs`: `4.0.10` -> `5.3.0` +* `Core`: + * `Message` now inherited by two variants: `AccessibleMessage` and `InaccessibleMessage` +* `Common`: + * In most places `disableWebPagePreview` has been replaced by new `LinkPreviewOptions` + * In most places arguments `replyToMessageId` and `allowSendingWithoutReply` has been replaced with + `ReplyParameters` + * In `reply` extension two parameters have been added: `replyInChatId` and `replyInThreadId` + ## 9.4.3 **IetfLanguageCode has been renamed to IetfLang in MicroUtils** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c27a805358..a45ca4b8f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ ktor = "2.3.7" ksp = "1.9.22-1.0.16" kotlin-poet = "1.15.3" -microutils = "0.20.25" +microutils = "0.20.26" kslog = "1.3.1" versions = "0.50.0" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt index 21b5244bde..419a3bba83 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt @@ -28,7 +28,7 @@ sealed interface ReplyInfo { val messageMeta: Message.MetaInfo? data class Internal( - val message: AccessibleMessage + val message: Message ): ReplyInfo { override val messageMeta: Message.MetaInfo get() = message.metaInfo 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 e28264eda0..0a8735da19 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 @@ -251,7 +251,7 @@ internal data class RawMessage( } } - val asMessage: AccessibleMessage by lazy { + val asMessage: Message by lazy { if (date.date == 0L) { return@lazy InaccessibleMessage( chat, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt index 69a1906a3c..e439de4b23 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt @@ -49,7 +49,7 @@ interface AccessibleMessage : Message data class InaccessibleMessage( override val chat: PreviewChat, override val messageId: MessageId, -) : AccessibleMessage { +) : Message { override val date: DateTime get() = DateTime.invoke(0L) } From d88fc2c9c02b1ccc8b4f7865e8ee3e9857f8ef60 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Jan 2024 01:18:25 +0600 Subject: [PATCH 60/65] rename replyInChat -> replyInChatId; replace AccessibleMessage by Message in Reply parts --- .../tgbotapi/extensions/api/send/Replies.kt | 446 +++++++++--------- .../api/send/RepliesWithChatsAndMessages.kt | 446 +++++++++--------- .../message/abstracts/PossiblyReplyMessage.kt | 2 +- .../utils/extensions/raw/Message.kt | 2 +- 4 files changed, 448 insertions(+), 448 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index a05460af2c..011f690eac 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -47,14 +47,14 @@ suspend inline fun TelegramBot.reply( phoneNumber: String, firstName: String, lastName: String? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - replyInChat, + replyInChatId, phoneNumber, firstName, lastName, @@ -72,14 +72,14 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( to: AccessibleMessage, contact: Contact, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - replyInChat, + replyInChatId, contact, replyInThreadId, disableNotification, @@ -98,13 +98,13 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithDice( to: AccessibleMessage, animationType: DiceAnimationType? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(replyInChat, animationType, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendDice(replyInChatId, animationType, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -113,13 +113,13 @@ suspend inline fun TelegramBot.replyWithDice( suspend inline fun TelegramBot.reply( to: AccessibleMessage, animationType: DiceAnimationType, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(to, animationType, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(to, animationType, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -132,14 +132,14 @@ suspend inline fun TelegramBot.reply( to: AccessibleMessage, latitude: Double, longitude: Double, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - replyInChat, + replyInChatId, latitude, longitude, replyInThreadId, @@ -156,14 +156,14 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( to: AccessibleMessage, location: StaticLocation, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - replyInChat, + replyInChatId, location, replyInThreadId, disableNotification, @@ -184,14 +184,14 @@ suspend inline fun TelegramBot.reply( text: String, parseMode: ParseMode? = null, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - replyInChat, + replyInChatId, text, parseMode, linkPreviewOptions, @@ -210,14 +210,14 @@ suspend inline fun TelegramBot.reply( to: AccessibleMessage, entities: TextSourcesList, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - replyInChat, + replyInChatId, entities, linkPreviewOptions, replyInThreadId, @@ -235,14 +235,14 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, separator: TextSource? = null, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -252,14 +252,14 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, separator: String, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -278,14 +278,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = replyInChat, + chatId = replyInChatId, latitude = latitude, longitude = longitude, title = title, @@ -310,14 +310,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = replyInChat, + chatId = replyInChatId, latitude = location.latitude, longitude = location.longitude, title = title, @@ -336,14 +336,14 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( to: AccessibleMessage, venue: Venue, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = replyInChat, + chatId = replyInChatId, venue = venue, threadId = replyInThreadId, disableNotification = disableNotification, @@ -358,39 +358,39 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithGame( to: AccessibleMessage, gameShortName: String, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - replyInChat, gameShortName, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChatId, gameShortName, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( to: AccessibleMessage, game: Game, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - replyInChat, game.title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChatId, game.title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( to: AccessibleMessage, game: Game, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(to, game, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(to, game, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation @@ -405,14 +405,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - replyInChat, + replyInChatId, animation, thumb, text, @@ -437,13 +437,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(replyInChat, animation, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChatId, animation, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( to: AccessibleMessage, @@ -454,14 +454,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - replyInChat, + replyInChatId, animation, thumb, entities, @@ -484,13 +484,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(replyInChat, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChatId, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio @@ -504,13 +504,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, thumb, text, parseMode, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, thumb, text, parseMode, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -518,13 +518,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, title: String? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( to: AccessibleMessage, @@ -534,26 +534,26 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, thumb, entities, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, thumb, entities, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, audio: AudioFile, entities: TextSourcesList, title: String? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents @@ -564,55 +564,55 @@ suspend inline fun TelegramBot.replyWithDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, thumb, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, thumb, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( to: AccessibleMessage, document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, thumb, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, thumb, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: AccessibleMessage, document: DocumentFile, entities: TextSourcesList, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @@ -621,42 +621,42 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithMediaGroup( to: AccessibleMessage, media: List, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( to: AccessibleMessage, media: List, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendPlaylist(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( to: AccessibleMessage, media: List, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendDocumentsGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( to: AccessibleMessage, media: List, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendVisualMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo @@ -667,13 +667,13 @@ suspend inline fun TelegramBot.replyWithPhoto( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -681,13 +681,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -695,13 +695,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -709,39 +709,39 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, photo: Photo, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, photoSize: PhotoSize, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker @@ -750,25 +750,25 @@ suspend inline fun TelegramBot.replyWithSticker( to: AccessibleMessage, sticker: InputFile, emoji: String? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChatId, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, sticker: Sticker, emoji: String? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChatId, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos @@ -783,13 +783,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, thumb, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChatId, video, thumb, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -797,13 +797,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChatId, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( to: AccessibleMessage, @@ -814,26 +814,26 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, thumb, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChatId, video, thumb, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, video: VideoFile, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideo(replyInChatId, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // VideoNotes @@ -844,24 +844,24 @@ suspend inline fun TelegramBot.replyWithVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(replyInChat, videoNote, thumb, duration, size, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideoNote(replyInChatId, videoNote, thumb, duration, size, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, videoNote: VideoNoteFile, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(replyInChat, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVideoNote(replyInChatId, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Voice @@ -872,26 +872,26 @@ suspend inline fun TelegramBot.replyWithVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChatId, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChatId, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -899,25 +899,25 @@ suspend inline fun TelegramBot.replyWithVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, entities, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChatId, voice, entities, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, voice: VoiceFile, entities: TextSourcesList, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendVoice(replyInChatId, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Invoice @@ -945,13 +945,13 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(replyInChat, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendInvoice(replyInChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Polls @@ -964,13 +964,13 @@ suspend inline fun TelegramBot.reply( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(replyInChat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendRegularPoll(replyInChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -981,13 +981,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(replyInChat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendRegularPoll(replyInChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -999,13 +999,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -1018,13 +1018,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -1035,13 +1035,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, @@ -1053,13 +1053,13 @@ suspend inline fun TelegramBot.reply( correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), isAnonymous: Boolean = quizPoll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) +) = sendQuizPoll(replyInChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( @@ -1070,8 +1070,8 @@ suspend inline fun TelegramBot.reply( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1086,7 +1086,7 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1103,7 +1103,7 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1119,14 +1119,14 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( - replyInChat, + replyInChatId, fromChatId, messageId, text, @@ -1144,39 +1144,39 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(to, fromChat.id, messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, fromChat.id, messageId, text, parseMode, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: AccessibleMessage, copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(to, copy.chat.id, copy.messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, copy.chat.id, copy.messageId, text, parseMode, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( to: AccessibleMessage, content: MessageContent, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ): AccessibleMessage = execute( content.createResend( - replyInChat, + replyInChatId, replyInThreadId, disableNotification, protectContent, @@ -1194,13 +1194,13 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) = handleLiveLocation( - replyInChat, + replyInChatId, locationsFlow, liveTimeMillis, replyInThreadId, @@ -1220,14 +1220,14 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - replyInChat, + replyInChatId, locationsFlow, liveTimeMillis, replyInThreadId, @@ -1248,14 +1248,14 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - replyInChat, + replyInChatId, locationsFlow, liveTimeMillis, replyInThreadId, @@ -1268,8 +1268,8 @@ suspend fun TelegramBot.reply( suspend fun TelegramBot.reply( to: AccessibleMessage, mediaFile: TelegramMediaFile, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1279,7 +1279,7 @@ suspend fun TelegramBot.reply( is AudioFile -> reply( to = to, audio = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1289,7 +1289,7 @@ suspend fun TelegramBot.reply( is AnimationFile -> reply( to = to, animation = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1299,7 +1299,7 @@ suspend fun TelegramBot.reply( is VoiceFile -> reply( to = to, voice = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1309,7 +1309,7 @@ suspend fun TelegramBot.reply( is VideoFile -> reply( to = to, video = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1319,7 +1319,7 @@ suspend fun TelegramBot.reply( is VideoNoteFile -> reply( to = to, videoNote = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1329,7 +1329,7 @@ suspend fun TelegramBot.reply( is DocumentFile -> reply( to = to, document = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1339,7 +1339,7 @@ suspend fun TelegramBot.reply( is Sticker -> reply( to = to, sticker = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1349,7 +1349,7 @@ suspend fun TelegramBot.reply( is PhotoSize -> reply( to = to, photoSize = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1359,7 +1359,7 @@ suspend fun TelegramBot.reply( else -> reply( to = to, document = mediaFile.asDocumentFile(), - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1374,8 +1374,8 @@ suspend fun TelegramBot.reply( content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1387,7 +1387,7 @@ suspend fun TelegramBot.reply( voice = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1399,7 +1399,7 @@ suspend fun TelegramBot.reply( audio = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1411,7 +1411,7 @@ suspend fun TelegramBot.reply( photoSize = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1423,7 +1423,7 @@ suspend fun TelegramBot.reply( video = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1435,7 +1435,7 @@ suspend fun TelegramBot.reply( animation = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1447,7 +1447,7 @@ suspend fun TelegramBot.reply( document = content.media.asDocumentFile(), text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1461,8 +1461,8 @@ suspend fun TelegramBot.reply( to: AccessibleMessage, content: TextedMediaContent, entities: TextSourcesList, - replyInChat: IdChatIdentifier = to.chat.id, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1473,7 +1473,7 @@ suspend fun TelegramBot.reply( to = to, voice = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1484,7 +1484,7 @@ suspend fun TelegramBot.reply( to = to, audio = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1495,7 +1495,7 @@ suspend fun TelegramBot.reply( to = to, photoSize = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1506,7 +1506,7 @@ suspend fun TelegramBot.reply( to = to, video = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1517,7 +1517,7 @@ suspend fun TelegramBot.reply( to = to, animation = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1528,7 +1528,7 @@ suspend fun TelegramBot.reply( to = to, document = content.media.asDocumentFile(), entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index eec896e704..e2e2455bbb 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -47,14 +47,14 @@ suspend inline fun TelegramBot.reply( phoneNumber: String, firstName: String, lastName: String? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - replyInChat, + replyInChatId, phoneNumber, firstName, lastName, @@ -73,14 +73,14 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, contact: Contact, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - replyInChat, + replyInChatId, contact, replyInThreadId, disableNotification, @@ -100,13 +100,13 @@ suspend inline fun TelegramBot.replyWithDice( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(replyInChat, animationType, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendDice(replyInChatId, animationType, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -116,13 +116,13 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(toChatId, toMessageId, animationType, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(toChatId, toMessageId, animationType, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -136,14 +136,14 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, latitude: Double, longitude: Double, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - replyInChat, + replyInChatId, latitude, longitude, replyInThreadId, @@ -161,14 +161,14 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, location: StaticLocation, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - replyInChat, + replyInChatId, location, replyInThreadId, disableNotification, @@ -190,14 +190,14 @@ suspend inline fun TelegramBot.reply( text: String, parseMode: ParseMode? = null, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - replyInChat, + replyInChatId, text, parseMode, linkPreviewOptions, @@ -217,14 +217,14 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, entities: TextSourcesList, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - replyInChat, + replyInChatId, entities, linkPreviewOptions, replyInThreadId, @@ -243,14 +243,14 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: TextSource? = null, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -261,14 +261,14 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: String, linkPreviewOptions: LinkPreviewOptions? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -288,14 +288,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = replyInChat, + chatId = replyInChatId, latitude = latitude, longitude = longitude, title = title, @@ -321,14 +321,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = replyInChat, + chatId = replyInChatId, latitude = location.latitude, longitude = location.longitude, title = title, @@ -348,14 +348,14 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, venue: Venue, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = replyInChat, + chatId = replyInChatId, venue = venue, threadId = replyInThreadId, disableNotification = disableNotification, @@ -371,41 +371,41 @@ suspend inline fun TelegramBot.replyWithGame( toChatId: IdChatIdentifier, toMessageId: MessageId, gameShortName: String, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - replyInChat, gameShortName, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChatId, gameShortName, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - replyInChat, game.title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup + replyInChatId, game.title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(toChatId, toMessageId, game, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(toChatId, toMessageId, game, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation @@ -421,14 +421,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - replyInChat, + replyInChatId, animation, thumb, text, @@ -454,13 +454,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(replyInChat, animation, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChatId, animation, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( toChatId: IdChatIdentifier, @@ -472,14 +472,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - replyInChat, + replyInChatId, animation, thumb, entities, @@ -503,13 +503,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(replyInChat, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAnimation(replyInChatId, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio @@ -524,13 +524,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, thumb, text, parseMode, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, thumb, text, parseMode, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -539,13 +539,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, title: String? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( toChatId: IdChatIdentifier, @@ -556,13 +556,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, thumb, entities, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, thumb, entities, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -570,13 +570,13 @@ suspend inline fun TelegramBot.reply( audio: AudioFile, entities: TextSourcesList, title: String? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(replyInChat, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendAudio(replyInChatId, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents @@ -588,14 +588,14 @@ suspend inline fun TelegramBot.replyWithDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, thumb, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, thumb, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -603,14 +603,14 @@ suspend inline fun TelegramBot.reply( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( toChatId: IdChatIdentifier, @@ -618,28 +618,28 @@ suspend inline fun TelegramBot.replyWithDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, thumb, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, thumb, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, document: DocumentFile, entities: TextSourcesList, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(replyInChat, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @@ -649,45 +649,45 @@ suspend inline fun TelegramBot.replyWithMediaGroup( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendPlaylist(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendDocumentsGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(replyInChat, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) +) = sendVisualMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo @@ -699,13 +699,13 @@ suspend inline fun TelegramBot.replyWithPhoto( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -714,13 +714,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -729,13 +729,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -744,13 +744,13 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -758,13 +758,13 @@ suspend inline fun TelegramBot.reply( photo: Photo, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -772,13 +772,13 @@ suspend inline fun TelegramBot.reply( photoSize: PhotoSize, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(replyInChat, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendPhoto(replyInChatId, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker @@ -787,27 +787,27 @@ suspend inline fun TelegramBot.replyWithSticker( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: InputFile, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChatId, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: Sticker, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(replyInChat, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendSticker(replyInChatId, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos @@ -823,13 +823,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, thumb, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChatId, video, thumb, text, parseMode, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -838,13 +838,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChatId, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( toChatId: IdChatIdentifier, @@ -856,13 +856,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, thumb, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChatId, video, thumb, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -870,13 +870,13 @@ suspend inline fun TelegramBot.reply( video: VideoFile, entities: TextSourcesList, spoilered: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(replyInChat, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideo(replyInChatId, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // VideoNotes @@ -888,25 +888,25 @@ suspend inline fun TelegramBot.replyWithVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(replyInChat, videoNote, thumb, duration, size, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideoNote(replyInChatId, videoNote, thumb, duration, size, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, videoNote: VideoNoteFile, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(replyInChat, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVideoNote(replyInChatId, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Voice @@ -918,13 +918,13 @@ suspend inline fun TelegramBot.replyWithVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChatId, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -932,13 +932,13 @@ suspend inline fun TelegramBot.reply( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChatId, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -947,26 +947,26 @@ suspend inline fun TelegramBot.replyWithVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, entities, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChatId, voice, entities, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, voice: VoiceFile, entities: TextSourcesList, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(replyInChat, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendVoice(replyInChatId, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Invoice @@ -995,13 +995,13 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(replyInChat, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendInvoice(replyInChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Polls @@ -1015,13 +1015,13 @@ suspend inline fun TelegramBot.reply( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(replyInChat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendRegularPoll(replyInChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1033,13 +1033,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(replyInChat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendRegularPoll(replyInChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1052,13 +1052,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1072,13 +1072,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1090,13 +1090,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1109,13 +1109,13 @@ suspend inline fun TelegramBot.reply( correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), isAnonymous: Boolean = quizPoll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(replyInChat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) +) = sendQuizPoll(replyInChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( @@ -1127,8 +1127,8 @@ suspend inline fun TelegramBot.reply( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1144,7 +1144,7 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1162,7 +1162,7 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1179,14 +1179,14 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( - replyInChat, + replyInChatId, fromChatId, messageId, text, @@ -1205,13 +1205,13 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -1219,20 +1219,20 @@ suspend inline fun TelegramBot.reply( copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, replyInChat, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, content: MessageContent, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1240,7 +1240,7 @@ suspend fun TelegramBot.reply( ) { execute( content.createResend( - replyInChat, + replyInChatId, replyInThreadId, disableNotification, protectContent, @@ -1260,13 +1260,13 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) = handleLiveLocation( - replyInChat, + replyInChatId, locationsFlow, liveTimeMillis, replyInThreadId, @@ -1287,14 +1287,14 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - replyInChat, + replyInChatId, locationsFlow, liveTimeMillis, replyInThreadId, @@ -1316,14 +1316,14 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - replyInChat, + replyInChatId, locationsFlow, liveTimeMillis, replyInThreadId, @@ -1337,8 +1337,8 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, mediaFile: TelegramMediaFile, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1349,7 +1349,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, audio = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1360,7 +1360,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, animation = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1371,7 +1371,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, voice = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1382,7 +1382,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, video = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1393,7 +1393,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, videoNote = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1404,7 +1404,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, document = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1415,7 +1415,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, sticker = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1426,7 +1426,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, photoSize = mediaFile, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1437,7 +1437,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, document = mediaFile.asDocumentFile(), - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1453,8 +1453,8 @@ suspend fun TelegramBot.reply( content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1467,7 +1467,7 @@ suspend fun TelegramBot.reply( voice = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1480,7 +1480,7 @@ suspend fun TelegramBot.reply( audio = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1493,7 +1493,7 @@ suspend fun TelegramBot.reply( photoSize = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1506,7 +1506,7 @@ suspend fun TelegramBot.reply( video = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1519,7 +1519,7 @@ suspend fun TelegramBot.reply( animation = content.media, text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1532,7 +1532,7 @@ suspend fun TelegramBot.reply( document = content.media.asDocumentFile(), text = text, parseMode = parseMode, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1547,8 +1547,8 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, content: TextedMediaContent, entities: List, - replyInChat: IdChatIdentifier = toChatId, - replyInThreadId: MessageThreadId? = replyInChat.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1560,7 +1560,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, voice = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1572,7 +1572,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, audio = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1584,7 +1584,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, photoSize = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1596,7 +1596,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, video = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1608,7 +1608,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, animation = content.media, entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, @@ -1620,7 +1620,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, document = content.media.asDocumentFile(), entities = entities, - replyInChat = replyInChat, + replyInChatId = replyInChatId, replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt index 7a59546392..001377e7ef 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyReplyMessage.kt @@ -4,6 +4,6 @@ import dev.inmo.tgbotapi.types.ReplyInfo interface PossiblyReplyMessage { val replyInfo: ReplyInfo? - val replyTo: AccessibleMessage? + val replyTo: Message? get() = (replyInfo as? ReplyInfo.Internal) ?.message } \ No newline at end of file diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index 9b65ae7a90..f4e20698bb 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -50,7 +50,7 @@ inline val AccessibleMessage.forward_date: TelegramDate? inline val AccessibleMessage.is_automatic_forward: Boolean? get() = this is ConnectedFromChannelGroupContentMessage<*> @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.reply_to_message: AccessibleMessage? +inline val AccessibleMessage.reply_to_message: Message? get() = asPossiblyReplyMessage() ?.replyTo @RiskFeature(RawFieldsUsageWarning) inline val AccessibleMessage.via_bot: CommonBot? From 852065ad387164bf11c6421e6290b213c2104f98 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Jan 2024 01:44:56 +0600 Subject: [PATCH 61/65] get back LinksFormatting for Message --- .../tgbotapi/extensions/utils/formatting/LinksFormatting.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt index 5364f4cdda..a158750400 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.formatting import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.* -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.textsources.link import io.ktor.http.encodeURLQueryComponent @@ -69,7 +69,7 @@ fun makeLinkToMessage( ): String = makeLinkToMessage(chatId.chatId, messageId, chatId.threadId) /** - * Link which can be used as by any user to get access to [AccessibleMessage]. Returns null in case when there are no + * Link which can be used as by any user to get access to [Message]. Returns null in case when there are no * known way to build link (for [PrivateChat]s, for example) */ fun makeLinkToMessage( @@ -88,7 +88,7 @@ fun makeLinkToMessage( /** * @see makeLinkToMessage */ -val AccessibleMessage.messageLink: String? +val Message.messageLink: String? get() = makeLinkToMessage( chat, messageId From 66e31e5d0c8f6c01dbd67dac8f13b79b31d282b2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Jan 2024 01:53:40 +0600 Subject: [PATCH 62/65] fixes in AccessibleMessage -> Message in several old parts --- .../tgbotapi/extensions/utils/ClassCasts.kt | 186 +++++++++--------- .../utils/extensions/raw/Message.kt | 110 +++++------ 2 files changed, 148 insertions(+), 148 deletions(-) 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 f78dbe92bf..ccb25f7023 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 @@ -978,346 +978,346 @@ inline fun SecureValue.requireSecureValueWithTranslations(): SecureValueWithTran this as SecureValueWithTranslations @PreviewFeature -inline fun AccessibleMessage.whenAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl) -> T) = +inline fun Message.whenAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl) -> T) = asAnonymousGroupContentMessageImpl()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl? = +inline fun Message.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl? = this as? AnonymousGroupContentMessageImpl @PreviewFeature -inline fun AccessibleMessage.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl = +inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl = this as AnonymousGroupContentMessageImpl @PreviewFeature -inline fun AccessibleMessage.whenChannelContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl) -> T) = +inline fun Message.whenChannelContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl) -> T) = asChannelContentMessageImpl()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl? = +inline fun Message.asChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl? = this as? UnconnectedFromChannelGroupContentMessageImpl @PreviewFeature -inline fun AccessibleMessage.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl = +inline fun Message.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl = this as UnconnectedFromChannelGroupContentMessageImpl @PreviewFeature -inline fun AccessibleMessage.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage()?.let(block) +inline fun Message.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPassportMessage(): PassportMessage? = this as? PassportMessage +inline fun Message.asPassportMessage(): PassportMessage? = this as? PassportMessage @PreviewFeature -inline fun AccessibleMessage.requirePassportMessage(): PassportMessage = this as PassportMessage +inline fun Message.requirePassportMessage(): PassportMessage = this as PassportMessage @PreviewFeature -inline fun AccessibleMessage.whenPrivateContentMessageImpl(block: (PrivateContentMessageImpl) -> T) = +inline fun Message.whenPrivateContentMessageImpl(block: (PrivateContentMessageImpl) -> T) = asPrivateContentMessageImpl()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPrivateContentMessageImpl(): PrivateContentMessageImpl? = +inline fun Message.asPrivateContentMessageImpl(): PrivateContentMessageImpl? = this as? PrivateContentMessageImpl @PreviewFeature -inline fun AccessibleMessage.requirePrivateContentMessageImpl(): PrivateContentMessageImpl = +inline fun Message.requirePrivateContentMessageImpl(): PrivateContentMessageImpl = this as PrivateContentMessageImpl @PreviewFeature -inline fun AccessibleMessage.whenChannelEventMessage(block: (ChannelEventMessage) -> T) = +inline fun Message.whenChannelEventMessage(block: (ChannelEventMessage) -> T) = asChannelEventMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asChannelEventMessage(): ChannelEventMessage? = +inline fun Message.asChannelEventMessage(): ChannelEventMessage? = this as? ChannelEventMessage @PreviewFeature -inline fun AccessibleMessage.requireChannelEventMessage(): ChannelEventMessage = +inline fun Message.requireChannelEventMessage(): ChannelEventMessage = this as ChannelEventMessage @PreviewFeature -inline fun AccessibleMessage.whenCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T) = +inline fun Message.whenCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T) = asCommonGroupEventMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asCommonGroupEventMessage(): CommonGroupEventMessage? = +inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = this as? CommonGroupEventMessage @PreviewFeature -inline fun AccessibleMessage.requireCommonGroupEventMessage(): CommonGroupEventMessage = +inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage = this as CommonGroupEventMessage @PreviewFeature -inline fun AccessibleMessage.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T) = +inline fun Message.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T) = asCommonSupergroupEventMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = +inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = this as? CommonSupergroupEventMessage @PreviewFeature -inline fun AccessibleMessage.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = +inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = this as CommonSupergroupEventMessage @PreviewFeature -inline fun AccessibleMessage.whenAnonymousGroupContentMessage(block: (AnonymousGroupContentMessage) -> T) = +inline fun Message.whenAnonymousGroupContentMessage(block: (AnonymousGroupContentMessage) -> T) = asAnonymousGroupContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage? = +inline fun Message.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage? = this as? AnonymousGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage = +inline fun Message.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage = this as AnonymousGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.whenChannelContentMessage(block: (ChannelContentMessage) -> T) = +inline fun Message.whenChannelContentMessage(block: (ChannelContentMessage) -> T) = asChannelContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asChannelContentMessage(): ChannelContentMessage? = +inline fun Message.asChannelContentMessage(): ChannelContentMessage? = this as? ChannelContentMessage @PreviewFeature -inline fun AccessibleMessage.requireChannelContentMessage(): ChannelContentMessage = +inline fun Message.requireChannelContentMessage(): ChannelContentMessage = this as ChannelContentMessage @PreviewFeature -inline fun AccessibleMessage.whenConnectedFromChannelGroupContentMessage(block: (ConnectedFromChannelGroupContentMessage) -> T) = +inline fun Message.whenConnectedFromChannelGroupContentMessage(block: (ConnectedFromChannelGroupContentMessage) -> T) = asConnectedFromChannelGroupContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage? = +inline fun Message.asConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage? = this as? ConnectedFromChannelGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.requireConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage = +inline fun Message.requireConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage = this as ConnectedFromChannelGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.whenUnconnectedFromChannelGroupContentMessage(block: (UnconnectedFromChannelGroupContentMessage) -> T) = +inline fun Message.whenUnconnectedFromChannelGroupContentMessage(block: (UnconnectedFromChannelGroupContentMessage) -> T) = asUnconnectedFromChannelGroupContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage? = +inline fun Message.asUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage? = this as? UnconnectedFromChannelGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.requireUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage = +inline fun Message.requireUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage = this as UnconnectedFromChannelGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.whenChatEventMessage(block: (ChatEventMessage) -> T) = +inline fun Message.whenChatEventMessage(block: (ChatEventMessage) -> T) = asChatEventMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage +inline fun Message.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage @PreviewFeature -inline fun AccessibleMessage.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage +inline fun Message.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage @PreviewFeature -inline fun AccessibleMessage.whenCommonGroupContentMessage(block: (CommonGroupContentMessage) -> T) = +inline fun Message.whenCommonGroupContentMessage(block: (CommonGroupContentMessage) -> T) = asCommonGroupContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asCommonGroupContentMessage(): CommonGroupContentMessage? = +inline fun Message.asCommonGroupContentMessage(): CommonGroupContentMessage? = this as? CommonGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.requireCommonGroupContentMessage(): CommonGroupContentMessage = +inline fun Message.requireCommonGroupContentMessage(): CommonGroupContentMessage = this as CommonGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.whenCommonMessage(block: (CommonMessage) -> T) = asCommonMessage()?.let(block) +inline fun Message.whenCommonMessage(block: (CommonMessage) -> T) = asCommonMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asCommonMessage(): CommonMessage? = this as? CommonMessage +inline fun Message.asCommonMessage(): CommonMessage? = this as? CommonMessage @PreviewFeature -inline fun AccessibleMessage.requireCommonMessage(): CommonMessage = this as CommonMessage +inline fun Message.requireCommonMessage(): CommonMessage = this as CommonMessage @PreviewFeature -inline fun AccessibleMessage.whenContentMessage(block: (ContentMessage) -> T) = asContentMessage()?.let(block) +inline fun Message.whenContentMessage(block: (ContentMessage) -> T) = asContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asContentMessage(): ContentMessage? = this as? ContentMessage +inline fun Message.asContentMessage(): ContentMessage? = this as? ContentMessage @PreviewFeature -inline fun AccessibleMessage.requireContentMessage(): ContentMessage = this as ContentMessage +inline fun Message.requireContentMessage(): ContentMessage = this as ContentMessage @PreviewFeature -inline fun AccessibleMessage.whenFromChannelGroupContentMessage(block: (FromChannelGroupContentMessage) -> T) = +inline fun Message.whenFromChannelGroupContentMessage(block: (FromChannelGroupContentMessage) -> T) = asFromChannelGroupContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage? = +inline fun Message.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage? = this as? FromChannelGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage = +inline fun Message.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage = this as FromChannelGroupContentMessage @PreviewFeature -inline fun AccessibleMessage.whenGroupEventMessage(block: (GroupEventMessage) -> T) = +inline fun Message.whenGroupEventMessage(block: (GroupEventMessage) -> T) = asGroupEventMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage +inline fun Message.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage @PreviewFeature -inline fun AccessibleMessage.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage +inline fun Message.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage @PreviewFeature -inline fun AccessibleMessage.whenPrivateEventMessage(block: (PrivateEventMessage) -> T) = +inline fun Message.whenPrivateEventMessage(block: (PrivateEventMessage) -> T) = asPrivateEventMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPrivateEventMessage(): PrivateEventMessage? = +inline fun Message.asPrivateEventMessage(): PrivateEventMessage? = this as? PrivateEventMessage @PreviewFeature -inline fun AccessibleMessage.requirePrivateEventMessage(): PrivateEventMessage = +inline fun Message.requirePrivateEventMessage(): PrivateEventMessage = this as PrivateEventMessage @PreviewFeature -inline fun AccessibleMessage.whenGroupContentMessage(block: (GroupContentMessage) -> T) = +inline fun Message.whenGroupContentMessage(block: (GroupContentMessage) -> T) = asGroupContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asGroupContentMessage(): GroupContentMessage? = +inline fun Message.asGroupContentMessage(): GroupContentMessage? = this as? GroupContentMessage @PreviewFeature -inline fun AccessibleMessage.requireGroupContentMessage(): GroupContentMessage = +inline fun Message.requireGroupContentMessage(): GroupContentMessage = this as GroupContentMessage @PreviewFeature -inline fun AccessibleMessage.whenMediaGroupMessage(block: (MediaGroupMessage) -> T) = +inline fun Message.whenMediaGroupMessage(block: (MediaGroupMessage) -> T) = asMediaGroupMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asMediaGroupMessage(): MediaGroupMessage? = +inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = this as? MediaGroupMessage @PreviewFeature -inline fun AccessibleMessage.requireMediaGroupMessage(): MediaGroupMessage = +inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = this as MediaGroupMessage @PreviewFeature -inline fun AccessibleMessage.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) = +inline fun Message.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) = asPossiblyEditedMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage +inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage @PreviewFeature -inline fun AccessibleMessage.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage +inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage @PreviewFeature -inline fun AccessibleMessage.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) = +inline fun Message.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) = asPossiblyReplyMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage +inline fun Message.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage @PreviewFeature -inline fun AccessibleMessage.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage +inline fun Message.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage @PreviewFeature -inline fun AccessibleMessage.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) = +inline fun Message.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) = asPossiblyForwardedMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage +inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage @PreviewFeature -inline fun AccessibleMessage.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage +inline fun Message.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage @PreviewFeature -inline fun AccessibleMessage.whenPossiblyPaymentMessage(block: (PossiblyPaymentMessage) -> T) = +inline fun Message.whenPossiblyPaymentMessage(block: (PossiblyPaymentMessage) -> T) = asPossiblyPaymentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage +inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage @PreviewFeature -inline fun AccessibleMessage.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage +inline fun Message.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage @PreviewFeature -inline fun AccessibleMessage.whenPrivateContentMessage(block: (PrivateContentMessage) -> T) = +inline fun Message.whenPrivateContentMessage(block: (PrivateContentMessage) -> T) = asPrivateContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPrivateContentMessage(): PrivateContentMessage? = +inline fun Message.asPrivateContentMessage(): PrivateContentMessage? = this as? PrivateContentMessage @PreviewFeature -inline fun AccessibleMessage.requirePrivateContentMessage(): PrivateContentMessage = +inline fun Message.requirePrivateContentMessage(): PrivateContentMessage = this as PrivateContentMessage @PreviewFeature -inline fun AccessibleMessage.whenPublicContentMessage(block: (PublicContentMessage) -> T) = +inline fun Message.whenPublicContentMessage(block: (PublicContentMessage) -> T) = asPublicContentMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPublicContentMessage(): PublicContentMessage? = +inline fun Message.asPublicContentMessage(): PublicContentMessage? = this as? PublicContentMessage @PreviewFeature -inline fun AccessibleMessage.requirePublicContentMessage(): PublicContentMessage = +inline fun Message.requirePublicContentMessage(): PublicContentMessage = this as PublicContentMessage @PreviewFeature -inline fun AccessibleMessage.whenSignedMessage(block: (SignedMessage) -> T) = asSignedMessage()?.let(block) +inline fun Message.whenSignedMessage(block: (SignedMessage) -> T) = asSignedMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asSignedMessage(): SignedMessage? = this as? SignedMessage +inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage @PreviewFeature -inline fun AccessibleMessage.requireSignedMessage(): SignedMessage = this as SignedMessage +inline fun Message.requireSignedMessage(): SignedMessage = this as SignedMessage @PreviewFeature -inline fun AccessibleMessage.whenSupergroupEventMessage(block: (SupergroupEventMessage) -> T) = +inline fun Message.whenSupergroupEventMessage(block: (SupergroupEventMessage) -> T) = asSupergroupEventMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asSupergroupEventMessage(): SupergroupEventMessage? = +inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = this as? SupergroupEventMessage @PreviewFeature -inline fun AccessibleMessage.requireSupergroupEventMessage(): SupergroupEventMessage = +inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage = this as SupergroupEventMessage @PreviewFeature -inline fun AccessibleMessage.whenUnknownMessageType(block: (UnknownMessageType) -> T) = asUnknownMessageType()?.let(block) +inline fun Message.whenUnknownMessageType(block: (UnknownMessageType) -> T) = asUnknownMessageType()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType +inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType @PreviewFeature -inline fun AccessibleMessage.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType +inline fun Message.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType @PreviewFeature -inline fun AccessibleMessage.whenPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage) -> T) = +inline fun Message.whenPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage) -> T) = asPossiblySentViaBotCommonMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = +inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = this as? PossiblySentViaBotCommonMessage @PreviewFeature -inline fun AccessibleMessage.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = +inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = this as PossiblySentViaBotCommonMessage @PreviewFeature -inline fun AccessibleMessage.whenFromUserMessage(block: (FromUserMessage) -> T) = asFromUserMessage()?.let(block) +inline fun Message.whenFromUserMessage(block: (FromUserMessage) -> T) = asFromUserMessage()?.let(block) @PreviewFeature -inline fun AccessibleMessage.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage +inline fun Message.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage @PreviewFeature -inline fun AccessibleMessage.requireFromUserMessage(): FromUserMessage = this as FromUserMessage +inline fun Message.requireFromUserMessage(): FromUserMessage = this as FromUserMessage @PreviewFeature inline fun BotAction.whenFindLocationAction(block: (FindLocationAction) -> T) = asFindLocationAction()?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index f4e20698bb..b0f918d3fc 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -23,58 +23,58 @@ import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.utils.RiskFeature @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.from: User? +inline val Message.from: User? get() = asFromUser() ?.from @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.sender_chat: PublicChat? +inline val Message.sender_chat: PublicChat? get() = asFromChannelGroupContentMessage() ?.senderChat @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.forward_from: User? +inline val Message.forward_from: User? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asUserForwardInfo() ?.from @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.forward_from_chat: Chat? +inline val Message.forward_from_chat: Chat? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromPublicChatInfo() ?.chat @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.forward_from_message_id: MessageId? +inline val Message.forward_from_message_id: MessageId? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.messageId @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.forward_signature: ForwardSignature? +inline val Message.forward_signature: ForwardSignature? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.signature @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.forward_sender_name: ForwardSenderName? +inline val Message.forward_sender_name: ForwardSenderName? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asAnonymousForwardInfo() ?.senderName @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.forward_date: TelegramDate? +inline val Message.forward_date: TelegramDate? get() = asPossiblyForwardedMessage() ?.forwardInfo ?.dateOfOriginal @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.is_automatic_forward: Boolean? +inline val Message.is_automatic_forward: Boolean? get() = this is ConnectedFromChannelGroupContentMessage<*> @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.reply_to_message: Message? +inline val Message.reply_to_message: Message? get() = asPossiblyReplyMessage() ?.replyTo @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.via_bot: CommonBot? +inline val Message.via_bot: CommonBot? get() = asPossiblySentViaBotCommonMessage() ?.senderBot @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.edit_date: TelegramDate? +inline val Message.edit_date: TelegramDate? get() = asPossiblyEditedMessage() ?.editDate ?.toTelegramDate() @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.has_protected_content: Boolean? +inline val Message.has_protected_content: Boolean? get() = asContentMessage() ?.hasProtectedContent @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.media_group_id: MediaGroupIdentifier? +inline val Message.media_group_id: MediaGroupIdentifier? get() = asMediaGroupMessage() ?.mediaGroupId @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.author_signature: AuthorSignature? +inline val Message.author_signature: AuthorSignature? get() = asSignedMessage() ?.authorSignature @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.text: String? +inline val Message.text: String? get() = asContentMessage() ?.content ?.asTextContent() ?.text @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.entities: TextSourcesList? +inline val Message.entities: TextSourcesList? get() = asContentMessage() ?.content ?.asTextContent() ?.textSources @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.caption: String? +inline val Message.caption: String? get() = whenContentMessage { if (it.content !is TextContent) { it.content.asTextedInput() ?.text @@ -83,7 +83,7 @@ inline val AccessibleMessage.caption: String? } } @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.caption_entities: TextSourcesList? +inline val Message.caption_entities: TextSourcesList? get() = whenContentMessage { if (it.content !is TextContent) { it.content.asTextedInput() ?.textSources @@ -92,117 +92,117 @@ inline val AccessibleMessage.caption_entities: TextSourcesList? } } @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.audio: AudioFile? +inline val Message.audio: AudioFile? get() = asContentMessage() ?.content ?.asAudioContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.document: DocumentFile? +inline val Message.document: DocumentFile? get() = asContentMessage() ?.content ?.asDocumentContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.animation: AnimationFile? +inline val Message.animation: AnimationFile? get() = asContentMessage() ?.content ?.asAnimationContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.game: Game? +inline val Message.game: Game? get() = asContentMessage() ?.content ?.asGameContent() ?.game @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.photo: Photo? +inline val Message.photo: Photo? get() = asContentMessage() ?.content ?.asPhotoContent() ?.mediaCollection @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.sticker: Sticker? +inline val Message.sticker: Sticker? get() = asContentMessage() ?.content ?.asStickerContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.video: VideoFile? +inline val Message.video: VideoFile? get() = asContentMessage() ?.content ?.asVideoContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.voice: VoiceFile? +inline val Message.voice: VoiceFile? get() = asContentMessage() ?.content ?.asVoiceContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.video_note: VideoNoteFile? +inline val Message.video_note: VideoNoteFile? get() = asContentMessage() ?.content ?.asVideoNoteContent() ?.media @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.contact: Contact? +inline val Message.contact: Contact? get() = asContentMessage() ?.content ?.asContactContent() ?.contact @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.location: Location? +inline val Message.location: Location? get() = asContentMessage() ?.content ?.asLocationContent() ?.location @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.venue: Venue? +inline val Message.venue: Venue? get() = asContentMessage() ?.content ?.asVenueContent() ?.venue @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.poll: Poll? +inline val Message.poll: Poll? get() = asContentMessage() ?.content ?.asPollContent() ?.poll @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.invoice: Invoice? +inline val Message.invoice: Invoice? get() = asContentMessage() ?.content ?.asInvoiceContent() ?.invoice @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.dice: Dice? +inline val Message.dice: Dice? get() = asContentMessage() ?.content ?.asDiceContent() ?.dice @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.new_chat_members: List? +inline val Message.new_chat_members: List? get() = asChatEventMessage() ?.chatEvent ?.asNewChatMembers() ?.members @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.left_chat_member: User? +inline val Message.left_chat_member: User? get() = asChatEventMessage() ?.chatEvent ?.asLeftChatMember() ?.user @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.new_chat_title: String? +inline val Message.new_chat_title: String? get() = asChatEventMessage() ?.chatEvent ?.asNewChatTitle() ?.title @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.new_chat_photo: Photo? +inline val Message.new_chat_photo: Photo? get() = asChatEventMessage() ?.chatEvent ?.asNewChatPhoto() ?.photo @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.delete_chat_photo: Boolean +inline val Message.delete_chat_photo: Boolean get() = asChatEventMessage() ?.chatEvent is DeleteChatPhoto @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.group_chat_created: Boolean +inline val Message.group_chat_created: Boolean get() = asChatEventMessage() ?.chatEvent is GroupChatCreated @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.supergroup_chat_created: Boolean +inline val Message.supergroup_chat_created: Boolean get() = asChatEventMessage() ?.chatEvent is SupergroupChatCreated @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.channel_chat_created: Boolean +inline val Message.channel_chat_created: Boolean get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.migrate_to_chat_id: IdChatIdentifier? +inline val Message.migrate_to_chat_id: IdChatIdentifier? get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.migrate_from_chat_id: IdChatIdentifier? +inline val Message.migrate_from_chat_id: IdChatIdentifier? get() = asChatEventMessage() ?.chatEvent ?.let { it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom } @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.pinned_message: Message? +inline val Message.pinned_message: Message? get() = asChatEventMessage() ?.chatEvent ?.asPinnedMessage() ?.message @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.successful_payment: SuccessfulPayment? +inline val Message.successful_payment: SuccessfulPayment? get() = asChatEventMessage() ?.chatEvent ?.asSuccessfulPaymentEvent() ?.payment @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.video_chat_scheduled: VideoChatScheduled? +inline val Message.video_chat_scheduled: VideoChatScheduled? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatScheduled() @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.video_chat_started: VideoChatStarted? +inline val Message.video_chat_started: VideoChatStarted? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatStarted() @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.video_chat_ended: VideoChatEnded? +inline val Message.video_chat_ended: VideoChatEnded? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatEnded() @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.video_chat_participants_invited: VideoChatParticipantsInvited? +inline val Message.video_chat_participants_invited: VideoChatParticipantsInvited? get() = asChatEventMessage() ?.chatEvent ?.asVideoChatParticipantsInvited() @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? +inline val Message.message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? get() = asChatEventMessage() ?.chatEvent ?.asMessageAutoDeleteTimerChanged() @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.connected_website: String? +inline val Message.connected_website: String? get() = asChatEventMessage() ?.chatEvent ?.asUserLoggedIn() ?.domain @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.proximity_alert_triggered: ProximityAlertTriggered? +inline val Message.proximity_alert_triggered: ProximityAlertTriggered? get() = asChatEventMessage() ?.chatEvent ?.asProximityAlertTriggered() @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.passport_data: PassportData? +inline val Message.passport_data: PassportData? get() = asPassportMessage() ?.passportData @RiskFeature(RawFieldsUsageWarning) -inline val AccessibleMessage.reply_markup: InlineKeyboardMarkup? +inline val Message.reply_markup: InlineKeyboardMarkup? get() = asCommonMessage() ?.replyMarkup From 225fedde3aa8cf41814427a60d5568fa26a182bc Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Jan 2024 02:14:46 +0600 Subject: [PATCH 63/65] several more fixes --- .../utils/extensions/OptionalThreadId.kt | 4 +- .../extensions/utils/ClassCastsNew.kt | 12 +++--- .../extensions/utils/extensions/Same.kt | 40 +++++++++---------- .../utils/extensions/raw/Message.kt | 1 - .../utils/updates/MessageFilters.kt | 10 ++--- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt index bab83ae2e4..2369d24ba4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.utils.extensions -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage -val AccessibleMessage.threadIdOrNull +val Message.threadIdOrNull get() = (this as? PossiblyTopicMessage) ?.threadId 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 e73520d8cd..4def5e7843 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 @@ -260,7 +260,7 @@ import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage import dev.inmo.tgbotapi.types.message.ForwardInfo import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.message.PrivateEventMessage -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage @@ -3495,13 +3495,13 @@ public inline fun Message.ifCommonForumContentMessage(block: (CommonForumContentMessage) -> T): T? = commonForumContentMessageOrNull() ?.let(block) -public inline fun Message.accessibleMessageOrNull(): AccessibleMessage? = this as? - dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +public inline fun Message.accessibleMessageOrNull(): Message? = this as? + dev.inmo.tgbotapi.types.message.abstracts.Message -public inline fun Message.accessibleMessageOrThrow(): AccessibleMessage = this as - dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +public inline fun Message.accessibleMessageOrThrow(): Message = this as + dev.inmo.tgbotapi.types.message.abstracts.Message -public inline fun Message.ifAccessibleMessage(block: (AccessibleMessage) -> T): T? = +public inline fun Message.ifMessage(block: (Message) -> T): T? = accessibleMessageOrNull() ?.let(block) public inline fun Message.inaccessibleMessageOrNull(): InaccessibleMessage? = this as? diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt index a8d3eb25ea..360d71c6f4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt @@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.Username import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull @@ -32,43 +32,43 @@ inline fun WithPreviewChat.sameChat(chat: Chat) = * @return true in case if [this] message is placed in the same chat that [other] */ @Suppress("NOTHING_TO_INLINE") -inline fun WithPreviewChat.sameChat(other: AccessibleMessage) = sameChat(other.chat) +inline fun WithPreviewChat.sameChat(other: Message) = sameChat(other.chat) /** - * @return true in case if [this] message is from the same chat (with id == [chatId]) and [this] [AccessibleMessage.messageId] + * @return true in case if [this] message is from the same chat (with id == [chatId]) and [this] [Message.messageId] * equal [messageId] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameMessage( +inline fun Message.sameMessage( chatId: ChatIdentifier, messageId: MessageId ) = sameChat(chatId) && this.messageId == messageId /** - * @return true in case if [this] message is from the same [chat] and [this] [AccessibleMessage.messageId] equal [messageId] + * @return true in case if [this] message is from the same [chat] and [this] [Message.messageId] equal [messageId] * identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameMessage( +inline fun Message.sameMessage( chat: Chat, messageId: MessageId ) = sameChat(chat) && this.messageId == messageId /** * @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat - * and have equal [AccessibleMessage.messageId] identifier + * and have equal [Message.messageId] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameMessage(other: AccessibleMessage) = sameMessage(other.chat, other.messageId) +inline fun Message.sameMessage(other: Message) = sameMessage(other.chat, other.messageId) /** * Thread is the same thing that topic * * @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these - * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier + * messages from one chat and have equal [Message.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameTopic( +inline fun Message.sameTopic( chatId: ChatIdentifier, threadId: MessageThreadId? = chatId.threadId ) = sameChat(chatId) && threadIdOrNull == threadId @@ -77,10 +77,10 @@ inline fun AccessibleMessage.sameTopic( * Thread is the same thing that topic * * @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these - * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier + * messages from one chat and have equal [Message.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameThread( +inline fun Message.sameThread( chatId: ChatIdentifier, threadId: MessageThreadId? = chatId.threadId ) = sameTopic(chatId, threadId) @@ -89,10 +89,10 @@ inline fun AccessibleMessage.sameThread( * Thread is the same thing that topic * * @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these - * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier + * messages from one chat and have equal [Message.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameTopic( +inline fun Message.sameTopic( chat: Chat, threadId: MessageThreadId? = chat.id.threadId ) = sameTopic(chat.id, threadId) @@ -101,10 +101,10 @@ inline fun AccessibleMessage.sameTopic( * Thread is the same thing that topic * * @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these - * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier + * messages from one chat and have equal [Message.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameThread( +inline fun Message.sameThread( chat: Chat, threadId: MessageThreadId? = chat.id.threadId ) = sameThread(chat.id, threadId) @@ -113,16 +113,16 @@ inline fun AccessibleMessage.sameThread( * Thread is the same thing that topic * * @return true in case if [this] message is from the same chat and topic as [other]. The same here means that these - * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier + * messages from one chat and have equal [Message.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameTopic(other: AccessibleMessage) = sameTopic(other.chat, other.threadIdOrNull) +inline fun Message.sameTopic(other: Message) = sameTopic(other.chat, other.threadIdOrNull) /** * Thread is the same thing that topic * * @return true in case if [this] message is in the same topic as the [other]. The same here means that these messages - * from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier + * from one chat and have equal [Message.threadIdOrNull] identifier */ @Suppress("NOTHING_TO_INLINE") -inline fun AccessibleMessage.sameThread(other: AccessibleMessage) = sameTopic(other) +inline fun Message.sameThread(other: Message) = sameTopic(other) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index b0f918d3fc..ca069ef5c4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -11,7 +11,6 @@ import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.ConnectedFromChannelGroupContentMessage -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt index 9461999457..03963a88f4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull @@ -58,10 +58,10 @@ fun CommonMessage<*>.hasNoCommands(): Boolean = !this.hasCommands() * } * ``` * - * @return true if this [AccessibleMessage] is from forum ([threadIdOrNull] is not null). False otherwise. + * @return true if this [Message] is from forum ([threadIdOrNull] is not null). False otherwise. * @see notForumMessage */ -fun AccessibleMessage.forumMessage(): Boolean = threadIdOrNull != null +fun Message.forumMessage(): Boolean = threadIdOrNull != null /** * A predicate to test that message has not been sent in the forum. @@ -76,7 +76,7 @@ fun AccessibleMessage.forumMessage(): Boolean = threadIdOrNull != null * } * ``` * - * @return true if this [AccessibleMessage] is not from forum ([threadIdOrNull] is not null). False otherwise. + * @return true if this [Message] is not from forum ([threadIdOrNull] is not null). False otherwise. * @see forumMessage */ -fun AccessibleMessage.notForumMessage(): Boolean = !forumMessage() +fun Message.notForumMessage(): Boolean = !forumMessage() From e902f85b367829e5c35677de702dd19ae320c24d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Jan 2024 02:21:22 +0600 Subject: [PATCH 64/65] fixes in build --- .../inmo/tgbotapi/extensions/utils/ClassCastsNew.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 4def5e7843..e73520d8cd 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 @@ -260,7 +260,7 @@ import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage import dev.inmo.tgbotapi.types.message.ForwardInfo import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.message.PrivateEventMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage @@ -3495,13 +3495,13 @@ public inline fun Message.ifCommonForumContentMessage(block: (CommonForumContentMessage) -> T): T? = commonForumContentMessageOrNull() ?.let(block) -public inline fun Message.accessibleMessageOrNull(): Message? = this as? - dev.inmo.tgbotapi.types.message.abstracts.Message +public inline fun Message.accessibleMessageOrNull(): AccessibleMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage -public inline fun Message.accessibleMessageOrThrow(): Message = this as - dev.inmo.tgbotapi.types.message.abstracts.Message +public inline fun Message.accessibleMessageOrThrow(): AccessibleMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage -public inline fun Message.ifMessage(block: (Message) -> T): T? = +public inline fun Message.ifAccessibleMessage(block: (AccessibleMessage) -> T): T? = accessibleMessageOrNull() ?.let(block) public inline fun Message.inaccessibleMessageOrNull(): InaccessibleMessage? = this as? From ac63d52b14f13c9adccc98fcf528f0bf09ce1496 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 12 Jan 2024 02:44:30 +0600 Subject: [PATCH 65/65] add notes about telegram bots api 7.0 support --- CHANGELOG.md | 2 ++ README.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eda7f1847..521021b2c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 10.0.0 +**Add support of [Telegram Bots API 7.0](https://core.telegram.org/bots/api-changelog#december-29-2023)** + **IN THIS UPDATE KLOCK DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-time` UP TO 5.3.0 VERSION** **IN THIS UPDATE KRYPTO DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-crypto` UP TO 5.3.0 VERSION** diff --git a/README.md b/README.md index 255b27541a..1051e31109 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.9-blue)](https://core.telegram.org/bots/api-changelog#september-22-2023) +# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-7.0-blue)](https://core.telegram.org/bots/api-changelog#december-29-2023) | Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) | |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|