diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c424e3fa2..521021b2c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # TelegramBotAPI changelog +## 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** + +* `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/README.md b/README.md index bcab411479..bf5b95739d 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) | |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| 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 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 00c5ee3dbe..a45ca4b8f7 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.21-1.0.16" +ksp = "1.9.22-1.0.16" kotlin-poet = "1.15.3" -microutils = "0.20.23" +microutils = "0.20.26" 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.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/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 new file mode 100644 index 0000000000..ee392340b9 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessages.kt @@ -0,0 +1,78 @@ +package dev.inmo.tgbotapi.extensions.api + +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 +import kotlin.jvm.JvmName + +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( + messagesMetas: List +) = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) -> + deleteMessages( + chatId = chatId, + messageIds = messages.map { it.messageId } + ) +}.all { it } + +@JvmName("deleteMessagesWithMessages") +suspend fun TelegramBot.deleteMessages( + messages: List +) = deleteMessages(messages.map { it.metaInfo }) + +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( + 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/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 new file mode 100644 index 0000000000..d30b499ad4 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessages.kt @@ -0,0 +1,193 @@ +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 +import kotlin.jvm.JvmName + +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, + messagesMetas: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) -> + forwardMessages( + toChatId = toChatId, + fromChatId = chatId, + messageIds = messages.map { it.messageId }, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption + ) +} + +@JvmName("forwardMessagesWithMessages") +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, + 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, + 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 +) + +@JvmName("forwardWithMessages") +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/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 4222a29c89..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 @@ -2,38 +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 @@ -110,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() @@ -127,8 +112,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -157,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, @@ -172,8 +155,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -192,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, @@ -207,8 +188,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -227,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, @@ -242,8 +221,7 @@ suspend fun TelegramBot.startLiveLocation( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -252,7 +230,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, @@ -277,8 +255,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( threadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -287,7 +264,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, @@ -310,7 +287,6 @@ suspend inline fun TelegramBot.replyWithLiveLocation( threadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) 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 4cd890c605..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) @@ -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/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 c66886e28a..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 @@ -3,13 +3,14 @@ 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 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.* @@ -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] @@ -173,11 +174,11 @@ 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, - 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] @@ -185,12 +186,12 @@ 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, - 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] @@ -198,9 +199,9 @@ 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, - 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/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.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..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.Message -import dev.inmo.tgbotapi.types.threadId +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage /** * @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 @@ -186,16 +173,15 @@ 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, 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 @@ -203,16 +189,15 @@ 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, 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 @@ -220,15 +205,14 @@ 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, 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 @@ -236,15 +220,14 @@ 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, 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/CopyMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt new file mode 100644 index 0000000000..f9d2265c6b --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt @@ -0,0 +1,192 @@ +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.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message +import kotlin.jvm.JvmName + +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, + messagesMetas: List, + threadId: MessageThreadId? = toChatId.threadId, + disableNotification: Boolean = false, + protectContent: Boolean = false, + removeCaption: Boolean = false +) = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) -> + copyMessages( + toChatId = toChatId, + fromChatId = chatId, + messageIds = messages.map { it.messageId }, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + removeCaption = removeCaption + ) +} + +@JvmName("copyMessagesWithMessages") +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 +) + +@JvmName("copyWithMessages") +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 +) 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..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 @@ -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,24 +43,25 @@ 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, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - to.chat, + replyInChatId, phoneNumber, firstName, lastName, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -70,20 +70,21 @@ 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, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - to.chat, + replyInChatId, contact, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -95,26 +96,30 @@ 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, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, to.messageId, 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 * [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, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(to, animationType, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(to, animationType, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -124,22 +129,23 @@ 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, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - to.chat, + replyInChatId, latitude, longitude, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - allowSendingWithoutReply, - to.messageId, + replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -148,20 +154,21 @@ 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, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - to.chat, + replyInChatId, location, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - allowSendingWithoutReply, - to.messageId, + replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -173,24 +180,25 @@ 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, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - to.chat, + replyInChatId, text, parseMode, - disableWebPagePreview, - to.threadIdOrNull, + linkPreviewOptions, + replyInThreadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -199,22 +207,23 @@ 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, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - to.chat, + replyInChatId, entities, - disableWebPagePreview, - to.threadIdOrNull, + linkPreviewOptions, + replyInThreadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -223,30 +232,34 @@ suspend inline fun TelegramBot.reply( * as a builder for that */ suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, + 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), disableWebPagePreview, 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] * as a builder for that */ suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, separator: String, - disableWebPagePreview: Boolean? = null, + linkPreviewOptions: LinkPreviewOptions? = null, + 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), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -256,7 +269,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, @@ -265,12 +278,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chat = to.chat, + chatId = replyInChatId, latitude = latitude, longitude = longitude, title = title, @@ -279,16 +294,15 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = to.threadIdOrNull, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = to.messageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, location: StaticLocation, title: String, address: String, @@ -296,12 +310,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chat = to.chat, + chatId = replyInChatId, latitude = location.latitude, longitude = location.longitude, title = title, @@ -310,29 +326,29 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = to.threadIdOrNull, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = to.messageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, venue: Venue, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chat = to.chat, + chatId = replyInChatId, venue = venue, - threadId = to.threadIdOrNull, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = to.messageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -340,41 +356,47 @@ suspend inline fun TelegramBot.reply( // Game suspend inline fun TelegramBot.replyWithGame( - to: Message, + to: AccessibleMessage, gameShortName: String, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup + replyInChatId, gameShortName, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.replyWithGame( - to: Message, + to: AccessibleMessage, game: Game, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup + replyInChatId, game.title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, game: Game, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(to, game, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(to, game, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation suspend inline fun TelegramBot.replyWithAnimation( - to: Message, + to: AccessibleMessage, animation: InputFile, thumb: InputFile? = null, text: String? = null, @@ -383,12 +405,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - to.chat, + replyInChatId, animation, thumb, text, @@ -397,16 +421,15 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, animation: AnimationFile, text: String? = null, parseMode: ParseMode? = null, @@ -414,14 +437,16 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, 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: Message, + to: AccessibleMessage, animation: InputFile, entities: TextSourcesList, spoilered: Boolean = false, @@ -429,12 +454,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - to.chat, + replyInChatId, animation, thumb, entities, @@ -442,33 +469,34 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, animation: AnimationFile, entities: TextSourcesList, spoilered: Boolean = false, duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(replyInChatId, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio suspend inline fun TelegramBot.replyWithAudio( - to: Message, + to: AccessibleMessage, audio: InputFile, thumb: InputFile? = null, text: String? = null, @@ -476,237 +504,277 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, 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: Message, + to: AccessibleMessage, audio: AudioFile, text: String? = null, parseMode: ParseMode? = null, title: String? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, 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(replyInChatId, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( - to: Message, + to: AccessibleMessage, audio: InputFile, thumb: InputFile? = null, entities: TextSourcesList, duration: Long? = null, performer: String? = null, title: String? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(replyInChatId, audio, thumb, entities, duration, performer, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, audio: AudioFile, entities: TextSourcesList, title: String? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(replyInChatId, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents suspend inline fun TelegramBot.replyWithDocument( - to: Message, + to: AccessibleMessage, document: InputFile, thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + 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(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, thumb, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, + 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(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( - to: Message, + to: AccessibleMessage, document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + 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(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, thumb, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, document: DocumentFile, entities: TextSourcesList, + 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(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @RiskFeature(rawSendingMediaGroupsWarning) suspend inline fun TelegramBot.replyWithMediaGroup( - to: Message, + to: AccessibleMessage, media: List, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( - to: Message, + to: AccessibleMessage, media: List, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendPlaylist(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( - to: Message, + to: AccessibleMessage, media: List, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendDocumentsGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( - to: Message, + to: AccessibleMessage, media: List, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, replyParameters = ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo suspend inline fun TelegramBot.replyWithPhoto( - to: Message, + to: AccessibleMessage, fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, 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(replyInChatId, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photo: Photo, text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, 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(replyInChatId, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, 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(replyInChatId, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( - to: Message, + to: AccessibleMessage, fileId: InputFile, entities: TextSourcesList, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photo: Photo, entities: TextSourcesList, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, photoSize: PhotoSize, entities: TextSourcesList, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker suspend inline fun TelegramBot.replyWithSticker( - to: Message, + to: AccessibleMessage, sticker: InputFile, emoji: String? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(replyInChatId, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, sticker: Sticker, emoji: String? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(replyInChatId, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos suspend inline fun TelegramBot.replyWithVideo( - to: Message, + to: AccessibleMessage, video: InputFile, thumb: InputFile? = null, text: String? = null, @@ -715,26 +783,30 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, 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: Message, + to: AccessibleMessage, video: VideoFile, text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, 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(replyInChatId, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( - to: Message, + to: AccessibleMessage, video: InputFile, thumb: InputFile? = null, entities: TextSourcesList, @@ -742,94 +814,110 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, 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: Message, + to: AccessibleMessage, video: VideoFile, entities: TextSourcesList, spoilered: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(replyInChatId, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // VideoNotes suspend inline fun TelegramBot.replyWithVideoNote( - to: Message, + to: AccessibleMessage, videoNote: InputFile, thumb: InputFile? = null, duration: Long? = null, size: Int? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, 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(replyInChatId, videoNote, thumb, duration, size, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, videoNote: VideoNoteFile, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(to.chat, videoNote, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(replyInChatId, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Voice suspend inline fun TelegramBot.replyWithVoice( - to: Message, + to: AccessibleMessage, voice: InputFile, text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, 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(replyInChatId, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(replyInChatId, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( - to: Message, + to: AccessibleMessage, voice: InputFile, entities: TextSourcesList, duration: Long? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(replyInChatId, voice, entities, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, voice: VoiceFile, entities: TextSourcesList, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(replyInChatId, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Invoice @@ -839,7 +927,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, @@ -857,31 +945,35 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, 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(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) // Polls suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, question: String, options: List, isAnonymous: Boolean = true, isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(replyInChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, replyInThreadId, disableNotification, protectContent, ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, poll: RegularPoll, isClosed: Boolean = false, question: String = poll.question, @@ -889,14 +981,16 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, 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: Message, + to: AccessibleMessage, question: String, options: List, correctOptionId: Int, @@ -905,14 +999,16 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, 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: Message, + to: AccessibleMessage, quizPoll: QuizPoll, isClosed: Boolean = false, question: String = quizPoll.question, @@ -922,14 +1018,16 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, 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: Message, + to: AccessibleMessage, question: String, options: List, correctOptionId: Int, @@ -937,14 +1035,16 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, 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: Message, + to: AccessibleMessage, quizPoll: QuizPoll, entities: TextSourcesList, isClosed: Boolean = false, @@ -953,21 +1053,25 @@ 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, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.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, to.messageId, allowSendingWithoutReply, 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( - to: Message, + to: AccessibleMessage, poll: Poll, isClosed: Boolean = false, question: String = poll.question, options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -982,6 +1086,8 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -997,6 +1103,8 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1006,151 +1114,162 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, fromChatId: ChatIdentifier, messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( - to.chat.id, + replyInChatId, fromChatId, messageId, text, parseMode, - to.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - to.messageId, - allowSendingWithoutReply, + ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply == true), replyMarkup ) suspend inline fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, fromChat: Chat, messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + 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, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, fromChat.id, messageId, text, parseMode, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - to: Message, - copy: Message, + to: AccessibleMessage, + copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, + 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, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(to, copy.chat.id, copy.messageId, text, parseMode, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, content: MessageContent, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -): Message = execute( +): AccessibleMessage = execute( content.createResend( - to.chat.id, - to.threadIdOrNull, + replyInChatId, + replyInThreadId, 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: Message, + to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) = handleLiveLocation( - message.chat.id, + replyInChatId, locationsFlow, liveTimeMillis, - message.threadIdOrNull, + replyInThreadId, 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: Message, + to: AccessibleMessage, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - message.chat.id, + replyInChatId, locationsFlow, liveTimeMillis, - message.threadIdOrNull, + replyInThreadId, 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: Message, + to: AccessibleMessage, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - message.chat.id, + replyInChatId, locationsFlow, liveTimeMillis, - message.threadIdOrNull, + replyInThreadId, disableNotification, protectContent, - message.messageId, - allowSendingWithoutReply + ReplyParameters(to, allowSendingWithoutReply = allowSendingWithoutReply == true) ) } suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, mediaFile: TelegramMediaFile, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1160,6 +1279,8 @@ suspend fun TelegramBot.reply( is AudioFile -> reply( to = to, audio = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1168,6 +1289,8 @@ suspend fun TelegramBot.reply( is AnimationFile -> reply( to = to, animation = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1176,6 +1299,8 @@ suspend fun TelegramBot.reply( is VoiceFile -> reply( to = to, voice = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1184,6 +1309,8 @@ suspend fun TelegramBot.reply( is VideoFile -> reply( to = to, video = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1192,6 +1319,8 @@ suspend fun TelegramBot.reply( is VideoNoteFile -> reply( to = to, videoNote = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1200,6 +1329,8 @@ suspend fun TelegramBot.reply( is DocumentFile -> reply( to = to, document = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1208,6 +1339,8 @@ suspend fun TelegramBot.reply( is Sticker -> reply( to = to, sticker = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1216,6 +1349,8 @@ suspend fun TelegramBot.reply( is PhotoSize -> reply( to = to, photoSize = mediaFile, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1224,6 +1359,8 @@ suspend fun TelegramBot.reply( else -> reply( to = to, document = mediaFile.asDocumentFile(), + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1233,10 +1370,12 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1248,6 +1387,8 @@ suspend fun TelegramBot.reply( voice = content.media, text = text, parseMode = parseMode, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1258,6 +1399,8 @@ suspend fun TelegramBot.reply( audio = content.media, text = text, parseMode = parseMode, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1268,6 +1411,8 @@ suspend fun TelegramBot.reply( photoSize = content.media, text = text, parseMode = parseMode, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1278,6 +1423,8 @@ suspend fun TelegramBot.reply( video = content.media, text = text, parseMode = parseMode, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1288,6 +1435,8 @@ suspend fun TelegramBot.reply( animation = content.media, text = text, parseMode = parseMode, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1298,6 +1447,8 @@ suspend fun TelegramBot.reply( document = content.media.asDocumentFile(), text = text, parseMode = parseMode, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1307,9 +1458,11 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - to: Message, + to: AccessibleMessage, content: TextedMediaContent, entities: TextSourcesList, + replyInChatId: IdChatIdentifier = to.chat.id, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1320,6 +1473,8 @@ suspend fun TelegramBot.reply( to = to, voice = content.media, entities = entities, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1329,6 +1484,8 @@ suspend fun TelegramBot.reply( to = to, audio = content.media, entities = entities, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1338,6 +1495,8 @@ suspend fun TelegramBot.reply( to = to, photoSize = content.media, entities = entities, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1347,6 +1506,8 @@ suspend fun TelegramBot.reply( to = to, video = content.media, entities = entities, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1356,6 +1517,8 @@ suspend fun TelegramBot.reply( to = to, animation = content.media, entities = entities, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1365,6 +1528,8 @@ suspend fun TelegramBot.reply( to = to, document = content.media.asDocumentFile(), entities = entities, + replyInChatId = replyInChatId, + 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 67af3688cb..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 @@ -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 @@ -47,21 +47,21 @@ suspend inline fun TelegramBot.reply( phoneNumber: String, firstName: String, lastName: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - toChatId, + replyInChatId, phoneNumber, firstName, lastName, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -73,19 +73,19 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, contact: Contact, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - toChatId, + replyInChatId, contact, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -100,12 +100,13 @@ suspend inline fun TelegramBot.replyWithDice( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(toChatId, animationType, threadId, disableNotification, protectContent, toMessageId, 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 @@ -115,12 +116,13 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(toChatId, toMessageId, animationType, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(toChatId, toMessageId, animationType, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -134,20 +136,20 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, latitude: Double, longitude: Double, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - toChatId, + replyInChatId, latitude, longitude, - threadId, + replyInThreadId, disableNotification, protectContent, - allowSendingWithoutReply, - toMessageId, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -159,19 +161,19 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, location: StaticLocation, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendLocation( - toChatId, + replyInChatId, location, - threadId, + replyInThreadId, disableNotification, protectContent, - allowSendingWithoutReply, - toMessageId, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -187,22 +189,22 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, text: String, parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = toChatId.threadId, + linkPreviewOptions: LinkPreviewOptions? = null, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - toChatId, + replyInChatId, text, parseMode, - disableWebPagePreview, - threadId, + linkPreviewOptions, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -214,21 +216,21 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, entities: TextSourcesList, - disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = toChatId.threadId, + linkPreviewOptions: LinkPreviewOptions? = null, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage( - toChatId, + replyInChatId, entities, - disableWebPagePreview, - threadId, + linkPreviewOptions, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -240,14 +242,15 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, separator: TextSource? = null, - disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = toChatId.threadId, + linkPreviewOptions: LinkPreviewOptions? = null, + 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), disableWebPagePreview, threadId, 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] @@ -257,14 +260,15 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, separator: String, - disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = toChatId.threadId, + linkPreviewOptions: LinkPreviewOptions? = null, + 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), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -284,13 +288,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = toChatId, + chatId = replyInChatId, latitude = latitude, longitude = longitude, title = title, @@ -299,11 +304,10 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = threadId, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = toMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -317,13 +321,14 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = toChatId, + chatId = replyInChatId, latitude = location.latitude, longitude = location.longitude, title = title, @@ -332,11 +337,10 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, - threadId = threadId, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = toMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -344,19 +348,19 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, venue: Venue, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVenue( - chatId = toChatId, + chatId = replyInChatId, venue = venue, - threadId = threadId, + threadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = toMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup = replyMarkup ) @@ -367,38 +371,41 @@ suspend inline fun TelegramBot.replyWithGame( toChatId: IdChatIdentifier, toMessageId: MessageId, gameShortName: String, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, gameShortName, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup + replyInChatId, 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, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, game.title, threadId, disableNotification, protectContent, toMessageId, 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, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(toChatId, toMessageId, game, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(toChatId, toMessageId, game, replyInChatId, replyInThreadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation @@ -414,13 +421,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - toChatId, + replyInChatId, animation, thumb, text, @@ -429,11 +437,10 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -447,12 +454,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -464,13 +472,14 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - toChatId, + replyInChatId, animation, thumb, entities, @@ -478,11 +487,10 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -495,12 +503,13 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(replyInChatId, animation, entities, spoilered, duration, width, height, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Audio @@ -515,12 +524,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -529,12 +539,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(replyInChatId, audio, text, parseMode, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithAudio( toChatId: IdChatIdentifier, @@ -545,12 +556,13 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, 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, @@ -558,12 +570,13 @@ suspend inline fun TelegramBot.reply( audio: AudioFile, entities: TextSourcesList, title: String? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, entities, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(replyInChatId, audio, entities, title, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Documents @@ -575,13 +588,14 @@ suspend inline fun TelegramBot.replyWithDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -589,13 +603,14 @@ suspend inline fun TelegramBot.reply( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, toMessageId, 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, @@ -603,26 +618,28 @@ suspend inline fun TelegramBot.replyWithDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, toMessageId, 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, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(replyInChatId, document, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup, disableContentTypeDetection) // Media Group @@ -632,41 +649,45 @@ suspend inline fun TelegramBot.replyWithMediaGroup( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithPlaylist( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendPlaylist(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithDocuments( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendDocumentsGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) suspend inline fun TelegramBot.replyWithGallery( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(replyInChatId, media, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply)) // Photo @@ -678,12 +699,13 @@ suspend inline fun TelegramBot.replyWithPhoto( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, fileId, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -692,12 +714,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, photo, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -706,12 +729,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, photoSize, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -720,12 +744,13 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, fileId, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -733,12 +758,13 @@ suspend inline fun TelegramBot.reply( photo: Photo, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, photo, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -746,12 +772,13 @@ suspend inline fun TelegramBot.reply( photoSize: PhotoSize, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(replyInChatId, photoSize, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Sticker @@ -760,25 +787,27 @@ suspend inline fun TelegramBot.replyWithSticker( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: InputFile, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, 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, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(replyInChatId, sticker, replyInThreadId, emoji, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Videos @@ -794,12 +823,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -808,12 +838,13 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(replyInChatId, video, text, parseMode, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVideo( toChatId: IdChatIdentifier, @@ -825,12 +856,13 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -838,12 +870,13 @@ suspend inline fun TelegramBot.reply( video: VideoFile, entities: TextSourcesList, spoilered: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(replyInChatId, video, entities, spoilered, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // VideoNotes @@ -855,23 +888,25 @@ suspend inline fun TelegramBot.replyWithVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, toMessageId, 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, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(replyInChatId, videoNote, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Voice @@ -883,12 +918,13 @@ suspend inline fun TelegramBot.replyWithVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(replyInChatId, voice, text, parseMode, duration, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, @@ -896,12 +932,13 @@ suspend inline fun TelegramBot.reply( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(replyInChatId, voice, text, parseMode, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -910,24 +947,26 @@ suspend inline fun TelegramBot.replyWithVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, toMessageId, 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, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(replyInChatId, voice, entities, replyInThreadId, disableNotification, protectContent, ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup) // Invoice @@ -956,12 +995,13 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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 @@ -975,12 +1015,13 @@ suspend inline fun TelegramBot.reply( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, 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, @@ -992,12 +1033,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -1010,12 +1052,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -1029,12 +1072,13 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -1046,12 +1090,13 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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, @@ -1064,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, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.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, toMessageId, 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( @@ -1081,7 +1127,8 @@ suspend inline fun TelegramBot.reply( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1097,7 +1144,8 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1114,7 +1162,8 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1130,22 +1179,22 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = copyMessage( - toChatId, + replyInChatId, fromChatId, messageId, text, parseMode, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) @@ -1156,31 +1205,34 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.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, threadId, 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, toMessageId: MessageId, - copy: Message, + copy: AccessibleMessage, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.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, threadId, 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, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1188,12 +1240,11 @@ suspend fun TelegramBot.reply( ) { execute( content.createResend( - toChatId, - threadId, + replyInChatId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply, + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply), replyMarkup ) ) @@ -1209,19 +1260,19 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) = handleLiveLocation( - toChatId, + replyInChatId, locationsFlow, liveTimeMillis, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) ) /** @@ -1236,20 +1287,20 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - toChatId, + replyInChatId, locationsFlow, liveTimeMillis, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) ) } @@ -1265,20 +1316,20 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null ) { handleLiveLocation( - toChatId, + replyInChatId, locationsFlow, liveTimeMillis, - threadId, + replyInThreadId, disableNotification, protectContent, - toMessageId, - allowSendingWithoutReply + ReplyParameters(toChatId, toMessageId, allowSendingWithoutReply = allowSendingWithoutReply) ) } @@ -1286,7 +1337,8 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, mediaFile: TelegramMediaFile, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1297,7 +1349,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, audio = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1307,7 +1360,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, animation = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1317,7 +1371,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, voice = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1327,7 +1382,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, video = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1337,7 +1393,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, videoNote = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1347,7 +1404,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, document = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1357,7 +1415,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, sticker = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1367,7 +1426,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, photoSize = mediaFile, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1377,7 +1437,8 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, document = mediaFile.asDocumentFile(), - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1392,7 +1453,8 @@ suspend fun TelegramBot.reply( content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1405,7 +1467,8 @@ suspend fun TelegramBot.reply( voice = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1417,7 +1480,8 @@ suspend fun TelegramBot.reply( audio = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1429,7 +1493,8 @@ suspend fun TelegramBot.reply( photoSize = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1441,7 +1506,8 @@ suspend fun TelegramBot.reply( video = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1453,7 +1519,8 @@ suspend fun TelegramBot.reply( animation = content.media, text = text, parseMode = parseMode, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1465,7 +1532,8 @@ suspend fun TelegramBot.reply( document = content.media.asDocumentFile(), text = text, parseMode = parseMode, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1479,7 +1547,8 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, content: TextedMediaContent, entities: List, - threadId: MessageThreadId? = toChatId.threadId, + replyInChatId: IdChatIdentifier = toChatId, + replyInThreadId: MessageThreadId? = replyInChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1491,7 +1560,8 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, voice = content.media, entities = entities, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1502,7 +1572,8 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, audio = content.media, entities = entities, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1513,7 +1584,8 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, photoSize = content.media, entities = entities, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1524,7 +1596,8 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, video = content.media, entities = entities, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1535,7 +1608,8 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, animation = content.media, entities = entities, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1546,7 +1620,8 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, document = content.media.asDocumentFile(), entities = entities, - threadId = threadId, + replyInChatId = replyInChatId, + replyInThreadId = replyInThreadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, 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 9bdc7b1cbb..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 @@ -19,24 +19,22 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( SendTextMessage( chatId, text, parseMode, - disableWebPagePreview, + linkPreviewOptions, threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) ) @@ -49,15 +47,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -68,14 +65,13 @@ 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, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -86,14 +82,13 @@ 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, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -102,15 +97,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) ) /** @@ -120,15 +114,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -138,15 +131,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -155,15 +147,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup ) /** @@ -173,15 +164,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -191,15 +181,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -208,14 +197,13 @@ 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, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendMessage(chat.id, entities, disableWebPagePreview, 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] @@ -224,15 +212,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -242,15 +229,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -260,14 +246,13 @@ 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, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat.id, entities, disableWebPagePreview, 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] @@ -276,15 +261,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -294,12 +278,11 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, 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 c9ce336499..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 @@ -550,14 +524,13 @@ 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, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendTextMessage] request @@ -568,14 +541,13 @@ 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, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyParameters, replyMarkup) /** * Will execute [sendTextMessage] request @@ -585,14 +557,13 @@ 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, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, entities, disableWebPagePreview, 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] @@ -601,15 +572,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -619,15 +589,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -638,14 +607,13 @@ 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, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, entities, disableWebPagePreview, 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] @@ -654,15 +622,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, replyParameters, replyMarkup) /** @@ -672,15 +639,14 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = 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, 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/SetMessageReactions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt new file mode 100644 index 0000000000..9b0931e842 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SetMessageReactions.kt @@ -0,0 +1,122 @@ +package dev.inmo.tgbotapi.extensions.api.send + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.send.SetMessageReactions +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, + messageId: MessageId, + reactions: List = emptyList(), + big: Boolean = false +) = execute( + SetMessageReactions(chatId, messageId, reactions, big) +) + +suspend fun TelegramBot.setMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + reaction: Reaction? = null, + big: Boolean = false +) = setMessageReactions(chatId, messageId, listOfNotNull(reaction), big) + +suspend fun TelegramBot.setMessageReactions( + chat: Chat, + messageId: MessageId, + reactions: List = emptyList(), + big: Boolean = false +) = setMessageReactions(chat.id, messageId, reactions, big) + +suspend fun TelegramBot.setMessageReaction( + chat: Chat, + messageId: MessageId, + reaction: Reaction? = null, + big: Boolean = false +) = setMessageReaction(chat.id, messageId, reaction, big) + +suspend fun TelegramBot.setMessageReactions( + meta: Message.MetaInfo, + reactions: List = emptyList(), + big: Boolean = false +) = setMessageReactions(meta.chatId, meta.messageId, reactions, big) + +suspend fun TelegramBot.setMessageReaction( + meta: Message.MetaInfo, + reaction: Reaction? = null, + big: Boolean = false +) = setMessageReaction(meta.chatId, meta.messageId, reaction, big) + +suspend fun TelegramBot.setMessageReactions( + message: AccessibleMessage, + reactions: List = emptyList(), + big: Boolean = false +) = setMessageReactions(message.metaInfo, reactions, big) + +suspend fun TelegramBot.setMessageReaction( + message: AccessibleMessage, + reaction: Reaction? = null, + big: Boolean = false +) = setMessageReaction(message.metaInfo, reaction, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + chatId: ChatIdentifier, + messageId: MessageId, + emojis: List, + big: Boolean = false +) = setMessageReactions(chatId, messageId, emojis.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + emoji: String?, + big: Boolean = false +) = setMessageReaction(chatId, messageId, emoji ?.let { Reaction.Emoji(it) }, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + chat: Chat, + messageId: MessageId, + emojis: List, + big: Boolean = false +) = setMessageReactions(chat, messageId, emojis.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + chat: Chat, + messageId: MessageId, + emoji: String?, + big: Boolean = false +) = setMessageReaction(chat, messageId, emoji ?.let { Reaction.Emoji(it) }, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + meta: Message.MetaInfo, + emojis: List, + big: Boolean = false +) = setMessageReactions(meta, emojis.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + meta: Message.MetaInfo, + emoji: String?, + big: Boolean = false +) = setMessageReaction(meta, emoji ?.let { Reaction.Emoji(it) }, big) + +@JvmName("setMessageReactionsStrings") +suspend fun TelegramBot.setMessageReactions( + message: AccessibleMessage, + emojis: List, + big: Boolean = false +) = setMessageReactions(message, emojis.map { Reaction.Emoji(it) }, big) + +suspend fun TelegramBot.setMessageReaction( + message: AccessibleMessage, + emoji: String?, + big: Boolean = false +) = setMessageReaction(message, emoji ?.let { Reaction.Emoji(it) }, big) 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.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/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/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 6bafc17182..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 @@ -138,3 +138,13 @@ suspend fun BehaviourContext.waitMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory).mapContent() + +suspend fun BehaviourContext.waitGiveawayContent( + 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..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? @@ -152,3 +149,13 @@ suspend fun BehaviourContext.waitMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory).mapWithContent() + +suspend fun BehaviourContext.waitGiveawayContentMessage( + 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..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 @@ -130,3 +130,14 @@ suspend fun BehaviourContext.waitEditedInvoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContent(initRequest, false, errorFactory) + +suspend fun BehaviourContext.waitEditedGiveawayContent( + 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..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 @@ -136,3 +135,14 @@ suspend fun BehaviourContext.waitEditedInvoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContentMessage(initRequest, errorFactory) + +suspend fun BehaviourContext.waitEditedGiveawayContentMessage( + 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/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 5a7165c7e5..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 @@ -19,10 +19,11 @@ 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 +import kotlinx.coroutines.flow.filter typealias EventMessageToEventMapper = suspend ChatEventMessage.() -> T? @@ -199,10 +200,15 @@ suspend fun BehaviourContext.waitChatSharedRequest( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEvents(initRequest, errorFactory) +suspend fun BehaviourContext.waitUsersShared( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) + suspend fun BehaviourContext.waitUserShared( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEvents(initRequest, errorFactory) +) = waitUsersShared(initRequest, errorFactory).filter { it.userIds.size == 1 } 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..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 @@ -19,10 +19,11 @@ 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 +import kotlinx.coroutines.flow.filter @RiskFeature(lowLevelRiskFeatureMessage) suspend inline fun BehaviourContext.waitEventsMessages( @@ -193,10 +194,15 @@ suspend fun BehaviourContext.waitChatSharedRequestEventsMessages( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitUsersSharedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) + suspend fun BehaviourContext.waitUserSharedEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEventsMessages(initRequest, errorFactory) +) = waitUsersSharedEventsMessages(initRequest, errorFactory).filter { it.chatEvent.userIds.size == 1 } suspend fun BehaviourContext.waitChatSharedEventsMessages( initRequest: Request<*>? = null, 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/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.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/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/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/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index a2b1a002b4..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 @@ -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.onGiveawayContent( + 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.onGiveawayPublicResultsContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + markerFactory: MarkerFactory = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onContentMessageWithType( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) 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..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.* @@ -25,7 +26,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( @@ -775,14 +776,34 @@ 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( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +suspend fun BC.onUsersShared( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = 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.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.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.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 +} 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 85e69e7406..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 @@ -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,12 +24,11 @@ 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, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendTextMessage( chatId, @@ -37,23 +36,21 @@ fun SendTextMessage( parseMode, null, threadId, - disableWebPagePreview, + linkPreviewOptions, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) fun SendTextMessage( 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, + replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendTextMessage( chatId, @@ -61,11 +58,10 @@ fun SendTextMessage( null, entities.toRawMessageEntities(), threadId, - disableWebPagePreview, + linkPreviewOptions, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -81,22 +77,20 @@ 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) 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>, TextableSendMessageRequest>, - DisableWebPagePreview + LinkPreviewOptionsContainer { override val textSources: TextSourcesList? by lazy { rawEntities ?.asTextSources(text) 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/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/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 2b16aaac31..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 @@ -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() @@ -51,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, @@ -62,9 +63,8 @@ fun SendPoll( isClosed, threadId = threadId, protectContent = protectContent, - allowSendingWithoutReply = allowSendingWithoutReply, disableNotification = disableNotification, - replyToMessageId = replyToMessageId, + replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -77,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( @@ -92,8 +91,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) is QuizPoll -> correctOptionId ?.let { correctOptionId -> @@ -109,8 +107,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } ?: SendRegularPoll( @@ -124,8 +121,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) is UnknownPollType -> SendRegularPoll( @@ -139,8 +135,7 @@ fun Poll.createRequest( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } @@ -207,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() { @@ -235,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, @@ -250,8 +242,7 @@ fun SendRegularPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -268,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, @@ -285,8 +275,7 @@ fun SendQuizPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -302,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, @@ -319,8 +307,7 @@ fun SendQuizPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -338,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, @@ -356,8 +342,7 @@ internal fun SendQuizPoll( threadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -391,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/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/ChatIdentifier.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt index 96881e086b..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 @@ -85,17 +85,28 @@ fun Int.toChatId(): IdChatIdentifier = toLong().toChatId() fun Byte.toChatId(): IdChatIdentifier = toLong().toChatId() @Serializable(ChatIdentifierSerializer::class) -data class Username( +@JvmInline +value class Username( + @Deprecated("Renamed", ReplaceWith("full")) val username: String ) : ChatIdentifier { + val full: String + get() = username + val withoutAt + get() = full.dropWhile { it == '@' } + @Deprecated("Renamed", ReplaceWith("withoutAt")) val usernameWithoutAt - get() = username.dropWhile { it == '@' } + get() = withoutAt init { - if (!username.startsWith("@")) { + if (!full.startsWith("@")) { throw IllegalArgumentException("Username must starts with `@`") } } + + override fun toString(): String { + return full + } } fun String.toUsername(): Username = Username(this) @@ -121,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) } } } @@ -159,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/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index ee4df3827e..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 @@ -175,6 +175,12 @@ val keywordsInStickerLimit = 0 .. 20 val stickerKeywordLengthLimit = 0 .. 64 +val keyboardButtonRequestUserLimit = 1 .. 10 + +val forwardMessagesLimit = 1 .. 100 +val copyMessagesLimit = forwardMessagesLimit +val deleteMessagesLimit = forwardMessagesLimit + const val botActionActualityTime: Seconds = 5 val cloudStorageKeyLimit = 1 .. 128 @@ -195,16 +201,30 @@ 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" +const val actorChatField = "actor_chat" const val messageThreadIdField = "message_thread_id" 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 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" +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" @@ -221,6 +241,11 @@ 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 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" @@ -229,6 +254,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" @@ -236,6 +262,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" @@ -322,8 +349,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" @@ -460,7 +489,15 @@ const val fromField = "from" const val userChatIdField = "user_chat_id" 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" const val chatField = "chat" +const val originField = "origin" +const val chatsField = "chats" const val usernameField = "username" const val bioField = "bio" const val nameField = "name" @@ -523,6 +560,8 @@ 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" const val firstStreetLineField = "street_line1" @@ -536,6 +575,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" @@ -584,6 +627,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" @@ -609,3 +653,21 @@ 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" +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" +const val isManualField = "is_manual" 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..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 +) : CommonContactData, ReplyInfo.External.ContentVariant 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/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt new file mode 100644 index 0000000000..5890f7d686 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -0,0 +1,129 @@ +package dev.inmo.tgbotapi.types + +import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +@Serializable(LinkPreviewOptions.Companion::class) +sealed interface LinkPreviewOptions { + val isDisabled: Boolean + val url: String? + val preferSmallMedia: Boolean + val preferLargeMedia: Boolean + val showAboveText: Boolean + + @Serializable(LinkPreviewOptions.Companion::class) + data object Disabled : LinkPreviewOptions { + @Required + @EncodeDefault + @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(LinkPreviewOptions.Companion::class) + data class Large( + @SerialName(urlField) + override val url: String?, + @SerialName(showAboveTextField) + 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 + get() = false + } + + @Serializable(LinkPreviewOptions.Companion::class) + data class Small( + @SerialName(urlField) + override val url: String?, + @SerialName(showAboveTextField) + 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 + get() = false + } + + @Serializable(LinkPreviewOptions.Companion::class) + data class Default( + @SerialName(urlField) + override val url: String?, + @SerialName(showAboveTextField) + override val showAboveText: Boolean + ) : LinkPreviewOptions { + @Required + @EncodeDefault + @SerialName(isDisabledField) + override val isDisabled: Boolean = false + override val preferSmallMedia: Boolean + get() = false + override val preferLargeMedia: Boolean + get() = false + } + + @Serializable + private data class Surrogate( + @SerialName(isDisabledField) + val isDisabled: Boolean = false, + @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 -> Default(surrogate.url, surrogate.showAboveText) + } + } + + override fun serialize(encoder: Encoder, value: LinkPreviewOptions) { + 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 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/ReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt new file mode 100644 index 0000000000..419a3bba83 --- /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.Giveaway +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: Message + ): 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: MediaContentVariant + ) : Content, SpoilerableData + } + + @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: Giveaway? = 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 MediaContentVariant -> { + 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/ReplyParameters.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt new file mode 100644 index 0000000000..cd3d451474 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyParameters.kt @@ -0,0 +1,153 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.abstracts.TextedInput +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? = null, + @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? = null, + quotePosition: Int? = null + ) : this( + chatIdentifier, + messageId, + allowSendingWithoutReply, + entities.makeSourceString(), + null, + entities.toRawMessageEntities(), + quotePosition + ) + constructor( + metaInfo: Message.MetaInfo, + entities: TextSourcesList, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + metaInfo.chatId, + metaInfo.messageId, + entities, + allowSendingWithoutReply, + quotePosition + ) + constructor( + message: Message, + entities: TextSourcesList, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + message.metaInfo, + entities, + allowSendingWithoutReply, + quotePosition + ) + constructor( + chatIdentifier: ChatIdentifier, + messageId: MessageId, + quote: String, + quoteParseMode: ParseMode, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + chatIdentifier, + messageId, + allowSendingWithoutReply, + quote, + quoteParseMode, + null, + quotePosition + ) + constructor( + metaInfo: Message.MetaInfo, + quote: String, + quoteParseMode: ParseMode, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + metaInfo.chatId, + metaInfo.messageId, + quote, + quoteParseMode, + allowSendingWithoutReply, + quotePosition + ) + constructor( + message: Message, + quote: String, + quoteParseMode: ParseMode, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + message.metaInfo, + quote, + quoteParseMode, + allowSendingWithoutReply, + quotePosition + ) + constructor( + chatIdentifier: ChatIdentifier, + messageId: MessageId, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + chatIdentifier, + messageId, + allowSendingWithoutReply, + null, + null, + null, + quotePosition + ) + constructor( + metaInfo: Message.MetaInfo, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + metaInfo.chatId, + metaInfo.messageId, + allowSendingWithoutReply, + quotePosition + ) + constructor( + message: Message, + allowSendingWithoutReply: Boolean? = null, + quotePosition: Int? = null + ) : this( + message.metaInfo, + allowSendingWithoutReply, + quotePosition + ) +} 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..2d2f639d16 --- /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 ?: emptyList()).asTextSources(text) + } + + 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/UpdateTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt index 2aa6dc43e8..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 @@ -14,14 +14,18 @@ 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" +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, @@ -29,5 +33,12 @@ val ALL_UPDATES_LIST = listOf( UPDATE_POLL_ANSWER, UPDATE_MY_CHAT_MEMBER, UPDATE_CHAT_MEMBER, - UPDATE_CHAT_JOIN_REQUEST + 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 ) 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/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..a4cb6d9fe8 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/boosts/ChatBoostSource.kt @@ -0,0 +1,175 @@ +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.* +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 + @EncodeDefault + @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 + @EncodeDefault + @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 + @EncodeDefault + @SerialName(sourceField) + override val sourceName: String = Giveaway.sourceCode + @Required + @EncodeDefault + @SerialName(isUnclaimedField) + override val unclaimed: Boolean = false + } + + @Serializable(ChatBoostSource.Companion::class) + data class Unclaimed( + @SerialName(giveawayMessageIdField) + 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) + 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 + @EncodeDefault + @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/buttons/KeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt index 64c326637d..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 } @@ -103,13 +104,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 +161,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 55% 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..6d5cd42911 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,23 @@ 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 isPremium: Boolean? + val maxCount: Int @Serializable data class Any( @SerialName(requestIdField) - override val requestId: RequestId - ) : KeyboardButtonRequestUser { + override val requestId: RequestId, + @SerialName(userIsPremiumField) + override val isPremium: Boolean? = null, + @SerialName(maxQuantityField) + override val maxCount: Int = keyboardButtonRequestUserLimit.first + ) : KeyboardButtonRequestUsers { @SerialName(userIsBotField) @EncodeDefault override val isBot: Boolean? = null @@ -35,8 +39,10 @@ sealed interface KeyboardButtonRequestUser { @SerialName(requestIdField) override val requestId: RequestId, @SerialName(userIsPremiumField) - val isPremium: Boolean? = null - ) : KeyboardButtonRequestUser { + override val isPremium: Boolean? = null, + @SerialName(maxQuantityField) + override val maxCount: Int = keyboardButtonRequestUserLimit.first + ) : KeyboardButtonRequestUsers { @SerialName(userIsBotField) @EncodeDefault override val isBot: Boolean = false @@ -45,15 +51,19 @@ 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 + override val isPremium: Boolean? + get() = null } - @Serializer(KeyboardButtonRequestUser::class) - companion object : KSerializer { + @Serializer(KeyboardButtonRequestUsers::class) + companion object : KSerializer { @Serializable private data class Surrogate( @SerialName(requestIdField) @@ -61,31 +71,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.userIsPremium, 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/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/buttons/reply/ReplyKeyboardButtonsShortcuts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt index e22ed517e7..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,46 +57,98 @@ inline fun webAppReplyButton( /** * Creates [RequestUserKeyboardButton] */ -inline fun requestUserReplyButton( +inline fun requestUsersReplyButton( text: String, - requestUser: KeyboardButtonRequestUser + requestUser: KeyboardButtonRequestUsers ) = RequestUserKeyboardButton( text, requestUser ) + /** - * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] + * Creates [RequestUserKeyboardButton] */ -inline fun requestBotReplyButton( +@Deprecated("Renamed", ReplaceWith("requestUsersReplyButton(text, requestUser)", "dev.inmo.tgbotapi.types.buttons.reply.requestUsersReplyButton")) +inline fun requestUserReplyButton( text: String, - requestId: RequestId -) = requestUserReplyButton( + requestUser: KeyboardButtonRequestUsers +) = requestUsersReplyButton(text, requestUser) + +/** + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] + */ +inline fun requestBotsReplyButton( + text: String, + requestId: RequestId, + maxCount: Int = keyboardButtonRequestUserLimit.first +) = requestUsersReplyButton( text, - KeyboardButtonRequestUser.Bot(requestId) + KeyboardButtonRequestUsers.Bot(requestId, maxCount) ) /** - * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] + * 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, +) = requestBotsReplyButton( + text, + 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) +) + +/** + * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common] */ inline fun requestUserReplyButton( text: String, requestId: RequestId, - premiumUser: Boolean? = null -) = requestUserReplyButton( + premiumUser: Boolean? = null, + maxCount: Int = keyboardButtonRequestUserLimit.first +) = requestUsersReplyButton( text, - KeyboardButtonRequestUser.Common(requestId, premiumUser) + requestId, + premiumUser, + maxCount ) /** - * Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] + * 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) +) + +/** + * 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/chat/ChatMessageReactionUpdated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionUpdated.kt new file mode 100644 index 0000000000..96ecb4a24b --- /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.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 +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 : WithPreviewChatAndMessageId { + 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..313b754fb1 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatMessageReactionsCountUpdated.kt @@ -0,0 +1,21 @@ +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 +import kotlinx.serialization.Serializable + +@Serializable +data class ChatMessageReactionsCountUpdated( + @SerialName(chatField) + override val chat: PreviewChat, + @SerialName(messageIdField) + 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/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index 91d502f931..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 @@ -1,8 +1,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.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 +34,23 @@ 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, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + 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, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false ) : ExtendedChannelChat @Serializable @@ -54,7 +72,23 @@ 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, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + 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, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false, ) : ExtendedGroupChat @Serializable @@ -81,7 +115,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 @@ -125,7 +167,23 @@ 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, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + 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, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false, ) : ExtendedSupergroupChat @Serializable @@ -167,7 +225,23 @@ 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, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null, + @SerialName(emojiStatusExpirationDateField) + 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, + @SerialName(hasVisibleHistoryField) + override val newMembersSeeHistory: Boolean = false, ) : ExtendedForumChat @Serializable @@ -186,7 +260,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 @@ -198,4 +280,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 09ac9d6f4f..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 @@ -1,11 +1,28 @@ 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 korlibs.time.DateTime +import dev.inmo.tgbotapi.types.reactions.Reaction 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) +sealed interface ExtendedNonBotChat : ExtendedChat { + val statusEmojiId: CustomEmojiId? + val statusEmojiExpiration: TelegramDate? +} + @Serializable(ExtendedChatSerializer.Companion::class) sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername { val linkedGroupChatId: IdChatIdentifier? @@ -17,23 +34,23 @@ 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) val pinnedMessage: Message? val membersHidden: Boolean + val availableReactions: List? + val newMembersSeeHistory: Boolean } @Serializable(ExtendedChatSerializer.Companion::class) @@ -63,11 +80,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 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/colors/ColorId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt new file mode 100644 index 0000000000..c53bb5410f --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/colors/ColorId.kt @@ -0,0 +1,11 @@ +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 +) \ No newline at end of file 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/dice/Dice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/dice/Dice.kt index 834df0c729..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 -) +) : 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 6492f43f39..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 @@ -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, + 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 e8a85ac00b..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 + 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 f2b57fe6a7..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 +) : 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 707eed7e2d..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 @@ -6,17 +6,35 @@ 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, 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 } @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..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 { +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 3fbc99a402..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 @@ -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, + 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 d98d872261..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 { +) : 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 f3a88b1e66..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 +) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, MediaContentVariant 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..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,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.ReplyInfo 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, ReplyInfo.External.ContentVariant 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..d8bea8ad5c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt @@ -0,0 +1,27 @@ +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 +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, ReplyInfo.External.ContentVariant \ 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..81cbc2ce03 --- /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.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 + +@Serializable +data class GiveawayPrivateResults( + override val chat: PreviewChat, + override val unclaimedCount: Int, + @Transient // TODO::Add message serializer + val message: AccessibleMessage? = null +) : GiveawayResults, ChatEvent, PublicChatEvent 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..850c0122e4 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPublicResults.kt @@ -0,0 +1,161 @@ +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.* +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, + ReplyInfo.External.ContentVariant { + val count: Int + val winners: List + val additionalChats: Int + val publicWinners: Boolean + val refunded: Boolean + + @Serializable + 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 + @EncodeDefault + 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 + 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 + @EncodeDefault + 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..90628b1ee3 --- /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 { + val unclaimedCount: Int +} 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..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 +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 e3e5f0dcb4..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 @@ -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.* @@ -16,10 +15,27 @@ data class ChannelContentMessageImpl( override val date: DateTime, override val editDate: DateTime?, override val hasProtectedContent: Boolean, - override val forwardInfo: ForwardInfo?, - override val replyTo: Message?, + override val forwardOrigin: MessageOrigin?, + override val replyInfo: ReplyInfo?, 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 ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, authorSignature, mediaGroupId + ) +} 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/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/message/ForwardInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt index 58eb633bd6..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 @@ -57,3 +57,56 @@ 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 + ) + is MessageOrigin.Unknown -> null +} + +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 73bd4a4174..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 @@ -14,62 +14,133 @@ 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: Message?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, 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 ?.let { ReplyInfo.Internal(it) }, 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: Message?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, 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 ?.let { ReplyInfo.Internal(it) }, 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: Message?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, 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 ?.let { ReplyInfo.Internal(it) }, 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: Message?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, 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 ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId + ) +} data class FromChannelForumContentMessageImpl( override val chat: PreviewForumChat, @@ -77,32 +148,69 @@ 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: Message?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, 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 ?.let { ReplyInfo.Internal(it) }, 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: Message?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, 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 ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId + ) +} data class CommonForumContentMessageImpl( override val chat: PreviewForumChat, @@ -110,12 +218,30 @@ 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: Message?, + override val replyInfo: ReplyInfo?, override val replyMarkup: InlineKeyboardMarkup?, 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 ?.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 new file mode 100644 index 0000000000..e2ff425a35 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/MessageOrigin.kt @@ -0,0 +1,181 @@ +package dev.inmo.tgbotapi.types.message + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.* +import kotlinx.serialization.* +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(MessageOrigin.Companion::class) +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 + @EncodeDefault + 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 + @EncodeDefault + override val type: String = Companion.type + + companion object { + val type: String = "hidden_user" + } + } + + @Serializable(MessageOrigin.Companion::class) + 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 + @EncodeDefault + 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 + @EncodeDefault + override val type: String = Companion.type + + companion object { + val type: String = "channel" + } + } + } + + @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 + @EncodeDefault + 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 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..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 @@ -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 @@ -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 replyTo: Message?, + override val forwardOrigin: MessageOrigin?, + override val replyInfo: ReplyInfo?, 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 ?.let { ReplyInfo.Internal(it) }, 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 fcaf6164b5..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 @@ -9,6 +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.* +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.* @@ -30,7 +32,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 @@ -48,14 +50,12 @@ 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 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, @@ -96,8 +96,10 @@ internal data class RawMessage( private val invoice: Invoice? = null, private val dice: Dice? = null, private val successful_payment: SuccessfulPayment? = null, + private val giveaway: Giveaway? = null, + private val giveaway_winners: GiveawayResults? = null, - private val user_shared: UserShared? = null, + private val users_shared: UsersShared? = null, private val chat_shared: ChatShared? = null, // Voice Chat Service Messages @@ -128,7 +130,13 @@ internal data class RawMessage( private val passport_data: PassportData? = null, private val proximity_alert_triggered: ProximityAlertTriggered? = null, - private val reply_markup: InlineKeyboardMarkup? = null + private val link_preview_options: LinkPreviewOptions? = null, + + private val reply_markup: InlineKeyboardMarkup? = null, + + // Giveaways + private val giveaway_created: GiveawayCreated? = null, + private val giveaway_completed: GiveawayPrivateResults? = null, ) { private val content: MessageContent? by lazy { val adaptedCaptionEntities = caption ?.let { @@ -141,40 +149,46 @@ 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, 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.toList(), + photo, caption, adaptedCaptionEntities, - has_media_spoiler ?: false + has_media_spoiler ?: false, + quote ) sticker != null -> StickerContent(sticker) dice != null -> DiceContent(dice) @@ -185,44 +199,8 @@ internal data class RawMessage( venue != null -> VenueContent(venue) poll != null -> PollContent(poll) invoice != null -> InvoiceContent(invoice) - else -> null - } - } - - 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 - ) - + giveaway != null -> GiveawayContent(chat, messageId, giveaway) + giveaway_winners is GiveawayPublicResults -> GiveawayPublicResultsContent(giveaway_winners) else -> null } } @@ -232,7 +210,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 @@ -264,13 +242,23 @@ 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 + giveaway_created != null -> giveaway_created + giveaway_winners is GiveawayPrivateResults -> giveaway_winners + giveaway_completed != null -> giveaway_completed else -> null } } val asMessage: Message by lazy { + if (date.date == 0L) { + return@lazy InaccessibleMessage( + chat, + messageId + ) + } + try { chatEvent?.let { chatEvent -> when (chat) { @@ -302,7 +290,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, @@ -311,8 +307,8 @@ internal data class RawMessage( date.asDate, edit_date?.asDate, has_protected_content == true, - forwarded, - reply_to_message?.asMessage, + forward_origin, + replyInfo, reply_markup, via_bot, author_signature, @@ -333,10 +329,10 @@ internal data class RawMessage( messageId, messageThreadId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -348,10 +344,10 @@ internal data class RawMessage( messageId, messageThreadId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -364,10 +360,10 @@ 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, + replyInfo, reply_markup, content, via_bot, @@ -382,10 +378,10 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -398,10 +394,10 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -413,10 +409,10 @@ internal data class RawMessage( chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -428,10 +424,10 @@ 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, + replyInfo, reply_markup, content, via_bot, @@ -446,10 +442,10 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -462,10 +458,10 @@ internal data class RawMessage( sender_chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -477,10 +473,10 @@ internal data class RawMessage( chat, messageId, date.asDate, - forwarded, + forward_origin, edit_date ?.asDate, has_protected_content == true, - reply_to_message ?.asMessage, + replyInfo, reply_markup, content, via_bot, @@ -492,10 +488,10 @@ 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, + replyInfo, reply_markup, content, via_bot, @@ -511,8 +507,8 @@ internal data class RawMessage( date.asDate, edit_date?.asDate, has_protected_content == true, - forwarded, - reply_to_message?.asMessage, + forward_origin, + replyInfo, reply_markup, via_bot, media_group_id 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..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( @@ -22,24 +25,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 +65,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 +185,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/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 0b34ea85a1..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 @@ -1,21 +1,57 @@ 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.types.ChatIdentifier 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.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 : WithPreviewChat { - val messageId: MessageId +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 + +@Serializable +data class InaccessibleMessage( + override val chat: PreviewChat, + override val messageId: MessageId, +) : Message { + override val date: DateTime + get() = DateTime.invoke(0L) } data class UnknownMessageType( @@ -23,7 +59,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..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 : Message { +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/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..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 @@ -1,5 +1,9 @@ package dev.inmo.tgbotapi.types.message.abstracts +import dev.inmo.tgbotapi.types.ReplyInfo + interface PossiblyReplyMessage { + val replyInfo: ReplyInfo? val replyTo: Message? + get() = (replyInfo as? ReplyInfo.Internal) ?.message } \ 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..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 @@ -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.* @@ -52,6 +49,8 @@ sealed interface MessageContent: ResendableContent { subclass(StickerContent::class) subclass(InvoiceContent::class) subclass(StoryContent::class) + subclass(GiveawayPublicResultsContent::class) + subclass(GiveawayContent::class) additionalBuilder() } @@ -139,18 +138,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 @@ -162,8 +149,30 @@ sealed interface ResendableContent { messageThreadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyToMessageId: MessageId? = 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 + ): Request = createResend( + chatId = chatId, + messageThreadId = messageThreadId, + disableNotification = disableNotification, + protectContent = protectContent, + replyParameters = replyToMessageId ?.let { + ReplyParameters( + chatId, + replyToMessageId, + allowSendingWithoutReply = allowSendingWithoutReply + ) + }, + replyMarkup = replyMarkup + ) } 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..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,11 +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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.DocumentFile @@ -19,15 +17,15 @@ 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, messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendAnimation( chatId, @@ -41,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 0b56455154..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,12 +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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.AudioFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -17,15 +15,15 @@ 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, messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendAudio( chatId, @@ -38,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 1b2720bcc8..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,12 +3,11 @@ 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.abstracts.WithOptionalQuoteInfo import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.files.asDocumentFile @@ -19,15 +18,15 @@ 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, messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendDocument( chatId, @@ -37,8 +36,7 @@ data class DocumentContent( messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) @@ -52,7 +50,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/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/GiveawayContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayContent.kt new file mode 100644 index 0000000000..db4cedf9ae --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayContent.kt @@ -0,0 +1,35 @@ +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 +import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.giveaway.Giveaway +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import kotlinx.serialization.Serializable + +@Serializable +data class GiveawayContent( + private val chat: Chat, + private val messageId: MessageId, + val giveaway: Giveaway +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, + disableNotification: Boolean, + protectContent: Boolean, + replyParameters: ReplyParameters?, + replyMarkup: KeyboardMarkup? + ): Request { + 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/message/content/GiveawayPublicResultsContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt new file mode 100644 index 0000000000..ddaf9ebd9e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt @@ -0,0 +1,32 @@ +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 +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, + replyParameters: ReplyParameters?, + replyMarkup: KeyboardMarkup? + ): Request { + 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/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 1b0c05cb53..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 @@ -2,25 +2,24 @@ 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 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 @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 @@ -36,8 +35,7 @@ data class MediaGroupContent( threadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request>> = SendMediaGroup( chatId, @@ -45,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 8b3e98c1ee..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,12 +2,11 @@ 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.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 +17,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( @@ -27,8 +27,7 @@ data class PhotoContent( messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendPhoto( chatId, @@ -38,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/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 920e6a8699..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,10 +5,9 @@ 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.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 @@ -24,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 ff83c6abc2..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 @@ -3,10 +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.* 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 @@ -15,24 +14,24 @@ import kotlinx.serialization.Serializable data class TextContent( override val text: String, override val textSources: TextSourcesList = emptyList(), -) : TextedContent { + val linkPreviewOptions: LinkPreviewOptions? = null, + override val quote: TextQuote? = null +) : TextedContent, WithOptionalQuoteInfo { override fun createResend( chatId: ChatIdentifier, messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendTextMessage( chatId, textSources, - false, + linkPreviewOptions, messageThreadId, disableNotification, protectContent, - replyToMessageId, - allowSendingWithoutReply, + replyParameters, replyMarkup ) } 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..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,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.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 7b8ed78713..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,11 +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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.toTelegramMediaVideo @@ -18,15 +16,15 @@ 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, messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendVideo( chatId, @@ -41,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 7e7deceea8..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 @@ -2,30 +2,28 @@ 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, messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, - replyToMessageId: MessageId?, - allowSendingWithoutReply: Boolean?, + replyParameters: ReplyParameters?, replyMarkup: KeyboardMarkup? ): Request> = SendVoice( chatId = chatId, @@ -35,8 +33,7 @@ data class VoiceContent( duration = media.duration, disableNotification = disableNotification, protectContent = protectContent, - replyToMessageId = replyToMessageId, - allowSendingWithoutReply = allowSendingWithoutReply, + replyParameters = replyParameters, replyMarkup = replyMarkup ) 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/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/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( 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..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 +) : 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 07110b525a..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 @@ -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 @@ -48,7 +49,7 @@ val LongSeconds.asExactScheduledCloseInfo @Serializable(PollSerializer::class) @ClassCastsIncluded -sealed interface Poll { +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/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/reactions/Reaction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt new file mode 100644 index 0000000000..a325317115 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/reactions/Reaction.kt @@ -0,0 +1,96 @@ +package dev.inmo.tgbotapi.types.reactions + +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.customEmojiIdField +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 +import kotlin.jvm.JvmInline + +@Serializable(Reaction.Companion::class) +@ClassCastsIncluded +sealed interface Reaction { + val type: String + + @Serializable(Reaction.Companion::class) + @JvmInline + value class Emoji( + val emoji: String + ) : Reaction { + override val type: String + get() = Companion.type + companion object { + const val type: String = "emoji" + } + } + + @Serializable(Reaction.Companion::class) + @JvmInline + value class CustomEmoji( + val customEmojiId: 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(customEmojiIdField) + val customEmojiId: 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.customEmojiId != null -> CustomEmoji(surrogate.customEmojiId) + 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, + customEmojiId = (value as? CustomEmoji) ?.customEmojiId, + ) + ) + } + } + + } +} 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/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.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..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,6 +1,7 @@ package dev.inmo.tgbotapi.types.stories +import dev.inmo.tgbotapi.types.ReplyInfo import kotlinx.serialization.Serializable @Serializable -class Story +class Story : ReplyInfo.External.ContentVariant 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/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/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/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 20f57940c0..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 @@ -4,7 +4,11 @@ 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 import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery @@ -24,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, @@ -38,8 +42,13 @@ 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 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 @@ -65,6 +74,10 @@ 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) + 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/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/types/venue/Venue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/venue/Venue.kt index f96a1f26bf..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 +) : CommonVenueData, Locationed by location, ReplyInfo.External.ContentVariant 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..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 @@ -37,6 +37,10 @@ interface FlowsUpdatesFilter : UpdatesFilter { val chatMemberUpdatesFlow: Flow val myChatMemberUpdatesFlow: Flow val chatJoinRequestUpdateFlow: Flow + val chatMessageReactionUpdatedUpdateFlow: Flow + val chatMessageReactionsCountUpdatedUpdateFlow: Flow + val chatBoostUpdatedUpdateFlow: Flow + val chatBoostRemovedUpdateFlow: Flow val unknownUpdatesFlow: Flow } @@ -55,7 +59,11 @@ 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() } + override val chatBoostUpdatedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val chatBoostRemovedUpdateFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } } /** 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/MediaGroupContentMessageCreator.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt index dcf3b4d3eb..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 @@ -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,8 +39,8 @@ fun List>.asMedia sourceMessage.date, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.forwardInfo, - sourceMessage.replyTo, + sourceMessage.forwardOrigin, + sourceMessage.replyInfo, sourceMessage.replyMarkup, sourceMessage.senderBot, sourceMessage.authorSignature, @@ -56,8 +54,8 @@ fun List>.asMedia sourceMessage.date, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.forwardInfo, - sourceMessage.replyTo, + sourceMessage.forwardOrigin, + sourceMessage.replyInfo, sourceMessage.replyMarkup, sourceMessage.senderBot, sourceMessage.mediaGroupId @@ -66,10 +64,10 @@ fun List>.asMedia sourceMessage.chat, sourceMessage.messageId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -81,10 +79,10 @@ fun List>.asMedia sourceMessage.messageId, sourceMessage.user, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -95,10 +93,10 @@ fun List>.asMedia sourceMessage.channel, sourceMessage.messageId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -110,10 +108,10 @@ fun List>.asMedia sourceMessage.channel, sourceMessage.messageId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -125,10 +123,10 @@ fun List>.asMedia sourceMessage.messageId, sourceMessage.threadId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -141,10 +139,10 @@ fun List>.asMedia sourceMessage.threadId, sourceMessage.user, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, @@ -156,10 +154,10 @@ fun List>.asMedia sourceMessage.messageId, sourceMessage.threadId, sourceMessage.date, - sourceMessage.forwardInfo, + sourceMessage.forwardOrigin, sourceMessage.editDate, sourceMessage.hasProtectedContent, - sourceMessage.replyTo, + sourceMessage.replyInfo, sourceMessage.replyMarkup, content, sourceMessage.senderBot, 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/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.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 } } 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()) 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) } 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..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 @@ -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 @@ -90,6 +91,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 @@ -102,7 +104,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 @@ -112,6 +114,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 @@ -120,6 +123,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 @@ -176,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 @@ -194,6 +200,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.GiveawayCreated +import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.location.StaticLocation @@ -252,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 @@ -267,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 @@ -288,6 +298,8 @@ 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 import dev.inmo.tgbotapi.types.message.content.LocationContent @@ -313,6 +325,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 @@ -405,9 +418,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 @@ -415,13 +432,18 @@ 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 -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.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 import dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.EditChannelPostUpdate @@ -827,6 +849,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 @@ -864,6 +896,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 @@ -1507,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 @@ -1615,6 +1737,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 @@ -1731,32 +1916,34 @@ 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 KeyboardButtonRequestUser.ifAny(block: (KeyboardButtonRequestUser.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 KeyboardButtonRequestUser.botOrThrow(): KeyboardButtonRequestUser.Bot = this as - dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Bot - -public inline fun KeyboardButtonRequestUser.ifBot(block: (KeyboardButtonRequestUser.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 KeyboardButtonRequestUser.commonOrThrow(): KeyboardButtonRequestUser.Common = this - as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Common +public inline fun KeyboardButtonRequestUsers.anyOrThrow(): KeyboardButtonRequestUsers.Any = this as + dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any public inline fun - KeyboardButtonRequestUser.ifCommon(block: (KeyboardButtonRequestUser.Common) -> T): T? = + 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 + +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.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.ifCommon(block: (KeyboardButtonRequestUsers.Common) -> T): T? = commonOrNull() ?.let(block) public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as? @@ -1902,6 +2089,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 @@ -1956,15 +2161,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 @@ -2111,6 +2307,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 @@ -2216,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 @@ -2243,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 @@ -2611,6 +2855,24 @@ public inline fun TelegramMedia.titledTelegramMediaOrThrow(): TitledTelegramMedi public inline fun TelegramMedia.ifTitledTelegramMedia(block: (TitledTelegramMedia) -> T): T? = titledTelegramMediaOrNull() ?.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.channelChatCreatedOrNull(): ChannelChatCreated? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated @@ -2938,13 +3200,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.usersSharedOrNull(): 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.usersSharedOrThrow(): UsersShared = this as + dev.inmo.tgbotapi.types.request.UsersShared -public inline fun ChatEvent.ifUserShared(block: (UserShared) -> T): T? = userSharedOrNull() +public inline fun ChatEvent.ifUsersShared(block: (UsersShared) -> T): T? = usersSharedOrNull() ?.let(block) public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as? @@ -3233,6 +3495,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 @@ -3515,6 +3795,27 @@ 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 + +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 @@ -3645,6 +3946,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 @@ -4485,6 +4795,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 @@ -4503,14 +4840,14 @@ 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.usersSharedOrNull(): 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.usersSharedOrThrow(): UsersShared = this as + dev.inmo.tgbotapi.types.request.UsersShared -public inline fun RequestResponse.ifUserShared(block: (UserShared) -> 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 @@ -4530,6 +4867,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 @@ -4539,6 +4894,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..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 } @@ -40,6 +39,10 @@ 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 }, + 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) @@ -57,6 +60,10 @@ fun Update.sourceChatWithConverters( is EditMessageUpdate -> editMessageUpdateConverter(this) is MyChatMemberUpdatedUpdate -> myChatMemberUpdatedUpdateConverter(this) 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 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) 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..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 @@ -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, 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..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,7 +3,9 @@ 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 import dev.inmo.tgbotapi.types.webapps.WebAppInfo import dev.inmo.tgbotapi.utils.* @@ -137,18 +139,45 @@ inline fun ReplyKeyboardRowBuilder.webAppButton( * @see replyKeyboard * @see ReplyKeyboardBuilder.row */ -inline fun ReplyKeyboardRowBuilder.requestUserButton( +inline fun ReplyKeyboardRowBuilder.requestUsersButton( text: String, - requestUser: KeyboardButtonRequestUser + requestUser: KeyboardButtonRequestUsers ) = add( - requestUserReplyButton( + requestUsersReplyButton( text, requestUser ) ) /** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot] + * 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 = keyboardButtonRequestUserLimit.first +) = requestUsersButton( + text, + KeyboardButtonRequestUsers.Bot(requestId, maxCount) +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot] * * @see replyKeyboard * @see ReplyKeyboardBuilder.row @@ -156,13 +185,30 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( inline fun ReplyKeyboardRowBuilder.requestBotButton( text: String, requestId: RequestId -) = requestUserButton( +) = requestBotsButton( text, - KeyboardButtonRequestUser.Bot(requestId) + requestId, + maxCount = keyboardButtonRequestUserLimit.first ) /** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common] + * 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 = keyboardButtonRequestUserLimit.first +) = requestUsersButton( + text, + KeyboardButtonRequestUsers.Common(requestId, premiumUser, maxCount) +) + +/** + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common] * * @see replyKeyboard * @see ReplyKeyboardBuilder.row @@ -171,13 +217,26 @@ 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, + premiumUser: Boolean? = null, + maxCount: Int = keyboardButtonRequestUserLimit.first +) = requestUsersButton( text, - KeyboardButtonRequestUser.Common(requestId, premiumUser) + KeyboardButtonRequestUsers.Any(requestId, premiumUser, maxCount) ) /** - * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any] + * Creates and put [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any] * * @see replyKeyboard * @see ReplyKeyboardBuilder.row @@ -185,9 +244,10 @@ inline fun ReplyKeyboardRowBuilder.requestUserButton( inline fun ReplyKeyboardRowBuilder.requestUserOrBotButton( text: String, requestId: RequestId -) = requestUserButton( +) = requestUsersOrBotsButton( text, - KeyboardButtonRequestUser.Any(requestId) + requestId, + maxCount = keyboardButtonRequestUserLimit.first ) 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 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 */