diff --git a/CHANGELOG.md b/CHANGELOG.md index ad6e1197b3..ce272c5b40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # TelegramBotAPI changelog +## 4.0.0 + +**!!! THIS UPDATE CONTAINS FULL REWORK OF MEDIA GROUPS FUNCTIONALITY !!!** + +**THIS UPDATE CONTAINS BREAKING CHANGES** + +* `Common`: + * All the media groups have been rewritten. Since this update, there are no separated messages types for media groups, + but new type of content (`MediaGroupContent`) has been introduced + * [Bot API 6.3](https://core.telegram.org/bots/api-changelog#november-5-2022) support +* `Versions`: + * `MicroUtils`: `0.13.2` -> `0.14.0` +* `Core`: + * New requests + ## 3.3.1 * `Versions`: diff --git a/README.md b/README.md index a6127d4d29..93c836b827 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.2-blue)](https://core.telegram.org/bots/api-changelog#august-12-2022) +# 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.3-blue)](https://core.telegram.org/bots/api-changelog#november-5-2022) | 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=Bookstack&message=Tutorial&color=blue&logo=bookstack)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | |:---:|:---:| diff --git a/gradle.properties b/gradle.properties index e27721d3cb..cd8beaf7f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=3.3.1 +library_version=4.0.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0ecb04a833..4d57db84be 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ ktor = "2.1.3" ksp = "1.7.20-1.0.8" kotlin-poet = "1.12.0" -microutils = "0.13.2" +microutils = "0.14.0" github-release-plugin = "2.4.1" 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 61c04d9a81..025419a86c 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.ForwardMessage 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 @@ -11,46 +12,52 @@ suspend fun TelegramBot.forwardMessage( fromChatId: ChatIdentifier, toChatId: ChatIdentifier, messageId: MessageId, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false ) = execute( - ForwardMessage(fromChatId, toChatId, messageId, disableNotification, protectContent) + ForwardMessage(fromChatId, toChatId, messageId, threadId, disableNotification, protectContent) ) suspend fun TelegramBot.forwardMessage( fromChat: Chat, toChatId: ChatIdentifier, messageId: MessageId, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false -) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification, protectContent) +) = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent) suspend fun TelegramBot.forwardMessage( fromChatId: ChatIdentifier, toChat: Chat, messageId: MessageId, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false -) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification, protectContent) +) = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent) suspend fun TelegramBot.forwardMessage( fromChat: Chat, toChat: Chat, messageId: MessageId, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false -) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification, protectContent) +) = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent) suspend fun TelegramBot.forwardMessage( toChatId: ChatIdentifier, message: Message, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false -) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification, protectContent) +) = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent) suspend fun TelegramBot.forwardMessage( toChat: Chat, message: Message, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false -) = forwardMessage(message.chat, toChat, message.messageId, disableNotification, protectContent) +) = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt index 3bc9a03bfa..387872f07a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt @@ -1,70 +1,57 @@ package dev.inmo.tgbotapi.extensions.api.InternalUtils import dev.inmo.tgbotapi.types.MediaGroupIdentifier -import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage +import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.abstracts.* -import dev.inmo.tgbotapi.types.update.media_group.* - -internal fun Update.lastUpdateIdentifier(): UpdateIdentifier { - return if (this is SentMediaGroupUpdate) { - origins.last().updateId - } else { - updateId - } -} - -internal fun List.lastUpdateIdentifier(): UpdateIdentifier? { - return maxByOrNull { it.updateId } ?.lastUpdateIdentifier() -} +import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage +/** + * Will convert incoming list of updates to list with [MediaGroupUpdate]s + */ internal fun List.convertWithMediaGroupUpdates(): List { val resultUpdates = mutableListOf() - val mediaGroups = mutableMapOf>() + val mediaGroups = mutableMapOf>>>() + for (update in this) { - val data = (update.data as? MediaGroupMessage<*>) - if (data == null) { + val message = (update.data as? PossiblySentViaBotCommonMessage<*>) ?.let { + if (it.content is MediaGroupPartContent) { + it as PossiblySentViaBotCommonMessage + } else { + null + } + } + val mediaGroupId = message ?.mediaGroupId + if (message == null || mediaGroupId == null) { resultUpdates.add(update) continue } when (update) { - is BaseEditMessageUpdate -> resultUpdates.add( - update.toEditMediaGroupUpdate() - ) is BaseSentMessageUpdate -> { - mediaGroups.getOrPut(data.mediaGroupId) { + mediaGroups.getOrPut(mediaGroupId) { mutableListOf() - }.add(update) + }.add(update to message) } else -> resultUpdates.add(update) } } - mediaGroups.values.map { - it.toSentMediaGroupUpdate() ?.let { mediaGroupUpdate -> - resultUpdates.add(mediaGroupUpdate) - } + + mediaGroups.map { (_, updatesWithMessages) -> + val update = updatesWithMessages.maxBy { it.first.updateId }.first + resultUpdates.add( + update.copy(updatesWithMessages.map { it.second }.asMediaGroupMessage()) + ) } + resultUpdates.sortBy { it.updateId } return resultUpdates } -internal fun List.toSentMediaGroupUpdate(): SentMediaGroupUpdate? = (this as? SentMediaGroupUpdate) ?: let { - if (isEmpty()) { - return@let null - } - val resultList = sortedBy { it.updateId } - when (first()) { - is MessageUpdate -> MessageMediaGroupUpdate(resultList) - is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(resultList) - else -> null - } -} - -internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate(): EditMediaGroupUpdate = (this as? EditMediaGroupUpdate) ?: let { - when (this) { - is EditMessageUpdate -> EditMessageMediaGroupUpdate(this) - is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this) - else -> error("Unsupported type of ${BaseEditMessageUpdate::class.simpleName}") - } -} +/** + * @return [EditMessageMediaGroupUpdate] in case if [this] is [EditMessageUpdate]. When [this] object is + * [EditChannelPostUpdate] instance - will return [EditChannelPostMediaGroupUpdate] + * + * @throws IllegalStateException + */ +internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate() = this 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 3862286f90..76d59ce25e 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 @@ -5,7 +5,9 @@ import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions import dev.inmo.tgbotapi.abstracts.* 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.send.send import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -39,6 +41,7 @@ suspend fun TelegramBot.handleLiveLocation( chatId: ChatIdentifier, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -56,7 +59,7 @@ suspend fun TelegramBot.handleLiveLocation( val capturedLiveLocationMessage = currentLiveLocationMessage if (capturedLiveLocationMessage == null) { updateMessageJob.start() - currentLiveLocationMessage = sendLiveLocation( + currentLiveLocationMessage = send( chatId, it.latitude, it.longitude, @@ -64,6 +67,7 @@ suspend fun TelegramBot.handleLiveLocation( it.horizontalAccuracy, it.heading, it.proximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -71,7 +75,7 @@ suspend fun TelegramBot.handleLiveLocation( it.replyMarkup ) } else { - editLiveLocation( + edit( capturedLiveLocationMessage, it.latitude, it.longitude, @@ -94,6 +98,7 @@ suspend fun TelegramBot.handleLiveLocation( chatId: ChatIdentifier, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -112,6 +117,7 @@ suspend fun TelegramBot.handleLiveLocation( ) }, liveTimeMillis, + threadId, disableNotification, protectContent, replyToMessageId, @@ -129,6 +135,7 @@ suspend fun TelegramBot.handleLiveLocation( chatId: ChatIdentifier, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -143,6 +150,7 @@ suspend fun TelegramBot.handleLiveLocation( ) }, liveTimeMillis, + threadId, disableNotification, protectContent, replyToMessageId, 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 c750b86ec9..3ffc151934 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 @@ -90,6 +90,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -106,6 +107,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy, initHeading, initProximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -135,6 +137,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -149,6 +152,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy, initHeading, initProximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -168,6 +172,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -182,6 +187,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy, initHeading, initProximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -201,6 +207,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -215,6 +222,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy, initHeading, initProximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -235,6 +243,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -248,6 +257,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( initHorizontalAccuracy, initHeading, initProximityAlertRadius, + threadId, disableNotification, protectContent, to.messageId, @@ -267,6 +277,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -279,6 +290,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( initHorizontalAccuracy, initHeading, initProximityAlertRadius, + threadId, disableNotification, protectContent, to.messageId, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/CloseForumTopic.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/CloseForumTopic.kt new file mode 100644 index 0000000000..778fc29129 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/CloseForumTopic.kt @@ -0,0 +1,28 @@ +package dev.inmo.tgbotapi.extensions.api.chat.forum + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.ForumTopic +import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.chat.Chat + +suspend fun TelegramBot.closeForumTopic( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId +) = execute( + CloseForumTopic( + chatId, + messageThreadId + ) +) + +suspend fun TelegramBot.closeForumTopic( + chat: Chat, + messageThreadId: MessageThreadId +) = closeForumTopic(chat.id, messageThreadId) + +suspend fun TelegramBot.closeForumTopic( + chat: Chat, + forumTopic: ForumTopic +) = closeForumTopic(chat.id, forumTopic.messageThreadId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/CreateForumTopic.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/CreateForumTopic.kt new file mode 100644 index 0000000000..016917a45d --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/CreateForumTopic.kt @@ -0,0 +1,29 @@ +package dev.inmo.tgbotapi.extensions.api.chat.forum + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.utils.RGBColor + +suspend fun TelegramBot.createForumTopic( + chatId: ChatIdentifier, + name: String, + color: RGBColor, + iconEmojiId: CustomEmojiId? = null +) = execute( + CreateForumTopic( + chatId, + name, + color, + iconEmojiId + ) +) + +suspend fun TelegramBot.createForumTopic( + chat: Chat, + name: String, + color: RGBColor, + iconEmojiId: CustomEmojiId? = null +) = createForumTopic(chat.id, name, color, iconEmojiId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/DeleteForumTopic.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/DeleteForumTopic.kt new file mode 100644 index 0000000000..6de481c828 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/DeleteForumTopic.kt @@ -0,0 +1,33 @@ +package dev.inmo.tgbotapi.extensions.api.chat.forum + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.forum.DeleteForumTopic +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.ForumTopic +import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.chat.Chat + +suspend fun TelegramBot.deleteForumTopic( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId +) = execute( + DeleteForumTopic( + chatId, + messageThreadId + ) +) + +suspend fun TelegramBot.deleteForumTopic( + chatId: ChatIdentifier, + forumTopic: ForumTopic +) = deleteForumTopic(chatId, forumTopic.messageThreadId) + +suspend fun TelegramBot.deleteForumTopic( + chat: Chat, + messageThreadId: MessageThreadId +) = deleteForumTopic(chat.id, messageThreadId) + +suspend fun TelegramBot.deleteForumTopic( + chat: Chat, + forumTopic: ForumTopic +) = deleteForumTopic(chat.id, forumTopic.messageThreadId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/EditForumTopic.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/EditForumTopic.kt new file mode 100644 index 0000000000..3039a884bf --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/EditForumTopic.kt @@ -0,0 +1,36 @@ +package dev.inmo.tgbotapi.extensions.api.chat.forum + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.ForumTopic +import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.chat.Chat + +suspend fun TelegramBot.editForumTopic( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId, + name: String, + iconEmojiId: CustomEmojiId +) = execute( + EditForumTopic( + chatId, + messageThreadId, + name, + iconEmojiId + ) +) + +suspend fun TelegramBot.editForumTopic( + chat: Chat, + messageThreadId: MessageThreadId, + name: String, + iconEmojiId: CustomEmojiId +) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId) + +suspend fun TelegramBot.editForumTopic( + chatIdentifier: ChatIdentifier, + forumTopic: ForumTopic, + iconEmojiId: CustomEmojiId = forumTopic.iconEmojiId ?: error("Icon emoji id in forum topic should be presented when edit forum topic basing on other forum topic object") +) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/ReopenForumTopic.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/ReopenForumTopic.kt new file mode 100644 index 0000000000..35bbd9cf6b --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/ReopenForumTopic.kt @@ -0,0 +1,28 @@ +package dev.inmo.tgbotapi.extensions.api.chat.forum + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.ForumTopic +import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.chat.Chat + +suspend fun TelegramBot.reopenForumTopic( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId +) = execute( + ReopenForumTopic( + chatId, + messageThreadId + ) +) + +suspend fun TelegramBot.reopenForumTopic( + chat: Chat, + messageThreadId: MessageThreadId +) = reopenForumTopic(chat.id, messageThreadId) + +suspend fun TelegramBot.reopenForumTopic( + chat: Chat, + forumTopic: ForumTopic +) = reopenForumTopic(chat.id, forumTopic.messageThreadId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/UnpinAllForumTopicMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/UnpinAllForumTopicMessages.kt new file mode 100644 index 0000000000..9f8ed3f2a7 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/forum/UnpinAllForumTopicMessages.kt @@ -0,0 +1,28 @@ +package dev.inmo.tgbotapi.extensions.api.chat.forum + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllForumTopicMessages +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.ForumTopic +import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.chat.Chat + +suspend fun TelegramBot.unpinAllForumTopicMessages( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId +) = execute( + UnpinAllForumTopicMessages( + chatId, + messageThreadId + ) +) + +suspend fun TelegramBot.unpinAllForumTopicMessages( + chat: Chat, + messageThreadId: MessageThreadId +) = unpinAllForumTopicMessages(chat.id, messageThreadId) + +suspend fun TelegramBot.unpinAllForumTopicMessages( + chat: Chat, + forumTopic: ForumTopic +) = unpinAllForumTopicMessages(chat.id, forumTopic.messageThreadId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt index 3bbf6f2d9a..6cfd50972a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt @@ -3,7 +3,27 @@ package dev.inmo.tgbotapi.extensions.api.chat.get import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.get.GetChat import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.chat.ChannelChat +import dev.inmo.tgbotapi.types.chat.ChannelChatImpl +import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.chat.CommonUser +import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat +import dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl +import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat +import dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl +import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat +import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl +import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat +import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat +import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl +import dev.inmo.tgbotapi.types.chat.ExtendedUser +import dev.inmo.tgbotapi.types.chat.GroupChat +import dev.inmo.tgbotapi.types.chat.GroupChatImpl +import dev.inmo.tgbotapi.types.chat.PrivateChat +import dev.inmo.tgbotapi.types.chat.PrivateChatImpl +import dev.inmo.tgbotapi.types.chat.PublicChat +import dev.inmo.tgbotapi.types.chat.SupergroupChat +import dev.inmo.tgbotapi.types.chat.SupergroupChatImpl import dev.inmo.tgbotapi.utils.PreviewFeature suspend fun TelegramBot.getChat( diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMenuButton.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMenuButton.kt index a4c1c1c0e1..3ae3801803 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMenuButton.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMenuButton.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.chat.get import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.get.GetChatMenuButton -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.chat.PrivateChat suspend fun TelegramBot.getChatMenuButton( diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetDefaultChatMenuButton.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetDefaultChatMenuButton.kt index e03a4f88e0..441317bd11 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetDefaultChatMenuButton.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetDefaultChatMenuButton.kt @@ -2,7 +2,5 @@ package dev.inmo.tgbotapi.extensions.api.chat.get import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.get.GetDefaultChatMenuButton -import dev.inmo.tgbotapi.requests.chat.modify.SetDefaultChatMenuButton -import dev.inmo.tgbotapi.types.MenuButton suspend fun TelegramBot.getDefaultChatMenuButton() = execute(GetDefaultChatMenuButton) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetForumTopicIconStickers.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetForumTopicIconStickers.kt new file mode 100644 index 0000000000..bdaccb143f --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetForumTopicIconStickers.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.extensions.api.chat.get + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.get.GetForumTopicIconStickers + +suspend fun TelegramBot.getForumTopicIconStickers() = execute(GetForumTopicIconStickers) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/ApproveChatJoinRequest.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/ApproveChatJoinRequest.kt index 640711873b..81add7d304 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/ApproveChatJoinRequest.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/ApproveChatJoinRequest.kt @@ -2,8 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.invite_links.ApproveChatJoinRequest -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.ChatJoinRequest +import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt index 711c751920..952ce79764 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt @@ -3,8 +3,11 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links import com.soywiz.klock.DateTime import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.invite_links.CreateChatInviteLink -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MembersLimit +import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.chat.PublicChat +import dev.inmo.tgbotapi.types.toTelegramDate suspend fun TelegramBot.createChatInviteLinkUnlimited( chatId: ChatIdentifier, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/DeclineChatJoinRequest.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/DeclineChatJoinRequest.kt index fbd14302df..9dac02ccfb 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/DeclineChatJoinRequest.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/DeclineChatJoinRequest.kt @@ -2,8 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.invite_links.DeclineChatJoinRequest -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.ChatJoinRequest +import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt index 60c1dda0a0..810b52049b 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt @@ -3,8 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links import com.soywiz.klock.DateTime import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.invite_links.EditChatInviteLink -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.ChatInviteLink +import dev.inmo.tgbotapi.types.MembersLimit +import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.chat.PublicChat +import dev.inmo.tgbotapi.types.toTelegramDate suspend fun TelegramBot.editChatInviteLinkUnlimited( chatId: ChatIdentifier, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt index 431d4fe4a0..af5a5bdfae 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt @@ -2,7 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.BanChatMember -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.TelegramDate +import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatSenderChat.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatSenderChat.kt index 3996021949..e71701fce7 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatSenderChat.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatSenderChat.kt @@ -2,7 +2,8 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.PublicChat suspend fun TelegramBot.banChatSenderChat( diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt index f348b9cb4a..9f0f28a66c 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt @@ -2,7 +2,9 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.GetChatMember -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt index d3900bd0d3..df88b9a3b0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt @@ -2,7 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.TelegramDate +import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User @@ -20,7 +23,8 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, canManageVideoChats: Boolean? = null, - canManageChat: Boolean? + canManageChat: Boolean? = null, + canManageTopics: Boolean? = null ) = execute( PromoteChatMember( chatId, @@ -36,7 +40,8 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages, canPromoteMembers, canManageVideoChats, - canManageChat + canManageChat, + canManageTopics ) ) @@ -54,7 +59,8 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, canManageVideoChats: Boolean? = null, - canManageChat: Boolean? = null + canManageChat: Boolean? = null, + canManageTopics: Boolean? = null ) = promoteChatMember( chat.id, userId, @@ -69,7 +75,8 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages, canPromoteMembers, canManageVideoChats, - canManageChat + canManageChat, + canManageTopics ) suspend fun TelegramBot.promoteChatMember( @@ -86,7 +93,8 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, canManageVideoChats: Boolean? = null, - canManageChat: Boolean? = null + canManageChat: Boolean? = null, + canManageTopics: Boolean? = null ) = promoteChatMember( chatId, user.id, @@ -101,7 +109,8 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages, canPromoteMembers, canManageVideoChats, - canManageChat + canManageChat, + canManageTopics ) suspend fun TelegramBot.promoteChatMember( @@ -118,7 +127,8 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, canManageVideoChats: Boolean? = null, - canManageChat: Boolean? = null + canManageChat: Boolean? = null, + canManageTopics: Boolean? = null ) = promoteChatMember( chat.id, user.id, @@ -133,5 +143,6 @@ suspend fun TelegramBot.promoteChatMember( canPinMessages, canPromoteMembers, canManageVideoChats, - canManageChat + canManageChat, + canManageTopics ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt index b2e2f2f52b..ceb513b90d 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt @@ -2,8 +2,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.RestrictChatMember -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.TelegramDate +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.ChatPermissions +import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User suspend fun TelegramBot.restrictChatMember( diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt index 6e91da2baa..3936721b26 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt @@ -2,7 +2,8 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.SetChatAdministratorCustomTitle -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt index 8600df5529..be8b798fb5 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt @@ -2,7 +2,9 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatSenderChat.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatSenderChat.kt index 1199133111..b6362f07cc 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatSenderChat.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatSenderChat.kt @@ -1,8 +1,9 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.chat.members.* -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.requests.chat.members.UnbanChatSenderChat +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.PublicChat suspend fun TelegramBot.unbanChatSenderChat( diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatMenuButton.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatMenuButton.kt index f4823e01ac..78e0cbcb53 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatMenuButton.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatMenuButton.kt @@ -1,8 +1,9 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.chat.modify.* -import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.requests.chat.modify.SetChatMenuButton +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.MenuButton import dev.inmo.tgbotapi.types.chat.PrivateChat suspend fun TelegramBot.setChatMenuButton( 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 fd6569993f..c192394f92 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 @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.CopyMessage import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -20,6 +21,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -32,6 +34,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId, text, parseMode, + threadId, disableNotification, protectContent, replyToMessageId, @@ -50,12 +53,13 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -67,12 +71,13 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -84,12 +89,13 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -101,6 +107,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -112,6 +119,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, toChatId, entities, + threadId, disableNotification, protectContent, replyToMessageId, @@ -129,12 +137,13 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChatId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -145,12 +154,13 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChat: Chat, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChatId, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChatId, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -161,12 +171,13 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChat: Chat, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(fromChat.id, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(fromChat.id, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -177,12 +188,13 @@ suspend inline fun TelegramBot.copyMessage( message: Message, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -193,12 +205,13 @@ suspend inline fun TelegramBot.copyMessage( message: Message, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -208,12 +221,13 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, message: Message, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChatId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -223,12 +237,13 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, message: Message, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = copyMessage(message.chat, message.messageId, toChat, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -240,6 +255,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -252,6 +268,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId, text, parseMode, + threadId, disableNotification, protectContent, replyToMessageId, @@ -270,6 +287,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -281,6 +299,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, text, parseMode, + threadId, disableNotification, protectContent, replyToMessageId, @@ -298,6 +317,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -309,6 +329,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, text, parseMode, + threadId, disableNotification, protectContent, replyToMessageId, @@ -326,6 +347,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -337,6 +359,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, text, parseMode, + threadId, disableNotification, protectContent, replyToMessageId, @@ -354,6 +377,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -365,6 +389,7 @@ suspend inline fun TelegramBot.copyMessage( messageId, toChatId, entities, + threadId, disableNotification, protectContent, replyToMessageId, @@ -382,6 +407,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, messageId: MessageId, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -392,6 +418,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat.id, messageId, entities, + threadId, disableNotification, protectContent, replyToMessageId, @@ -408,6 +435,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -418,6 +446,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId, messageId, entities, + threadId, disableNotification, protectContent, replyToMessageId, @@ -434,6 +463,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, messageId: MessageId, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -444,6 +474,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat.id, messageId, entities, + threadId, disableNotification, protectContent, replyToMessageId, 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 deleted file mode 100644 index 1673fd81ea..0000000000 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessages.kt +++ /dev/null @@ -1,173 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.send - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup -import dev.inmo.tgbotapi.types.ChatIdentifier -import dev.inmo.tgbotapi.types.media.* -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.chat.Chat -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChatId: ChatIdentifier, - messages: List>, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -): List> { - val first = messages.first().content.toMediaGroupMemberTelegramMedia().let { - if (text != null) { - when (it) { - is TelegramMediaAudio -> it.copy(text = text, parseMode = parseMode) - is TelegramMediaDocument -> it.copy(text = text, parseMode = parseMode) - is TelegramMediaPhoto -> it.copy(text = text, parseMode = parseMode) - is TelegramMediaVideo -> it.copy(text = text, parseMode = parseMode) - } - } else { - it - } - } - - return sendMediaGroup( - toChatId, - listOf(first) + messages.drop(1).map { - it.content.toMediaGroupMemberTelegramMedia() - }, - disableNotification, - protectContent, - replyToMessageId, - allowSendingWithoutReply - ) -} - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChat: Chat, - messages: List>, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = copyMessages(toChat.id, messages, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChat: ChatIdentifier, - update: SentMediaGroupUpdate, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = copyMessages(toChat, update.data, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChat: Chat, - update: SentMediaGroupUpdate, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = copyMessages(toChat.id, update, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChatId: ChatIdentifier, - messages: List>, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -): List> { - val first = messages.first().content.toMediaGroupMemberTelegramMedia().let { - when (it) { - is TelegramMediaAudio -> TelegramMediaAudio(it.file, entities, it.duration, it.performer, it.title, it.thumb) - is TelegramMediaDocument -> TelegramMediaDocument(it.file, entities, it.thumb, it.disableContentTypeDetection) - is TelegramMediaPhoto -> TelegramMediaPhoto(it.file, entities) - is TelegramMediaVideo -> TelegramMediaVideo(it.file, entities, it.width, it.height, it.duration, it.thumb) - } - } - - return sendMediaGroup( - toChatId, - listOf(first) + messages.drop(1).map { - it.content.toMediaGroupMemberTelegramMedia() - }, - disableNotification, - protectContent, - replyToMessageId, - allowSendingWithoutReply - ) -} - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChat: Chat, - messages: List>, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = copyMessages(toChat.id, messages, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChat: ChatIdentifier, - update: SentMediaGroupUpdate, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = copyMessages(toChat, update.data, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) - -/** - * Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements - * will be copied as they are - */ -suspend inline fun TelegramBot.copyMessages( - toChat: Chat, - update: SentMediaGroupUpdate, - entities: TextSourcesList, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null -) = copyMessages(toChat.id, update, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) 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 e9f4fdeebe..0290897343 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 @@ -23,6 +23,7 @@ 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.content.* import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.payments.LabeledPrice @@ -30,6 +31,7 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull import kotlinx.coroutines.flow.Flow import kotlin.js.JsName import kotlin.jvm.JvmName @@ -55,6 +57,7 @@ suspend inline fun TelegramBot.reply( phoneNumber, firstName, lastName, + to.threadIdOrNull, disableNotification, protectContent, to.messageId, @@ -76,6 +79,7 @@ suspend inline fun TelegramBot.reply( ) = sendContact( to.chat, contact, + to.threadIdOrNull, disableNotification, protectContent, to.messageId, @@ -97,7 +101,7 @@ suspend inline fun TelegramBot.replyWithDice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(to.chat, animationType, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -131,6 +135,7 @@ suspend inline fun TelegramBot.reply( to.chat, latitude, longitude, + to.threadIdOrNull, disableNotification, protectContent, allowSendingWithoutReply, @@ -152,6 +157,7 @@ suspend inline fun TelegramBot.reply( ) = sendLocation( to.chat, location, + to.threadIdOrNull, disableNotification, protectContent, allowSendingWithoutReply, @@ -180,6 +186,7 @@ suspend inline fun TelegramBot.reply( text, parseMode, disableWebPagePreview, + to.threadIdOrNull, disableNotification, protectContent, to.messageId, @@ -203,6 +210,7 @@ suspend inline fun TelegramBot.reply( to.chat, entities, disableWebPagePreview, + to.threadIdOrNull, disableNotification, protectContent, to.messageId, @@ -271,6 +279,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = to.messageId, @@ -301,6 +310,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = to.messageId, @@ -318,6 +328,7 @@ suspend inline fun TelegramBot.reply( ) = sendVenue( chat = to.chat, venue = venue, + threadId = to.threadIdOrNull, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = to.messageId, @@ -336,7 +347,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, gameShortName, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup + to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup ) suspend inline fun TelegramBot.replyWithGame( @@ -347,7 +358,7 @@ suspend inline fun TelegramBot.replyWithGame( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - to.chat, game.title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup + to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup ) suspend inline fun TelegramBot.reply( @@ -384,6 +395,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, + to.threadIdOrNull, disableNotification, protectContent, to.messageId, @@ -403,7 +415,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( to: Message, @@ -425,6 +437,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, + to.threadIdOrNull, disableNotification, protectContent, to.messageId, @@ -443,7 +456,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(to.chat, animation, entities, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(to.chat, animation, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Audio @@ -461,7 +474,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -473,7 +486,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, text, parseMode, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAudio( to: Message, @@ -487,7 +500,7 @@ suspend inline fun TelegramBot.replyWithAudio( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -498,7 +511,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(to.chat, audio, entities, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Documents @@ -514,7 +527,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: Message, @@ -526,7 +539,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( to: Message, @@ -538,7 +551,7 @@ suspend inline fun TelegramBot.replyWithDocument( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, thumb, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( to: Message, @@ -549,7 +562,7 @@ suspend inline fun TelegramBot.reply( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(to.chat, document, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) // Media Group @@ -561,7 +574,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithPlaylist( to: Message, @@ -569,7 +582,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithDocuments( to: Message, @@ -577,7 +590,7 @@ suspend inline fun TelegramBot.replyWithDocuments( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithGallery( to: Message, @@ -585,7 +598,7 @@ suspend inline fun TelegramBot.replyWithGallery( disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) // Photo @@ -599,7 +612,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, fileId, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -610,7 +623,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photo, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -621,7 +634,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photoSize, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -632,7 +645,7 @@ suspend inline fun TelegramBot.replyWithPhoto( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, fileId, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, fileId, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -642,7 +655,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photo, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photo, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -652,7 +665,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(to.chat, photoSize, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(to.chat, photoSize, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Sticker @@ -664,7 +677,7 @@ suspend inline fun TelegramBot.replyWithSticker( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -673,7 +686,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(to.chat, sticker, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Videos @@ -691,7 +704,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -702,7 +715,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVideo( to: Message, @@ -716,7 +729,7 @@ suspend inline fun TelegramBot.replyWithVideo( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, thumb, entities, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, thumb, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -726,7 +739,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(to.chat, video, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(to.chat, video, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // VideoNotes @@ -741,7 +754,7 @@ suspend inline fun TelegramBot.replyWithVideoNote( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(to.chat, videoNote, thumb, duration, size, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(to.chat, videoNote, thumb, duration, size, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -750,7 +763,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(to.chat, videoNote, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(to.chat, videoNote, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Voice @@ -765,7 +778,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, text, parseMode, duration, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, text, parseMode, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -776,7 +789,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -788,7 +801,7 @@ suspend inline fun TelegramBot.replyWithVoice( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, duration, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -798,7 +811,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(to.chat, voice, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(to.chat, voice, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Invoice @@ -830,7 +843,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) // Polls @@ -847,7 +860,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -862,7 +875,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -878,7 +891,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -895,7 +908,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -910,7 +923,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( to: Message, @@ -926,7 +939,7 @@ suspend inline fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( @@ -990,6 +1003,7 @@ suspend inline fun TelegramBot.reply( messageId, text, parseMode, + to.threadIdOrNull, disableNotification, protectContent, to.messageId, @@ -1027,18 +1041,17 @@ suspend fun TelegramBot.reply( protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) { - execute( - content.createResend( - to.chat.id, - disableNotification, - protectContent, - to.messageId, - allowSendingWithoutReply, - replyMarkup - ) +): Message = execute( + content.createResend( + to.chat.id, + to.threadIdOrNull, + disableNotification, + protectContent, + to.messageId, + allowSendingWithoutReply, + replyMarkup ) -} +) /** * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update @@ -1056,6 +1069,7 @@ suspend fun TelegramBot.reply( message.chat.id, locationsFlow, liveTimeMillis, + message.threadIdOrNull, disableNotification, protectContent, message.messageId, @@ -1081,6 +1095,7 @@ suspend fun TelegramBot.reply( message.chat.id, locationsFlow, liveTimeMillis, + message.threadIdOrNull, disableNotification, protectContent, message.messageId, @@ -1107,6 +1122,7 @@ suspend fun TelegramBot.reply( message.chat.id, locationsFlow, liveTimeMillis, + message.threadIdOrNull, disableNotification, protectContent, message.messageId, @@ -1219,7 +1235,7 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) - is AudioMediaGroupContent -> reply( + is AudioMediaGroupPartContent -> reply( to = to, audio = content.media, text = text, @@ -1291,7 +1307,7 @@ suspend fun TelegramBot.reply( allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) - is AudioMediaGroupContent -> reply( + is AudioMediaGroupPartContent -> reply( to = to, audio = content.media, entities = entities, 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 0a754e2c52..02c5e02555 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -47,6 +47,7 @@ suspend inline fun TelegramBot.reply( phoneNumber: String, firstName: String, lastName: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -56,6 +57,7 @@ suspend inline fun TelegramBot.reply( phoneNumber, firstName, lastName, + threadId, disableNotification, protectContent, toMessageId, @@ -71,6 +73,7 @@ suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, contact: Contact, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -78,6 +81,7 @@ suspend inline fun TelegramBot.reply( ) = sendContact( toChatId, contact, + threadId, disableNotification, protectContent, toMessageId, @@ -96,11 +100,12 @@ suspend inline fun TelegramBot.replyWithDice( toChatId: ChatId, toMessageId: MessageId, animationType: DiceAnimationType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(toChatId, animationType, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(toChatId, animationType, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -110,11 +115,12 @@ suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, animationType: DiceAnimationType, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithDice(toChatId, toMessageId, animationType, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithDice(toChatId, toMessageId, animationType, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Location @@ -128,6 +134,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -136,6 +143,7 @@ suspend inline fun TelegramBot.reply( toChatId, latitude, longitude, + threadId, disableNotification, protectContent, allowSendingWithoutReply, @@ -151,6 +159,7 @@ suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, location: StaticLocation, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -158,6 +167,7 @@ suspend inline fun TelegramBot.reply( ) = sendLocation( toChatId, location, + threadId, disableNotification, protectContent, allowSendingWithoutReply, @@ -178,6 +188,7 @@ suspend inline fun TelegramBot.reply( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -187,6 +198,7 @@ suspend inline fun TelegramBot.reply( text, parseMode, disableWebPagePreview, + threadId, disableNotification, protectContent, toMessageId, @@ -203,6 +215,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -211,6 +224,7 @@ suspend inline fun TelegramBot.reply( toChatId, entities, disableWebPagePreview, + threadId, disableNotification, protectContent, toMessageId, @@ -227,12 +241,13 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -243,12 +258,13 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: String, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Venue @@ -268,6 +284,7 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -282,6 +299,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = toMessageId, @@ -299,6 +317,7 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -313,6 +332,7 @@ suspend inline fun TelegramBot.reply( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = toMessageId, @@ -324,6 +344,7 @@ suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, venue: Venue, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -331,6 +352,7 @@ suspend inline fun TelegramBot.reply( ) = sendVenue( chatId = toChatId, venue = venue, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = toMessageId, @@ -345,35 +367,38 @@ suspend inline fun TelegramBot.replyWithGame( toChatId: ChatId, toMessageId: MessageId, gameShortName: String, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, gameShortName, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup + toChatId, gameShortName, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup ) suspend inline fun TelegramBot.replyWithGame( toChatId: ChatId, toMessageId: MessageId, game: Game, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - toChatId, game.title, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup + toChatId, game.title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup ) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, game: Game, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = replyWithGame(toChatId, toMessageId, game, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = replyWithGame(toChatId, toMessageId, game, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) // Animation @@ -388,6 +413,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -401,6 +427,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, + threadId, disableNotification, protectContent, toMessageId, @@ -417,11 +444,12 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, text, parseMode, duration, width, height, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(toChatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( toChatId: ChatId, @@ -432,6 +460,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -444,6 +473,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration, width, height, + threadId, disableNotification, protectContent, toMessageId, @@ -459,11 +489,12 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(toChatId, animation, entities, duration, width, height, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(toChatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Audio @@ -478,11 +509,12 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -491,11 +523,12 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, text, parseMode, title, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAudio( toChatId: ChatId, @@ -506,11 +539,12 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -518,11 +552,12 @@ suspend inline fun TelegramBot.reply( audio: AudioFile, entities: TextSourcesList, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(toChatId, audio, entities, title, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(toChatId, audio, entities, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Documents @@ -534,12 +569,13 @@ suspend inline fun TelegramBot.replyWithDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, text, parseMode, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -547,12 +583,13 @@ suspend inline fun TelegramBot.reply( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, text, parseMode, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( toChatId: ChatId, @@ -560,24 +597,26 @@ suspend inline fun TelegramBot.replyWithDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, thumb, entities, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, document: DocumentFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(toChatId, document, entities, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(toChatId, document, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) // Media Group @@ -587,37 +626,41 @@ suspend inline fun TelegramBot.replyWithMediaGroup( toChatId: ChatId, toMessageId: MessageId, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(toChatId, media, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithPlaylist( toChatId: ChatId, toMessageId: MessageId, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(toChatId, media, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithDocuments( toChatId: ChatId, toMessageId: MessageId, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(toChatId, media, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithGallery( toChatId: ChatId, toMessageId: MessageId, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(toChatId, media, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) // Photo @@ -628,11 +671,12 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, text, parseMode, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, fileId, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -640,11 +684,12 @@ suspend inline fun TelegramBot.reply( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, text, parseMode, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photo, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -652,11 +697,12 @@ suspend inline fun TelegramBot.reply( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, text, parseMode, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithPhoto( @@ -664,33 +710,36 @@ suspend inline fun TelegramBot.replyWithPhoto( toMessageId: MessageId, fileId: InputFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, fileId, entities, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, fileId, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, photo: Photo, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photo, entities, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photo, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, photoSize: PhotoSize, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(toChatId, photoSize, entities, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(toChatId, photoSize, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Sticker @@ -699,21 +748,23 @@ suspend inline fun TelegramBot.replyWithSticker( toChatId: ChatId, toMessageId: MessageId, sticker: InputFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, sticker: Sticker, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(toChatId, sticker, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Videos @@ -728,11 +779,12 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -740,11 +792,12 @@ suspend inline fun TelegramBot.reply( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, text, parseMode, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVideo( toChatId: ChatId, @@ -755,22 +808,24 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, thumb, entities, duration, width, height, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, video: VideoFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(toChatId, video, entities, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(toChatId, video, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // VideoNotes @@ -782,21 +837,23 @@ suspend inline fun TelegramBot.replyWithVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, thumb, duration, size, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, videoNote: VideoNoteFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(toChatId, videoNote, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(toChatId, videoNote, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Voice @@ -808,11 +865,12 @@ suspend inline fun TelegramBot.replyWithVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, duration, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -820,11 +878,12 @@ suspend inline fun TelegramBot.reply( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, text, parseMode, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVoice( @@ -833,22 +892,24 @@ suspend inline fun TelegramBot.replyWithVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, duration, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, voice: VoiceFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(toChatId, voice, entities, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(toChatId, voice, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Invoice @@ -877,11 +938,12 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, + threadId: MessageThreadId? = null, 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, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(toChatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) // Polls @@ -895,11 +957,12 @@ suspend inline fun TelegramBot.reply( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -911,11 +974,12 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -928,11 +992,12 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -946,11 +1011,12 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -962,11 +1028,12 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -979,11 +1046,12 @@ 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? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( @@ -995,6 +1063,7 @@ suspend inline fun TelegramBot.reply( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1010,6 +1079,7 @@ suspend inline fun TelegramBot.reply( isAnonymous = isAnonymous, allowMultipleAnswers = isAnonymous, closeInfo = closeInfo, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1026,6 +1096,7 @@ suspend inline fun TelegramBot.reply( options = options, isAnonymous = isAnonymous, closeInfo = closeInfo, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1041,6 +1112,7 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1051,6 +1123,7 @@ suspend inline fun TelegramBot.reply( messageId, text, parseMode, + threadId, disableNotification, protectContent, toMessageId, @@ -1065,11 +1138,12 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( toChatId: ChatId, @@ -1077,16 +1151,18 @@ suspend inline fun TelegramBot.reply( copy: Message, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) +) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, content: MessageContent, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1095,6 +1171,7 @@ suspend fun TelegramBot.reply( execute( content.createResend( toChatId, + threadId, disableNotification, protectContent, toMessageId, @@ -1114,6 +1191,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -1121,6 +1199,7 @@ suspend fun TelegramBot.reply( toChatId, locationsFlow, liveTimeMillis, + threadId, disableNotification, protectContent, toMessageId, @@ -1139,6 +1218,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -1147,6 +1227,7 @@ suspend fun TelegramBot.reply( toChatId, locationsFlow, liveTimeMillis, + threadId, disableNotification, protectContent, toMessageId, @@ -1166,6 +1247,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -1174,6 +1256,7 @@ suspend fun TelegramBot.reply( toChatId, locationsFlow, liveTimeMillis, + threadId, disableNotification, protectContent, toMessageId, @@ -1185,6 +1268,7 @@ suspend fun TelegramBot.reply( toChatId: ChatId, toMessageId: MessageId, mediaFile: TelegramMediaFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1195,6 +1279,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, audio = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1204,6 +1289,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, animation = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1213,6 +1299,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, voice = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1222,6 +1309,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, video = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1231,6 +1319,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, videoNote = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1240,6 +1329,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, document = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1249,6 +1339,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, sticker = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1258,6 +1349,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, photoSize = mediaFile, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1267,6 +1359,7 @@ suspend fun TelegramBot.reply( toChatId = toChatId, toMessageId = toMessageId, document = mediaFile.asDocumentFile(), + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1281,6 +1374,7 @@ suspend fun TelegramBot.reply( content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1293,17 +1387,19 @@ suspend fun TelegramBot.reply( voice = content.media, text = text, parseMode = parseMode, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) - is AudioMediaGroupContent -> reply( + is AudioMediaGroupPartContent -> reply( toChatId = toChatId, toMessageId = toMessageId, audio = content.media, text = text, parseMode = parseMode, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1315,6 +1411,7 @@ suspend fun TelegramBot.reply( photoSize = content.media, text = text, parseMode = parseMode, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1326,6 +1423,7 @@ suspend fun TelegramBot.reply( video = content.media, text = text, parseMode = parseMode, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1337,6 +1435,7 @@ suspend fun TelegramBot.reply( animation = content.media, text = text, parseMode = parseMode, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1348,6 +1447,7 @@ suspend fun TelegramBot.reply( document = content.media.asDocumentFile(), text = text, parseMode = parseMode, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1361,6 +1461,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, content: TextedMediaContent, entities: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1372,16 +1473,18 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, voice = content.media, entities = entities, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, replyMarkup = replyMarkup ) - is AudioMediaGroupContent -> reply( + is AudioMediaGroupPartContent -> reply( toChatId = toChatId, toMessageId = toMessageId, audio = content.media, entities = entities, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1392,6 +1495,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, photoSize = content.media, entities = entities, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1402,6 +1506,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, video = content.media, entities = entities, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1412,6 +1517,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, animation = content.media, entities = entities, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -1422,6 +1528,7 @@ suspend fun TelegramBot.reply( toMessageId = toMessageId, document = content.media.asDocumentFile(), entities = entities, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, 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 edb36004eb..b3ffe9138b 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 @@ -15,6 +15,7 @@ suspend fun TelegramBot.sendContact( phoneNumber: String, firstName: String, lastName: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -22,7 +23,7 @@ suspend fun TelegramBot.sendContact( replyMarkup: KeyboardMarkup? = null ) = execute( SendContact( - chatId, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) ) @@ -33,6 +34,7 @@ suspend fun TelegramBot.sendContact( suspend fun TelegramBot.sendContact( chatId: ChatIdentifier, contact: Contact, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -40,7 +42,7 @@ suspend fun TelegramBot.sendContact( replyMarkup: KeyboardMarkup? = null ) = execute( SendContact( - chatId, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) ) @@ -53,13 +55,14 @@ suspend fun TelegramBot.sendContact( phoneNumber: String, firstName: String, lastName: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - chat.id, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -69,11 +72,12 @@ suspend fun TelegramBot.sendContact( suspend fun TelegramBot.sendContact( chat: Chat, contact: Contact, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendContact( - chat.id, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 90a2af25ec..c5d7ce3cc9 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 @@ -4,6 +4,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.dice.DiceAnimationType @@ -15,13 +16,14 @@ import dev.inmo.tgbotapi.types.dice.DiceAnimationType suspend fun TelegramBot.sendDice( chatId: ChatIdentifier, animationType: DiceAnimationType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendDice(chatId, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendDice(chatId, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) /** @@ -31,9 +33,10 @@ suspend fun TelegramBot.sendDice( suspend fun TelegramBot.sendDice( chat: Chat, animationType: DiceAnimationType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(chat.id, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(chat.id, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 480c0577a4..d5666fd3b2 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 @@ -19,6 +19,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -33,6 +34,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy, heading, proximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -52,6 +54,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -65,6 +68,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy, heading, proximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -84,6 +88,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -97,6 +102,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy, heading, proximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -115,6 +121,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -128,6 +135,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy, heading, proximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -147,12 +155,13 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -165,12 +174,13 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -184,12 +194,13 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -202,9 +213,10 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 52425acfd2..0c267d18cd 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 @@ -20,13 +20,25 @@ suspend fun TelegramBot.sendMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendTextMessage( + chatId, + text, + parseMode, + disableWebPagePreview, + threadId, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply, + replyMarkup + ) ) /** @@ -38,32 +50,16 @@ suspend fun TelegramBot.sendTextMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, 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 fun TelegramBot.sendMessage( - chat: Chat, - text: String, - parseMode: ParseMode? = null, - disableWebPagePreview: Boolean? = null, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyToMessageId: MessageId? = null, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, 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 @@ -73,12 +69,31 @@ suspend fun TelegramBot.sendTextMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, 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 fun TelegramBot.sendMessage( + chat: Chat, + text: String, + parseMode: ParseMode? = null, + disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -88,13 +103,14 @@ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) /** @@ -105,13 +121,14 @@ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -122,13 +139,14 @@ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, separator: String, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -138,13 +156,14 @@ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendMessage( - chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -155,13 +174,14 @@ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -172,13 +192,14 @@ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, separator: String, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -188,12 +209,13 @@ suspend fun TelegramBot.sendMessage( chat: Chat, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -203,13 +225,14 @@ suspend fun TelegramBot.sendMessage( chat: Chat, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -220,13 +243,14 @@ suspend fun TelegramBot.sendMessage( chat: Chat, separator: String, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -237,12 +261,13 @@ suspend fun TelegramBot.sendTextMessage( chat: Chat, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -252,13 +277,14 @@ suspend fun TelegramBot.sendTextMessage( chat: Chat, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -269,10 +295,11 @@ suspend fun TelegramBot.sendTextMessage( chat: Chat, separator: String, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 c493505d76..6f545ec428 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 @@ -4,6 +4,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.location.Location @@ -16,6 +17,7 @@ suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -26,6 +28,7 @@ suspend fun TelegramBot.sendLocation( chatId, latitude, longitude, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, @@ -41,6 +44,7 @@ suspend fun TelegramBot.sendLocation( suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, location: Location, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -50,6 +54,7 @@ suspend fun TelegramBot.sendLocation( chatId, location.latitude, location.longitude, + threadId, disableNotification, protectContent, allowSendingWithoutReply, @@ -65,6 +70,7 @@ suspend fun TelegramBot.sendLocation( chat: Chat, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -74,6 +80,7 @@ suspend fun TelegramBot.sendLocation( chat.id, latitude, longitude, + threadId, disableNotification, protectContent, allowSendingWithoutReply, @@ -88,6 +95,7 @@ suspend fun TelegramBot.sendLocation( suspend fun TelegramBot.sendLocation( chat: Chat, location: Location, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -97,6 +105,7 @@ suspend fun TelegramBot.sendLocation( chat.id, location.latitude, location.longitude, + threadId, disableNotification, protectContent, allowSendingWithoutReply, @@ -112,12 +121,13 @@ suspend fun TelegramBot.sendStaticLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -126,12 +136,13 @@ suspend fun TelegramBot.sendStaticLocation( suspend fun TelegramBot.sendStaticLocation( chatId: ChatIdentifier, location: Location, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chatId, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chatId, location.latitude, location.longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -141,12 +152,13 @@ suspend fun TelegramBot.sendStaticLocation( chat: Chat, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chat.id, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -155,9 +167,10 @@ suspend fun TelegramBot.sendStaticLocation( suspend fun TelegramBot.sendStaticLocation( chat: Chat, location: Location, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendLocation(chat.id, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendLocation(chat.id, location.latitude, location.longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, 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 7a579887c3..4549d6afcf 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 @@ -22,6 +22,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -38,6 +39,7 @@ suspend fun TelegramBot.sendVenue( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = replyToMessageId, @@ -60,6 +62,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -75,6 +78,7 @@ suspend fun TelegramBot.sendVenue( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = replyToMessageId, @@ -95,6 +99,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -110,6 +115,7 @@ suspend fun TelegramBot.sendVenue( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = replyToMessageId, @@ -130,6 +136,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -145,6 +152,7 @@ suspend fun TelegramBot.sendVenue( foursquareType = foursquareType, googlePlaceId = googlePlaceId, googlePlaceType = googlePlaceType, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = replyToMessageId, @@ -159,6 +167,7 @@ suspend fun TelegramBot.sendVenue( suspend fun TelegramBot.sendVenue( chatId: ChatIdentifier, venue: Venue, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -168,6 +177,7 @@ suspend fun TelegramBot.sendVenue( SendVenue( chatId = chatId, venue = venue, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = replyToMessageId, @@ -183,6 +193,7 @@ suspend fun TelegramBot.sendVenue( suspend fun TelegramBot.sendVenue( chat: Chat, venue: Venue, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -191,6 +202,7 @@ suspend fun TelegramBot.sendVenue( ) = sendVenue( chatId = chat.id, venue = venue, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = replyToMessageId, 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 46305fbd0a..45df51e091 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 @@ -16,6 +16,7 @@ import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.dice.DiceAnimationType import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.games.Game +import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.location.StaticLocation import dev.inmo.tgbotapi.types.media.* import dev.inmo.tgbotapi.types.message.ParseMode @@ -58,12 +59,13 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chatId, animation, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAnimation] request @@ -78,12 +80,13 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat, animation, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAnimation] request @@ -97,12 +100,13 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chatId, animation, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAnimation] request @@ -116,12 +120,13 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat, animation, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAudio] request @@ -134,12 +139,13 @@ suspend fun TelegramBot.send( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio, text, parseMode, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAudio] request @@ -152,12 +158,13 @@ suspend fun TelegramBot.send( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat, audio, text, parseMode, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAudio] request @@ -169,12 +176,13 @@ suspend inline fun TelegramBot.send( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio, entities, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio, entities, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendAudio] request @@ -186,12 +194,13 @@ suspend inline fun TelegramBot.send( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat, audio, entities, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat, audio, entities, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendContact] request @@ -203,12 +212,13 @@ suspend fun TelegramBot.send( phoneNumber: String, firstName: String, lastName: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chatId, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chatId, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendContact] request @@ -218,12 +228,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, contact: Contact, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chatId, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chatId, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendContact] request @@ -235,12 +246,13 @@ suspend fun TelegramBot.send( phoneNumber: String, firstName: String, lastName: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chat, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chat, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendContact] request @@ -250,12 +262,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, contact: Contact, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendContact(chat, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendContact(chat, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendDice] request @@ -265,12 +278,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, animationType: DiceAnimationType, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(chatId, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(chatId, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendDice] request @@ -280,12 +294,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, animationType: DiceAnimationType, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendDice(chat, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendDice(chat, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendDocument] request @@ -297,13 +312,14 @@ suspend fun TelegramBot.send( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chatId, document, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chatId, document, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) /** * Will execute [sendDocument] request @@ -315,13 +331,14 @@ suspend fun TelegramBot.send( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat, document, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat, document, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) /** * Will execute [sendDocument] request @@ -332,13 +349,14 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, document: DocumentFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chatId, document, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chatId, document, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) /** * Will execute [sendDocument] request @@ -349,13 +367,14 @@ suspend inline fun TelegramBot.send( chat: Chat, document: DocumentFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat, document, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat, document, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) /** * Will execute [sendGame] request @@ -365,12 +384,13 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, game: Game, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendGame(chatId, game, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendGame(chatId, game, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendGame] request @@ -380,12 +400,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, game: Game, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendGame(chat, game, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendGame(chat, game, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendInvoice] request @@ -411,12 +432,13 @@ suspend fun TelegramBot.send( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, 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, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendInvoice] request @@ -442,12 +464,13 @@ suspend fun TelegramBot.send( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = 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, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -458,12 +481,13 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chatId, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -473,12 +497,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, location: StaticLocation, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chatId, location, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chatId, location, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -489,12 +514,13 @@ suspend fun TelegramBot.send( chat: Chat, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chat, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chat, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -504,12 +530,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, location: StaticLocation, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, replyToMessageId: MessageId? = null, replyMarkup: KeyboardMarkup? = null -) = sendStaticLocation(chat, location, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) +) = sendStaticLocation(chat, location, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup) /** * Will execute [sendTextMessage] request @@ -521,12 +548,13 @@ suspend fun TelegramBot.send( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendTextMessage] request @@ -538,12 +566,13 @@ suspend fun TelegramBot.send( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendTextMessage] request @@ -554,12 +583,13 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -569,13 +599,14 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -586,13 +617,14 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, separator: String, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -604,12 +636,13 @@ suspend fun TelegramBot.send( chat: Chat, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendTextMessage(chat, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendTextMessage(chat, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -619,13 +652,14 @@ suspend fun TelegramBot.send( chat: Chat, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -636,13 +670,14 @@ suspend fun TelegramBot.send( chat: Chat, separator: String, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, builderBody: EntitiesBuilderBody -) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -654,12 +689,13 @@ suspend fun TelegramBot.send( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -671,12 +707,13 @@ suspend fun TelegramBot.send( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photo, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -688,12 +725,13 @@ suspend fun TelegramBot.send( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -705,12 +743,13 @@ suspend fun TelegramBot.send( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photoSize, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -721,12 +760,13 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, photo: Photo, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -737,12 +777,13 @@ suspend inline fun TelegramBot.send( chat: Chat, photo: Photo, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photo, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -753,12 +794,13 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, photoSize: PhotoSize, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendPhoto] request @@ -769,12 +811,13 @@ suspend inline fun TelegramBot.send( chat: Chat, photoSize: PhotoSize, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat, photoSize, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -789,12 +832,13 @@ suspend fun TelegramBot.send( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -810,12 +854,13 @@ suspend fun TelegramBot.send( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -830,12 +875,13 @@ suspend fun TelegramBot.send( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendRegularPoll] request @@ -851,12 +897,13 @@ suspend fun TelegramBot.send( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -873,12 +920,13 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -895,12 +943,13 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -918,13 +967,14 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -943,12 +993,13 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -964,12 +1015,13 @@ suspend inline fun TelegramBot.send( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -985,12 +1037,13 @@ suspend inline fun TelegramBot.send( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -1007,12 +1060,13 @@ suspend inline fun TelegramBot.send( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendQuizPoll] request @@ -1029,12 +1083,13 @@ suspend inline fun TelegramBot.send( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendQuizPoll(chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendSticker] request @@ -1044,12 +1099,13 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, sticker: Sticker, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chatId, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendSticker] request @@ -1059,12 +1115,116 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, sticker: Sticker, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + +/** + * Will execute [sendLiveLocation] request + * @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 fun TelegramBot.send( + chatId: ChatIdentifier, + latitude: Double, + longitude: Double, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLiveLocation( + chatId = chatId, + latitude = latitude, + longitude = longitude, + livePeriod = livePeriod, + horizontalAccuracy = horizontalAccuracy, + heading = heading, + proximityAlertRadius = proximityAlertRadius, + threadId = threadId, + disableNotification = disableNotification, + protectContent = protectContent, + replyToMessageId = replyToMessageId, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup +) + +/** + * Will execute [sendLiveLocation] request + * @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 fun TelegramBot.send( + chatId: ChatIdentifier, + location: Location, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLiveLocation( + chatId, location, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup +) + +/** + * Will execute [sendLiveLocation] request + * @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 fun TelegramBot.send( + chat: Chat, + latitude: Double, + longitude: Double, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLiveLocation( + chat, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup +) + +/** + * Will execute [sendLiveLocation] request + * @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 fun TelegramBot.send( + chat: Chat, + location: Location, + livePeriod: Seconds, + horizontalAccuracy: Meters? = null, + heading: Degrees? = null, + proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) = sendLiveLocation( + chat, location, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup +) /** * Will execute [sendVenue] request @@ -1081,12 +1241,13 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chatId, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chatId, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVenue] request @@ -1103,12 +1264,13 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chat, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chat, latitude, longitude, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVenue] request @@ -1124,12 +1286,13 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chatId, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chatId, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVenue] request @@ -1145,12 +1308,13 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chat, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chat, location, title, address, foursquareId, foursquareType, googlePlaceId, googlePlaceType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVenue] request @@ -1160,12 +1324,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, venue: Venue, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chatId, venue, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chatId, venue, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVenue] request @@ -1175,12 +1340,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, venue: Venue, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVenue(chat, venue, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVenue(chat, venue, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideo] request @@ -1192,12 +1358,13 @@ suspend fun TelegramBot.send( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideo] request @@ -1209,12 +1376,13 @@ suspend fun TelegramBot.send( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat, video, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideo] request @@ -1225,12 +1393,13 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, video: VideoFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideo] request @@ -1241,12 +1410,13 @@ suspend inline fun TelegramBot.send( chat: Chat, video: VideoFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat, video, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideoNote] request @@ -1256,12 +1426,13 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, videoNote: VideoNoteFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chatId, videoNote, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chatId, videoNote, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVideoNote] request @@ -1271,12 +1442,13 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, videoNote: VideoNoteFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chat, videoNote, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chat, videoNote, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVoice] request @@ -1288,12 +1460,13 @@ suspend fun TelegramBot.send( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chatId, voice, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chatId, voice, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVoice] request @@ -1305,12 +1478,13 @@ suspend fun TelegramBot.send( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat, voice, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat, voice, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVoice] request @@ -1321,12 +1495,13 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, voice: VoiceFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chatId, voice, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chatId, voice, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendVoice] request @@ -1337,12 +1512,13 @@ suspend inline fun TelegramBot.send( chat: Chat, voice: VoiceFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat, voice, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat, voice, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @see SendMediaGroup @@ -1352,11 +1528,12 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendMediaGroup @@ -1366,11 +1543,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendMediaGroup @@ -1379,12 +1557,13 @@ suspend fun TelegramBot.send( @JvmName("sendMedaGroupByContent") suspend fun TelegramBot.send( chatId: ChatIdentifier, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendMediaGroup @@ -1393,12 +1572,13 @@ suspend fun TelegramBot.send( @JvmName("sendMedaGroupByContent") suspend fun TelegramBot.send( chat: Chat, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendMediaGroup(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendPlaylist @@ -1407,11 +1587,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendPlaylist(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendPlaylist @@ -1420,11 +1601,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendPlaylist(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendPlaylist @@ -1433,11 +1615,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendPlaylist(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendPlaylist @@ -1446,11 +1629,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendPlaylist(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendPlaylist(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendDocumentsGroup @@ -1459,11 +1643,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendDocumentsGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendDocumentsGroup @@ -1472,11 +1657,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendDocumentsGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendDocumentsGroup @@ -1485,11 +1671,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendDocumentsGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendDocumentsGroup @@ -1498,11 +1685,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendDocumentsGroup(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendDocumentsGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendVisualMediaGroup @@ -1511,11 +1699,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendVisualMediaGroup @@ -1524,11 +1713,12 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendVisualMediaGroup @@ -1536,12 +1726,13 @@ suspend fun TelegramBot.send( @JvmName("sendVisualMediaGroupByContent") suspend fun TelegramBot.send( chatId: ChatIdentifier, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * @see SendVisualMediaGroup @@ -1549,9 +1740,10 @@ suspend fun TelegramBot.send( @JvmName("sendVisualMediaGroupByContent") suspend fun TelegramBot.send( chat: Chat, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = sendVisualMediaGroup(chat, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = sendVisualMediaGroup(chat, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) 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 f5067ebc9d..2982753287 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 @@ -4,6 +4,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.games.Game @@ -15,6 +16,7 @@ import dev.inmo.tgbotapi.types.games.Game suspend fun TelegramBot.sendGame( chatId: ChatIdentifier, gameShortName: String, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -22,7 +24,7 @@ suspend fun TelegramBot.sendGame( replyMarkup: KeyboardMarkup? = null ) = execute( SendGame( - chatId, gameShortName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, gameShortName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) ) @@ -33,13 +35,14 @@ suspend fun TelegramBot.sendGame( suspend fun TelegramBot.sendGame( chat: Chat, gameShortName: String, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - chat.id, gameShortName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, gameShortName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -49,13 +52,14 @@ suspend fun TelegramBot.sendGame( suspend fun TelegramBot.sendGame( chatId: ChatIdentifier, game: Game, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - chatId, game.title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, game.title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -65,11 +69,12 @@ suspend fun TelegramBot.sendGame( suspend fun TelegramBot.sendGame( chat: Chat, game: Game, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendGame( - chat.id, game.title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, game.title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 82db42d558..1cc5ccffab 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendAnimation import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -24,6 +25,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -39,6 +41,7 @@ suspend fun TelegramBot.sendAnimation( duration, width, height, + threadId, disableNotification, protectContent, replyToMessageId, @@ -59,13 +62,14 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -81,12 +85,13 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -100,12 +105,13 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -120,6 +126,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -134,6 +141,7 @@ suspend fun TelegramBot.sendAnimation( duration, width, height, + threadId, disableNotification, protectContent, replyToMessageId, @@ -153,13 +161,14 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation( - chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -174,12 +183,13 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -192,9 +202,10 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAnimation(chat.id, animation, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAnimation(chat.id, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 bf8cb7da53..a0e00630fd 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendAudio import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -24,6 +25,7 @@ suspend fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -39,6 +41,7 @@ suspend fun TelegramBot.sendAudio( duration, performer, title, + threadId, disableNotification, protectContent, replyToMessageId, @@ -60,12 +63,13 @@ suspend fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -77,12 +81,13 @@ suspend fun TelegramBot.sendAudio( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -94,12 +99,13 @@ suspend fun TelegramBot.sendAudio( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, text, parseMode, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -114,6 +120,7 @@ suspend inline fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -128,6 +135,7 @@ suspend inline fun TelegramBot.sendAudio( duration, performer, title, + threadId, disableNotification, protectContent, replyToMessageId, @@ -148,12 +156,13 @@ suspend inline fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -164,12 +173,13 @@ suspend inline fun TelegramBot.sendAudio( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -180,9 +190,10 @@ suspend inline fun TelegramBot.sendAudio( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio(chat.id, audio, entities, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendAudio(chat.id, audio, entities, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 c62b3cc3bc..d23bb801da 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendDocument import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -21,6 +22,7 @@ suspend fun TelegramBot.sendDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -34,6 +36,7 @@ suspend fun TelegramBot.sendDocument( thumb, text, parseMode, + threadId, disableNotification, protectContent, replyToMessageId, @@ -53,13 +56,14 @@ suspend fun TelegramBot.sendDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, thumb, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, thumb, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -70,6 +74,7 @@ suspend fun TelegramBot.sendDocument( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -77,7 +82,7 @@ suspend fun TelegramBot.sendDocument( replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = sendDocument( - chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection + chatId, document.fileId, document.thumb ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection ) /** @@ -89,13 +94,14 @@ suspend fun TelegramBot.sendDocument( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -106,6 +112,7 @@ suspend inline fun TelegramBot.sendDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -118,6 +125,7 @@ suspend inline fun TelegramBot.sendDocument( document, thumb, entities, + threadId, disableNotification, protectContent, replyToMessageId, @@ -136,13 +144,14 @@ suspend inline fun TelegramBot.sendDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, thumb, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, thumb, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -152,6 +161,7 @@ suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: DocumentFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -159,7 +169,7 @@ suspend inline fun TelegramBot.sendDocument( replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = sendDocument( - chatId, document.fileId, document.thumb ?.fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection + chatId, document.fileId, document.thumb ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection ) /** @@ -170,10 +180,11 @@ suspend inline fun TelegramBot.sendDocument( chat: Chat, document: DocumentFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null -) = sendDocument(chat.id, document, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +) = sendDocument(chat.id, document, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 70392452d5..c89915764d 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 @@ -5,9 +5,10 @@ import dev.inmo.tgbotapi.requests.send.media.* import dev.inmo.tgbotapi.types.ChatIdentifier 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.MediaGroupContent -import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent +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.utils.RiskFeature @@ -20,13 +21,14 @@ import kotlin.jvm.JvmName suspend fun TelegramBot.sendMediaGroup( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = execute( - SendMediaGroup( - chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + SendMediaGroup( + chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) ) @@ -37,12 +39,13 @@ suspend fun TelegramBot.sendMediaGroup( suspend fun TelegramBot.sendMediaGroup( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendMediaGroup( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -52,13 +55,14 @@ suspend fun TelegramBot.sendMediaGroup( @JvmName("sendMedaGroupByContent") suspend fun TelegramBot.sendMediaGroup( chatId: ChatIdentifier, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendMediaGroup( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -68,13 +72,14 @@ suspend fun TelegramBot.sendMediaGroup( @JvmName("sendMedaGroupByContent") suspend fun TelegramBot.sendMediaGroup( chat: Chat, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendMediaGroup( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -83,13 +88,14 @@ suspend fun TelegramBot.sendMediaGroup( suspend fun TelegramBot.sendPlaylist( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = execute( SendPlaylist( - chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) ) @@ -99,12 +105,13 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendPlaylist( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendPlaylist( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -114,12 +121,13 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendPlaylist( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendPlaylist( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -129,12 +137,13 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendPlaylist( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendPlaylist( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -143,13 +152,14 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendDocumentsGroup( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = execute( SendDocumentsGroup( - chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) ) @@ -159,12 +169,13 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendDocumentsGroup( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendDocumentsGroup( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -174,12 +185,13 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendDocumentsGroup( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendDocumentsGroup( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -189,12 +201,13 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendDocumentsGroup( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendDocumentsGroup( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -203,13 +216,14 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendVisualMediaGroup( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = execute( SendVisualMediaGroup( - chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) ) @@ -219,12 +233,13 @@ suspend fun TelegramBot.sendVisualMediaGroup( suspend fun TelegramBot.sendVisualMediaGroup( chat: Chat, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendVisualMediaGroup( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -233,13 +248,14 @@ suspend fun TelegramBot.sendVisualMediaGroup( @JvmName("sendVisualMediaGroupByContent") suspend fun TelegramBot.sendVisualMediaGroup( chatId: ChatIdentifier, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendVisualMediaGroup( - chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) /** @@ -248,11 +264,12 @@ suspend fun TelegramBot.sendVisualMediaGroup( @JvmName("sendVisualMediaGroupByContent") suspend fun TelegramBot.sendVisualMediaGroup( chat: Chat, - media: List, + media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null ) = sendVisualMediaGroup( - chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply + chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply ) 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 69ab1135c7..e876006f71 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendPhoto import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -20,6 +21,7 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -31,6 +33,7 @@ suspend fun TelegramBot.sendPhoto( fileId, text, parseMode, + threadId, disableNotification, protectContent, replyToMessageId, @@ -48,12 +51,13 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -64,12 +68,13 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -80,12 +85,13 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -96,12 +102,13 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -112,12 +119,13 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -128,6 +136,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -138,6 +147,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId, fileId, entities, + threadId, disableNotification, protectContent, replyToMessageId, @@ -154,12 +164,13 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -169,12 +180,13 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -184,12 +196,13 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photo, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -199,12 +212,13 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photoSize: PhotoSize, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chatId, photoSize.fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chatId, photoSize.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -214,9 +228,10 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photoSize: PhotoSize, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendPhoto(chat.id, photoSize, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendPhoto(chat.id, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 1b0e559d04..d77908e86f 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 @@ -5,6 +5,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.Sticker @@ -16,13 +17,14 @@ import dev.inmo.tgbotapi.types.files.Sticker suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: InputFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = execute( - SendSticker(chatId, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + SendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) /** @@ -32,12 +34,13 @@ suspend fun TelegramBot.sendSticker( suspend fun TelegramBot.sendSticker( chat: Chat, sticker: InputFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat.id, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat.id, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -46,12 +49,13 @@ suspend fun TelegramBot.sendSticker( suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: Sticker, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chatId, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chatId, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -60,9 +64,10 @@ suspend fun TelegramBot.sendSticker( suspend fun TelegramBot.sendSticker( chat: Chat, sticker: Sticker, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendSticker(chat, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendSticker(chat, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 4b195e6434..9c9ba07fb4 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendVideo import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -24,6 +25,7 @@ suspend fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -40,6 +42,7 @@ suspend fun TelegramBot.sendVideo( width, height, null, + threadId, disableNotification, protectContent, replyToMessageId, @@ -57,12 +60,13 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -77,12 +81,13 @@ suspend fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -94,12 +99,13 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -113,6 +119,7 @@ suspend inline fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -128,6 +135,7 @@ suspend inline fun TelegramBot.sendVideo( width, height, null, + threadId, disableNotification, protectContent, replyToMessageId, @@ -144,12 +152,13 @@ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -163,12 +172,13 @@ suspend inline fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -179,9 +189,10 @@ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo(chat.id, video, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideo(chat.id, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 e2a46147a4..b7c101a6ca 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 @@ -5,6 +5,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.VideoNoteFile @@ -19,6 +20,7 @@ suspend fun TelegramBot.sendVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -31,6 +33,7 @@ suspend fun TelegramBot.sendVideoNote( thumb, duration, size, + threadId, disableNotification, protectContent, replyToMessageId, @@ -46,13 +49,14 @@ suspend fun TelegramBot.sendVideoNote( suspend fun TelegramBot.sendVideoNote( chatId: ChatIdentifier, videoNote: VideoNoteFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVideoNote( - chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -65,12 +69,13 @@ suspend fun TelegramBot.sendVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chat.id, videoNote, thumb, duration, size, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chat.id, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -79,9 +84,10 @@ suspend fun TelegramBot.sendVideoNote( suspend fun TelegramBot.sendVideoNote( chat: Chat, videoNote: VideoNoteFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideoNote(chat.id, videoNote, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVideoNote(chat.id, videoNote, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 4244ed33e3..6350bb4792 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendVoice import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -21,6 +22,7 @@ suspend fun TelegramBot.sendVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -33,6 +35,7 @@ suspend fun TelegramBot.sendVoice( text, parseMode, duration, + threadId, disableNotification, protectContent, replyToMessageId, @@ -51,12 +54,13 @@ suspend fun TelegramBot.sendVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, text, parseMode, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, text, parseMode, duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -67,13 +71,14 @@ suspend fun TelegramBot.sendVoice( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVoice( - chatId, voice.fileId, text, parseMode, voice.duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, voice.fileId, text, parseMode, voice.duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -85,12 +90,13 @@ suspend fun TelegramBot.sendVoice( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** @@ -102,6 +108,7 @@ suspend inline fun TelegramBot.sendVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -113,6 +120,7 @@ suspend inline fun TelegramBot.sendVoice( voice, entities, duration, + threadId, disableNotification, protectContent, replyToMessageId, @@ -130,12 +138,13 @@ suspend inline fun TelegramBot.sendVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, entities, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, entities, duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -145,13 +154,14 @@ suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: VoiceFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVoice( - chatId, voice.fileId, entities, voice.duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, voice.fileId, entities, voice.duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -161,9 +171,10 @@ suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: VoiceFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendVoice(chat.id, voice, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendVoice(chat.id, voice, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 ebd388e6a2..f6e4e4371f 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 @@ -31,13 +31,14 @@ suspend fun TelegramBot.sendInvoice( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = 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, 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, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) /** @@ -63,9 +64,10 @@ suspend fun TelegramBot.sendInvoice( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null -) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, 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, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 c3c6454e70..71d3202fd4 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -23,6 +24,7 @@ suspend fun TelegramBot.sendRegularPoll( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -30,7 +32,7 @@ suspend fun TelegramBot.sendRegularPoll( replyMarkup: KeyboardMarkup? = null ) = execute( SendRegularPoll( - chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) ) /** @@ -46,12 +48,13 @@ suspend fun TelegramBot.sendRegularPoll( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -65,13 +68,14 @@ suspend fun TelegramBot.sendRegularPoll( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -87,13 +91,14 @@ suspend fun TelegramBot.sendRegularPoll( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendRegularPoll( - chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) @@ -111,6 +116,7 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -118,7 +124,7 @@ suspend fun TelegramBot.sendQuizPoll( replyMarkup: KeyboardMarkup? = null ) = execute( SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) ) @@ -136,13 +142,14 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -160,13 +167,14 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -184,13 +192,14 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) @@ -207,6 +216,7 @@ suspend inline fun TelegramBot.sendQuizPoll( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -214,7 +224,7 @@ suspend inline fun TelegramBot.sendQuizPoll( replyMarkup: KeyboardMarkup? = null ) = execute( SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) ) @@ -231,13 +241,14 @@ suspend inline fun TelegramBot.sendQuizPoll( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -254,13 +265,14 @@ suspend inline fun TelegramBot.sendQuizPoll( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) /** @@ -277,11 +289,12 @@ suspend inline fun TelegramBot.sendQuizPoll( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendQuizPoll( - chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt index 54845e4c3a..1c660b8ad2 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.extensions.api.utils import dev.inmo.tgbotapi.extensions.api.InternalUtils.convertWithMediaGroupUpdates -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.UpdateReceiver @@ -30,10 +30,21 @@ fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation( launch { launch { for (update in updatesChannel) { - when (val data = update.data) { - is MediaGroupMessage<*> -> mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate) - else -> output(update) + val dataAsPossiblySentViaBotCommonMessage = update.data as? PossiblySentViaBotCommonMessage<*> + + if (dataAsPossiblySentViaBotCommonMessage == null) { + output(update) + continue } + + val mediaGroupId = dataAsPossiblySentViaBotCommonMessage.mediaGroupId + + if (mediaGroupId == null) { + output(update) + continue + } + + mediaGroupChannel.send("${mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate) } } launch { 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 91bce4c17e..86028c62a8 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 @@ -66,12 +66,12 @@ suspend fun BehaviourContext.waitAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -81,12 +81,12 @@ suspend fun BehaviourContext.waitAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) +) = waitContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt index 9620795bf2..d908e016dd 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 @@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow @@ -25,20 +24,7 @@ suspend inline fun BehaviourContext.waitContentMess initRequest, errorFactory ) { - val messages = when (it) { - is SentMediaGroupUpdate -> { - if (includeMediaGroups) { - it.data - } else { - emptyList() - } - } - is BaseSentMessageUpdate -> listOf(it.data) - else -> return@expectFlow emptyList() - } - messages.mapNotNull { message -> - (message as? CommonMessage<*>) ?.withContent() - } + listOfNotNull((it.data as? CommonMessage<*>) ?.withContent()) } internal inline fun contentMessageConverter( @@ -103,12 +89,12 @@ suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -118,12 +104,12 @@ suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitTextedMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index a552348dd8..c78ab0452a 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 @@ -15,7 +15,7 @@ suspend inline fun BehaviourContext.waitEditedConte initRequest: Request<*>? = null, includeMediaGroups: Boolean = true, noinline errorFactory: NullableRequestBuilder<*> = { null } -): Flow = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory).map { it.content } +): Flow = waitEditedContentMessage(initRequest, errorFactory).map { it.content } suspend fun BehaviourContext.waitEditedMessageContent( initRequest: Request<*>? = null, @@ -64,12 +64,12 @@ suspend fun BehaviourContext.waitEditedAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -79,12 +79,12 @@ suspend fun BehaviourContext.waitEditedAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = true -) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContent(initRequest, includeMediaGroups, errorFactory) suspend fun BehaviourContext.waitEditedTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt index c5204f68ec..99d14d8d0b 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,11 +3,11 @@ 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 import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate import dev.inmo.tgbotapi.utils.RiskFeature @@ -17,7 +17,6 @@ import kotlinx.coroutines.flow.Flow @RiskFeature(lowLevelRiskFeatureMessage) suspend inline fun BehaviourContext.waitEditedContentMessage( initRequest: Request<*>? = null, - includeMediaGroups: Boolean = true, noinline errorFactory: NullableRequestBuilder<*> = { null } ): Flow> = expectFlow( initRequest, @@ -26,11 +25,7 @@ suspend inline fun BehaviourContext.waitEditedConte val messages = when (it) { is BaseEditMessageUpdate -> { val commonMessage = it.data.commonMessageOrNull() ?: return@expectFlow emptyList() - if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) { - listOf(commonMessage) - } else { - emptyList() - } + listOf(commonMessage) } else -> return@expectFlow emptyList() } @@ -41,109 +36,103 @@ suspend inline fun BehaviourContext.waitEditedConte suspend fun BehaviourContext.waitEditedMessageContentMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedContactMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedDiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedGameMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedLiveLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedStaticLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedTextMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedVenueMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedAudioMediaGroupContentMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = false -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedAnyMediaGroupContentMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedVisualMediaGroupContentMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedTextedMediaContentMessage( initRequest: Request<*>? = null, - errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedAnimationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedAudioMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = false -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedDocumentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = false -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedPhotoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = false -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedStickerMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedVideoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean = false -) = waitEditedContentMessage(initRequest, includeMediaGroups, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedVideoNoteMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedVoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = waitEditedContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitEditedInvoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitEditedContentMessage(initRequest, false, errorFactory) +) = 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 4b7fc377dc..4bdc582d43 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 @@ -7,6 +7,9 @@ import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent @@ -136,3 +139,15 @@ suspend fun BehaviourContext.waitWebAppDataEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEvents(initRequest, errorFactory) +suspend fun BehaviourContext.waitForumTopicClosed( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) +suspend fun BehaviourContext.waitForumTopicCreated( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) +suspend fun BehaviourContext.waitForumTopicReopened( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) 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 f5db11ad3b..a26a4215ad 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 @@ -7,6 +7,9 @@ import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent @@ -133,3 +136,15 @@ suspend fun BehaviourContext.waitWebAppDataEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitForumTopicClosedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitForumTopicCreatedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) +suspend fun BehaviourContext.waitForumTopicReopenedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt index 37260e9340..111c400f4a 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt @@ -1,40 +1,46 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull +import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull +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.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map - -typealias MediaGroupFilter = SimpleFilter>> - @RiskFeature(lowLevelRiskFeatureMessage) -suspend inline fun BehaviourContext.buildMediaGroupWaiter( +suspend inline fun BehaviourContext.buildMediaGroupWaiter( initRequest: Request<*>? = null, noinline errorFactory: NullableRequestBuilder<*> = { null } -): Flow> = buildMediaGroupMessagesWaiter(initRequest, errorFactory).map { it.map { it.content } } +): Flow> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update -> + update.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull>() ?.let { message -> + if (message.content.group.all { it is T }) { + listOf(message.content as MediaGroupContent) + } else { + null + } + } ?: emptyList() +} suspend fun BehaviourContext.waitMediaGroup( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupWaiter(initRequest, errorFactory) +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitPlaylist( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupWaiter(initRequest, errorFactory) +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitDocumentsGroup( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupWaiter(initRequest, errorFactory) +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitVisualGallery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupWaiter(initRequest, errorFactory) +) = buildMediaGroupWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitPhotoGallery( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt index f75f8767b7..2b592a355e 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroupMessages.kt @@ -1,44 +1,46 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull +import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull +import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull 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.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow @RiskFeature(lowLevelRiskFeatureMessage) -suspend inline fun BehaviourContext.buildMediaGroupMessagesWaiter( +suspend inline fun BehaviourContext.buildMediaGroupMessagesWaiter( initRequest: Request<*>? = null, noinline errorFactory: NullableRequestBuilder<*> = { null } -): Flow>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update -> - update.sentMediaGroupUpdateOrNull() ?.data ?.let { mediaGroup -> - val mapped = mediaGroup.mapNotNull { it.withContent() } - listOf( - mapped - ) +): Flow> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update -> + update.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull>() ?.let { message -> + if (message.content.group.all { it is T }) { + listOf(message as MediaGroupMessage) + } else { + null + } } ?: emptyList() } suspend fun BehaviourContext.waitMediaGroupMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitPlaylistMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitDocumentsGroupMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitVisualGalleryMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) +) = buildMediaGroupMessagesWaiter(initRequest, errorFactory) suspend fun BehaviourContext.waitPhotoGalleryMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } 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 60389a5ecf..f6d4fc2b76 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 @@ -3,18 +3,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 MessageFilterExcludingMediaGroups: BehaviourContextAndTwoTypesReceiver, Update> = { _, update -> - update !is MediaGroupMessage<*> -} - /** * Allow only messages which are not [MediaGroupMessage] */ val CommonMessageFilterExcludeMediaGroups = SimpleFilter { - it !is MediaGroupMessage<*> + 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 new file mode 100644 index 0000000000..c108b48867 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterForums.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.filters + +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.types.message.abstracts.* +import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull + +/** + * Allow only messages which are not in some forum + */ +val MessageFilterForums = SimpleFilter { + it.threadIdOrNull == null +} diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index e9a19d4d7d..d83be5e0f5 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 @@ -14,7 +14,6 @@ import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate typealias CommonMessageFilter = SimpleFilter> @@ -26,7 +25,6 @@ internal suspend inline fun ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { when (it) { is BaseSentMessageUpdate -> it.data.whenCommonMessage(::listOfNotNull) - is SentMediaGroupUpdate -> it.data else -> null } ?.mapNotNull { message -> if (message.content is T) message as CommonMessage else null @@ -287,7 +285,7 @@ suspend fun BC.onVenue( * data */ suspend fun BC.onAudioMediaGroup( - initialFilter: CommonMessageFilter? = null, + initialFilter: CommonMessageFilter? = null, subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver @@ -311,7 +309,7 @@ suspend fun BC.onAudioMediaGroup( * data */ suspend fun BC.onDocumentMediaGroupContent( - initialFilter: CommonMessageFilter? = null, + initialFilter: CommonMessageFilter? = null, subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index e339c6f66f..0b6337d018 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -222,7 +222,7 @@ suspend fun BC.onEditedVenue( * data */ suspend fun BC.onEditedAudioMediaGroup( - initialFilter: CommonMessageFilter? = null, + initialFilter: CommonMessageFilter? = null, subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver @@ -246,7 +246,7 @@ suspend fun BC.onEditedAudioMediaGroup( * data */ suspend fun BC.onEditedDocumentMediaGroupContent( - initialFilter: CommonMessageFilter? = null, + initialFilter: CommonMessageFilter? = null, subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver 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 db41229f8b..69e4f87929 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 @@ -11,9 +11,13 @@ import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull import dev.inmo.tgbotapi.extensions.utils.chatEventMessageOrNull import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.PrivateEventMessage import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage +import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.update.abstracts.Update @@ -27,6 +31,16 @@ internal suspend inline fun BC.on (it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.takeIf { it.chatEvent is T } as? ChatEventMessage) ?.let(::listOfNotNull) } +internal suspend inline fun > BC.onEventWithCustomChatEventMessage( + initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + markerFactory: MarkerFactory = ByChatMessageMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + @Suppress("UNCHECKED_CAST") + (it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.takeIf { it.chatEvent is T } as? CEM) ?.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, @@ -503,12 +517,61 @@ suspend fun BC.onWebAppData( subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver> -) = onEvent( - initialFilter ?.let { { it is PrivateEventMessage && initialFilter(it) } }, - subcontextUpdatesFilter ?.let { { message: ChatEventMessage, update: Update -> message is PrivateEventMessage && subcontextUpdatesFilter(message, update) } }, - markerFactory -) { - if (it is PrivateEventMessage) { - scenarioReceiver(it) - } -} +) = 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.onForumTopicClosed( + 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.onForumTopicCreated( + 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.onForumTopicReopened( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt index 31f52a2e73..80c386c70c 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt @@ -13,11 +13,20 @@ internal suspend inline fun BC.on( noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver, noinline updateToData: (Update) -> List? -) = flowsUpdatesFilter.expectFlow(bot) { - updateToData(it) ?.mapNotNull { data -> - if (initialFilter ?.invoke(data) != false) it to data else null - } ?: emptyList() -}.subscribeSafelyWithoutExceptionsAsync( +) = flowsUpdatesFilter.expectFlow( + bot, + filter = initialFilter ?.let { + { + updateToData(it) ?.mapNotNull { data -> + if (initialFilter(data)) it to data else null + } ?: emptyList() + } + } ?: { + updateToData(it) ?.mapNotNull { data -> + it to data + } ?: emptyList() + } +).subscribeSafelyWithoutExceptionsAsync( scope, { markerFactory(it.second) } ) { (update, triggerData) -> diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupMessagesTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupMessagesTriggers.kt new file mode 100644 index 0000000000..b4f80f4fd5 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupMessagesTriggers.kt @@ -0,0 +1,164 @@ +@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.ByChatMessageMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull +import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull +import dev.inmo.tgbotapi.extensions.utils.withContentOrNull +import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.content.* +import dev.inmo.tgbotapi.types.update.abstracts.Update +import dev.inmo.tgbotapi.utils.PreviewFeature + +@PreviewFeature +internal suspend inline fun BC.buildMediaGroupMessagesTrigger( + initialFilter: SimpleFilter>? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + it.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull>() ?.let { + if (it.content.group.all { it.content is T }) { + listOf(it as MediaGroupMessage) + } else { + null + } + } ?: emptyList() +} + +/** + * @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.onMediaGroupMessages( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = buildMediaGroupMessagesTrigger(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.onPlaylistMessages( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = buildMediaGroupMessagesTrigger(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.onDocumentsGroupMessages( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = buildMediaGroupMessagesTrigger(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.onVisualGalleryMessages( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = buildMediaGroupMessagesTrigger(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.onVisualMediaGroupMessages( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onVisualGalleryMessages(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.onPhotoGalleryMessages( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = buildMediaGroupMessagesTrigger(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.onVideoGalleryMessages( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = buildMediaGroupMessagesTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt index 58efa0cee3..16057119ae 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt @@ -3,28 +3,31 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling import dev.inmo.tgbotapi.extensions.behaviour_builder.* -import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessagesFilterByChat import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMediaGroupMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.AnyMarkerFactory import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory -import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull +import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull +import dev.inmo.tgbotapi.extensions.utils.withContentOrNull +import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.utils.PreviewFeature @PreviewFeature -internal suspend inline fun BC.buildMediaGroupTrigger( - initialFilter: SimpleFilter>>? = null, - noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> +internal suspend inline fun BC.buildMediaGroupTrigger( + initialFilter: SimpleFilter>? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { - (it.sentMediaGroupUpdateOrNull() ?.data ?.takeIf { messages -> - messages.all { message -> - message.content is T + it.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull>() ?.let { + if (it.content.group.all { it.content is T }) { + listOf(it.content as MediaGroupContent) + } else { + null } - } as? List>) ?.let(::listOfNotNull) + } ?: emptyList() } /** @@ -40,10 +43,10 @@ internal suspend inline fun BC.onMediaGroup( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -59,10 +62,10 @@ suspend fun BC.onMediaGroup( * data */ suspend fun BC.onPlaylist( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -78,10 +81,10 @@ suspend fun BC.onPlaylist( * data */ suspend fun BC.onDocumentsGroup( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -97,10 +100,10 @@ suspend fun BC.onDocumentsGroup( * data */ suspend fun BC.onVisualGallery( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -116,10 +119,10 @@ suspend fun BC.onVisualGallery( * data */ suspend fun BC.onVisualMediaGroup( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onVisualGallery(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -135,10 +138,10 @@ suspend fun BC.onVisualMediaGroup( * data */ suspend fun BC.onPhotoGallery( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -154,8 +157,8 @@ suspend fun BC.onPhotoGallery( * data */ suspend fun BC.onVideoGallery( - initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = null, + markerFactory: MarkerFactory, Any> = AnyMarkerFactory(), + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/AnyMarkerFactory.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/AnyMarkerFactory.kt new file mode 100644 index 0000000000..dcf3059fcd --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/AnyMarkerFactory.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +private val commonAnyMarker = MarkerFactory { it } + +fun AnyMarkerFactory() = commonAnyMarker as MarkerFactory diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt deleted file mode 100644 index 233d3f3a3b..0000000000 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories - -import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage - -object ByChatMediaGroupMarkerFactory : MarkerFactory>, Any> { - override suspend fun invoke(data: List>) = data.chat ?: error("Data must not be empty") -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessage.kt index 493f510c08..aa0aae7480 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/ForwardMessage.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.requests import dev.inmo.tgbotapi.abstracts.types.MessageAction 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.abstracts.PossiblyForwardedMessage import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass @@ -18,11 +19,13 @@ data class ForwardMessage( val toChatId: ChatIdentifier, @SerialName(messageIdField) override val messageId: MessageId, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false -): SimpleRequest, MessageAction, ProtectContent { +): SimpleRequest, MessageAction, ProtectContent, OptionallyMessageThreadRequest { override val chatId: ChatIdentifier get() = fromChatId diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/CloseForumTopic.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/CloseForumTopic.kt new file mode 100644 index 0000000000..27a1dd8234 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/CloseForumTopic.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class CloseForumTopic ( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageThreadIdField) + val messageThreadId: MessageThreadId +): ModifyForumRequest { + override fun method(): String = "closeForumTopic" + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/CreateForumTopic.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/CreateForumTopic.kt new file mode 100644 index 0000000000..9119706218 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/CreateForumTopic.kt @@ -0,0 +1,32 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class CreateForumTopic ( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(nameField) + val name: String, + @SerialName(iconColorField) + val color: RGBColor, + @SerialName(iconCustomEmojiIdField) + val iconEmojiId: CustomEmojiId? = null, +): ForumRequest { + init { + if (name.length !in threadNameLength) { + throw IllegalArgumentException("Thread name must be in $threadNameLength range") + } + } + + override fun method(): String = "createForumTopic" + override val resultDeserializer: DeserializationStrategy + get() = ForumTopic.serializer() + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/DeleteForumTopic.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/DeleteForumTopic.kt new file mode 100644 index 0000000000..c5ee2547b9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/DeleteForumTopic.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class DeleteForumTopic ( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageThreadIdField) + val messageThreadId: MessageThreadId +): ModifyForumRequest { + override fun method(): String = "deleteForumTopic" + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/EditForumTopic.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/EditForumTopic.kt new file mode 100644 index 0000000000..6a1c8dc768 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/EditForumTopic.kt @@ -0,0 +1,30 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class EditForumTopic ( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageThreadIdField) + val messageThreadId: MessageThreadId, + @SerialName(nameField) + val name: String, + @SerialName(iconCustomEmojiIdField) + val iconEmojiId: CustomEmojiId, +): ModifyForumRequest { + init { + if (name.length !in threadNameLength) { + throw IllegalArgumentException("Thread name must be in $threadNameLength range") + } + } + + override fun method(): String = "editForumTopic" + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ForumRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ForumRequest.kt new file mode 100644 index 0000000000..3b160b177d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ForumRequest.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest + +sealed interface ForumRequest : SimpleRequest, ChatRequest diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ModifyForumRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ModifyForumRequest.kt new file mode 100644 index 0000000000..8e78fa0628 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ModifyForumRequest.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.builtins.serializer + +sealed interface ModifyForumRequest : ForumRequest { + override val resultDeserializer: DeserializationStrategy + get() = Boolean.serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ReopenForumTopic.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ReopenForumTopic.kt new file mode 100644 index 0000000000..17c07b6deb --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/ReopenForumTopic.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class ReopenForumTopic ( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageThreadIdField) + val messageThreadId: MessageThreadId +): ModifyForumRequest { + override fun method(): String = "reopenForumTopic" + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/UnpinAllForumTopicMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/UnpinAllForumTopicMessages.kt new file mode 100644 index 0000000000..7a792b7548 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/forum/UnpinAllForumTopicMessages.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.requests.chat.forum + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.* +import kotlinx.serialization.builtins.serializer + +@Serializable +data class UnpinAllForumTopicMessages ( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageThreadIdField) + val messageThreadId: MessageThreadId +): ModifyForumRequest { + override fun method(): String = "unpinAllForumTopicMessages" + override val requestSerializer: SerializationStrategy<*> + get() = serializer() +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetForumTopicIconStickers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetForumTopicIconStickers.kt new file mode 100644 index 0000000000..e870191a79 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetForumTopicIconStickers.kt @@ -0,0 +1,23 @@ +package dev.inmo.tgbotapi.requests.chat.get + +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.abstracts.types.OptionalChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.files.Sticker +import dev.inmo.tgbotapi.types.files.StickerSerializer +import kotlinx.serialization.* +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.builtins.serializer + +@Serializable +object GetForumTopicIconStickers : SimpleRequest> { + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + private val deserializer = ListSerializer(StickerSerializer) + + override fun method(): String = "getForumTopicIconStickers" + + override val resultDeserializer: DeserializationStrategy> + get() = deserializer +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt index 4bfe27e29a..7e15264d7f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt @@ -35,7 +35,9 @@ data class PromoteChatMember( @SerialName(canManageVideoChatsField) private val canManageVideoChats: Boolean? = null, @SerialName(canManageChatField) - private val canManageChat: Boolean? = null + private val canManageChat: Boolean? = null, + @SerialName(canManageTopicsField) + private val canManageTopics: Boolean? = null ) : ChatMemberRequest, UntilDate { override fun method(): String = "promoteChatMember" override val resultDeserializer: DeserializationStrategy 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 e6f542eb6e..39a9def570 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.abstracts.TextedOutput import dev.inmo.tgbotapi.abstracts.types.MessageAction 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.requests.send.abstracts.ReplyingMarkupSendMessageRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSource @@ -26,6 +27,7 @@ fun CopyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -38,6 +40,7 @@ fun CopyMessage( text, parseMode, null, + threadId, disableNotification, protectContent, replyToMessageId, @@ -50,6 +53,7 @@ fun CopyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -62,6 +66,7 @@ fun CopyMessage( entities.makeString(), null, entities.toRawMessageEntities(), + threadId, disableNotification, protectContent, replyToMessageId, @@ -75,6 +80,7 @@ fun CopyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -87,6 +93,7 @@ fun CopyMessage( text, parseMode, null, + threadId, disableNotification, protectContent, replyToMessageId, @@ -99,6 +106,7 @@ fun CopyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -111,6 +119,7 @@ fun CopyMessage( entities.makeString(), null, entities.toRawMessageEntities(), + threadId, disableNotification, protectContent, replyToMessageId, @@ -132,6 +141,8 @@ data class CopyMessage internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -146,7 +157,8 @@ data class CopyMessage internal constructor( ReplyingMarkupSendMessageRequest, MessageAction, TextedOutput, - ProtectContent { + ProtectContent, + OptionallyMessageThreadRequest { override val chatId: ChatIdentifier get() = fromChatId override val textSources: List? by lazy { 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 2bef286363..cf12d44db3 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 @@ -22,6 +22,8 @@ data class SendContact( val firstName: String, @SerialName(lastNameField) val lastName: String? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -38,6 +40,7 @@ data class SendContact( constructor( chatId: ChatIdentifier, contact: Contact, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -48,6 +51,7 @@ data class SendContact( contact.phoneNumber, contact.firstName, contact.lastName, + threadId, disableNotification, protectContent, replyToMessageId, @@ -64,6 +68,7 @@ data class SendContact( fun Contact.toRequest( chatId: ChatIdentifier, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -72,6 +77,7 @@ fun Contact.toRequest( ): SendContact = SendContact( chatId, this, + threadId, disableNotification, protectContent, replyToMessageId, 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 685a024be0..5225d3a5fe 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 @@ -20,6 +20,8 @@ data class SendDice( override val chatId: ChatIdentifier, @SerialName(emojiField) val animationType: DiceAnimationType? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId?, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 193711c98f..8631b754e2 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 @@ -18,6 +18,7 @@ fun SendLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -31,6 +32,7 @@ fun SendLocation( null, null, null, + threadId, disableNotification, protectContent, replyToMessageId, @@ -42,12 +44,13 @@ fun SendStaticLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null -) = SendLocation(chatId, latitude, longitude, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = SendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) fun SendLiveLocation( chatId: ChatIdentifier, @@ -57,6 +60,7 @@ fun SendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -70,6 +74,7 @@ fun SendLiveLocation( horizontalAccuracy, heading, proximityAlertRadius, + threadId, disableNotification, protectContent, replyToMessageId, @@ -93,6 +98,8 @@ data class SendLocation internal constructor( override val heading: Degrees? = null, @SerialName(proximityAlertRadiusField) override val proximityAlertRadius: Meters? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 d702726186..985c370832 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 @@ -25,6 +25,7 @@ fun SendTextMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -35,6 +36,7 @@ fun SendTextMessage( text, parseMode, null, + threadId, disableWebPagePreview, disableNotification, protectContent, @@ -47,6 +49,7 @@ fun SendTextMessage( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -57,6 +60,7 @@ fun SendTextMessage( entities.makeString(), null, entities.toRawMessageEntities(), + threadId, disableWebPagePreview, disableNotification, protectContent, @@ -75,6 +79,8 @@ data class SendTextMessage internal constructor( override val parseMode: ParseMode? = null, @SerialName(entitiesField) private val rawEntities: List? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableWebPagePreviewField) override val disableWebPagePreview: Boolean? = null, @SerialName(disableNotificationField) 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 2df4e80018..ebfc14d123 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 @@ -32,6 +32,8 @@ data class SendVenue( val googlePlaceId: GooglePlaceId? = null, @SerialName(googlePlaceTypeField) val googlePlaceType: GooglePlaceType? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -50,6 +52,7 @@ data class SendVenue( constructor( chatId: ChatIdentifier, venue: Venue, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -65,6 +68,7 @@ data class SendVenue( foursquareType = venue.foursquareType, googlePlaceId = venue.googlePlaceId, googlePlaceType = venue.googlePlaceType, + threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, replyToMessageId = replyToMessageId, @@ -81,6 +85,7 @@ data class SendVenue( fun Venue.toRequest( chatId: ChatIdentifier, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -89,6 +94,7 @@ fun Venue.toRequest( ): SendVenue = SendVenue( chatId, this, + threadId, disableNotification, protectContent, replyToMessageId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyMessageThreadRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyMessageThreadRequest.kt new file mode 100644 index 0000000000..8fbacbaac9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyMessageThreadRequest.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.requests.send.abstracts + +import dev.inmo.tgbotapi.types.MessageThreadId + +interface OptionallyMessageThreadRequest { + val threadId: MessageThreadId? +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendChatMessageRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendChatMessageRequest.kt index ffc9818312..46c9896d6d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendChatMessageRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendChatMessageRequest.kt @@ -2,5 +2,6 @@ package dev.inmo.tgbotapi.requests.send.abstracts import dev.inmo.tgbotapi.abstracts.types.ChatRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.MessageThreadId interface SendChatMessageRequest : SimpleRequest, ChatRequest 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 27a8a7beb6..b3dbca83a2 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 @@ -2,4 +2,8 @@ package dev.inmo.tgbotapi.requests.send.abstracts import dev.inmo.tgbotapi.abstracts.types.* -interface SendMessageRequest : SendChatMessageRequest, ReplyMessageId, DisableNotification, ProtectContent +interface SendMessageRequest : SendChatMessageRequest, + ReplyMessageId, + 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 0bec6ea1e2..b73451db82 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 @@ -18,6 +18,8 @@ data class SendGame ( override val chatId: ChatIdentifier, @SerialName(gameShortNameField) val gameShortName: String, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 f9ceb727f5..2dd7f07681 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 @@ -28,6 +28,7 @@ fun SendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -49,6 +50,7 @@ fun SendAnimation( duration, width, height, + threadId, disableNotification, protectContent, replyToMessageId, @@ -74,6 +76,7 @@ fun SendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -95,6 +98,7 @@ fun SendAnimation( duration, width, height, + threadId, disableNotification, protectContent, replyToMessageId, @@ -135,6 +139,8 @@ data class SendAnimationData internal constructor( override val width: Int? = null, @SerialName(heightField) override val height: Int? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 3b438608af..ea74af2e3c 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 @@ -29,6 +29,7 @@ fun SendAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -50,6 +51,7 @@ fun SendAudio( duration, performer, title, + threadId, disableNotification, protectContent, replyToMessageId, @@ -75,6 +77,7 @@ fun SendAudio( duration: Long? = null, performer: String? = null, title: String? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -96,6 +99,7 @@ fun SendAudio( duration, performer, title, + threadId, disableNotification, protectContent, replyToMessageId, @@ -136,6 +140,8 @@ data class SendAudioData internal constructor( override val performer: String? = null, @SerialName(titleField) override val title: String? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 8960ac5bb4..977ac85e49 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 @@ -34,6 +34,7 @@ fun SendDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -53,6 +54,7 @@ fun SendDocument( text, parseMode, null, + threadId, disableNotification, protectContent, replyToMessageId, @@ -85,6 +87,7 @@ fun SendDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -104,6 +107,7 @@ fun SendDocument( entities.makeString(), null, entities.toRawMessageEntities(), + threadId, disableNotification, protectContent, replyToMessageId, @@ -148,6 +152,8 @@ data class SendDocumentData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 c19ff31c0f..c3c599aab9 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 @@ -6,29 +6,38 @@ import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.* -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent +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.message.content.MediaGroupContent import dev.inmo.tgbotapi.utils.* +import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage import kotlinx.serialization.* 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" @RiskFeature(rawSendingMediaGroupsWarning) -fun SendMediaGroup( +fun SendMediaGroup( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -): Request>> { +): Request> { if (media.size !in mediaCountInMediaGroup) { throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size) } @@ -47,6 +56,7 @@ fun SendMediaGroup( val data = SendMediaGroupData( chatId, media, + threadId, disableNotification, protectContent, replyToMessageId, @@ -60,7 +70,7 @@ fun SendMediaGroup( data, SendMediaGroupFiles(files) ) - }) as Request>> + }) as Request> } /** @@ -72,11 +82,12 @@ fun SendMediaGroup( inline fun SendPlaylist( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * Use this method to be sure that you are correctly sending documents media group @@ -87,11 +98,12 @@ inline fun SendPlaylist( inline fun SendDocumentsGroup( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) /** * Use this method to be sure that you are correctly sending visual media group @@ -103,20 +115,35 @@ inline fun SendDocumentsGroup( inline fun SendVisualMediaGroup( chatId: ChatIdentifier, media: List, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) +) = SendMediaGroup(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply) -private val messagesListSerializer: KSerializer>> - = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass()) +private object MessagesListSerializer: KSerializer>> { + private val serializer = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass>()) + override val descriptor: SerialDescriptor = serializer.descriptor + + override fun deserialize(decoder: Decoder): PossiblySentViaBotCommonMessage> { + val messages = serializer.deserialize(decoder) + return messages.asMediaGroupMessage() + } + + override fun serialize(encoder: Encoder, value: PossiblySentViaBotCommonMessage>) { + serializer.serialize(encoder, value.content.group.map { it.sourceMessage }) + } + +} @Serializable data class SendMediaGroupData internal constructor( @SerialName(chatIdField) override val chatId: ChatIdentifier, val media: List = emptyList(), + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -125,7 +152,8 @@ data class SendMediaGroupData internal constructor( override val replyToMessageId: MessageId? = null, @SerialName(allowSendingWithoutReplyField) override val allowSendingWithoutReply: Boolean? = null -) : DataRequest>>, SendMessageRequest>> { +) : DataRequest>>, + SendMessageRequest>> { @SerialName(mediaField) private val convertedMedia: String get() = buildJsonArray { @@ -138,8 +166,8 @@ data class SendMediaGroupData internal constructor( override fun method(): String = "sendMediaGroup" override val requestSerializer: SerializationStrategy<*> get() = serializer() - override val resultDeserializer: DeserializationStrategy>> - get() = messagesListSerializer + override val resultDeserializer: DeserializationStrategy>> + get() = MessagesListSerializer } data class SendMediaGroupFiles internal constructor( 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 3c99d91311..6a65961780 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 @@ -23,6 +23,7 @@ fun SendPhoto( photo: InputFile, text: String? = null, parseMode: ParseMode? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -35,6 +36,7 @@ fun SendPhoto( text, parseMode, null, + threadId, disableNotification, protectContent, replyToMessageId, @@ -53,6 +55,7 @@ fun SendPhoto( chatId: ChatIdentifier, photo: InputFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -65,6 +68,7 @@ fun SendPhoto( entities.makeString(), null, entities.toRawMessageEntities(), + threadId, disableNotification, protectContent, replyToMessageId, @@ -94,6 +98,8 @@ data class SendPhotoData internal constructor( override val parseMode: ParseMode? = null, @SerialName(captionEntitiesField) private val rawEntities: List? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 44ed930193..a29ccb529b 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 @@ -15,6 +15,7 @@ import kotlinx.serialization.json.JsonObject fun SendSticker( chatId: ChatIdentifier, sticker: InputFile, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -23,6 +24,7 @@ fun SendSticker( ): Request> = SendStickerByFileId( chatId, sticker as? FileId, + threadId, disableNotification, protectContent, replyToMessageId, @@ -44,6 +46,8 @@ data class SendStickerByFileId internal constructor( override val chatId: ChatIdentifier, @SerialName(stickerField) val sticker: FileId? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 88c0a12655..c3c3923cff 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 @@ -29,6 +29,7 @@ fun SendVideo( width: Int? = null, height: Int? = null, supportStreaming: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -51,6 +52,7 @@ fun SendVideo( width, height, supportStreaming, + threadId, disableNotification, protectContent, replyToMessageId, @@ -77,6 +79,7 @@ fun SendVideo( width: Int? = null, height: Int? = null, supportStreaming: Boolean? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -99,6 +102,7 @@ fun SendVideo( width, height, supportStreaming, + threadId, disableNotification, protectContent, replyToMessageId, @@ -141,6 +145,8 @@ data class SendVideoData internal constructor( override val height: Int? = null, @SerialName(supportStreamingField) val supportStreaming: Boolean? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 5e69d17ecf..0ef8e8d090 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 @@ -17,6 +17,7 @@ fun SendVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, // in documentation - length (size of video side) + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -34,6 +35,7 @@ fun SendVideoNote( thumbAsFileId, duration, size, + threadId, disableNotification, protectContent, replyToMessageId, @@ -66,6 +68,8 @@ data class SendVideoNoteData internal constructor( override val duration: Long? = null, @SerialName(lengthField) override val width: Int? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 216d854594..a84e655594 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 @@ -25,6 +25,7 @@ fun SendVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -41,6 +42,7 @@ fun SendVoice( parseMode, null, duration, + threadId, disableNotification, protectContent, replyToMessageId, @@ -62,6 +64,7 @@ fun SendVoice( chatId: ChatIdentifier, voice: InputFile, entities: TextSourcesList, + threadId: MessageThreadId? = null, duration: Long? = null, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -79,6 +82,7 @@ fun SendVoice( null, entities.toRawMessageEntities(), duration, + threadId, disableNotification, protectContent, replyToMessageId, @@ -113,6 +117,8 @@ data class SendVoiceData internal constructor( private val rawEntities: List? = null, @SerialName(durationField) override val duration: Long? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 aace9e8806..6273f29443 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 @@ -58,6 +58,8 @@ data class SendInvoice( override val shouldSendEmailToProvider: Boolean = false, @SerialName(priceDependOnShipAddressField) override val priceDependOnShipAddress: Boolean = false, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 dd9d3a1e31..8982be33d4 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 @@ -48,6 +48,7 @@ fun SendPoll( options: List, isAnonymous: Boolean = true, isClosed: Boolean = false, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -59,6 +60,8 @@ fun SendPoll( options, isAnonymous, isClosed, + threadId = threadId, + protectContent = protectContent, allowSendingWithoutReply = allowSendingWithoutReply, disableNotification = disableNotification, replyToMessageId = replyToMessageId, @@ -71,6 +74,7 @@ fun SendPoll( */ fun Poll.createRequest( chatId: ChatIdentifier, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -85,6 +89,7 @@ fun Poll.createRequest( isClosed, allowMultipleAnswers, scheduledCloseInfo, + threadId, disableNotification, protectContent, replyToMessageId, @@ -101,6 +106,7 @@ fun Poll.createRequest( isClosed, textSources, scheduledCloseInfo, + threadId, disableNotification, protectContent, replyToMessageId, @@ -115,6 +121,7 @@ fun Poll.createRequest( isClosed, false, scheduledCloseInfo, + threadId, disableNotification, protectContent, replyToMessageId, @@ -129,6 +136,7 @@ fun Poll.createRequest( isClosed, false, scheduledCloseInfo, + threadId, disableNotification, protectContent, replyToMessageId, @@ -193,6 +201,8 @@ data class SendRegularPoll( override val openPeriod: LongSeconds?= null, @SerialName(closeDateField) override val closeDate: LongSeconds?, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -222,6 +232,7 @@ fun SendRegularPoll( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -236,6 +247,7 @@ fun SendRegularPoll( allowMultipleAnswers, (closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod, (closeInfo as? ExactScheduledCloseInfo) ?.closeDate, + threadId, disableNotification, protectContent, replyToMessageId, @@ -253,6 +265,7 @@ fun SendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -269,6 +282,7 @@ fun SendQuizPoll( parseMode, null, closeInfo, + threadId, disableNotification, protectContent, replyToMessageId, @@ -285,6 +299,7 @@ fun SendQuizPoll( isClosed: Boolean = false, entities: List, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -301,6 +316,7 @@ fun SendQuizPoll( null, entities.toRawMessageEntities(), closeInfo, + threadId, disableNotification, protectContent, replyToMessageId, @@ -319,6 +335,7 @@ internal fun SendQuizPoll( parseMode: ParseMode? = null, rawEntities: List? = null, closeInfo: ScheduledCloseInfo? = null, + threadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -336,6 +353,7 @@ internal fun SendQuizPoll( rawEntities, (closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod, (closeInfo as? ExactScheduledCloseInfo) ?.closeDate, + threadId, disableNotification, protectContent, replyToMessageId, @@ -367,6 +385,8 @@ data class SendQuizPoll internal constructor( override val openPeriod: LongSeconds? = null, @SerialName(closeDateField) override val closeDate: LongSeconds? = null, + @SerialName(messageThreadIdField) + override val threadId: MessageThreadId? = null, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 70f9e1f47b..a9ff556602 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 @@ -11,6 +11,7 @@ import kotlin.jvm.JvmInline typealias Identifier = Long typealias MessageId = Long +typealias MessageThreadId = Long typealias MessageIdentifier = MessageId typealias InlineQueryIdentifier = String typealias UpdateIdentifier = Long @@ -93,6 +94,7 @@ val captionLength = 0 .. 1024 val textLength = 1 .. 4096 val userProfilePhotosRequestLimit = 0 .. 100 val chatTitleLength = 1 until 255 +val threadNameLength = 1 until 128 val chatDescriptionLength = 0 until 256 val inlineResultQueryIdLingth = 1 until 64 val allowedConnectionsLength = 1 .. 100 @@ -148,6 +150,8 @@ const val tgWebAppStartParamField = "tgWebAppStartParam" const val chatIdField = "chat_id" const val senderChatIdField = "sender_chat_id" const val messageIdField = "message_id" +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" @@ -168,6 +172,8 @@ const val addedToAttachmentMenuField = "added_to_attachment_menu" const val isPremiumField = "is_premium" 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 iconCustomEmojiIdField = "icon_custom_emoji_id" const val canJoinGroupsField = "can_join_groups" const val canReadAllGroupMessagesField = "can_read_all_group_messages" const val supportInlineQueriesField = "supports_inline_queries" @@ -220,6 +226,7 @@ const val totalVoterCountField = "total_voter_count" const val correctOptionIdField = "correct_option_id" const val allowsMultipleAnswersField = "allows_multiple_answers" const val isAnonymousField = "is_anonymous" +const val canManageTopicsField = "can_manage_topics" const val captionEntitiesField = "caption_entities" const val loginUrlField = "login_url" const val forwardTextField = "forward_text" @@ -230,6 +237,7 @@ const val isAnimatedField = "is_animated" const val isVideoField = "is_video" const val inviteLinkField = "invite_link" const val pinnedMessageField = "pinned_message" +const val activeUsernamesField = "active_usernames" const val customTitleField = "custom_title" const val optionIdsField = "option_ids" const val ipAddressField = "ip_address" @@ -245,6 +253,7 @@ const val expireDateField = "expire_date" const val createsJoinRequestField = "creates_join_request" const val pendingJoinRequestCountField = "pending_join_request_count" const val memberLimitField = "member_limit" +const val iconColorField = "icon_color" const val requestContactField = "request_contact" const val requestLocationField = "request_location" @@ -313,6 +322,7 @@ const val botCommandsField = "commands" const val scopeField = "scope" const val isMemberField = "is_member" +const val isForumField = "is_forum" const val canSendMessagesField = "can_send_messages" const val canSendMediaMessagesField = "can_send_media_messages" const val canSendOtherMessagesField = "can_send_other_messages" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ForumTopic.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ForumTopic.kt new file mode 100644 index 0000000000..b241e01701 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ForumTopic.kt @@ -0,0 +1,26 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ForumTopic( + @SerialName(messageThreadIdField) + val messageThreadId: MessageThreadId, + @SerialName(nameField) + val name: String, + @SerialName(iconColorField) + val color: RGBColor, + @SerialName(iconCustomEmojiIdField) + val iconEmojiId: CustomEmojiId? = null +) { + companion object { + val CYAN = RGBColor(0x6FB9F0) + val YELLOW = RGBColor(0xffd67e) + val PURPLE = RGBColor(0xCB86DB) + val GREEN = RGBColor(0x8EEE98) + val PINK = RGBColor(0xFF93B2) + val RED = RGBColor(0xFB6F5F) + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt index 2bb134d168..258604a209 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt @@ -5,10 +5,9 @@ import dev.inmo.tgbotapi.types.* import kotlinx.serialization.Serializable @Serializable(PreviewChatSerializer::class) -sealed interface ChannelChat : SuperPublicChat - -@Serializable(PreviewChatSerializer::class) -sealed interface GroupChat : PublicChat +sealed interface UsernameChat : Chat { + val username: Username? +} @Serializable(PreviewChatSerializer::class) sealed interface PrivateChat : Chat, UsernameChat { @@ -22,16 +21,20 @@ sealed interface PublicChat : Chat { val title: String } -@Serializable(PreviewChatSerializer::class) -sealed interface SupergroupChat : GroupChat, SuperPublicChat - @Serializable(PreviewChatSerializer::class) sealed interface SuperPublicChat : PublicChat, UsernameChat @Serializable(PreviewChatSerializer::class) -sealed interface UsernameChat : Chat { - val username: Username? -} +sealed interface ChannelChat : SuperPublicChat + +@Serializable(PreviewChatSerializer::class) +sealed interface GroupChat : PublicChat + +@Serializable(PreviewChatSerializer::class) +sealed interface SupergroupChat : GroupChat, SuperPublicChat + +@Serializable(PreviewChatSerializer::class) +sealed interface ForumChat : SupergroupChat @Serializable(PreviewChatSerializer::class) sealed interface PossiblyPremiumChat : Chat { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt index 3d887f8ffe..c211b909ba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatSerializers.kt @@ -57,11 +57,16 @@ object PreviewChatSerializer : KSerializer { val decodedJson = JsonObject.serializer().deserialize(decoder) val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson") + val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true return when (type) { ChatType.PrivateChatType -> formatter.decodeFromJsonElement(PrivateChatImpl.serializer(), decodedJson) ChatType.GroupChatType -> formatter.decodeFromJsonElement(GroupChatImpl.serializer(), decodedJson) - ChatType.SupergroupChatType -> formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson) + ChatType.SupergroupChatType -> if (isForum) { + formatter.decodeFromJsonElement(ForumChatImpl.serializer(), decodedJson) + } else { + formatter.decodeFromJsonElement(SupergroupChatImpl.serializer(), decodedJson) + } ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ChannelChatImpl.serializer(), decodedJson) is ChatType.UnknownChatType -> UnknownChatType( formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(), @@ -77,6 +82,7 @@ object PreviewChatSerializer : KSerializer { is PrivateChatImpl -> PrivateChatImpl.serializer().serialize(encoder, value) is GroupChatImpl -> GroupChatImpl.serializer().serialize(encoder, value) is SupergroupChatImpl -> SupergroupChatImpl.serializer().serialize(encoder, value) + is ForumChatImpl -> ForumChatImpl.serializer().serialize(encoder, value) is ChannelChatImpl -> ChannelChatImpl.serializer().serialize(encoder, value) is CommonBot -> CommonBot.serializer().serialize(encoder, value) is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, value) @@ -95,12 +101,17 @@ object ExtendedChatSerializer : KSerializer { val decodedJson = JsonObject.serializer().deserialize(decoder) val type = decodedJson[typeField] ?.jsonPrimitive ?.content ?.asChatType ?: error("Field $typeField must be presented, but absent in $decodedJson") + val isForum = decodedJson[isForumField] ?.jsonPrimitive ?.booleanOrNull == true return when (type) { // else -> throw IllegalArgumentException("Unknown type of chat") ChatType.PrivateChatType -> formatter.decodeFromJsonElement(ExtendedPrivateChatImpl.serializer(), decodedJson) ChatType.GroupChatType -> formatter.decodeFromJsonElement(ExtendedGroupChatImpl.serializer(), decodedJson) - ChatType.SupergroupChatType -> formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson) + ChatType.SupergroupChatType -> if (isForum) { + formatter.decodeFromJsonElement(ExtendedForumChatImpl.serializer(), decodedJson) + } else { + formatter.decodeFromJsonElement(ExtendedSupergroupChatImpl.serializer(), decodedJson) + } ChatType.ChannelChatType -> formatter.decodeFromJsonElement(ExtendedChannelChatImpl.serializer(), decodedJson) is ChatType.UnknownChatType -> UnknownExtendedChat( formatter.decodeFromJsonElement(Long.serializer(), decodedJson[chatIdField] ?: JsonPrimitive(-1)).toChatId(), @@ -115,6 +126,7 @@ object ExtendedChatSerializer : KSerializer { is ExtendedPrivateChatImpl -> ExtendedPrivateChatImpl.serializer().serialize(encoder, value) is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, value) is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, value) + is ExtendedForumChatImpl -> ExtendedForumChatImpl.serializer().serialize(encoder, value) is ExtendedChannelChatImpl -> ExtendedChannelChatImpl.serializer().serialize(encoder, value) is UnknownExtendedChat -> JsonObject.serializer().serialize(encoder, value.rawJson) } 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 01ead1be28..719d28c025 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 @@ -15,6 +15,8 @@ data class ExtendedChannelChatImpl( override val title: String, @SerialName(usernameField) override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), @SerialName(photoField) override val chatPhoto: ChatPhoto? = null, @SerialName(descriptionField) @@ -55,6 +57,8 @@ data class ExtendedPrivateChatImpl( override val chatPhoto: ChatPhoto? = null, @SerialName(usernameField) override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), @SerialName(firstNameField) override val firstName: String = "", @SerialName(lastNameField) @@ -64,7 +68,9 @@ data class ExtendedPrivateChatImpl( @SerialName(hasPrivateForwardsField) override val hasPrivateForwards: Boolean = false, @SerialName(hasRestrictedVoiceAndVideoMessagesField) - override val hasRestrictedVoiceAndVideoMessages: Boolean = false + override val hasRestrictedVoiceAndVideoMessages: Boolean = false, + @SerialName(emojiStatusCustomEmojiIdField) + override val statusEmojiId: CustomEmojiId? = null ) : ExtendedPrivateChat typealias ExtendedUser = ExtendedPrivateChatImpl @@ -77,6 +83,8 @@ data class ExtendedSupergroupChatImpl( override val title: String, @SerialName(usernameField) override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), @SerialName(photoField) override val chatPhoto: ChatPhoto? = null, @SerialName(permissionsField) @@ -104,6 +112,43 @@ data class ExtendedSupergroupChatImpl( override val requireAdminApproveToJoin: Boolean = false ) : ExtendedSupergroupChat +@Serializable +data class ExtendedForumChatImpl( + @SerialName(idField) + override val id: ChatId, + @SerialName(titleField) + override val title: String, + @SerialName(usernameField) + override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), + @SerialName(photoField) + override val chatPhoto: ChatPhoto? = null, + @SerialName(permissionsField) + override val permissions: ChatPermissions, + @SerialName(descriptionField) + override val description: String = "", + @SerialName(inviteLinkField) + override val inviteLink: String? = null, + @SerialName(pinnedMessageField) + @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) + override val pinnedMessage: Message? = null, + @SerialName(stickerSetNameFullField) + override val stickerSetName: StickerSetName? = null, + @SerialName(slowModeDelayField) + override val slowModeDelay: Long? = null, + @SerialName(canSetStickerSetField) + override val canSetStickerSet: Boolean = false, + @SerialName(linkedChatIdField) + override val linkedChannelChatId: ChatId? = null, + @SerialName(locationField) + override val location: ChatLocation? = null, + @SerialName(joinToSendMessagesField) + override val requiresJoinForMessaging: Boolean = false, + @SerialName(joinByRequestField) + override val requireAdminApproveToJoin: Boolean = false +) : ExtendedForumChat + @Serializable data class ExtendedBot( override val id: UserId, 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 6705d8203d..0f68e43802 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 @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializ import kotlinx.serialization.Serializable @Serializable(ExtendedChatSerializer::class) -sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat { +sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername { val linkedGroupChatId: ChatId? } @@ -16,10 +16,11 @@ sealed interface ExtendedGroupChat : GroupChat, ExtendedPublicChat { } @Serializable(ExtendedChatSerializer::class) -sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChat { +sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername { val bio: String val hasPrivateForwards: Boolean val hasRestrictedVoiceAndVideoMessages: Boolean + val statusEmojiId: CustomEmojiId? val allowCreateUserIdLink: Boolean get() = hasPrivateForwards @@ -33,7 +34,7 @@ sealed interface ExtendedPublicChat : ExtendedChat, PublicChat { } @Serializable(ExtendedChatSerializer::class) -sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat { +sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, ExtendedChatWithUsername { val slowModeDelay: Long? val stickerSetName: StickerSetName? val canSetStickerSet: Boolean @@ -51,7 +52,15 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat { val requireAdminApproveToJoin: Boolean } +@Serializable(ExtendedChatSerializer::class) +sealed interface ExtendedForumChat : ExtendedSupergroupChat + @Serializable(ExtendedChatSerializer::class) sealed interface ExtendedChat : Chat { val chatPhoto: ChatPhoto? } + +@Serializable(ExtendedChatSerializer::class) +sealed interface ExtendedChatWithUsername : UsernameChat, ExtendedChat { + val activeUsernames: List +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt index ac61c30301..3af9d12774 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt @@ -37,6 +37,16 @@ data class SupergroupChatImpl( override val username: Username? = null ) : SupergroupChat +@Serializable +data class ForumChatImpl( + @SerialName(idField) + override val id: ChatId, + @SerialName(titleField) + override val title: String, + @SerialName(usernameField) + override val username: Username? = null +) : ForumChat + @Serializable data class ChannelChatImpl( @SerialName(idField) 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 f6421cb160..4e2cf26eac 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 @@ -33,7 +33,9 @@ data class AdministratorChatMemberImpl( @SerialName(isAnonymousField) override val isAnonymous: Boolean = false, @SerialName(customTitleField) - override val customTitle: String? = null + override val customTitle: String? = null, + @SerialName(canManageTopicsField) + override val canManageTopics: Boolean = false ) : AdministratorChatMember { @SerialName(statusField) @Required diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights.kt index 683325ed12..4e68b58147 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights.kt @@ -4,6 +4,7 @@ sealed interface SpecialChatAdministratorRights { val canChangeInfo: Boolean val canInviteUsers: Boolean val canPinMessages: Boolean + val canManageTopics: Boolean } sealed interface ChatAdministratorRights : SpecialChatAdministratorRights { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRightsImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRightsImpl.kt index 8f1ea768b3..823f3ebebb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRightsImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRightsImpl.kt @@ -27,5 +27,7 @@ data class ChatAdministratorRightsImpl( @SerialName(canManageChatField) override val canManageChat: Boolean = false, @SerialName(isAnonymousField) - override val isAnonymous: Boolean = false + override val isAnonymous: Boolean = false, + @SerialName(canManageTopicsField) + override val canManageTopics: Boolean = false ) : ChatAdministratorRights 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 ef730c86ec..428aedd0d8 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 @@ -34,6 +34,8 @@ data class OwnerChatMember( override val canManageVideoChats: Boolean = true @Transient override val canManageChat: Boolean = true + @Transient + override val canManageTopics: Boolean = true @SerialName(statusField) @Required private val type: String = "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 f28a9ffe1a..c3449784c8 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 @@ -27,7 +27,9 @@ data class RestrictedChatMember( @SerialName(canInviteUsersField) override val canInviteUsers: Boolean = false, @SerialName(canPinMessagesField) - override val canPinMessages: Boolean = false + override val canPinMessages: Boolean = false, + @SerialName(canManageTopicsField) + override val canManageTopics: Boolean = false ) : BannedChatMember, SpecialRightsChatMember { @SerialName(statusField) @Required 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 a9ff456ec5..a53ce0f3c9 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 @@ -19,5 +19,6 @@ data class ChannelContentMessageImpl( override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, - override val authorSignature: AuthorSignature? + override val authorSignature: AuthorSignature?, + override val mediaGroupId: MediaGroupIdentifier?, ) : ChannelContentMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMediaGroupMessage.kt deleted file mode 100644 index 859e4415b3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelMediaGroupMessage.kt +++ /dev/null @@ -1,23 +0,0 @@ -package dev.inmo.tgbotapi.types.message - -import com.soywiz.klock.DateTime -import dev.inmo.tgbotapi.types.MediaGroupIdentifier -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.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent - -data class ChannelMediaGroupMessage( - override val messageId: MessageId, - override val chat: Chat, - override val date: DateTime, - override val mediaGroupId: MediaGroupIdentifier, - override val content: T, - override val editDate: DateTime?, - override val hasProtectedContent: Boolean, - override val forwardInfo: ForwardInfo?, - override val replyTo: Message?, - override val replyMarkup: InlineKeyboardMarkup? -) : MediaGroupMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ForumEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ForumEvent.kt new file mode 100644 index 0000000000..cffe4f281c --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ForumEvent.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts + +interface ForumEvent: SupergroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicClosed.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicClosed.kt new file mode 100644 index 0000000000..637f63b72f --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicClosed.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.forum + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent +import kotlinx.serialization.Serializable + +@Serializable +object ForumTopicClosed : ForumEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated.kt new file mode 100644 index 0000000000..b93064982d --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.forum + +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.iconColorField +import dev.inmo.tgbotapi.types.iconCustomEmojiIdField +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent +import dev.inmo.tgbotapi.types.nameField +import dev.inmo.tgbotapi.utils.RGBColor +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ForumTopicCreated( + @SerialName(nameField) + val name: String, + @SerialName(iconColorField) + val iconColor: RGBColor, + @SerialName(iconCustomEmojiIdField) + val iconEmojiId: CustomEmojiId? = null +) : ForumEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicReopened.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicReopened.kt new file mode 100644 index 0000000000..6daef136ab --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicReopened.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.forum + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent +import kotlinx.serialization.Serializable + +@Serializable +object ForumTopicReopened : ForumEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt deleted file mode 100644 index ea544158d6..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt +++ /dev/null @@ -1,23 +0,0 @@ -package dev.inmo.tgbotapi.types.message - -import com.soywiz.klock.DateTime -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.chat.User -import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent - -data class CommonMediaGroupMessage( - override val messageId: MessageId, - override val from: User, - override val chat: Chat, - override val date: DateTime, - override val mediaGroupId: MediaGroupIdentifier, - override val content: T, - override val editDate: DateTime?, - override val hasProtectedContent: Boolean, - override val forwardInfo: ForwardInfo?, - override val replyTo: Message?, - override val replyMarkup: InlineKeyboardMarkup? -) : MediaGroupMessage, FromUserMessage 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 18b98428e4..a3fd4d4dcc 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 @@ -21,7 +21,8 @@ data class ConnectedFromChannelGroupContentMessageImpl( override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, - override val authorSignature: AuthorSignature? + override val authorSignature: AuthorSignature?, + override val mediaGroupId: MediaGroupIdentifier?, ) : ConnectedFromChannelGroupContentMessage data class UnconnectedFromChannelGroupContentMessageImpl( @@ -36,7 +37,8 @@ data class UnconnectedFromChannelGroupContentMessageImpl( override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, - override val authorSignature: AuthorSignature? + override val authorSignature: AuthorSignature?, + override val mediaGroupId: MediaGroupIdentifier?, ) : UnconnectedFromChannelGroupContentMessage data class AnonymousGroupContentMessageImpl( @@ -50,7 +52,8 @@ data class AnonymousGroupContentMessageImpl( override val replyMarkup: InlineKeyboardMarkup?, override val content: T, override val senderBot: CommonBot?, - override val authorSignature: AuthorSignature? + override val authorSignature: AuthorSignature?, + override val mediaGroupId: MediaGroupIdentifier?, ) : AnonymousGroupContentMessage data class CommonGroupContentMessageImpl( @@ -64,5 +67,55 @@ data class CommonGroupContentMessageImpl( override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup?, override val content: T, - override val senderBot: CommonBot? + override val senderBot: CommonBot?, + override val mediaGroupId: MediaGroupIdentifier?, ) : CommonGroupContentMessage + +data class FromChannelForumContentMessageImpl( + override val chat: ForumChat, + override val channel: ChannelChat, + override val messageId: MessageId, + override val threadId: MessageThreadId, + override val date: DateTime, + override val forwardInfo: ForwardInfo?, + override val editDate: DateTime?, + override val hasProtectedContent: Boolean, + override val replyTo: Message?, + override val replyMarkup: InlineKeyboardMarkup?, + override val content: T, + override val senderBot: CommonBot?, + override val authorSignature: AuthorSignature?, + override val mediaGroupId: MediaGroupIdentifier?, +) : FromChannelForumContentMessage + +data class AnonymousForumContentMessageImpl( + override val chat: ForumChat, + override val messageId: MessageId, + override val threadId: MessageThreadId, + override val date: DateTime, + override val forwardInfo: ForwardInfo?, + override val editDate: DateTime?, + override val hasProtectedContent: Boolean, + override val replyTo: Message?, + override val replyMarkup: InlineKeyboardMarkup?, + override val content: T, + override val senderBot: CommonBot?, + override val authorSignature: AuthorSignature?, + override val mediaGroupId: MediaGroupIdentifier?, +) : AnonymousForumContentMessage + +data class CommonForumContentMessageImpl( + override val chat: ForumChat, + override val messageId: MessageId, + override val threadId: MessageThreadId, + override val from: User, + override val date: DateTime, + override val forwardInfo: ForwardInfo?, + override val editDate: DateTime?, + override val hasProtectedContent: Boolean, + override val replyTo: Message?, + override val replyMarkup: InlineKeyboardMarkup?, + override val content: T, + override val senderBot: CommonBot?, + override val mediaGroupId: MediaGroupIdentifier?, +) : CommonForumContentMessage 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 300b2afc3f..aac98484a3 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 @@ -21,5 +21,6 @@ data class PrivateContentMessageImpl( override val forwardInfo: ForwardInfo?, override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup?, - override val senderBot: CommonBot? + override val senderBot: CommonBot?, + override val mediaGroupId: MediaGroupIdentifier?, ) : PrivateContentMessage 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 459c45ca2e..2e63c28a71 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 @@ -12,6 +12,9 @@ import dev.inmo.tgbotapi.types.games.RawGame import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.content.* @@ -34,6 +37,8 @@ internal data class RawMessage( val messageId: MessageId, val date: TelegramDate, private val chat: Chat, + @SerialName(messageThreadIdField) + private val messageThreadId: MessageThreadId? = null, private val from: User? = null, private val sender_chat: PublicChat? = null, private val forward_from: User? = null, @@ -89,6 +94,11 @@ internal data class RawMessage( private val video_chat_ended: VideoChatEnded? = null, private val video_chat_participants_invited: VideoChatParticipantsInvited? = null, + // Forum + private val forum_topic_created: ForumTopicCreated? = null, + private val forum_topic_closed: ForumTopicClosed? = null, + private val forum_topic_reopened: ForumTopicReopened? = null, + // AutoDelete Message time changed private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null, @@ -202,6 +212,9 @@ internal data class RawMessage( 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 + forum_topic_created != null -> forum_topic_created + forum_topic_closed != null -> forum_topic_closed + forum_topic_reopened != null -> forum_topic_reopened video_chat_ended != null -> video_chat_ended video_chat_participants_invited != null -> video_chat_participants_invited delete_chat_photo -> DeleteChatPhoto() @@ -256,43 +269,7 @@ internal data class RawMessage( ) else -> error("Expected one of the public chats, but was $chat (in extracting of chat event message)") } - } ?: content?.let { content -> - media_group_id?.let { - val checkedContent = when (content) { - is PhotoContent -> content - is VideoContent -> content - is AudioContent -> content - is DocumentContent -> content - else -> error("Unsupported content for media group") - } - when (from) { - null -> ChannelMediaGroupMessage( - messageId, - chat, - date.asDate, - it, - checkedContent, - edit_date?.asDate, - has_protected_content == true, - forwarded, - reply_to_message?.asMessage, - reply_markup - ) - else -> CommonMediaGroupMessage( - messageId, - from, - chat, - date.asDate, - it, - checkedContent, - edit_date?.asDate, - has_protected_content == true, - forwarded, - reply_to_message?.asMessage, - reply_markup - ) - } - } ?: when (chat) { + } ?: content?.let { content -> when (chat) { is PublicChat -> when (chat) { is ChannelChat -> ChannelContentMessageImpl( messageId, @@ -305,8 +282,123 @@ internal data class RawMessage( reply_to_message?.asMessage, reply_markup, via_bot, - author_signature + author_signature, + media_group_id ) + is ForumChat -> if (messageThreadId != null) { + when (sender_chat) { + is ChannelChat -> FromChannelForumContentMessageImpl( + chat, + sender_chat, + messageId, + messageThreadId, + date.asDate, + forwarded, + edit_date ?.asDate, + has_protected_content == true, + reply_to_message ?.asMessage, + reply_markup, + content, + via_bot, + author_signature, + media_group_id + ) + is GroupChat -> AnonymousForumContentMessageImpl( + chat, + messageId, + messageThreadId, + date.asDate, + forwarded, + edit_date ?.asDate, + has_protected_content == true, + reply_to_message ?.asMessage, + reply_markup, + content, + via_bot, + author_signature, + media_group_id + ) + null -> CommonForumContentMessageImpl( + chat, + messageId, + messageThreadId, + from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), + date.asDate, + forwarded, + edit_date ?.asDate, + has_protected_content == true, + reply_to_message ?.asMessage, + reply_markup, + content, + via_bot, + media_group_id + ) + } + } else { + when (sender_chat) { + is ChannelChat -> if (is_automatic_forward == true) { + ConnectedFromChannelGroupContentMessageImpl( + chat, + sender_chat, + messageId, + date.asDate, + forwarded, + edit_date ?.asDate, + has_protected_content == true, + reply_to_message ?.asMessage, + reply_markup, + content, + via_bot, + author_signature, + media_group_id + ) + } else { + UnconnectedFromChannelGroupContentMessageImpl( + chat, + sender_chat, + messageId, + date.asDate, + forwarded, + edit_date ?.asDate, + has_protected_content == true, + reply_to_message ?.asMessage, + reply_markup, + content, + via_bot, + author_signature, + media_group_id + ) + } + is GroupChat -> AnonymousGroupContentMessageImpl( + chat, + messageId, + date.asDate, + forwarded, + edit_date ?.asDate, + has_protected_content == true, + reply_to_message ?.asMessage, + reply_markup, + content, + via_bot, + author_signature, + media_group_id + ) + null -> CommonGroupContentMessageImpl( + chat, + messageId, + from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), + date.asDate, + forwarded, + edit_date ?.asDate, + has_protected_content == true, + reply_to_message ?.asMessage, + reply_markup, + content, + via_bot, + media_group_id + ) + } + } is GroupChat -> when (sender_chat) { is ChannelChat -> if (is_automatic_forward == true) { ConnectedFromChannelGroupContentMessageImpl( @@ -321,7 +413,8 @@ internal data class RawMessage( reply_markup, content, via_bot, - author_signature + author_signature, + media_group_id ) } else { UnconnectedFromChannelGroupContentMessageImpl( @@ -336,7 +429,8 @@ internal data class RawMessage( reply_markup, content, via_bot, - author_signature + author_signature, + media_group_id ) } is GroupChat -> AnonymousGroupContentMessageImpl( @@ -350,7 +444,8 @@ internal data class RawMessage( reply_markup, content, via_bot, - author_signature + author_signature, + media_group_id ) null -> CommonGroupContentMessageImpl( chat, @@ -363,11 +458,10 @@ internal data class RawMessage( reply_to_message ?.asMessage, reply_markup, content, - via_bot + via_bot, + media_group_id ) - else -> error("Currently in groups supported only fields \"sender_chat\" with channel, group or null, but was $sender_chat") } - else -> error("Unknown type of public chat: $chat") } is PrivateChat -> PrivateContentMessageImpl( messageId, @@ -380,7 +474,8 @@ internal data class RawMessage( forwarded, reply_to_message?.asMessage, reply_markup, - via_bot + via_bot, + media_group_id ) else -> error("Unknown type of chat: $chat") } 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 bca2700613..7adf185282 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,9 +2,10 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.content.MessageContent -interface CommonMessage : Message, +sealed interface CommonMessage : Message, PossiblyForwardedMessage, PossiblyEditedMessage, PossiblyReplyMessage, PossiblyMarkedUp, + PossiblyMediaGroupMessage, ContentMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt index 7ec7f0bc6c..7553560cb3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt @@ -1,15 +1,22 @@ package dev.inmo.tgbotapi.types.message.abstracts +import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.chat.ChannelChat +import dev.inmo.tgbotapi.types.chat.ForumChat import dev.inmo.tgbotapi.types.chat.GroupChat import dev.inmo.tgbotapi.types.message.content.MessageContent -interface GroupContentMessage : PublicContentMessage { +sealed interface GroupContentMessage : PublicContentMessage { override val chat: GroupChat } +sealed interface ForumContentMessage : GroupContentMessage, PossiblyTopicMessage { + override val chat: ForumChat + override val threadId: MessageThreadId +} -interface FromChannelGroupContentMessage : GroupContentMessage, SignedMessage, WithSenderChatMessage { + +sealed interface FromChannelGroupContentMessage : GroupContentMessage, SignedMessage, WithSenderChatMessage { val channel: ChannelChat override val senderChat: ChannelChat get() = channel @@ -24,3 +31,12 @@ interface AnonymousGroupContentMessage : GroupContentMessage } interface CommonGroupContentMessage : GroupContentMessage, FromUserMessage + +interface FromChannelForumContentMessage : FromChannelGroupContentMessage, ForumContentMessage + +interface AnonymousForumContentMessage : ForumContentMessage, SignedMessage, WithSenderChatMessage { + override val senderChat: GroupChat + get() = chat +} + +interface CommonForumContentMessage : ForumContentMessage, FromUserMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/MediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/MediaGroupMessage.kt deleted file mode 100644 index faac6c32eb..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/MediaGroupMessage.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.inmo.tgbotapi.types.message.abstracts - -import dev.inmo.tgbotapi.types.MediaGroupIdentifier -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent - -interface MediaGroupMessage : CommonMessage { - val mediaGroupId: MediaGroupIdentifier -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyMediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyMediaGroupMessage.kt new file mode 100644 index 0000000000..fa865da83b --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyMediaGroupMessage.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.types.message.abstracts + +import dev.inmo.tgbotapi.types.MediaGroupIdentifier +import dev.inmo.tgbotapi.types.message.content.MessageContent + +interface PossiblyMediaGroupMessage : ContentMessage { + val mediaGroupId: MediaGroupIdentifier? +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblySentViaBotCommonMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblySentViaBotCommonMessage.kt index 155b0fdc17..5b7574457d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblySentViaBotCommonMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblySentViaBotCommonMessage.kt @@ -2,4 +2,4 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.content.MessageContent -interface PossiblySentViaBotCommonMessage : CommonMessage, PossiblySentViaBot +sealed interface PossiblySentViaBotCommonMessage : CommonMessage, PossiblySentViaBot 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 new file mode 100644 index 0000000000..8027809031 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.abstracts + +import dev.inmo.tgbotapi.types.MessageThreadId + +interface PossiblyTopicMessage : Message { + val threadId: MessageThreadId? +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PublicMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PublicMessage.kt index 18a4b904b6..21264b6db0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PublicMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PublicMessage.kt @@ -3,6 +3,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.message.content.MessageContent -interface PublicContentMessage : PossiblySentViaBotCommonMessage { +sealed interface PublicContentMessage : PossiblySentViaBotCommonMessage { override val chat: PublicChat } 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 c1cc0c0a44..4610948074 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,6 +4,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.media.TelegramMedia @@ -15,10 +16,10 @@ sealed interface MessageContent: ResendableContent { companion object { @RiskFeature("This serialization module can be changed in near releases") fun serializationModule( - visualMediaGroupContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, - documentMediaGroupContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, - audioMediaGroupContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, - mediaGroupContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, + visualMediaGroupContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, + documentMediaGroupContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, + audioMediaGroupContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, + mediaGroupPartContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, textedMediaContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, mediaContentAdditionalBuilder: PolymorphicModuleBuilder.() -> Unit = {}, mediaCollectionContentAdditionalBuilder: PolymorphicModuleBuilder>.() -> Unit = {}, @@ -73,24 +74,24 @@ sealed interface MessageContent: ResendableContent { textedMediaContentAdditionalBuilder() } - polymorphic(MediaGroupContent::class) { + polymorphic(MediaGroupPartContent::class) { subclass(PhotoContent::class) subclass(AudioContent::class) subclass(DocumentContent::class) - mediaGroupContentAdditionalBuilder() + mediaGroupPartContentAdditionalBuilder() } - polymorphic(AudioMediaGroupContent::class) { + polymorphic(AudioMediaGroupPartContent::class) { subclass(AudioContent::class) audioMediaGroupContentAdditionalBuilder() } - polymorphic(DocumentMediaGroupContent::class) { + polymorphic(DocumentMediaGroupPartContent::class) { subclass(DocumentContent::class) documentMediaGroupContentAdditionalBuilder() } - polymorphic(VisualMediaGroupContent::class) { + polymorphic(VisualMediaGroupPartContent::class) { subclass(PhotoContent::class) subclass(VideoContent::class) @@ -113,6 +114,7 @@ sealed interface MediaContent: MessageContent { sealed interface ResendableContent { fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId? = null, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 3d31a732c1..21dd74142f 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 @@ -1,28 +1,44 @@ 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.files.AudioFile import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.media.* +import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage +import kotlinx.serialization.Serializable -sealed interface AudioMediaGroupContent : MediaGroupContent { +sealed interface AudioMediaGroupPartContent : MediaGroupPartContent { override val media: AudioFile override fun toMediaGroupMemberTelegramMedia(): AudioMediaGroupMemberTelegramMedia } -sealed interface DocumentMediaGroupContent : MediaGroupContent { +sealed interface DocumentMediaGroupPartContent : MediaGroupPartContent { override val media: DocumentFile override fun toMediaGroupMemberTelegramMedia(): DocumentMediaGroupMemberTelegramMedia } -sealed interface MediaGroupContent : TextedMediaContent { +sealed interface TextedMediaContent : MediaContent, TextedInput + +sealed interface MediaGroupCollectionContent : TextedMediaContent { + @Serializable + data class PartWrapper( + val messageId: MessageId, + val content: T, + val sourceMessage: PossiblySentViaBotCommonMessage + ) + val group: List> + val mediaGroupId: MediaGroupIdentifier +} + +sealed interface MediaGroupPartContent : TextedMediaContent { fun toMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia } -sealed interface TextedMediaContent : MediaContent, TextedInput - -sealed interface VisualMediaGroupContent : MediaGroupContent { +sealed interface VisualMediaGroupPartContent : MediaGroupPartContent { override fun toMediaGroupMemberTelegramMedia(): VisualMediaGroupMemberTelegramMedia } 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 1c072ed5c5..8c842f36c6 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -21,6 +22,7 @@ data class AnimationContent( ) : TextedMediaContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -34,6 +36,7 @@ data class AnimationContent( media.duration, media.width, media.height, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 27498e173f..5ac88ae625 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 @@ -7,6 +7,7 @@ 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,9 +18,10 @@ data class AudioContent( override val media: AudioFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : AudioMediaGroupContent { +) : AudioMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -33,6 +35,7 @@ data class AudioContent( media.duration, media.performer, media.title, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 78dab7b864..694b4ff5d5 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 @@ -13,12 +13,13 @@ data class ContactContent( ) : MessageContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, allowSendingWithoutReply: Boolean?, replyMarkup: KeyboardMarkup? ): Request> = SendContact( - chatId, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, contact, messageThreadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 11ae6056aa..fc319a695d 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.dice.Dice import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -15,6 +16,7 @@ data class DiceContent( ) : MessageContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -23,6 +25,7 @@ data class DiceContent( ): Request> = SendDice( chatId, dice.animationType, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 56c82a6028..5c27ebbf9f 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 @@ -8,6 +8,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.files.asDocumentFile @@ -19,9 +20,10 @@ data class DocumentContent( override val media: DocumentFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : DocumentMediaGroupContent { +) : DocumentMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -32,6 +34,7 @@ data class DocumentContent( media.fileId, media.thumb ?.fileId, textSources, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 d6eb18d9e4..e3b72c96a8 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -15,6 +16,7 @@ data class GameContent( ) : MessageContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -23,6 +25,7 @@ data class GameContent( ): Request> = SendGame( chatId, game.title, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 bd95f7ad2c..aba78dbf89 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 @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.message.content 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.payments.Invoice @@ -14,6 +15,7 @@ data class InvoiceContent( ) : MessageContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, 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 044d1490b1..f4f932158c 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.SendStaticLocation 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -99,6 +100,7 @@ data class LiveLocationContent( ) : LocationContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -112,6 +114,7 @@ data class LiveLocationContent( location.horizontalAccuracy, location.heading, location.proximityAlertRadius, + messageThreadId, disableNotification, protectContent, replyToMessageId, @@ -130,6 +133,7 @@ data class StaticLocationContent( ) : LocationContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -139,6 +143,7 @@ data class StaticLocationContent( chatId, location.latitude, location.longitude, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 new file mode 100644 index 0000000000..8af2a53a34 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/MediaGroupContent.kt @@ -0,0 +1,50 @@ +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.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.files.TelegramMediaFile +import dev.inmo.tgbotapi.types.media.TelegramMedia +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 { + val mainContent: MediaGroupPartContent + get() = group.first().content + override val media: TelegramMediaFile + get() = mainContent.media + + override val textSources: List + get() = mainContent.textSources + override val text: String? + get() = mainContent.text + + override fun asTelegramMedia(): TelegramMedia = mainContent.asTelegramMedia() + + override fun createResend( + chatId: ChatIdentifier, + threadId: MessageThreadId?, + disableNotification: Boolean, + protectContent: Boolean, + replyToMessageId: MessageId?, + allowSendingWithoutReply: Boolean?, + replyMarkup: KeyboardMarkup? + ): Request = SendMediaGroup( + chatId, + group.map { it.content.toMediaGroupMemberTelegramMedia() }, + threadId, + disableNotification, + protectContent, + replyToMessageId, + allowSendingWithoutReply + ) +} 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 2d134a3c61..75a488771e 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 @@ -7,6 +7,7 @@ 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -17,11 +18,12 @@ data class PhotoContent( override val mediaCollection: Photo, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : MediaCollectionContent, VisualMediaGroupContent { +) : MediaCollectionContent, VisualMediaGroupPartContent { override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -31,6 +33,7 @@ data class PhotoContent( chatId, media.fileId, textSources, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 baca120c88..7d81ddaa60 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.polls.Poll @@ -15,6 +16,7 @@ data class PollContent( ) : MessageContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -22,6 +24,7 @@ data class PollContent( replyMarkup: KeyboardMarkup? ): Request> = poll.createRequest( chatId, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 2e2d2adac8..635f855d5a 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 @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendSticker 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -16,6 +17,7 @@ data class StickerContent( ) : MediaContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -24,6 +26,7 @@ data class StickerContent( ): Request> = SendSticker( chatId, media.fileId, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 a4a00d05c8..d16933944b 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier 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.message.abstracts.ContentMessage import kotlinx.serialization.Serializable @@ -17,6 +18,7 @@ data class TextContent( ) : MessageContent, TextedInput { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -26,6 +28,7 @@ data class TextContent( chatId, textSources, false, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 397ffde08e..9ed6c11430 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 @@ -20,12 +20,12 @@ typealias VideoNoteMessage = CommonMessage typealias StickerMessage = CommonMessage typealias TextedMediaMessage = CommonMessage typealias VoiceMessage = CommonMessage -typealias MediaGroupMessage = CommonMessage -typealias AudioMediaGroupMessage = CommonMessage +typealias MediaGroupMessage = CommonMessage> +typealias AudioMediaGroupMessage = CommonMessage typealias AudioMessage = CommonMessage -typealias DocumentMediaGroupMessage = CommonMessage +typealias DocumentMediaGroupMessage = CommonMessage typealias DocumentMessage = CommonMessage -typealias VisualMediaGroupMessage = CommonMessage +typealias VisualMediaGroupMessage = CommonMessage typealias VideoMessage = CommonMessage typealias PhotoMessage = CommonMessage typealias AnimationMessage = 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 b16687bcdc..12fa337486 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 @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.Request 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.venue.Venue @@ -15,12 +16,13 @@ data class VenueContent( ) : MessageContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, allowSendingWithoutReply: Boolean?, replyMarkup: KeyboardMarkup? ): Request> = SendVenue( - chatId, venue, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup + chatId, venue, messageThreadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, 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 ef160c455f..53312ed522 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier 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 @@ -17,9 +18,10 @@ data class VideoContent( override val media: VideoFile, override val text: String? = null, override val textSources: TextSourcesList = emptyList() -) : VisualMediaGroupContent { +) : VisualMediaGroupPartContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -34,6 +36,7 @@ data class VideoContent( media.width, media.height, null, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 e81a39031b..047f0203e5 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 @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendVideoNote 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VideoNoteFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -16,6 +17,7 @@ data class VideoNoteContent( ) : MediaContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -27,6 +29,7 @@ data class VideoNoteContent( media.thumb ?.fileId, media.duration, media.width, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 1c90b02e14..075f99ec31 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 @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier 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.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.VoiceFile import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage @@ -19,6 +20,7 @@ data class VoiceContent( ) : TextedMediaContent { override fun createResend( chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, disableNotification: Boolean, protectContent: Boolean, replyToMessageId: MessageId?, @@ -29,6 +31,7 @@ data class VoiceContent( media.fileId, textSources, media.duration, + messageThreadId, disableNotification, protectContent, replyToMessageId, 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 23a14e9dcf..b5cbaa55b8 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 @@ -7,4 +7,6 @@ import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate data class ChannelPostUpdate( override val updateId: UpdateIdentifier, override val data: Message -) : BaseSentMessageUpdate +) : BaseSentMessageUpdate { + override fun copy(newData: Message): BaseSentMessageUpdate = copy(updateId, newData) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MessageUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MessageUpdate.kt index 86d02a25c4..9585386627 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 @@ -7,4 +7,6 @@ import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate data class MessageUpdate( override val updateId: UpdateIdentifier, override val data: Message -) : BaseSentMessageUpdate +) : BaseSentMessageUpdate { + override fun copy(newData: Message) = copy(updateId, newData) +} 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 bc8493432f..65efc5e9eb 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,3 +1,7 @@ package dev.inmo.tgbotapi.types.update.abstracts -interface BaseSentMessageUpdate : BaseMessageUpdate +import dev.inmo.tgbotapi.types.message.abstracts.Message + +interface BaseSentMessageUpdate : BaseMessageUpdate { + fun copy(newData: Message): BaseSentMessageUpdate +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/ChannelPostMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/ChannelPostMediaGroupUpdate.kt deleted file mode 100644 index 85414d9489..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/ChannelPostMediaGroupUpdate.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.update.media_group - -import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate - -data class ChannelPostMediaGroupUpdate( - override val origins: List -) : SentMediaGroupUpdate { - override val updateId: UpdateIdentifier = origins.last().updateId - override val data: List> = origins.mapNotNull { it.data as? MediaGroupMessage } -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/EditChannelPostMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/EditChannelPostMediaGroupUpdate.kt deleted file mode 100644 index eaee526558..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/EditChannelPostMediaGroupUpdate.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.update.media_group - -import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.update.EditChannelPostUpdate - -data class EditChannelPostMediaGroupUpdate( - override val origin: EditChannelPostUpdate -) : EditMediaGroupUpdate { - override val updateId: UpdateIdentifier = origin.updateId - override val data: MediaGroupMessage = origin.data as MediaGroupMessage -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/EditMessageMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/EditMessageMediaGroupUpdate.kt deleted file mode 100644 index cf9dddbeb3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/EditMessageMediaGroupUpdate.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.update.media_group - -import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.update.EditMessageUpdate - -data class EditMessageMediaGroupUpdate( - override val origin: EditMessageUpdate -) : EditMediaGroupUpdate { - override val updateId: UpdateIdentifier = origin.updateId - override val data: MediaGroupMessage = origin.data as MediaGroupMessage -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/MediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/MediaGroupUpdate.kt deleted file mode 100644 index 7f9b13358b..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/MediaGroupUpdate.kt +++ /dev/null @@ -1,24 +0,0 @@ -package dev.inmo.tgbotapi.types.update.media_group - -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.update.abstracts.* - -/** - * By default there is no instances of objects which could be deserialized from raw updates. If you want to get objects - * with this type, you should use something like [dev.inmo.tgbotapi.extensions.api.SetWebhookKt.includeWebhookInRoute] - * - * @see dev.inmo.tgbotapi.extensions.api.SetWebhookKt.includeWebhookInRoute - * @see dev.inmo.tgbotapi.extensions.api.updates.UpdatesPollingKt.startGettingOfUpdates - */ -sealed interface MediaGroupUpdate : Update - -sealed interface SentMediaGroupUpdate: MediaGroupUpdate { - override val data: List> - val origins: List -} - -sealed interface EditMediaGroupUpdate : BaseEditMessageUpdate, MediaGroupUpdate { - override val data: MediaGroupMessage - val origin: BaseMessageUpdate -} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/MessageMediaGroupUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/MessageMediaGroupUpdate.kt deleted file mode 100644 index 329d75c8d3..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/media_group/MessageMediaGroupUpdate.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.inmo.tgbotapi.types.update.media_group - -import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate - -data class MessageMediaGroupUpdate( - override val origins: List -) : SentMediaGroupUpdate { - override val updateId: UpdateIdentifier = origins.last().updateId - override val data: List> = origins.mapNotNull { it.data as? MediaGroupMessage } -} 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 c3265bc419..2e9c700266 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 @@ -2,10 +2,11 @@ package dev.inmo.tgbotapi.updateshandlers import dev.inmo.micro_utils.coroutines.plus import dev.inmo.tgbotapi.types.ALL_UPDATES_LIST +import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage import dev.inmo.tgbotapi.types.update.* +import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.types.update.media_group.* import kotlinx.coroutines.channels.* import kotlinx.coroutines.flow.* @@ -13,16 +14,22 @@ interface FlowsUpdatesFilter : UpdatesFilter { override val allowedUpdates: List get() = ALL_UPDATES_LIST val allUpdatesFlow: Flow + @Deprecated("Since 4.0.0 is not actual", ReplaceWith("allUpdatesFlow")) val allUpdatesWithoutMediaGroupsGroupingFlow: Flow + get() = allUpdatesFlow val messagesFlow: Flow - val messageMediaGroupsFlow: Flow + val messageMediaGroupsFlow: Flow + get() = messagesFlow.filter { (it.data as? PossiblySentViaBotCommonMessage<*>) ?.mediaGroupId != null } val editedMessagesFlow: Flow - val editedMessageMediaGroupsFlow: Flow + val editedMessageMediaGroupsFlow: Flow + get() = editedMessagesFlow.filter { (it.data as? PossiblySentViaBotCommonMessage<*>) ?.mediaGroupId != null } val channelPostsFlow: Flow - val channelPostMediaGroupsFlow: Flow + val channelPostMediaGroupsFlow: Flow + get() = channelPostsFlow.filter { (it.data as? PossiblySentViaBotCommonMessage<*>) ?.mediaGroupId != null } val editedChannelPostsFlow: Flow - val editedChannelPostMediaGroupsFlow: Flow + val editedChannelPostMediaGroupsFlow: Flow + get() = editedChannelPostsFlow.filter { (it.data as? PossiblySentViaBotCommonMessage<*>) ?.mediaGroupId != null } val chosenInlineResultsFlow: Flow val inlineQueriesFlow: Flow val callbackQueriesFlow: Flow @@ -37,23 +44,10 @@ interface FlowsUpdatesFilter : UpdatesFilter { } abstract class AbstractFlowsUpdatesFilter : FlowsUpdatesFilter { - override val allUpdatesWithoutMediaGroupsGroupingFlow: Flow - get() = allUpdatesFlow.flatMapConcat { - when (it) { - is SentMediaGroupUpdate -> it.origins.asFlow() - is EditMediaGroupUpdate -> flowOf(it.origin) - else -> flowOf(it) - } - } - override val messagesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } - override val messageMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val editedMessagesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } - override val editedMessageMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val channelPostsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } - override val channelPostMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val editedChannelPostsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } - override val editedChannelPostMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val chosenInlineResultsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val inlineQueriesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } override val callbackQueriesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } @@ -92,14 +86,6 @@ class DefaultFlowsUpdatesFilter( it } } - @Suppress("MemberVisibilityCanBePrivate") - override val allUpdatesWithoutMediaGroupsGroupingFlow: Flow = allUpdatesFlow.flatMapConcat { - when (it) { - is SentMediaGroupUpdate -> it.origins.asFlow() - is EditMediaGroupUpdate -> flowOf(it.origin) - else -> flowOf(it) - } - } override val asUpdateReceiver: UpdateReceiver = additionalUpdatesSharedFlow::emit } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/UpdatesFilter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/UpdatesFilter.kt index 4704a4c9d5..cfb0dc2a26 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/UpdatesFilter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/UpdatesFilter.kt @@ -1,10 +1,6 @@ package dev.inmo.tgbotapi.updateshandlers -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.update.* -import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.types.update.media_group.* typealias UpdateReceiver = suspend (T) -> Unit @@ -12,111 +8,3 @@ interface UpdatesFilter { val asUpdateReceiver: UpdateReceiver val allowedUpdates: List } - -data class SimpleUpdatesFilter( - private val messageCallback: UpdateReceiver? = null, - private val messageMediaGroupCallback: UpdateReceiver? = null, - private val editedMessageCallback: UpdateReceiver? = null, - private val editedMessageMediaGroupCallback: UpdateReceiver? = null, - private val channelPostCallback: UpdateReceiver? = null, - private val channelPostMediaGroupCallback: UpdateReceiver? = null, - private val editedChannelPostCallback: UpdateReceiver? = null, - private val editedChannelPostMediaGroupCallback: UpdateReceiver? = null, - private val chosenInlineResultCallback: UpdateReceiver? = null, - private val inlineQueryCallback: UpdateReceiver? = null, - private val callbackQueryCallback: UpdateReceiver? = null, - private val shippingQueryCallback: UpdateReceiver? = null, - private val preCheckoutQueryCallback: UpdateReceiver? = null, - private val pollUpdateCallback: UpdateReceiver? = null, - private val pollAnswerUpdateCallback: UpdateReceiver? = null, - private val unknownUpdateTypeCallback: UpdateReceiver? = null -) : UpdatesFilter { - override val asUpdateReceiver: UpdateReceiver = this::invoke - override val allowedUpdates = listOfNotNull( - (messageCallback ?: messageMediaGroupCallback) ?.let { UPDATE_MESSAGE }, - (editedMessageCallback ?: editedMessageMediaGroupCallback) ?.let { UPDATE_EDITED_MESSAGE }, - (channelPostCallback ?: channelPostMediaGroupCallback) ?.let { UPDATE_CHANNEL_POST }, - (editedChannelPostCallback ?: editedChannelPostMediaGroupCallback) ?.let { UPDATE_EDITED_CHANNEL_POST }, - chosenInlineResultCallback ?.let { UPDATE_CHOSEN_INLINE_RESULT }, - inlineQueryCallback ?.let { UPDATE_INLINE_QUERY }, - callbackQueryCallback ?.let { UPDATE_CALLBACK_QUERY }, - shippingQueryCallback ?.let { UPDATE_SHIPPING_QUERY }, - preCheckoutQueryCallback ?.let { UPDATE_PRE_CHECKOUT_QUERY }, - pollUpdateCallback ?.let { UPDATE_POLL }, - pollAnswerUpdateCallback ?.let { UPDATE_POLL_ANSWER } - ) - - suspend fun invoke(update: Update) { - when (update) { - is MessageUpdate -> messageCallback ?.invoke(update) - is MessageMediaGroupUpdate -> messageMediaGroupCallback ?.also { receiver -> - receiver(update) - } ?: messageCallback ?.also { receiver -> - update.origins.mapNotNull { it as? MessageUpdate }.forEach { - receiver(it) - } - } - is EditMessageUpdate -> editedMessageCallback ?.invoke(update) - is EditMessageMediaGroupUpdate -> editedMessageMediaGroupCallback ?.also { receiver -> - receiver(update) - } ?: editedMessageCallback ?.also { receiver -> - receiver(update.origin) - } - is ChannelPostUpdate -> channelPostCallback ?.invoke(update) - is ChannelPostMediaGroupUpdate -> channelPostMediaGroupCallback ?.also { receiver -> - receiver(update) - } ?: channelPostCallback ?.also { receiver -> - update.origins.mapNotNull { it as? ChannelPostUpdate }.forEach { - receiver(it) - } - } - is EditChannelPostUpdate -> editedChannelPostCallback ?.invoke(update) - is EditChannelPostMediaGroupUpdate -> editedChannelPostMediaGroupCallback ?.also { receiver -> - receiver(update) - } ?: editedChannelPostCallback ?.also { receiver -> - receiver(update.origin) - } - is ChosenInlineResultUpdate -> chosenInlineResultCallback ?.invoke(update) - is InlineQueryUpdate -> inlineQueryCallback ?.invoke(update) - is CallbackQueryUpdate -> callbackQueryCallback ?.invoke(update) - is ShippingQueryUpdate -> shippingQueryCallback ?.invoke(update) - is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update) - is PollUpdate -> pollUpdateCallback ?.invoke(update) - is PollAnswerUpdate -> pollAnswerUpdateCallback ?.invoke(update) - is UnknownUpdate -> unknownUpdateTypeCallback ?.invoke(update) - } - } -} - -fun createSimpleUpdateFilter( - messageCallback: UpdateReceiver? = null, - mediaGroupCallback: UpdateReceiver? = null, - editedMessageCallback: UpdateReceiver? = null, - channelPostCallback: UpdateReceiver? = null, - editedChannelPostCallback: UpdateReceiver? = null, - chosenInlineResultCallback: UpdateReceiver? = null, - inlineQueryCallback: UpdateReceiver? = null, - callbackQueryCallback: UpdateReceiver? = null, - shippingQueryCallback: UpdateReceiver? = null, - preCheckoutQueryCallback: UpdateReceiver? = null, - pollCallback: UpdateReceiver? = null, - pollAnswerCallback: UpdateReceiver? = null, - unknownCallback: UpdateReceiver? = null -): UpdatesFilter = SimpleUpdatesFilter( - messageCallback = messageCallback, - messageMediaGroupCallback = mediaGroupCallback, - editedMessageCallback = editedMessageCallback, - editedMessageMediaGroupCallback = mediaGroupCallback, - channelPostCallback = channelPostCallback, - channelPostMediaGroupCallback = mediaGroupCallback, - editedChannelPostCallback = editedChannelPostCallback, - editedChannelPostMediaGroupCallback = mediaGroupCallback, - chosenInlineResultCallback = chosenInlineResultCallback, - inlineQueryCallback = inlineQueryCallback, - callbackQueryCallback = callbackQueryCallback, - shippingQueryCallback = shippingQueryCallback, - preCheckoutQueryCallback = preCheckoutQueryCallback, - pollUpdateCallback = pollCallback, - pollAnswerUpdateCallback = pollAnswerCallback, - unknownUpdateTypeCallback = unknownCallback -) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/RGBColor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/RGBColor.kt new file mode 100644 index 0000000000..4c9c0d4caf --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/RGBColor.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.utils + +import kotlinx.serialization.Serializable +import kotlin.jvm.JvmInline + +@Serializable +@JvmInline +value class RGBColor( + val int: Int +) 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 new file mode 100644 index 0000000000..dcf3b4d3eb --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt @@ -0,0 +1,170 @@ +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 +import dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl +import dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl +import dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl +import dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl +import dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl +import dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl +import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage +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 +import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.UnconnectedFromChannelGroupContentMessage +import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent +import dev.inmo.tgbotapi.types.message.content.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent +import dev.inmo.tgbotapi.utils.RiskFeature + +@RiskFeature("This API is experimental and can be changed without any notice, use with caution") +fun List>.asMediaGroupMessage(): PossiblySentViaBotCommonMessage> { + val sourceMessage = first() + val content = MediaGroupContent( + map { MediaGroupCollectionContent.PartWrapper(it.messageId, it.content, it) }, + sourceMessage.mediaGroupId ?: error("Can't create media group message with the first message without media group id") + ) + return when (sourceMessage) { + is ChannelContentMessage -> ChannelContentMessageImpl( + sourceMessage.messageId, + sourceMessage.chat, + content, + sourceMessage.date, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.forwardInfo, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + sourceMessage.senderBot, + sourceMessage.authorSignature, + sourceMessage.mediaGroupId + ) + is PrivateContentMessage -> PrivateContentMessageImpl( + sourceMessage.messageId, + sourceMessage.user, + sourceMessage.chat, + content, + sourceMessage.date, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.forwardInfo, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + sourceMessage.senderBot, + sourceMessage.mediaGroupId + ) + is AnonymousGroupContentMessage -> AnonymousGroupContentMessageImpl( + sourceMessage.chat, + sourceMessage.messageId, + sourceMessage.date, + sourceMessage.forwardInfo, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + content, + sourceMessage.senderBot, + sourceMessage.authorSignature, + sourceMessage.mediaGroupId + ) + is CommonGroupContentMessage -> CommonGroupContentMessageImpl( + sourceMessage.chat, + sourceMessage.messageId, + sourceMessage.user, + sourceMessage.date, + sourceMessage.forwardInfo, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + content, + sourceMessage.senderBot, + sourceMessage.mediaGroupId + ) + is ConnectedFromChannelGroupContentMessage -> ConnectedFromChannelGroupContentMessageImpl( + sourceMessage.chat, + sourceMessage.channel, + sourceMessage.messageId, + sourceMessage.date, + sourceMessage.forwardInfo, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + content, + sourceMessage.senderBot, + sourceMessage.authorSignature, + sourceMessage.mediaGroupId + ) + is UnconnectedFromChannelGroupContentMessage -> UnconnectedFromChannelGroupContentMessageImpl( + sourceMessage.chat, + sourceMessage.channel, + sourceMessage.messageId, + sourceMessage.date, + sourceMessage.forwardInfo, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + content, + sourceMessage.senderBot, + sourceMessage.authorSignature, + sourceMessage.mediaGroupId + ) + is AnonymousForumContentMessage -> AnonymousForumContentMessageImpl( + sourceMessage.chat, + sourceMessage.messageId, + sourceMessage.threadId, + sourceMessage.date, + sourceMessage.forwardInfo, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + content, + sourceMessage.senderBot, + sourceMessage.authorSignature, + sourceMessage.mediaGroupId + ) + is CommonForumContentMessage -> CommonForumContentMessageImpl( + sourceMessage.chat, + sourceMessage.messageId, + sourceMessage.threadId, + sourceMessage.user, + sourceMessage.date, + sourceMessage.forwardInfo, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + content, + sourceMessage.senderBot, + sourceMessage.mediaGroupId + ) + is FromChannelForumContentMessage -> FromChannelForumContentMessageImpl( + sourceMessage.chat, + sourceMessage.channel, + sourceMessage.messageId, + sourceMessage.threadId, + sourceMessage.date, + sourceMessage.forwardInfo, + sourceMessage.editDate, + sourceMessage.hasProtectedContent, + sourceMessage.replyTo, + sourceMessage.replyMarkup, + content, + sourceMessage.senderBot, + sourceMessage.authorSignature, + sourceMessage.mediaGroupId + ) + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt new file mode 100644 index 0000000000..2369d24ba4 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/OptionalThreadId.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.utils.extensions + +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage + +val Message.threadIdOrNull + get() = (this as? PossiblyTopicMessage) ?.threadId diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 0a9cfa3e83..27b1e6f8fa 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -34,7 +34,6 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMember import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.message.textsources.* @@ -47,7 +46,6 @@ import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.queries.callback.* import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.abstracts.* -import dev.inmo.tgbotapi.types.update.media_group.* import dev.inmo.tgbotapi.utils.PreviewFeature @PreviewFeature @@ -1037,18 +1035,6 @@ inline fun Message.asChannelEventMessage(): ChannelEventMessage? = inline fun Message.requireChannelEventMessage(): ChannelEventMessage = this as ChannelEventMessage -@PreviewFeature -inline fun Message.whenChannelMediaGroupMessage(block: (ChannelMediaGroupMessage) -> T) = - asChannelMediaGroupMessage()?.let(block) - -@PreviewFeature -inline fun Message.asChannelMediaGroupMessage(): ChannelMediaGroupMessage? = - this as? ChannelMediaGroupMessage - -@PreviewFeature -inline fun Message.requireChannelMediaGroupMessage(): ChannelMediaGroupMessage = - this as ChannelMediaGroupMessage - @PreviewFeature inline fun Message.whenCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T) = asCommonGroupEventMessage()?.let(block) @@ -1061,18 +1047,6 @@ inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage = this as CommonGroupEventMessage -@PreviewFeature -inline fun Message.whenCommonMediaGroupMessage(block: (CommonMediaGroupMessage) -> T) = - asCommonMediaGroupMessage()?.let(block) - -@PreviewFeature -inline fun Message.asCommonMediaGroupMessage(): CommonMediaGroupMessage? = - this as? CommonMediaGroupMessage - -@PreviewFeature -inline fun Message.requireCommonMediaGroupMessage(): CommonMediaGroupMessage = - this as CommonMediaGroupMessage - @PreviewFeature inline fun Message.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T) = asCommonSupergroupEventMessage()?.let(block) @@ -1220,16 +1194,16 @@ inline fun Message.requireGroupContentMessage(): GroupContentMessage @PreviewFeature -inline fun Message.whenMediaGroupMessage(block: (MediaGroupMessage) -> T) = +inline fun Message.whenMediaGroupMessage(block: (MediaGroupMessage) -> T) = asMediaGroupMessage()?.let(block) @PreviewFeature -inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = - this as? MediaGroupMessage +inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = + this as? MediaGroupMessage @PreviewFeature -inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = - this as MediaGroupMessage +inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = + this as MediaGroupMessage @PreviewFeature inline fun Message.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) = @@ -2219,79 +2193,6 @@ inline fun Update.asInlineQueryUpdate(): InlineQueryUpdate? = this as? InlineQue @PreviewFeature inline fun Update.requireInlineQueryUpdate(): InlineQueryUpdate = this as InlineQueryUpdate -@PreviewFeature -inline fun Update.whenChannelPostMediaGroupUpdate(block: (ChannelPostMediaGroupUpdate) -> T) = - asChannelPostMediaGroupUpdate()?.let(block) - -@PreviewFeature -inline fun Update.asChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate? = this as? ChannelPostMediaGroupUpdate - -@PreviewFeature -inline fun Update.requireChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate = - this as ChannelPostMediaGroupUpdate - -@PreviewFeature -inline fun Update.whenEditChannelPostMediaGroupUpdate(block: (EditChannelPostMediaGroupUpdate) -> T) = - asEditChannelPostMediaGroupUpdate()?.let(block) - -@PreviewFeature -inline fun Update.asEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate? = - this as? EditChannelPostMediaGroupUpdate - -@PreviewFeature -inline fun Update.requireEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate = - this as EditChannelPostMediaGroupUpdate - -@PreviewFeature -inline fun Update.whenEditMediaGroupUpdate(block: (EditMediaGroupUpdate) -> T) = - asEditMediaGroupUpdate()?.let(block) - -@PreviewFeature -inline fun Update.asEditMediaGroupUpdate(): EditMediaGroupUpdate? = this as? EditMediaGroupUpdate - -@PreviewFeature -inline fun Update.requireEditMediaGroupUpdate(): EditMediaGroupUpdate = this as EditMediaGroupUpdate - -@PreviewFeature -inline fun Update.whenEditMessageMediaGroupUpdate(block: (EditMessageMediaGroupUpdate) -> T) = - asEditMessageMediaGroupUpdate()?.let(block) - -@PreviewFeature -inline fun Update.asEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate? = this as? EditMessageMediaGroupUpdate - -@PreviewFeature -inline fun Update.requireEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate = - this as EditMessageMediaGroupUpdate - -@PreviewFeature -inline fun Update.whenMediaGroupUpdate(block: (MediaGroupUpdate) -> T) = asMediaGroupUpdate()?.let(block) - -@PreviewFeature -inline fun Update.asMediaGroupUpdate(): MediaGroupUpdate? = this as? MediaGroupUpdate - -@PreviewFeature -inline fun Update.requireMediaGroupUpdate(): MediaGroupUpdate = this as MediaGroupUpdate - -@PreviewFeature -inline fun Update.whenMessageMediaGroupUpdate(block: (MessageMediaGroupUpdate) -> T) = - asMessageMediaGroupUpdate()?.let(block) - -@PreviewFeature -inline fun Update.asMessageMediaGroupUpdate(): MessageMediaGroupUpdate? = this as? MessageMediaGroupUpdate - -@PreviewFeature -inline fun Update.requireMessageMediaGroupUpdate(): MessageMediaGroupUpdate = this as MessageMediaGroupUpdate - -@PreviewFeature -inline fun Update.whenSentMediaGroupUpdate(block: (SentMediaGroupUpdate) -> T) = - asSentMediaGroupUpdate()?.let(block) - -@PreviewFeature -inline fun Update.asSentMediaGroupUpdate(): SentMediaGroupUpdate? = this as? SentMediaGroupUpdate - -@PreviewFeature -inline fun Update.requireSentMediaGroupUpdate(): SentMediaGroupUpdate = this as SentMediaGroupUpdate - @PreviewFeature inline fun Update.whenMessageUpdate(block: (MessageUpdate) -> T) = asMessageUpdate()?.let(block) @@ -2836,26 +2737,26 @@ inline fun ResendableContent.asVenueContent(): VenueContent? = this as? VenueCon inline fun ResendableContent.requireVenueContent(): VenueContent = this as VenueContent @PreviewFeature -inline fun ResendableContent.whenAudioMediaGroupContent(block: (AudioMediaGroupContent) -> T) = +inline fun ResendableContent.whenAudioMediaGroupContent(block: (AudioMediaGroupPartContent) -> T) = asAudioMediaGroupContent()?.let(block) @PreviewFeature -inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupContent? = this as? AudioMediaGroupContent +inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupPartContent? = this as? AudioMediaGroupPartContent @PreviewFeature -inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupContent = this as AudioMediaGroupContent +inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupPartContent = this as AudioMediaGroupPartContent @PreviewFeature -inline fun ResendableContent.whenDocumentMediaGroupContent(block: (DocumentMediaGroupContent) -> T) = +inline fun ResendableContent.whenDocumentMediaGroupContent(block: (DocumentMediaGroupPartContent) -> T) = asDocumentMediaGroupContent()?.let(block) @PreviewFeature -inline fun ResendableContent.asDocumentMediaGroupContent(): DocumentMediaGroupContent? = - this as? DocumentMediaGroupContent +inline fun ResendableContent.asDocumentMediaGroupContent(): DocumentMediaGroupPartContent? = + this as? DocumentMediaGroupPartContent @PreviewFeature -inline fun ResendableContent.requireDocumentMediaGroupContent(): DocumentMediaGroupContent = - this as DocumentMediaGroupContent +inline fun ResendableContent.requireDocumentMediaGroupContent(): DocumentMediaGroupPartContent = + this as DocumentMediaGroupPartContent @PreviewFeature inline fun ResendableContent.whenMediaCollectionContent(block: (MediaCollectionContent) -> T) = @@ -2891,14 +2792,14 @@ inline fun ResendableContent.asMediaContent(): MediaContent? = this as? MediaCon inline fun ResendableContent.requireMediaContent(): MediaContent = this as MediaContent @PreviewFeature -inline fun ResendableContent.whenMediaGroupContent(block: (MediaGroupContent) -> T) = +inline fun ResendableContent.whenMediaGroupContent(block: (MediaGroupPartContent) -> T) = asMediaGroupContent()?.let(block) @PreviewFeature -inline fun ResendableContent.asMediaGroupContent(): MediaGroupContent? = this as? MediaGroupContent +inline fun ResendableContent.asMediaGroupContent(): MediaGroupPartContent? = this as? MediaGroupPartContent @PreviewFeature -inline fun ResendableContent.requireMediaGroupContent(): MediaGroupContent = this as MediaGroupContent +inline fun ResendableContent.requireMediaGroupContent(): MediaGroupPartContent = this as MediaGroupPartContent @PreviewFeature inline fun ResendableContent.whenMessageContent(block: (MessageContent) -> T) = asMessageContent()?.let(block) @@ -2910,14 +2811,14 @@ inline fun ResendableContent.asMessageContent(): MessageContent? = this as? Mess inline fun ResendableContent.requireMessageContent(): MessageContent = this as MessageContent @PreviewFeature -inline fun ResendableContent.whenVisualMediaGroupContent(block: (VisualMediaGroupContent) -> T) = +inline fun ResendableContent.whenVisualMediaGroupContent(block: (VisualMediaGroupPartContent) -> T) = asVisualMediaGroupContent()?.let(block) @PreviewFeature -inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupContent? = this as? VisualMediaGroupContent +inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupPartContent? = this as? VisualMediaGroupPartContent @PreviewFeature -inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupContent = this as VisualMediaGroupContent +inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupPartContent = this as VisualMediaGroupPartContent @PreviewFeature inline fun ResendableContent.whenAnimationContent(block: (AnimationContent) -> T) = asAnimationContent()?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index 54668e5609..2f2929d78d 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 @@ -124,6 +124,9 @@ import dev.inmo.tgbotapi.types.chat.ExtendedBot import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat import dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl 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.ExtendedForumChatImpl import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat import dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat @@ -131,6 +134,8 @@ import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl +import dev.inmo.tgbotapi.types.chat.ForumChat +import dev.inmo.tgbotapi.types.chat.ForumChatImpl import dev.inmo.tgbotapi.types.chat.GroupChat import dev.inmo.tgbotapi.types.chat.GroupChatImpl import dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat @@ -212,10 +217,10 @@ import dev.inmo.tgbotapi.types.media.TelegramMediaVideo import dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia import dev.inmo.tgbotapi.types.media.TitledTelegramMedia import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia +import dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl import dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl import dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl import dev.inmo.tgbotapi.types.message.ChannelEventMessage -import dev.inmo.tgbotapi.types.message.ChannelMediaGroupMessage import dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated import dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto import dev.inmo.tgbotapi.types.message.ChatEvents.GroupChatCreated @@ -233,42 +238,52 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.WebAppData import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PrivateEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatStarted +import dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl import dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl import dev.inmo.tgbotapi.types.message.CommonGroupEventMessage -import dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage import dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl import dev.inmo.tgbotapi.types.message.ForwardInfo +import dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl import dev.inmo.tgbotapi.types.message.PrivateEventMessage import dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl +import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage +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.ContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.ForumContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage 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.MediaGroupMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage import dev.inmo.tgbotapi.types.message.abstracts.PublicContentMessage import dev.inmo.tgbotapi.types.message.abstracts.SignedMessage @@ -277,18 +292,20 @@ import dev.inmo.tgbotapi.types.message.abstracts.UnconnectedFromChannelGroupCont import dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType import dev.inmo.tgbotapi.types.message.content.AnimationContent import dev.inmo.tgbotapi.types.message.content.AudioContent -import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.ContactContent import dev.inmo.tgbotapi.types.message.content.DiceContent import dev.inmo.tgbotapi.types.message.content.DocumentContent -import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent +import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.GameContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.message.content.LiveLocationContent import dev.inmo.tgbotapi.types.message.content.LocationContent import dev.inmo.tgbotapi.types.message.content.MediaCollectionContent import dev.inmo.tgbotapi.types.message.content.MediaContent +import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent import dev.inmo.tgbotapi.types.message.content.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.PhotoContent import dev.inmo.tgbotapi.types.message.content.PollContent @@ -300,7 +317,7 @@ import dev.inmo.tgbotapi.types.message.content.TextedMediaContent import dev.inmo.tgbotapi.types.message.content.VenueContent import dev.inmo.tgbotapi.types.message.content.VideoContent import dev.inmo.tgbotapi.types.message.content.VideoNoteContent -import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent +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.BoldTextSource @@ -425,13 +442,6 @@ import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.types.update.media_group.ChannelPostMediaGroupUpdate -import dev.inmo.tgbotapi.types.update.media_group.EditChannelPostMediaGroupUpdate -import dev.inmo.tgbotapi.types.update.media_group.EditMediaGroupUpdate -import dev.inmo.tgbotapi.types.update.media_group.EditMessageMediaGroupUpdate -import dev.inmo.tgbotapi.types.update.media_group.MediaGroupUpdate -import dev.inmo.tgbotapi.types.update.media_group.MessageMediaGroupUpdate -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import kotlin.Suppress public inline fun CommonSendInvoiceData.createInvoiceLinkOrNull(): CreateInvoiceLink? = this as? @@ -725,18 +735,6 @@ public inline fun WithUser.ifCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T): T? = commonGroupEventMessageOrNull() ?.let(block) -public inline fun WithUser.commonMediaGroupMessageOrNull(): - CommonMediaGroupMessage? = this as? - dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage - -public inline fun WithUser.commonMediaGroupMessageOrThrow(): - CommonMediaGroupMessage = this as - dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage - -public inline fun - WithUser.ifCommonMediaGroupMessage(block: (CommonMediaGroupMessage) -> T): T? - = commonMediaGroupMessageOrNull() ?.let(block) - public inline fun WithUser.commonSupergroupEventMessageOrNull(): CommonSupergroupEventMessage? = this as? dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage @@ -761,6 +759,18 @@ public inline fun WithUser.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl) -> T): T? = commonGroupContentMessageImplOrNull() ?.let(block) +public inline fun WithUser.commonForumContentMessageImplOrNull(): + CommonForumContentMessageImpl? = this as? + dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl + +public inline fun WithUser.commonForumContentMessageImplOrThrow(): + CommonForumContentMessageImpl = this as + dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl + +public inline fun + WithUser.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl) -> T): + T? = commonForumContentMessageImplOrNull() ?.let(block) + public inline fun WithUser.passportMessageOrNull(): PassportMessage? = this as? dev.inmo.tgbotapi.types.message.PassportMessage @@ -812,6 +822,18 @@ public inline fun WithUser.ifCommonGroupContentMessage(block: (CommonGroupContentMessage) -> T): T? = commonGroupContentMessageOrNull() ?.let(block) +public inline fun WithUser.commonForumContentMessageOrNull(): + CommonForumContentMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage + +public inline fun WithUser.commonForumContentMessageOrThrow(): + CommonForumContentMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage + +public inline fun + WithUser.ifCommonForumContentMessage(block: (CommonForumContentMessage) -> T): + T? = commonForumContentMessageOrNull() ?.let(block) + public inline fun WithUser.privateContentMessageOrNull(): PrivateContentMessage? = this as? dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage @@ -1848,23 +1870,15 @@ public inline fun KeyboardMarkup.replyKeyboardRemoveOrThrow(): ReplyKeyboardRemo public inline fun KeyboardMarkup.ifReplyKeyboardRemove(block: (ReplyKeyboardRemove) -> T): T? = replyKeyboardRemoveOrNull() ?.let(block) -public inline fun Chat.channelChatOrNull(): ChannelChat? = this as? - dev.inmo.tgbotapi.types.chat.ChannelChat +public inline fun Chat.usernameChatOrNull(): UsernameChat? = this as? + dev.inmo.tgbotapi.types.chat.UsernameChat -public inline fun Chat.channelChatOrThrow(): ChannelChat = this as - dev.inmo.tgbotapi.types.chat.ChannelChat +public inline fun Chat.usernameChatOrThrow(): UsernameChat = this as + dev.inmo.tgbotapi.types.chat.UsernameChat -public inline fun Chat.ifChannelChat(block: (ChannelChat) -> T): T? = channelChatOrNull() +public inline fun Chat.ifUsernameChat(block: (UsernameChat) -> T): T? = usernameChatOrNull() ?.let(block) -public inline fun Chat.groupChatOrNull(): GroupChat? = this as? - dev.inmo.tgbotapi.types.chat.GroupChat - -public inline fun Chat.groupChatOrThrow(): GroupChat = this as - dev.inmo.tgbotapi.types.chat.GroupChat - -public inline fun Chat.ifGroupChat(block: (GroupChat) -> T): T? = groupChatOrNull() ?.let(block) - public inline fun Chat.privateChatOrNull(): PrivateChat? = this as? dev.inmo.tgbotapi.types.chat.PrivateChat @@ -1883,15 +1897,6 @@ public inline fun Chat.publicChatOrThrow(): PublicChat = this as public inline fun Chat.ifPublicChat(block: (PublicChat) -> T): T? = publicChatOrNull() ?.let(block) -public inline fun Chat.supergroupChatOrNull(): SupergroupChat? = this as? - dev.inmo.tgbotapi.types.chat.SupergroupChat - -public inline fun Chat.supergroupChatOrThrow(): SupergroupChat = this as - dev.inmo.tgbotapi.types.chat.SupergroupChat - -public inline fun Chat.ifSupergroupChat(block: (SupergroupChat) -> T): T? = - supergroupChatOrNull() ?.let(block) - public inline fun Chat.superPublicChatOrNull(): SuperPublicChat? = this as? dev.inmo.tgbotapi.types.chat.SuperPublicChat @@ -1901,15 +1906,40 @@ public inline fun Chat.superPublicChatOrThrow(): SuperPublicChat = this as public inline fun Chat.ifSuperPublicChat(block: (SuperPublicChat) -> T): T? = superPublicChatOrNull() ?.let(block) -public inline fun Chat.usernameChatOrNull(): UsernameChat? = this as? - dev.inmo.tgbotapi.types.chat.UsernameChat +public inline fun Chat.channelChatOrNull(): ChannelChat? = this as? + dev.inmo.tgbotapi.types.chat.ChannelChat -public inline fun Chat.usernameChatOrThrow(): UsernameChat = this as - dev.inmo.tgbotapi.types.chat.UsernameChat +public inline fun Chat.channelChatOrThrow(): ChannelChat = this as + dev.inmo.tgbotapi.types.chat.ChannelChat -public inline fun Chat.ifUsernameChat(block: (UsernameChat) -> T): T? = usernameChatOrNull() +public inline fun Chat.ifChannelChat(block: (ChannelChat) -> T): T? = channelChatOrNull() ?.let(block) +public inline fun Chat.groupChatOrNull(): GroupChat? = this as? + dev.inmo.tgbotapi.types.chat.GroupChat + +public inline fun Chat.groupChatOrThrow(): GroupChat = this as + dev.inmo.tgbotapi.types.chat.GroupChat + +public inline fun Chat.ifGroupChat(block: (GroupChat) -> T): T? = groupChatOrNull() ?.let(block) + +public inline fun Chat.supergroupChatOrNull(): SupergroupChat? = this as? + dev.inmo.tgbotapi.types.chat.SupergroupChat + +public inline fun Chat.supergroupChatOrThrow(): SupergroupChat = this as + dev.inmo.tgbotapi.types.chat.SupergroupChat + +public inline fun Chat.ifSupergroupChat(block: (SupergroupChat) -> T): T? = + supergroupChatOrNull() ?.let(block) + +public inline fun Chat.forumChatOrNull(): ForumChat? = this as? + dev.inmo.tgbotapi.types.chat.ForumChat + +public inline fun Chat.forumChatOrThrow(): ForumChat = this as + dev.inmo.tgbotapi.types.chat.ForumChat + +public inline fun Chat.ifForumChat(block: (ForumChat) -> T): T? = forumChatOrNull() ?.let(block) + public inline fun Chat.possiblyPremiumChatOrNull(): PossiblyPremiumChat? = this as? dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat @@ -1965,6 +1995,15 @@ public inline fun Chat.extendedSupergroupChatImplOrThrow(): ExtendedSupergroupCh public inline fun Chat.ifExtendedSupergroupChatImpl(block: (ExtendedSupergroupChatImpl) -> T): T? = extendedSupergroupChatImplOrNull() ?.let(block) +public inline fun Chat.extendedForumChatImplOrNull(): ExtendedForumChatImpl? = this as? + dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl + +public inline fun Chat.extendedForumChatImplOrThrow(): ExtendedForumChatImpl = this as + dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl + +public inline fun Chat.ifExtendedForumChatImpl(block: (ExtendedForumChatImpl) -> T): T? = + extendedForumChatImplOrNull() ?.let(block) + public inline fun Chat.extendedBotOrNull(): ExtendedBot? = this as? dev.inmo.tgbotapi.types.chat.ExtendedBot @@ -2028,6 +2067,15 @@ public inline fun Chat.extendedSupergroupChatOrThrow(): ExtendedSupergroupChat = public inline fun Chat.ifExtendedSupergroupChat(block: (ExtendedSupergroupChat) -> T): T? = extendedSupergroupChatOrNull() ?.let(block) +public inline fun Chat.extendedForumChatOrNull(): ExtendedForumChat? = this as? + dev.inmo.tgbotapi.types.chat.ExtendedForumChat + +public inline fun Chat.extendedForumChatOrThrow(): ExtendedForumChat = this as + dev.inmo.tgbotapi.types.chat.ExtendedForumChat + +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 @@ -2037,6 +2085,15 @@ public inline fun Chat.extendedChatOrThrow(): ExtendedChat = this as 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 + +public inline fun Chat.extendedChatWithUsernameOrThrow(): ExtendedChatWithUsername = this as + dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername + +public inline fun Chat.ifExtendedChatWithUsername(block: (ExtendedChatWithUsername) -> T): T? = + extendedChatWithUsernameOrNull() ?.let(block) + public inline fun Chat.groupChatImplOrNull(): GroupChatImpl? = this as? dev.inmo.tgbotapi.types.chat.GroupChatImpl @@ -2064,6 +2121,15 @@ public inline fun Chat.supergroupChatImplOrThrow(): SupergroupChatImpl = this as public inline fun Chat.ifSupergroupChatImpl(block: (SupergroupChatImpl) -> T): T? = supergroupChatImplOrNull() ?.let(block) +public inline fun Chat.forumChatImplOrNull(): ForumChatImpl? = this as? + dev.inmo.tgbotapi.types.chat.ForumChatImpl + +public inline fun Chat.forumChatImplOrThrow(): ForumChatImpl = this as + dev.inmo.tgbotapi.types.chat.ForumChatImpl + +public inline fun Chat.ifForumChatImpl(block: (ForumChatImpl) -> T): T? = forumChatImplOrNull() + ?.let(block) + public inline fun Chat.channelChatImplOrNull(): ChannelChatImpl? = this as? dev.inmo.tgbotapi.types.chat.ChannelChatImpl @@ -2746,6 +2812,15 @@ public inline fun ChatEvent.commonEventOrThrow(): CommonEvent = this as public inline fun ChatEvent.ifCommonEvent(block: (CommonEvent) -> T): T? = commonEventOrNull() ?.let(block) +public inline fun ChatEvent.forumEventOrNull(): ForumEvent? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent + +public inline fun ChatEvent.forumEventOrThrow(): ForumEvent = this as + dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent + +public inline fun ChatEvent.ifForumEvent(block: (ForumEvent) -> T): T? = forumEventOrNull() + ?.let(block) + public inline fun ChatEvent.groupEventOrNull(): GroupEvent? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent @@ -2791,6 +2866,33 @@ public inline fun ChatEvent.videoChatEventOrThrow(): VideoChatEvent = this as public inline fun ChatEvent.ifVideoChatEvent(block: (VideoChatEvent) -> T): T? = videoChatEventOrNull() ?.let(block) +public inline fun ChatEvent.forumTopicClosedOrNull(): ForumTopicClosed? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed + +public inline fun ChatEvent.forumTopicClosedOrThrow(): ForumTopicClosed = this as + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed + +public inline fun ChatEvent.ifForumTopicClosed(block: (ForumTopicClosed) -> T): T? = + forumTopicClosedOrNull() ?.let(block) + +public inline fun ChatEvent.forumTopicCreatedOrNull(): ForumTopicCreated? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated + +public inline fun ChatEvent.forumTopicCreatedOrThrow(): ForumTopicCreated = this as + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated + +public inline fun ChatEvent.ifForumTopicCreated(block: (ForumTopicCreated) -> T): T? = + forumTopicCreatedOrNull() ?.let(block) + +public inline fun ChatEvent.forumTopicReopenedOrNull(): ForumTopicReopened? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened + +public inline fun ChatEvent.forumTopicReopenedOrThrow(): ForumTopicReopened = this as + dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened + +public inline fun ChatEvent.ifForumTopicReopened(block: (ForumTopicReopened) -> T): T? = + forumTopicReopenedOrNull() ?.let(block) + public inline fun ChatEvent.videoChatEndedOrNull(): VideoChatEnded? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded @@ -2915,18 +3017,6 @@ public inline fun Message.ifChannelEventMessage(block: (ChannelEventMessage) -> T): T? = channelEventMessageOrNull() ?.let(block) -public inline fun Message.channelMediaGroupMessageOrNull(): - ChannelMediaGroupMessage? = this as? - dev.inmo.tgbotapi.types.message.ChannelMediaGroupMessage - -public inline fun Message.channelMediaGroupMessageOrThrow(): - ChannelMediaGroupMessage = this as - dev.inmo.tgbotapi.types.message.ChannelMediaGroupMessage - -public inline fun - Message.ifChannelMediaGroupMessage(block: (ChannelMediaGroupMessage) -> T): - T? = channelMediaGroupMessageOrNull() ?.let(block) - public inline fun Message.commonGroupEventMessageOrNull(): CommonGroupEventMessage? = this as? dev.inmo.tgbotapi.types.message.CommonGroupEventMessage @@ -2939,18 +3029,6 @@ public inline fun Message.ifCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T): T? = commonGroupEventMessageOrNull() ?.let(block) -public inline fun Message.commonMediaGroupMessageOrNull(): - CommonMediaGroupMessage? = this as? - dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage - -public inline fun Message.commonMediaGroupMessageOrThrow(): - CommonMediaGroupMessage = this as - dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage - -public inline fun - Message.ifCommonMediaGroupMessage(block: (CommonMediaGroupMessage) -> T): T? - = commonMediaGroupMessageOrNull() ?.let(block) - public inline fun Message.commonSupergroupEventMessageOrNull(): CommonSupergroupEventMessage? = this as? dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage @@ -3011,6 +3089,42 @@ public inline fun Message.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl) -> T): T? = commonGroupContentMessageImplOrNull() ?.let(block) +public inline fun Message.fromChannelForumContentMessageImplOrNull(): + FromChannelForumContentMessageImpl? = this as? + dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl + +public inline fun Message.fromChannelForumContentMessageImplOrThrow(): + FromChannelForumContentMessageImpl = this as + dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl + +public inline fun + Message.ifFromChannelForumContentMessageImpl(block: (FromChannelForumContentMessageImpl) -> T): + T? = fromChannelForumContentMessageImplOrNull() ?.let(block) + +public inline fun Message.anonymousForumContentMessageImplOrNull(): + AnonymousForumContentMessageImpl? = this as? + dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl + +public inline fun Message.anonymousForumContentMessageImplOrThrow(): + AnonymousForumContentMessageImpl = this as + dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl + +public inline fun + Message.ifAnonymousForumContentMessageImpl(block: (AnonymousForumContentMessageImpl) -> T): + T? = anonymousForumContentMessageImplOrNull() ?.let(block) + +public inline fun Message.commonForumContentMessageImplOrNull(): + CommonForumContentMessageImpl? = this as? + dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl + +public inline fun Message.commonForumContentMessageImplOrThrow(): + CommonForumContentMessageImpl = this as + dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl + +public inline fun + Message.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl) -> T): + T? = commonForumContentMessageImplOrNull() ?.let(block) + public inline fun Message.passportMessageOrNull(): PassportMessage? = this as? dev.inmo.tgbotapi.types.message.PassportMessage @@ -3111,6 +3225,18 @@ public inline fun Message.ifGroupContentMessage(block: (GroupContentMessage) -> T): T? = groupContentMessageOrNull() ?.let(block) +public inline fun Message.forumContentMessageOrNull(): ForumContentMessage? = this + as? + dev.inmo.tgbotapi.types.message.abstracts.ForumContentMessage + +public inline fun Message.forumContentMessageOrThrow(): ForumContentMessage = this + as + dev.inmo.tgbotapi.types.message.abstracts.ForumContentMessage + +public inline fun + Message.ifForumContentMessage(block: (ForumContentMessage) -> T): T? = + forumContentMessageOrNull() ?.let(block) + public inline fun Message.fromChannelGroupContentMessageOrNull(): FromChannelGroupContentMessage? = this as? dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupContentMessage @@ -3171,16 +3297,41 @@ public inline fun Message.ifCommonGroupContentMessage(block: (CommonGroupContentMessage) -> T): T? = commonGroupContentMessageOrNull() ?.let(block) -public inline fun Message.mediaGroupMessageOrNull(): MediaGroupMessage? = this - as? - dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +public inline fun Message.fromChannelForumContentMessageOrNull(): + FromChannelForumContentMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage -public inline fun Message.mediaGroupMessageOrThrow(): MediaGroupMessage = this as - dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +public inline fun Message.fromChannelForumContentMessageOrThrow(): + FromChannelForumContentMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.FromChannelForumContentMessage public inline fun - Message.ifMediaGroupMessage(block: (MediaGroupMessage) -> T): T? = - mediaGroupMessageOrNull() ?.let(block) + Message.ifFromChannelForumContentMessage(block: (FromChannelForumContentMessage) -> T): + T? = fromChannelForumContentMessageOrNull() ?.let(block) + +public inline fun Message.anonymousForumContentMessageOrNull(): + AnonymousForumContentMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage + +public inline fun Message.anonymousForumContentMessageOrThrow(): + AnonymousForumContentMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage + +public inline fun + Message.ifAnonymousForumContentMessage(block: (AnonymousForumContentMessage) -> T): + T? = anonymousForumContentMessageOrNull() ?.let(block) + +public inline fun Message.commonForumContentMessageOrNull(): + CommonForumContentMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage + +public inline fun Message.commonForumContentMessageOrThrow(): + CommonForumContentMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.CommonForumContentMessage + +public inline fun + Message.ifCommonForumContentMessage(block: (CommonForumContentMessage) -> T): T? + = commonForumContentMessageOrNull() ?.let(block) public inline fun Message.unknownMessageTypeOrNull(): UnknownMessageType? = this as? dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType @@ -3209,6 +3360,18 @@ public inline fun Message.possiblyForwardedMessageOrThrow(): PossiblyForwardedMe public inline fun Message.ifPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T): T? = possiblyForwardedMessageOrNull() ?.let(block) +public inline fun Message.possiblyMediaGroupMessageOrNull(): + PossiblyMediaGroupMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage + +public inline fun Message.possiblyMediaGroupMessageOrThrow(): + PossiblyMediaGroupMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage + +public inline fun + Message.ifPossiblyMediaGroupMessage(block: (PossiblyMediaGroupMessage) -> T): T? + = possiblyMediaGroupMessageOrNull() ?.let(block) + public inline fun Message.possiblyPaymentMessageOrNull(): PossiblyPaymentMessage? = this as? dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage @@ -3230,6 +3393,15 @@ public inline fun Message.ifPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage) -> T): T? = possiblySentViaBotCommonMessageOrNull() ?.let(block) +public inline fun Message.possiblyTopicMessageOrNull(): PossiblyTopicMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage + +public inline fun Message.possiblyTopicMessageOrThrow(): PossiblyTopicMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage + +public inline fun Message.ifPossiblyTopicMessage(block: (PossiblyTopicMessage) -> T): T? = + possiblyTopicMessageOrNull() ?.let(block) + public inline fun Message.privateContentMessageOrNull(): PrivateContentMessage? = this as? dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage @@ -3305,34 +3477,27 @@ public inline fun ResendableContent.mediaContentOrThrow(): MediaContent = this a public inline fun ResendableContent.ifMediaContent(block: (MediaContent) -> T): T? = mediaContentOrNull() ?.let(block) -public inline fun ResendableContent.audioMediaGroupContentOrNull(): AudioMediaGroupContent? = this - as? dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent +public inline fun ResendableContent.audioMediaGroupPartContentOrNull(): AudioMediaGroupPartContent? + = this as? dev.inmo.tgbotapi.types.message.content.AudioMediaGroupPartContent -public inline fun ResendableContent.audioMediaGroupContentOrThrow(): AudioMediaGroupContent = this - as dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent +public inline fun ResendableContent.audioMediaGroupPartContentOrThrow(): AudioMediaGroupPartContent + = this as dev.inmo.tgbotapi.types.message.content.AudioMediaGroupPartContent public inline fun - ResendableContent.ifAudioMediaGroupContent(block: (AudioMediaGroupContent) -> T): T? = - audioMediaGroupContentOrNull() ?.let(block) + ResendableContent.ifAudioMediaGroupPartContent(block: (AudioMediaGroupPartContent) -> T): T? = + audioMediaGroupPartContentOrNull() ?.let(block) -public inline fun ResendableContent.documentMediaGroupContentOrNull(): DocumentMediaGroupContent? = - this as? dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent +public inline fun ResendableContent.documentMediaGroupPartContentOrNull(): + DocumentMediaGroupPartContent? = this as? + dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupPartContent -public inline fun ResendableContent.documentMediaGroupContentOrThrow(): DocumentMediaGroupContent = - this as dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent +public inline fun ResendableContent.documentMediaGroupPartContentOrThrow(): + DocumentMediaGroupPartContent = this as + dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupPartContent public inline fun - ResendableContent.ifDocumentMediaGroupContent(block: (DocumentMediaGroupContent) -> T): T? = - documentMediaGroupContentOrNull() ?.let(block) - -public inline fun ResendableContent.mediaGroupContentOrNull(): MediaGroupContent? = this as? - dev.inmo.tgbotapi.types.message.content.MediaGroupContent - -public inline fun ResendableContent.mediaGroupContentOrThrow(): MediaGroupContent = this as - dev.inmo.tgbotapi.types.message.content.MediaGroupContent - -public inline fun ResendableContent.ifMediaGroupContent(block: (MediaGroupContent) -> T): T? = - mediaGroupContentOrNull() ?.let(block) + ResendableContent.ifDocumentMediaGroupPartContent(block: (DocumentMediaGroupPartContent) -> T): + T? = documentMediaGroupPartContentOrNull() ?.let(block) public inline fun ResendableContent.textedMediaContentOrNull(): TextedMediaContent? = this as? dev.inmo.tgbotapi.types.message.content.TextedMediaContent @@ -3343,15 +3508,39 @@ public inline fun ResendableContent.textedMediaContentOrThrow(): TextedMediaCont public inline fun ResendableContent.ifTextedMediaContent(block: (TextedMediaContent) -> T): T? = textedMediaContentOrNull() ?.let(block) -public inline fun ResendableContent.visualMediaGroupContentOrNull(): VisualMediaGroupContent? = this - as? dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent +public inline fun ResendableContent.mediaGroupCollectionContentOrNull(): + MediaGroupCollectionContent? = this as? + dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent -public inline fun ResendableContent.visualMediaGroupContentOrThrow(): VisualMediaGroupContent = this - as dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent +public inline fun ResendableContent.mediaGroupCollectionContentOrThrow(): + MediaGroupCollectionContent = this as + dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent public inline fun - ResendableContent.ifVisualMediaGroupContent(block: (VisualMediaGroupContent) -> T): T? = - visualMediaGroupContentOrNull() ?.let(block) + ResendableContent.ifMediaGroupCollectionContent(block: (MediaGroupCollectionContent) -> T): + T? = mediaGroupCollectionContentOrNull() ?.let(block) + +public inline fun ResendableContent.mediaGroupPartContentOrNull(): MediaGroupPartContent? = this as? + dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent + +public inline fun ResendableContent.mediaGroupPartContentOrThrow(): MediaGroupPartContent = this as + dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent + +public inline fun + ResendableContent.ifMediaGroupPartContent(block: (MediaGroupPartContent) -> T): T? = + mediaGroupPartContentOrNull() ?.let(block) + +public inline fun ResendableContent.visualMediaGroupPartContentOrNull(): + VisualMediaGroupPartContent? = this as? + dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent + +public inline fun ResendableContent.visualMediaGroupPartContentOrThrow(): + VisualMediaGroupPartContent = this as + dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent + +public inline fun + ResendableContent.ifVisualMediaGroupPartContent(block: (VisualMediaGroupPartContent) -> T): T? = + visualMediaGroupPartContentOrNull() ?.let(block) public inline fun ResendableContent.animationContentOrNull(): AnimationContent? = this as? dev.inmo.tgbotapi.types.message.content.AnimationContent @@ -3444,6 +3633,18 @@ public inline fun ResendableContent.ifStaticLocationContent(block: (StaticLocationContent) -> T): T? = staticLocationContentOrNull() ?.let(block) +public inline fun ResendableContent.mediaGroupContentOrNull(): + MediaGroupContent? = this as? + dev.inmo.tgbotapi.types.message.content.MediaGroupContent + +public inline fun ResendableContent.mediaGroupContentOrThrow(): + MediaGroupContent = this as + dev.inmo.tgbotapi.types.message.content.MediaGroupContent + +public inline fun + ResendableContent.ifMediaGroupContent(block: (MediaGroupContent) -> T): + T? = mediaGroupContentOrNull() ?.let(block) + public inline fun ResendableContent.photoContentOrNull(): PhotoContent? = this as? dev.inmo.tgbotapi.types.message.content.PhotoContent @@ -4527,69 +4728,3 @@ public inline fun Update.unknownUpdateOrThrow(): UnknownUpdate = this as public inline fun Update.ifUnknownUpdate(block: (UnknownUpdate) -> T): T? = unknownUpdateOrNull() ?.let(block) - -public inline fun Update.channelPostMediaGroupUpdateOrNull(): ChannelPostMediaGroupUpdate? = this - as? dev.inmo.tgbotapi.types.update.media_group.ChannelPostMediaGroupUpdate - -public inline fun Update.channelPostMediaGroupUpdateOrThrow(): ChannelPostMediaGroupUpdate = this as - dev.inmo.tgbotapi.types.update.media_group.ChannelPostMediaGroupUpdate - -public inline fun - Update.ifChannelPostMediaGroupUpdate(block: (ChannelPostMediaGroupUpdate) -> T): T? = - channelPostMediaGroupUpdateOrNull() ?.let(block) - -public inline fun Update.editChannelPostMediaGroupUpdateOrNull(): EditChannelPostMediaGroupUpdate? = - this as? dev.inmo.tgbotapi.types.update.media_group.EditChannelPostMediaGroupUpdate - -public inline fun Update.editChannelPostMediaGroupUpdateOrThrow(): EditChannelPostMediaGroupUpdate = - this as dev.inmo.tgbotapi.types.update.media_group.EditChannelPostMediaGroupUpdate - -public inline fun - Update.ifEditChannelPostMediaGroupUpdate(block: (EditChannelPostMediaGroupUpdate) -> T): T? = - editChannelPostMediaGroupUpdateOrNull() ?.let(block) - -public inline fun Update.editMessageMediaGroupUpdateOrNull(): EditMessageMediaGroupUpdate? = this - as? dev.inmo.tgbotapi.types.update.media_group.EditMessageMediaGroupUpdate - -public inline fun Update.editMessageMediaGroupUpdateOrThrow(): EditMessageMediaGroupUpdate = this as - dev.inmo.tgbotapi.types.update.media_group.EditMessageMediaGroupUpdate - -public inline fun - Update.ifEditMessageMediaGroupUpdate(block: (EditMessageMediaGroupUpdate) -> T): T? = - editMessageMediaGroupUpdateOrNull() ?.let(block) - -public inline fun Update.mediaGroupUpdateOrNull(): MediaGroupUpdate? = this as? - dev.inmo.tgbotapi.types.update.media_group.MediaGroupUpdate - -public inline fun Update.mediaGroupUpdateOrThrow(): MediaGroupUpdate = this as - dev.inmo.tgbotapi.types.update.media_group.MediaGroupUpdate - -public inline fun Update.ifMediaGroupUpdate(block: (MediaGroupUpdate) -> T): T? = - mediaGroupUpdateOrNull() ?.let(block) - -public inline fun Update.sentMediaGroupUpdateOrNull(): SentMediaGroupUpdate? = this as? - dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate - -public inline fun Update.sentMediaGroupUpdateOrThrow(): SentMediaGroupUpdate = this as - dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate - -public inline fun Update.ifSentMediaGroupUpdate(block: (SentMediaGroupUpdate) -> T): T? = - sentMediaGroupUpdateOrNull() ?.let(block) - -public inline fun Update.editMediaGroupUpdateOrNull(): EditMediaGroupUpdate? = this as? - dev.inmo.tgbotapi.types.update.media_group.EditMediaGroupUpdate - -public inline fun Update.editMediaGroupUpdateOrThrow(): EditMediaGroupUpdate = this as - dev.inmo.tgbotapi.types.update.media_group.EditMediaGroupUpdate - -public inline fun Update.ifEditMediaGroupUpdate(block: (EditMediaGroupUpdate) -> T): T? = - editMediaGroupUpdateOrNull() ?.let(block) - -public inline fun Update.messageMediaGroupUpdateOrNull(): MessageMediaGroupUpdate? = this as? - dev.inmo.tgbotapi.types.update.media_group.MessageMediaGroupUpdate - -public inline fun Update.messageMediaGroupUpdateOrThrow(): MessageMediaGroupUpdate = this as - dev.inmo.tgbotapi.types.update.media_group.MessageMediaGroupUpdate - -public inline fun Update.ifMessageMediaGroupUpdate(block: (MessageMediaGroupUpdate) -> T): T? = - messageMediaGroupUpdateOrNull() ?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentCastsNew.kt index 05cd19bd49..51d5200ded 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentCastsNew.kt @@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.utils import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent +import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.MessageContent inline fun ContentMessage<*>.withContentOrNull() = if (content is T) { this as ContentMessage } else { null } @@ -36,6 +36,3 @@ inline fun AnonymousGroupContentMessage<*>.withCont inline fun CommonGroupContentMessage<*>.withContentOrNull() = if (content is T) { this as CommonGroupContentMessage } else { null } inline fun CommonGroupContentMessage<*>.withContentOrThrow() = withContentOrNull()!! - -inline fun MediaGroupMessage<*>.withContentOrNull() = if (content is T) { this as MediaGroupMessage } else { null } -inline fun MediaGroupMessage<*>.withContentOrThrow() = withContentOrNull()!! diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt index 80dea0da67..7fdcdf54fb 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt @@ -3,7 +3,8 @@ package dev.inmo.tgbotapi.extensions.utils 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.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.MessageContent inline fun ContentMessage<*>.withContent() = if (content is T) { this as ContentMessage } else { null } @@ -36,6 +37,3 @@ inline fun AnonymousGroupContentMessage<*>.requireW inline fun CommonGroupContentMessage<*>.withContent() = if (content is T) { this as CommonGroupContentMessage } else { null } inline fun CommonGroupContentMessage<*>.requireWithContent() = withContent()!! - -inline fun MediaGroupMessage<*>.withContent() = if (content is T) { this as MediaGroupMessage } else { null } -inline fun MediaGroupMessage<*>.requireWithContent() = withContent()!! diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt index 0b79a6b2ca..20ede5d212 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/Same.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.extensions.utils.extensions import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull /** * @return true in case if [this] message is placed in the same chat that [other] @@ -14,3 +15,21 @@ inline fun Message.sameChat(other: Message) = chat.id == other.chat.id */ @Suppress("NOTHING_TO_INLINE") inline fun Message.sameMessage(other: Message) = sameChat(other) && messageId == other.messageId + +/** + * Thread is the same thing that topic + * + * @return true in case if [this] message is in the same topic as the [other]. The same here means that these messages + * from one chat and have equal [Message.threadIdOrNull] identifier + */ +@Suppress("NOTHING_TO_INLINE") +inline fun Message.sameTopic(other: Message) = sameChat(other) && threadIdOrNull == other.threadIdOrNull + +/** + * Thread is the same thing that topic + * + * @return true in case if [this] message is in the same topic as the [other]. The same here means that these messages + * from one chat and have equal [Message.threadIdOrNull] identifier + */ +@Suppress("NOTHING_TO_INLINE") +inline fun Message.sameThread(other: Message) = sameChat(other) && threadIdOrNull == other.threadIdOrNull 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 aaf91e4521..56ec9dc233 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 @@ -3,21 +3,15 @@ package dev.inmo.tgbotapi.extensions.utils.extensions import dev.inmo.tgbotapi.abstracts.FromUser import dev.inmo.tgbotapi.abstracts.WithUser import dev.inmo.tgbotapi.extensions.utils.asUser -import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.types.update.media_group.* import dev.inmo.tgbotapi.utils.PreviewFeature @PreviewFeature fun Update.sourceChat(): Chat? = when (this) { - is MediaGroupUpdate -> when (this) { - is SentMediaGroupUpdate -> data.chat - is EditMediaGroupUpdate -> data.chat - } is BaseMessageUpdate -> data.chat is ChatJoinRequestUpdate -> data.chat else -> { diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt index 4b3956f4ac..91acd5419e 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt @@ -8,7 +8,6 @@ import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage @@ -30,19 +29,6 @@ inline fun filterForContentMessage(): suspend (Cont inline fun Flow.filterContentMessages( ): Flow> = asContentMessagesFlow().mapNotNull(filterForContentMessage()) -@RiskFeature("This method is low-level") -inline fun Flow.filterMediaGroupMessages( -): Flow>> = map { - it.data.mapNotNull { message -> - if (message.content is T) { - @Suppress("UNCHECKED_CAST") - message as CommonMessage - } else { - null - } - } -} - /** * @param scopeToIncludeChannels This parameter is required when you want to include [textMessages] for channels too. * In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messagesFlow] and @@ -62,39 +48,9 @@ inline fun FlowsUpdatesFilter.filterContentMessages( } ?: messagesFlow).filterContentMessages() } -/** - * @param scopeToIncludeChannels This parameter is required when you want to include [SentMediaGroupUpdate] for channels - * too. In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messagesFlow] and - * [FlowsUpdatesFilter.channelPostsFlow]. In case it is null will be used [Flow]s mapping - */ -@Suppress("UNCHECKED_CAST") -@RiskFeature(lowLevelRiskFeatureMessage) -inline fun FlowsUpdatesFilter.filterMediaGroupMessages( - scopeToIncludeChannels: CoroutineScope? = null -): Flow>> { - return (scopeToIncludeChannels ?.let { scope -> - aggregateFlows( - scope, - messageMediaGroupsFlow, - channelPostMediaGroupsFlow - ) - } ?: messageMediaGroupsFlow).filterMediaGroupMessages() -} - fun FlowsUpdatesFilter.sentMessages( scopeToIncludeChannels: CoroutineScope? = null ): Flow> = filterContentMessages(scopeToIncludeChannels) -fun FlowsUpdatesFilter.sentMessagesWithMediaGroups( - scopeToIncludeChannels: CoroutineScope? = null -): Flow> = merge( - sentMessages(scopeToIncludeChannels), - mediaGroupMessages(scopeToIncludeChannels).flatMap { - it.mapNotNull { - @Suppress("UNCHECKED_CAST") - it as? ContentMessage - } - } -) fun Flow.animationMessages() = filterContentMessages() fun FlowsUpdatesFilter.animationMessages( @@ -105,12 +61,6 @@ fun Flow.audioMessages() = filterContentMessages(scopeToIncludeChannels) -fun FlowsUpdatesFilter.audioMessagesWithMediaGroups( - scopeToIncludeChannels: CoroutineScope? = null -) = merge( - filterContentMessages(scopeToIncludeChannels), - mediaGroupAudioMessages(scopeToIncludeChannels).flatten() -) fun Flow.contactMessages() = filterContentMessages() fun FlowsUpdatesFilter.contactMessages( @@ -126,12 +76,6 @@ fun Flow.documentMessages() = filterContentMessages(scopeToIncludeChannels) -fun FlowsUpdatesFilter.documentMessagesWithMediaGroups( - scopeToIncludeChannels: CoroutineScope? = null -) = merge( - filterContentMessages(scopeToIncludeChannels), - mediaGroupDocumentMessages(scopeToIncludeChannels).flatten() -) fun Flow.gameMessages() = filterContentMessages() fun FlowsUpdatesFilter.gameMessages( @@ -153,12 +97,6 @@ fun Flow.imageMessages() = photoMessages() fun FlowsUpdatesFilter.photoMessages( scopeToIncludeChannels: CoroutineScope? = null ) = filterContentMessages(scopeToIncludeChannels) -fun FlowsUpdatesFilter.photoMessagesWithMediaGroups( - scopeToIncludeChannels: CoroutineScope? = null -) = merge( - filterContentMessages(scopeToIncludeChannels), - mediaGroupPhotosMessages(scopeToIncludeChannels).flatten() -) /** * Shortcut for [photoMessages] */ @@ -166,9 +104,6 @@ fun FlowsUpdatesFilter.photoMessagesWithMediaGroups( inline fun FlowsUpdatesFilter.imageMessages( scopeToIncludeChannels: CoroutineScope? = null ) = photoMessages(scopeToIncludeChannels) -fun FlowsUpdatesFilter.imageMessagesWithMediaGroups( - scopeToIncludeChannels: CoroutineScope? = null -) = photoMessagesWithMediaGroups(scopeToIncludeChannels) fun Flow.pollMessages() = filterContentMessages() fun FlowsUpdatesFilter.pollMessages( @@ -194,12 +129,6 @@ fun Flow.videoMessages() = filterContentMessages(scopeToIncludeChannels) -fun FlowsUpdatesFilter.videoMessagesWithMediaGroups( - scopeToIncludeChannels: CoroutineScope? = null -) = merge( - filterContentMessages(scopeToIncludeChannels), - mediaGroupVideosMessages(scopeToIncludeChannels).flatten() -) fun Flow.videoNoteMessages() = filterContentMessages() fun FlowsUpdatesFilter.videoNoteMessages( @@ -210,34 +139,3 @@ fun Flow.voiceMessages() = filterContentMessages(scopeToIncludeChannels) - - -fun Flow.mediaGroupMessages() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupMessages( - scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) - -fun Flow.mediaGroupPhotosMessages() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupPhotosMessages( - scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) - -fun Flow.mediaGroupVideosMessages() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupVideosMessages( - scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) - -fun Flow.mediaGroupVisualMessages() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupVisualMessages( - scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) - -fun Flow.mediaGroupAudioMessages() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupAudioMessages( - scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) - -fun Flow.mediaGroupDocumentMessages() = filterMediaGroupMessages() -fun FlowsUpdatesFilter.mediaGroupDocumentMessages( - scopeToIncludeChannels: CoroutineScope? = null -) = filterMediaGroupMessages(scopeToIncludeChannels) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt deleted file mode 100644 index f5c106d568..0000000000 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt +++ /dev/null @@ -1,63 +0,0 @@ -package dev.inmo.tgbotapi.extensions.utils.shortcuts - -import dev.inmo.tgbotapi.requests.send.media.SendMediaGroup -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.chat.Chat -import dev.inmo.tgbotapi.types.message.ForwardInfo -import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.content.MediaGroupContent -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate - -val List>.forwardInfo: ForwardInfo? - get() = firstOrNull() ?.forwardInfo -val List>.replyTo: Message? - get() = firstOrNull() ?.replyTo -val List>.chat: Chat? - get() = firstOrNull() ?.chat -val List>.mediaGroupId: MediaGroupIdentifier? - get() = firstOrNull() ?.mediaGroupId - -val SentMediaGroupUpdate.forwardInfo: ForwardInfo? - get() = data.first().forwardInfo -val SentMediaGroupUpdate.replyTo: Message? - get() = data.first().replyTo -val SentMediaGroupUpdate.chat: Chat - get() = data.chat!! -val SentMediaGroupUpdate.mediaGroupId: MediaGroupIdentifier - get() = data.mediaGroupId!! - -fun List>.createResend( - chatId: ChatId, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyTo: MessageId? = null -) = SendMediaGroup( - chatId, - map { it.content.toMediaGroupMemberTelegramMedia() }, - disableNotification, - protectContent, - replyTo -) - -fun List>.createResend( - chat: Chat, - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyTo: MessageId? = null -) = createResend( - chat.id, - disableNotification, - protectContent, - replyTo -) - -fun SentMediaGroupUpdate.createResend( - disableNotification: Boolean = false, - protectContent: Boolean = false, - replyTo: MessageId? = null -) = data.createResend( - chat, - disableNotification, - protectContent, - replyTo -) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt index 0caa1805cc..2eae2350b0 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.types.update.abstracts.* -import dev.inmo.tgbotapi.types.update.media_group.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filterIsInstance @@ -16,22 +15,3 @@ fun Flow.onlySentMessageUpdates(): Flow.onlyEditMessageUpdates(): Flow = filterIsInstance() - -/** - * Converts flow to [Flow] of [MediaGroupUpdate]. Please, remember that it could be either [EditMediaGroupUpdate] - * or [SentMediaGroupUpdate] - * - * @see onlySentMediaGroupUpdates - * @see onlyEditMediaGroupUpdates - */ -fun Flow.onlyMediaGroupsUpdates(): Flow = filterIsInstance() - -/** - * Converts flow to [Flow] of [SentMediaGroupUpdate] - */ -fun Flow.onlySentMediaGroupUpdates(): Flow = filterIsInstance() - -/** - * Converts flow to [Flow] of [EditMediaGroupUpdate] - */ -fun Flow.onlyEditMediaGroupUpdates(): Flow = filterIsInstance() diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt index 40d996bc6f..03963a88f4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/MessageFilters.kt @@ -2,8 +2,10 @@ package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource +import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull /** * A predicate to test whether a message contains any commands in its body. @@ -42,3 +44,39 @@ fun CommonMessage<*>.hasCommands(): Boolean = withContentOrNull() ? * @see hasCommands */ fun CommonMessage<*>.hasNoCommands(): Boolean = !this.hasCommands() + +/** + * A predicate to test that message has been sent in the forum. + * Use it as the `initialFilter` parameter in behaviour builder triggers. + * E.g. + * + * ```kotlin + * onContentMessage( + * initialFilter = Message::forumMessage + * ) { + * // The message here will be from forum + * } + * ``` + * + * @return true if this [Message] is from forum ([threadIdOrNull] is not null). False otherwise. + * @see notForumMessage + */ +fun Message.forumMessage(): Boolean = threadIdOrNull != null + +/** + * A predicate to test that message has not been sent in the forum. + * Use it as the `initialFilter` parameter in behaviour builder triggers. + * E.g. + * + * ```kotlin + * onContentMessage( + * initialFilter = Message::notForumMessage + * ) { + * // The message here will not be from forum + * } + * ``` + * + * @return true if this [Message] is not from forum ([threadIdOrNull] is not null). False otherwise. + * @see forumMessage + */ +fun Message.notForumMessage(): Boolean = !forumMessage() diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt index 70be37786a..bf415ce45e 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt @@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.extensions.utils.updates import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter @@ -15,13 +14,3 @@ fun Flow.filterBaseMessageUpdatesByChatId(chatId: Cha * [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat] */ fun Flow.filterBaseMessageUpdatesByChat(chat: Chat): Flow = filterBaseMessageUpdatesByChatId(chat.id) - - -/** - * [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] - */ -fun Flow.filterSentMediaGroupUpdatesByChatId(chatId: ChatId): Flow = filter { it.data.first().chat.id == chatId } -/** - * [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] using [Chat.id] of [chat] - */ -fun Flow.filterSentMediaGroupUpdatesByChat(chat: Chat): Flow = filterSentMediaGroupUpdatesByChatId(chat.id) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt index 27439971cf..a0c36c0c35 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt @@ -1,21 +1,20 @@ package dev.inmo.tgbotapi.extensions.utils.updates +import dev.inmo.tgbotapi.extensions.utils.withContentOrNull import dev.inmo.tgbotapi.types.MediaGroupIdentifier import dev.inmo.tgbotapi.types.UpdateIdentifier -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage +import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.abstracts.* -import dev.inmo.tgbotapi.types.update.media_group.* +import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage /** * @return If [this] is [SentMediaGroupUpdate] - [Update.updateId] of [last] element, or its own [Update.updateId] */ +@Deprecated("Redundant", ReplaceWith("updateId")) fun Update.lastUpdateIdentifier(): UpdateIdentifier { - return if (this is SentMediaGroupUpdate) { - origins.last().updateId - } else { - updateId - } + return updateId } /** @@ -24,7 +23,7 @@ fun Update.lastUpdateIdentifier(): UpdateIdentifier { * @see [Update.lastUpdateIdentifier] */ fun List.lastUpdateIdentifier(): UpdateIdentifier? { - return maxByOrNull { it.updateId } ?.lastUpdateIdentifier() + return maxByOrNull { it.updateId } ?.updateId } /** @@ -32,62 +31,40 @@ fun List.lastUpdateIdentifier(): UpdateIdentifier? { */ fun List.convertWithMediaGroupUpdates(): List { val resultUpdates = mutableListOf() - val mediaGroups = mutableMapOf>() + val mediaGroups = mutableMapOf>>>() + for (update in this) { - val data = (update.data as? MediaGroupMessage<*>) - if (data == null) { + val message = (update.data as? PossiblySentViaBotCommonMessage<*>) ?.withContentOrNull() + val mediaGroupId = message ?.mediaGroupId + if (message == null || mediaGroupId == null) { resultUpdates.add(update) continue } when (update) { - is BaseEditMessageUpdate -> resultUpdates.add( - update.toEditMediaGroupUpdate() - ) is BaseSentMessageUpdate -> { - mediaGroups.getOrPut(data.mediaGroupId) { + mediaGroups.getOrPut(mediaGroupId) { mutableListOf() - }.add(update) + }.add(update to message) } else -> resultUpdates.add(update) } } - mediaGroups.values.map { - it.toSentMediaGroupUpdate() ?.let { mediaGroupUpdate -> - resultUpdates.add(mediaGroupUpdate) - } + + mediaGroups.map { (_, updatesWithMessages) -> + val update = updatesWithMessages.maxBy { it.first.updateId }.first + resultUpdates.add( + update.copy(updatesWithMessages.map { it.second }.asMediaGroupMessage()) + ) } + resultUpdates.sortBy { it.updateId } return resultUpdates } -/** - * @receiver List of [BaseSentMessageUpdate] where [BaseSentMessageUpdate.data] is [MediaGroupMessage] and all messages - * have the same [MediaGroupMessage.mediaGroupId] - * @return [MessageMediaGroupUpdate] in case if [first] object of [this] is [MessageUpdate]. When [first] object is - * [ChannelPostUpdate] instance - will return [ChannelPostMediaGroupUpdate]. Otherwise will be returned null - */ -fun List.toSentMediaGroupUpdate(): SentMediaGroupUpdate? = (this as? SentMediaGroupUpdate) ?: let { - if (isEmpty()) { - return@let null - } - val resultList = sortedBy { it.updateId } - when (first()) { - is MessageUpdate -> MessageMediaGroupUpdate(resultList) - is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(resultList) - else -> null - } -} - /** * @return [EditMessageMediaGroupUpdate] in case if [this] is [EditMessageUpdate]. When [this] object is * [EditChannelPostUpdate] instance - will return [EditChannelPostMediaGroupUpdate] * * @throws IllegalStateException */ -fun BaseEditMessageUpdate.toEditMediaGroupUpdate(): EditMediaGroupUpdate = (this as? EditMediaGroupUpdate) ?: let { - when (this) { - is EditMessageUpdate -> EditMessageMediaGroupUpdate(this) - is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this) - else -> error("Unsupported type of ${BaseEditMessageUpdate::class.simpleName}") - } -} +fun BaseEditMessageUpdate.toEditMediaGroupUpdate() = this diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt index 3e9f27dfaa..7306a8946a 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt @@ -8,9 +8,11 @@ import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates import dev.inmo.tgbotapi.extensions.utils.updates.lastUpdateIdentifier import dev.inmo.tgbotapi.requests.GetUpdates import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.content.MediaGroupContent import dev.inmo.tgbotapi.types.update.* +import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate import dev.inmo.tgbotapi.updateshandlers.* import io.ktor.client.plugins.HttpRequestTimeoutException import io.ktor.utils.io.CancellationException @@ -56,7 +58,10 @@ fun TelegramBot.longPollingFlow( * We are throw out the last media group and will reretrieve it again in the next get updates * and it will guarantee that it is full */ - if (originalUpdates.size == getUpdatesLimit.last && converted.last() is SentMediaGroupUpdate) { + if ( + originalUpdates.size == getUpdatesLimit.last + && ((converted.last() as? BaseSentMessageUpdate) ?.data as? CommonMessage<*>) ?.content is MediaGroupContent<*> + ) { converted - converted.last() } else { converted @@ -67,7 +72,7 @@ fun TelegramBot.longPollingFlow( for (update in updates) { send(update) - lastUpdateIdentifier = update.lastUpdateIdentifier() + lastUpdateIdentifier = update.updateId } }.onFailure { cancel(it as? CancellationException ?: return@onFailure) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt index c369e14c16..f4e43f6e6b 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates.retrieving import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates -import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage +import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.UpdateReceiver @@ -32,7 +32,7 @@ fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation( launch { for (update in updatesChannel) { when (val data = update.data) { - is MediaGroupMessage<*> -> mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate) + is PossiblyMediaGroupMessage<*> -> mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate) else -> output(update) } } @@ -57,4 +57,4 @@ fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation( */ fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation( output: UpdateReceiver -) = updateHandlerWithMediaGroupsAdaptation(output, 1000L) \ No newline at end of file +) = updateHandlerWithMediaGroupsAdaptation(output, 1000L)