From 39335b1dab7622704cbeef82af17b241077443ac Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 09:01:14 +0600 Subject: [PATCH 01/10] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index cd8beaf7f7..12f8e88ed4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=4.0.0 +library_version=4.1.0 From 733ad342898a6602efd4d178d11b95871b32ec69 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 09:11:13 +0600 Subject: [PATCH 02/10] Create ChatIdentifierWithThreadId.kt --- .../extensions/ChatIdentifierWithThreadId.kt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt new file mode 100644 index 0000000000..e571a47bd5 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt @@ -0,0 +1,36 @@ +package dev.inmo.tgbotapi.utils.extensions + +sealed interface ChatIdWithThreadId { + val chatId: ChatId + val threadId: MessageThreadId? + + // Light weight due to absence of any conversations + value class ByMessage( + val sourceMessage: Message + ) : ChatIdWithThreadId { + override val chatId: ChatId + get() = sourceMessage.chat.id + override val threadId: MessageThreadId? + get() = sourceMessage.threadIdOrNull + } + @Serializable + value class ByPair( + val pair: Pair + ) : ChatIdWithThreadId { + override val chatId: ChatId + get() = pair.first + override val threadId: MessageThreadId? + get() = pair.second + } + + companion { + inline operator fun invoke(message: Message) = ByMessage(message) + inline fun serializable(message: Message) = ByPair(message.chatId.id to message.threadIdOrNull) + inline fun serializable(pair: Pair) = ByPair(pair) + } +} + +val Message.chatIdWithThreadId + get() = ChatIdWithThreadId(this) +val Message.serializableChatIdWithThreadId + get() = ChatIdWithThreadId.serializable(this) From 304b281d80205133d2f4fd56ffc5c16b02779b5f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 09:13:31 +0600 Subject: [PATCH 03/10] Update ChatIdentifierWithThreadId.kt --- .../utils/extensions/ChatIdentifierWithThreadId.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt index e571a47bd5..141bb6b5d8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt @@ -1,23 +1,23 @@ package dev.inmo.tgbotapi.utils.extensions sealed interface ChatIdWithThreadId { - val chatId: ChatId + val chatId: ChatIdentifier val threadId: MessageThreadId? // Light weight due to absence of any conversations value class ByMessage( val sourceMessage: Message ) : ChatIdWithThreadId { - override val chatId: ChatId + override val chatId: ChatIdentifier get() = sourceMessage.chat.id override val threadId: MessageThreadId? get() = sourceMessage.threadIdOrNull } @Serializable value class ByPair( - val pair: Pair + val pair: Pair ) : ChatIdWithThreadId { - override val chatId: ChatId + override val chatId: ChatIdentifier get() = pair.first override val threadId: MessageThreadId? get() = pair.second @@ -26,7 +26,7 @@ sealed interface ChatIdWithThreadId { companion { inline operator fun invoke(message: Message) = ByMessage(message) inline fun serializable(message: Message) = ByPair(message.chatId.id to message.threadIdOrNull) - inline fun serializable(pair: Pair) = ByPair(pair) + inline fun serializable(pair: Pair) = ByPair(pair) } } From 1b8ee5c4d76b0d7931dd6a0765e65baa190efe5b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 09:16:46 +0600 Subject: [PATCH 04/10] Update ChatIdentifierWithThreadId.kt --- .../tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt index 141bb6b5d8..a75885a626 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt @@ -1,5 +1,11 @@ package dev.inmo.tgbotapi.utils.extensions +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageThreadId +import kotlinx.serialization.Serializable +import kotlin.Pair +import dev.inmo.tgbotapi.types.message.abstract.Message + sealed interface ChatIdWithThreadId { val chatId: ChatIdentifier val threadId: MessageThreadId? From f2f15d7173cdeb3f1a00ffc400232750bb3e99a6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 09:24:32 +0600 Subject: [PATCH 05/10] Update ChatIdentifierWithThreadId.kt --- .../utils/extensions/ChatIdentifierWithThreadId.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt index a75885a626..88ddd92faa 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt @@ -1,29 +1,29 @@ package dev.inmo.tgbotapi.utils.extensions -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.MessageThreadId import kotlinx.serialization.Serializable import kotlin.Pair import dev.inmo.tgbotapi.types.message.abstract.Message sealed interface ChatIdWithThreadId { - val chatId: ChatIdentifier + val chatId: ChatId val threadId: MessageThreadId? // Light weight due to absence of any conversations value class ByMessage( val sourceMessage: Message ) : ChatIdWithThreadId { - override val chatId: ChatIdentifier + override val chatId: ChatId get() = sourceMessage.chat.id override val threadId: MessageThreadId? get() = sourceMessage.threadIdOrNull } @Serializable value class ByPair( - val pair: Pair + val pair: Pair ) : ChatIdWithThreadId { - override val chatId: ChatIdentifier + override val chatId: ChatId get() = pair.first override val threadId: MessageThreadId? get() = pair.second @@ -32,7 +32,7 @@ sealed interface ChatIdWithThreadId { companion { inline operator fun invoke(message: Message) = ByMessage(message) inline fun serializable(message: Message) = ByPair(message.chatId.id to message.threadIdOrNull) - inline fun serializable(pair: Pair) = ByPair(pair) + inline fun serializable(pair: Pair) = ByPair(pair) } } From 236e47478f95f5b0973f71182c16ab0096d8afb0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 12:05:59 +0600 Subject: [PATCH 06/10] update ChatIdentifierWithThreadId and kdocs --- .../extensions/ChatIdentifierWithThreadId.kt | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt index 88ddd92faa..5d796cab28 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt @@ -2,15 +2,24 @@ package dev.inmo.tgbotapi.utils.extensions import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.utils.extensions.ChatIdWithThreadId.ByPair import kotlinx.serialization.Serializable import kotlin.Pair -import dev.inmo.tgbotapi.types.message.abstract.Message +import kotlin.jvm.JvmInline +/** + * Union to keep both [ChatId] and optionally [MessageThreadId] as an identifier of target for messages sending and + * other information + */ sealed interface ChatIdWithThreadId { val chatId: ChatId val threadId: MessageThreadId? - // Light weight due to absence of any conversations + /** + * Lightweight variant of [ChatIdWithThreadId] due to absence of any conversations + */ + @JvmInline value class ByMessage( val sourceMessage: Message ) : ChatIdWithThreadId { @@ -19,7 +28,15 @@ sealed interface ChatIdWithThreadId { override val threadId: MessageThreadId? get() = sourceMessage.threadIdOrNull } + + /** + * [Serializable] variant of [ChatIdWithThreadId] based on [Pair] of target [ChatId] and [MessageThreadId] + * + * @see invoke + * @see serializable + */ @Serializable + @JvmInline value class ByPair( val pair: Pair ) : ChatIdWithThreadId { @@ -29,14 +46,32 @@ sealed interface ChatIdWithThreadId { get() = pair.second } - companion { + companion object { + /** + * Creates lightweight [ByMessage] variant of [ChatIdWithThreadId] + */ inline operator fun invoke(message: Message) = ByMessage(message) - inline fun serializable(message: Message) = ByPair(message.chatId.id to message.threadIdOrNull) + + /** + * Creates [ByPair] variant of [ChatIdWithThreadId] using incoming [message] [Message.chat] and extension + * [Message.threadIdOrNull] + */ + inline fun serializable(message: Message) = ByPair(message.chat.id to message.threadIdOrNull) + + /** + * Creates [ByPair] variant of [ChatIdWithThreadId] using incoming [pair] + */ inline fun serializable(pair: Pair) = ByPair(pair) } } - +/** + * Creates [ChatIdWithThreadId.ByMessage] variant of [ChatIdWithThreadId] using [ChatIdWithThreadId.serializable] + */ val Message.chatIdWithThreadId get() = ChatIdWithThreadId(this) + +/** + * Creates [ChatIdWithThreadId.ByPair] variant of [ChatIdWithThreadId] using [ChatIdWithThreadId.serializable] + */ val Message.serializableChatIdWithThreadId get() = ChatIdWithThreadId.serializable(this) From 1ec45078910006f664f81473d1310930ee90abd5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 15:56:38 +0600 Subject: [PATCH 07/10] add new type of chats ids --- .../extensions/api/LiveLocationProvider.kt | 2 +- .../inmo/tgbotapi/extensions/api/StopPoll.kt | 2 +- .../api/chat/get/GetChatMenuButton.kt | 4 +- .../api/chat/members/BanChatMember.kt | 4 +- .../api/chat/members/BanChatSenderChat.kt | 8 +- .../api/chat/members/GetChatMember.kt | 4 +- .../api/chat/members/PromoteChatMember.kt | 4 +- .../api/chat/members/RestrictChatMember.kt | 4 +- .../SetChatAdministratorCustomTitle.kt | 6 +- .../api/chat/members/UnbanChatMember.kt | 4 +- .../api/chat/members/UnbanChatSenderChat.kt | 8 +- .../api/chat/modify/SetChatMenuButton.kt | 4 +- .../api/games/GetGameHighScoresByChat.kt | 4 +- .../api/games/SetGameScoreByChatId.kt | 4 +- .../api/send/RepliesWithChatsAndMessages.kt | 136 +++++++++--------- .../extensions/api/send/SendActionDSL.kt | 25 ++-- .../tgbotapi/extensions/api/send/Sends.kt | 2 +- .../extensions/api/send/media/SendVoice.kt | 17 +-- .../api/send/payments/SendInvoice.kt | 4 +- .../extensions/api/send/polls/SendPoll.kt | 25 ++-- .../chat/abstracts/ChatSenderRequest.kt | 5 +- .../tgbotapi/requests/chat/get/GetChat.kt | 9 +- .../chat/members/BanChatSenderChat.kt | 2 +- .../chat/members/UnbanChatSenderChat.kt | 2 +- .../requests/games/GetGameHighScoresByChat.kt | 2 +- .../requests/games/SetGameScoreByChatId.kt | 2 +- .../requests/send/payments/SendInvoice.kt | 4 +- .../dev/inmo/tgbotapi/types/ChatIdentifier.kt | 45 ++++-- .../dev/inmo/tgbotapi/types/RequestError.kt | 2 +- .../tgbotapi/types/ResponseParametersRaw.kt | 2 +- .../dev/inmo/tgbotapi/types/chat/Abstracts.kt | 2 +- .../tgbotapi/types/chat/ChatSerializers.kt | 20 ++- .../dev/inmo/tgbotapi/types/chat/Extended.kt | 18 +-- .../tgbotapi/types/chat/ExtendedAbstracts.kt | 6 +- .../dev/inmo/tgbotapi/types/chat/Impls.kt | 10 +- .../tgbotapi/types/chat/UnknownChatType.kt | 4 +- .../message/ChatEvents/GroupChatCreated.kt | 4 +- .../ChatEvents/MigratedToSupergroup.kt | 4 +- .../ChatEvents/SupergroupChatCreated.kt | 4 +- .../inmo/tgbotapi/types/message/RawMessage.kt | 18 ++- .../extensions/ChatIdentifierWithThreadId.kt | 17 ++- .../ChatEvents/MigratedToSupergroupTest.kt | 6 +- .../utils/extensions/raw/Message.kt | 4 +- .../utils/formatting/StringFormatting.kt | 2 +- .../utils/updates/UpdatesChatFilters.kt | 8 +- 45 files changed, 262 insertions(+), 211 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt index 3ffc151934..9818e26730 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 @@ -166,7 +166,7 @@ suspend fun TelegramBot.startLiveLocation( */ suspend fun TelegramBot.startLiveLocation( scope: CoroutineScope, - chatId: ChatId, + chatId: IdChatIdentifier, location: StaticLocation, liveTimeMillis: Long = defaultLivePeriodDelayMillis, initHorizontalAccuracy: Meters? = null, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt index ad05103cd6..5bfd721463 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt @@ -34,7 +34,7 @@ suspend fun TelegramBot.stopPoll( * as a builder for that */ suspend fun TelegramBot.stopPoll( - chatId: ChatId, + chatId: IdChatIdentifier, message: Message, replyMarkup: InlineKeyboardMarkup? = null ) = stopPoll(chatId, message.messageId, replyMarkup) 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 3ae3801803..e75c0aa02d 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,11 +2,11 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.chat.PrivateChat suspend fun TelegramBot.getChatMenuButton( - chatId: ChatId + chatId: IdChatIdentifier ) = execute(GetChatMenuButton(chatId)) suspend fun TelegramBot.getChatMenuButton( 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 af5a5bdfae..36126639da 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,7 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.UserId @@ -24,7 +24,7 @@ suspend fun TelegramBot.banChatMember( ) = banChatMember(chat.id, userId, untilDate, revokeMessages) suspend fun TelegramBot.banChatMember( - chatId: ChatId, + chatId: IdChatIdentifier, user: User, untilDate: TelegramDate? = null, revokeMessages: Boolean? = null 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 e71701fce7..f7ae9f6dba 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,22 +2,22 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.PublicChat suspend fun TelegramBot.banChatSenderChat( chatId: ChatIdentifier, - senderChatId: ChatId + senderChatId: IdChatIdentifier ) = execute(BanChatSenderChat(chatId, senderChatId)) suspend fun TelegramBot.banChatSenderChat( chat: PublicChat, - senderChatId: ChatId + senderChatId: IdChatIdentifier ) = banChatSenderChat(chat.id, senderChatId) suspend fun TelegramBot.banChatSenderChat( - chatId: ChatId, + chatId: IdChatIdentifier, senderChat: PublicChat ) = banChatSenderChat(chatId, senderChat.id) 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 9f0f28a66c..ea407e6674 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,7 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat @@ -19,7 +19,7 @@ suspend fun TelegramBot.getChatMember( ) = getChatMember(chat.id, userId) suspend fun TelegramBot.getChatMember( - chatId: ChatId, + chatId: IdChatIdentifier, user: User ) = getChatMember(chatId, user.id) 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 df88b9a3b0..b13200feb8 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,7 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.UserId @@ -80,7 +80,7 @@ suspend fun TelegramBot.promoteChatMember( ) suspend fun TelegramBot.promoteChatMember( - chatId: ChatId, + chatId: IdChatIdentifier, user: User, untilDate: TelegramDate? = null, isAnonymous: Boolean? = null, 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 ceb513b90d..10ef93a219 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,7 +2,7 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.UserId @@ -25,7 +25,7 @@ suspend fun TelegramBot.restrictChatMember( ) = restrictChatMember(chat.id, userId, untilDate, permissions) suspend fun TelegramBot.restrictChatMember( - chatId: ChatId, + chatId: IdChatIdentifier, user: User, untilDate: TelegramDate? = null, permissions: ChatPermissions = ChatPermissions() 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 3936721b26..424fa346af 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,13 +2,13 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.User suspend fun TelegramBot.setChatAdministratorCustomTitle( - chatId: ChatId, + chatId: IdChatIdentifier, userId: UserId, customTitle: String ) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle)) @@ -20,7 +20,7 @@ suspend fun TelegramBot.setChatAdministratorCustomTitle( ) = setChatAdministratorCustomTitle(chat.id, userId, customTitle) suspend fun TelegramBot.setChatAdministratorCustomTitle( - chatId: ChatId, + chatId: IdChatIdentifier, user: User, customTitle: String ) = setChatAdministratorCustomTitle(chatId, user.id, customTitle) 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 be8b798fb5..2806a3ab50 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,7 @@ 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.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.chat.PublicChat @@ -21,7 +21,7 @@ suspend fun TelegramBot.unbanChatMember( ) = unbanChatMember(chat.id, userId, onlyIfBanned) suspend fun TelegramBot.unbanChatMember( - chatId: ChatId, + chatId: IdChatIdentifier, user: User, onlyIfBanned: Boolean? = null ) = unbanChatMember(chatId, user.id, onlyIfBanned) 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 b6362f07cc..cc3975e38f 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 @@ -2,22 +2,22 @@ package dev.inmo.tgbotapi.extensions.api.chat.members import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.members.UnbanChatSenderChat -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.PublicChat suspend fun TelegramBot.unbanChatSenderChat( chatId: ChatIdentifier, - senderChatId: ChatId + senderChatId: IdChatIdentifier ) = execute(UnbanChatSenderChat(chatId, senderChatId)) suspend fun TelegramBot.unbanChatSenderChat( chat: PublicChat, - senderChatId: ChatId + senderChatId: IdChatIdentifier ) = unbanChatSenderChat(chat.id, senderChatId) suspend fun TelegramBot.unbanChatSenderChat( - chatId: ChatId, + chatId: IdChatIdentifier, senderChat: PublicChat ) = unbanChatSenderChat(chatId, senderChat.id) 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 78e0cbcb53..81cddf247e 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 @@ -2,12 +2,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.chat.modify.SetChatMenuButton -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.MenuButton import dev.inmo.tgbotapi.types.chat.PrivateChat suspend fun TelegramBot.setChatMenuButton( - chatId: ChatId, + chatId: IdChatIdentifier, menuButton: MenuButton ) = execute(SetChatMenuButton(chatId, menuButton)) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt index 0677efd4c7..8231aa89d0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt @@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.message.content.GameContent suspend fun TelegramBot.getGameScore( userId: UserId, - chatId: ChatId, + chatId: IdChatIdentifier, messageId: MessageId ) = execute( GetGameHighScoresByChat(userId, chatId, messageId) @@ -18,7 +18,7 @@ suspend fun TelegramBot.getGameScore( suspend fun TelegramBot.getGameScore( user: CommonUser, - chatId: ChatId, + chatId: IdChatIdentifier, messageId: MessageId ) = getGameScore( user.id, chatId, messageId diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt index fb25c3eeb8..6976858703 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.message.content.GameContent suspend fun TelegramBot.setGameScore( userId: UserId, score: Long, - chatId: ChatId, + chatId: IdChatIdentifier, messageId: MessageId, force: Boolean = false, disableEditMessage: Boolean = false @@ -22,7 +22,7 @@ suspend fun TelegramBot.setGameScore( suspend fun TelegramBot.setGameScore( user: CommonUser, score: Long, - chatId: ChatId, + chatId: IdChatIdentifier, messageId: MessageId, force: Boolean = false, disableEditMessage: Boolean = false diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 02c5e02555..87e90fe760 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 @@ -42,7 +42,7 @@ import kotlin.jvm.JvmName * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, phoneNumber: String, firstName: String, @@ -70,7 +70,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, contact: Contact, threadId: MessageThreadId? = null, @@ -97,7 +97,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.replyWithDice( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType? = null, threadId: MessageThreadId? = null, @@ -112,7 +112,7 @@ suspend inline fun TelegramBot.replyWithDice( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType, threadId: MessageThreadId? = null, @@ -130,7 +130,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, latitude: Double, longitude: Double, @@ -156,7 +156,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, location: StaticLocation, threadId: MessageThreadId? = null, @@ -183,7 +183,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, text: String, parseMode: ParseMode? = null, @@ -211,7 +211,7 @@ suspend inline fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, @@ -237,7 +237,7 @@ suspend inline fun TelegramBot.reply( * as a builder for that */ suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, @@ -254,7 +254,7 @@ suspend fun TelegramBot.reply( * as a builder for that */ suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, separator: String, disableWebPagePreview: Boolean? = null, @@ -274,7 +274,7 @@ suspend fun TelegramBot.reply( * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, latitude: Double, longitude: Double, @@ -308,7 +308,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, location: StaticLocation, title: String, @@ -341,7 +341,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, venue: Venue, threadId: MessageThreadId? = null, @@ -364,7 +364,7 @@ suspend inline fun TelegramBot.reply( // Game suspend inline fun TelegramBot.replyWithGame( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, gameShortName: String, threadId: MessageThreadId? = null, @@ -377,7 +377,7 @@ suspend inline fun TelegramBot.replyWithGame( ) suspend inline fun TelegramBot.replyWithGame( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, threadId: MessageThreadId? = null, @@ -390,7 +390,7 @@ suspend inline fun TelegramBot.replyWithGame( ) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, threadId: MessageThreadId? = null, @@ -404,7 +404,7 @@ suspend inline fun TelegramBot.reply( // Animation suspend inline fun TelegramBot.replyWithAnimation( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, animation: InputFile, thumb: InputFile? = null, @@ -436,7 +436,7 @@ suspend inline fun TelegramBot.replyWithAnimation( ) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, animation: AnimationFile, text: String? = null, @@ -452,7 +452,7 @@ suspend inline fun TelegramBot.reply( ) = sendAnimation(toChatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAnimation( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, animation: InputFile, entities: TextSourcesList, @@ -482,7 +482,7 @@ suspend inline fun TelegramBot.replyWithAnimation( ) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, animation: AnimationFile, entities: TextSourcesList, @@ -500,7 +500,7 @@ suspend inline fun TelegramBot.reply( // Audio suspend inline fun TelegramBot.replyWithAudio( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, audio: InputFile, thumb: InputFile? = null, @@ -517,7 +517,7 @@ suspend inline fun TelegramBot.replyWithAudio( ) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, audio: AudioFile, text: String? = null, @@ -531,7 +531,7 @@ suspend inline fun TelegramBot.reply( ) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithAudio( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, audio: InputFile, thumb: InputFile? = null, @@ -547,7 +547,7 @@ suspend inline fun TelegramBot.replyWithAudio( ) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, audio: AudioFile, entities: TextSourcesList, @@ -563,7 +563,7 @@ suspend inline fun TelegramBot.reply( // Documents suspend inline fun TelegramBot.replyWithDocument( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, document: InputFile, thumb: InputFile? = null, @@ -578,7 +578,7 @@ suspend inline fun TelegramBot.replyWithDocument( ) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, document: DocumentFile, text: String? = null, @@ -592,7 +592,7 @@ suspend inline fun TelegramBot.reply( ) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.replyWithDocument( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, document: InputFile, thumb: InputFile? = null, @@ -606,7 +606,7 @@ suspend inline fun TelegramBot.replyWithDocument( ) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, document: DocumentFile, entities: TextSourcesList, @@ -623,7 +623,7 @@ suspend inline fun TelegramBot.reply( @RiskFeature(rawSendingMediaGroupsWarning) suspend inline fun TelegramBot.replyWithMediaGroup( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, threadId: MessageThreadId? = null, @@ -633,7 +633,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( ) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithPlaylist( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, threadId: MessageThreadId? = null, @@ -643,7 +643,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( ) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithDocuments( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, threadId: MessageThreadId? = null, @@ -653,7 +653,7 @@ suspend inline fun TelegramBot.replyWithDocuments( ) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) suspend inline fun TelegramBot.replyWithGallery( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, threadId: MessageThreadId? = null, @@ -666,7 +666,7 @@ suspend inline fun TelegramBot.replyWithGallery( // Photo suspend inline fun TelegramBot.replyWithPhoto( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, fileId: InputFile, text: String? = null, @@ -679,7 +679,7 @@ suspend inline fun TelegramBot.replyWithPhoto( ) = sendPhoto(toChatId, fileId, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, photo: Photo, text: String? = null, @@ -692,7 +692,7 @@ suspend inline fun TelegramBot.reply( ) = sendPhoto(toChatId, photo, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, photoSize: PhotoSize, text: String? = null, @@ -706,7 +706,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithPhoto( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, fileId: InputFile, entities: TextSourcesList, @@ -718,7 +718,7 @@ suspend inline fun TelegramBot.replyWithPhoto( ) = sendPhoto(toChatId, fileId, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, photo: Photo, entities: TextSourcesList, @@ -730,7 +730,7 @@ suspend inline fun TelegramBot.reply( ) = sendPhoto(toChatId, photo, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, photoSize: PhotoSize, entities: TextSourcesList, @@ -745,7 +745,7 @@ suspend inline fun TelegramBot.reply( // Sticker suspend inline fun TelegramBot.replyWithSticker( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: InputFile, threadId: MessageThreadId? = null, @@ -756,7 +756,7 @@ suspend inline fun TelegramBot.replyWithSticker( ) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: Sticker, threadId: MessageThreadId? = null, @@ -770,7 +770,7 @@ suspend inline fun TelegramBot.reply( // Videos suspend inline fun TelegramBot.replyWithVideo( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, video: InputFile, thumb: InputFile? = null, @@ -787,7 +787,7 @@ suspend inline fun TelegramBot.replyWithVideo( ) = sendVideo(toChatId, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, video: VideoFile, text: String? = null, @@ -800,7 +800,7 @@ suspend inline fun TelegramBot.reply( ) = sendVideo(toChatId, video, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.replyWithVideo( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, video: InputFile, thumb: InputFile? = null, @@ -816,7 +816,7 @@ suspend inline fun TelegramBot.replyWithVideo( ) = sendVideo(toChatId, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, video: VideoFile, entities: TextSourcesList, @@ -831,7 +831,7 @@ suspend inline fun TelegramBot.reply( // VideoNotes suspend inline fun TelegramBot.replyWithVideoNote( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, videoNote: InputFile, thumb: InputFile? = null, @@ -845,7 +845,7 @@ suspend inline fun TelegramBot.replyWithVideoNote( ) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, videoNote: VideoNoteFile, threadId: MessageThreadId? = null, @@ -859,7 +859,7 @@ suspend inline fun TelegramBot.reply( // Voice suspend inline fun TelegramBot.replyWithVoice( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, voice: InputFile, text: String? = null, @@ -873,7 +873,7 @@ suspend inline fun TelegramBot.replyWithVoice( ) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, voice: VoiceFile, text: String? = null, @@ -887,7 +887,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.replyWithVoice( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, voice: InputFile, entities: TextSourcesList, @@ -900,7 +900,7 @@ suspend inline fun TelegramBot.replyWithVoice( ) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, voice: VoiceFile, entities: TextSourcesList, @@ -919,7 +919,7 @@ suspend inline fun TelegramBot.reply( * as a builder for that */ suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, title: String, description: String, @@ -949,7 +949,7 @@ suspend inline fun TelegramBot.reply( // Polls suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, question: String, options: List, @@ -965,7 +965,7 @@ suspend inline fun TelegramBot.reply( ) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, poll: RegularPoll, isClosed: Boolean = false, @@ -982,7 +982,7 @@ suspend inline fun TelegramBot.reply( ) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, question: String, options: List, @@ -1000,7 +1000,7 @@ suspend inline fun TelegramBot.reply( ) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, quizPoll: QuizPoll, isClosed: Boolean = false, @@ -1019,7 +1019,7 @@ suspend inline fun TelegramBot.reply( ) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, question: String, options: List, @@ -1036,7 +1036,7 @@ suspend inline fun TelegramBot.reply( ) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, quizPoll: QuizPoll, entities: TextSourcesList, @@ -1055,7 +1055,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, poll: Poll, isClosed: Boolean = false, @@ -1106,7 +1106,7 @@ suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, fromChatId: ChatIdentifier, messageId: MessageId, @@ -1132,7 +1132,7 @@ suspend inline fun TelegramBot.reply( ) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, fromChat: Chat, messageId: MessageId, @@ -1146,7 +1146,7 @@ suspend inline fun TelegramBot.reply( ) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend inline fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, copy: Message, text: String? = null, @@ -1159,7 +1159,7 @@ suspend inline fun TelegramBot.reply( ) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, content: MessageContent, threadId: MessageThreadId? = null, @@ -1187,7 +1187,7 @@ suspend fun TelegramBot.reply( * @see handleLiveLocation */ suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, @@ -1214,7 +1214,7 @@ suspend fun TelegramBot.reply( @JvmName("replyLiveLocationWithLocationChatIdAndMessageId") @JsName("replyLiveLocationWithLocationChatIdAndMessageId") suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, @@ -1243,7 +1243,7 @@ suspend fun TelegramBot.reply( @JvmName("replyLiveLocationWithLatLongChatIdAndMessageId") @JsName("replyLiveLocationWithLatLongChatIdAndMessageId") suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, @@ -1265,7 +1265,7 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, mediaFile: TelegramMediaFile, threadId: MessageThreadId? = null, @@ -1369,7 +1369,7 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, content: TextedMediaContent, text: String?, @@ -1457,7 +1457,7 @@ suspend fun TelegramBot.reply( } suspend fun TelegramBot.reply( - toChatId: ChatId, + toChatId: IdChatIdentifier, toMessageId: MessageId, content: TextedMediaContent, entities: List, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 87a9dd7129..3a9db0be3a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.actions.* import dev.inmo.tgbotapi.types.chat.Chat import kotlinx.coroutines.* import kotlin.contracts.* -import kotlin.coroutines.coroutineContext private const val refreshTime: MilliSeconds = (botActionActualityTime - 1) * 1000L typealias TelegramBotActionCallback = suspend TelegramBot.() -> T @@ -37,7 +36,7 @@ suspend fun TelegramBot.withAction( @OptIn(ExperimentalContracts::class) suspend fun TelegramBot.withAction( - chatId: ChatId, + chatId: IdChatIdentifier, action: BotAction, block: TelegramBotActionCallback ): T { @@ -67,77 +66,77 @@ suspend fun TelegramBot.withAction( } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withTypingAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withTypingAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, TypingAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withUploadPhotoAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, UploadPhotoAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withRecordVideoAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, RecordVideoAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withUploadVideoAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, UploadVideoAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withRecordVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, RecordVoiceAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withUploadVoiceAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, UploadVoiceAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withUploadDocumentAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, UploadDocumentAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withFindLocationAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, FindLocationAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withRecordVideoNoteAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, RecordVideoNoteAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withUploadVideoNoteAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return withAction(chatId, UploadVideoNoteAction, block) } @OptIn(ExperimentalContracts::class) -suspend fun TelegramBot.withChooseStickerAction(chatId: ChatId, block: TelegramBotActionCallback) : T { +suspend fun TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback) : T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } 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 45df51e091..6f933f48b6 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 @@ -414,7 +414,7 @@ suspend fun TelegramBot.send( * as a builder for that */ suspend fun TelegramBot.send( - chatId: ChatId, + chatId: IdChatIdentifier, title: String, description: String, payload: String, 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 6350bb4792..641bb1a953 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.VoiceFile +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -22,7 +23,7 @@ suspend fun TelegramBot.sendVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -54,7 +55,7 @@ suspend fun TelegramBot.sendVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -71,7 +72,7 @@ suspend fun TelegramBot.sendVoice( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -90,7 +91,7 @@ suspend fun TelegramBot.sendVoice( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -108,7 +109,7 @@ suspend inline fun TelegramBot.sendVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -138,7 +139,7 @@ suspend inline fun TelegramBot.sendVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -154,7 +155,7 @@ suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: VoiceFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -171,7 +172,7 @@ suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: VoiceFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 f6e4e4371f..8a0888298d 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 @@ -13,7 +13,7 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency * as a builder for that */ suspend fun TelegramBot.sendInvoice( - chatId: ChatId, + chatId: IdChatIdentifier, title: String, description: String, payload: String, @@ -31,7 +31,7 @@ suspend fun TelegramBot.sendInvoice( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 71d3202fd4..e297e56394 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.polls.* +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -24,7 +25,7 @@ suspend fun TelegramBot.sendRegularPoll( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -48,7 +49,7 @@ suspend fun TelegramBot.sendRegularPoll( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -68,7 +69,7 @@ suspend fun TelegramBot.sendRegularPoll( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -91,7 +92,7 @@ suspend fun TelegramBot.sendRegularPoll( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -116,7 +117,7 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -142,7 +143,7 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -167,7 +168,7 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -192,7 +193,7 @@ suspend fun TelegramBot.sendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -216,7 +217,7 @@ suspend inline fun TelegramBot.sendQuizPoll( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -241,7 +242,7 @@ suspend inline fun TelegramBot.sendQuizPoll( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -265,7 +266,7 @@ suspend inline fun TelegramBot.sendQuizPoll( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -289,7 +290,7 @@ suspend inline fun TelegramBot.sendQuizPoll( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatSenderRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatSenderRequest.kt index 5e8fb31d1f..0d28e820de 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatSenderRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatSenderRequest.kt @@ -2,9 +2,8 @@ package dev.inmo.tgbotapi.requests.chat.abstracts import dev.inmo.tgbotapi.abstracts.types.ChatRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest -import dev.inmo.tgbotapi.types.ChatId -import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.IdChatIdentifier interface ChatSenderRequest : ChatRequest, SimpleRequest { - val senderChatId: ChatId + val senderChatId: IdChatIdentifier } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChat.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChat.kt index 00d0b359e5..913c083500 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChat.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChat.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.chat.get import dev.inmo.tgbotapi.abstracts.types.ChatRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.ChatIdWithThreadId import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.ExtendedChatSerializer import dev.inmo.tgbotapi.types.chat.ExtendedChat @@ -14,8 +15,12 @@ data class GetChat( override val chatId: ChatIdentifier ): ChatRequest, SimpleRequest { override fun method(): String = "getChat" - override val resultDeserializer: DeserializationStrategy - get() = ExtendedChatSerializer + @Transient + override val resultDeserializer: DeserializationStrategy = if (chatId is ChatIdWithThreadId) { + ExtendedChatSerializer.BasedOnForumThread(chatId.threadId) + } else { + ExtendedChatSerializer + } override val requestSerializer: SerializationStrategy<*> get() = serializer() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatSenderChat.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatSenderChat.kt index 6587275422..1832c60fae 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatSenderChat.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatSenderChat.kt @@ -13,7 +13,7 @@ data class BanChatSenderChat( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(senderChatIdField) - override val senderChatId: ChatId + override val senderChatId: IdChatIdentifier ) : ChatSenderRequest { override fun method(): String = "banChatSenderChat" override val resultDeserializer: DeserializationStrategy diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/UnbanChatSenderChat.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/UnbanChatSenderChat.kt index 8b43d5f038..324b92a44a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/UnbanChatSenderChat.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/UnbanChatSenderChat.kt @@ -13,7 +13,7 @@ data class UnbanChatSenderChat( @SerialName(chatIdField) override val chatId: ChatIdentifier, @SerialName(senderChatIdField) - override val senderChatId: ChatId + override val senderChatId: IdChatIdentifier ) : ChatSenderRequest { override fun method(): String = "unbanChatSenderChat" override val resultDeserializer: DeserializationStrategy diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/GetGameHighScoresByChat.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/GetGameHighScoresByChat.kt index 1f751a54f2..1d6af75973 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/GetGameHighScoresByChat.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/GetGameHighScoresByChat.kt @@ -10,7 +10,7 @@ data class GetGameHighScoresByChat ( @SerialName(userIdField) override val userId: UserId, @SerialName(chatIdField) - override val chatId: ChatId, + override val chatId: IdChatIdentifier, @SerialName(messageIdField) override val messageId: MessageId ) : GetGameHighScores, MessageAction { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/SetGameScoreByChatId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/SetGameScoreByChatId.kt index 3b1b92155c..cb2cf64cb6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/SetGameScoreByChatId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/games/SetGameScoreByChatId.kt @@ -12,7 +12,7 @@ data class SetGameScoreByChatId ( @SerialName(scoreField) override val score: Long, @SerialName(chatIdField) - override val chatId: ChatId, + override val chatId: IdChatIdentifier, @SerialName(messageIdField) override val messageId: MessageId, @SerialName(forceField) 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 6273f29443..010ef191b8 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 @@ -22,7 +22,7 @@ private val invoiceMessageSerializer: DeserializationStrategy) : IdChatIdentifier { + override val chatId: Identifier + get() = chatIdWithThreadId.first + override val threadId: MessageThreadId + get() = chatIdWithThreadId.second + + constructor(chatId: Identifier, threadId: MessageThreadId): this(chatId to threadId) +} + +val ChatIdentifier.threadId: MessageThreadId? + get() = (this as? IdChatIdentifier) ?.threadId /** * https://core.telegram.org/bots/api#formatting-options @@ -39,16 +64,16 @@ val UserId.userLink: String val User.link: String get() = id.userLink -typealias UserId = ChatId +typealias UserId = IdChatIdentifier -fun Identifier.toChatId(): ChatId = ChatId(this) -fun Int.toChatId(): ChatId = toLong().toChatId() -fun Byte.toChatId(): ChatId = toLong().toChatId() +fun Identifier.toChatId(): IdChatIdentifier = ChatId(this) +fun Int.toChatId(): IdChatIdentifier = toLong().toChatId() +fun Byte.toChatId(): IdChatIdentifier = toLong().toChatId() @Serializable(ChatIdentifierSerializer::class) data class Username( val username: String -) : ChatIdentifier() { +) : ChatIdentifier { val usernameWithoutAt get() = username.dropWhile { it == '@' } @@ -80,7 +105,7 @@ object ChatIdentifierSerializer : KSerializer { override fun serialize(encoder: Encoder, value: ChatIdentifier) { when (value) { - is ChatId -> encoder.encodeLong(value.chatId) + is IdChatIdentifier -> encoder.encodeLong(value.chatId) is Username -> encoder.encodeString(value.username) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/RequestError.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/RequestError.kt index 4a53843390..4f1bc24aff 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/RequestError.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/RequestError.kt @@ -14,7 +14,7 @@ data class RetryAfterError( } data class MigrateChatId( - val newChatId: ChatId + val newChatId: IdChatIdentifier ) : RequestError() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ResponseParametersRaw.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ResponseParametersRaw.kt index 71c837a1e9..f1e789b99f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ResponseParametersRaw.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ResponseParametersRaw.kt @@ -6,7 +6,7 @@ import kotlinx.serialization.* @Serializable data class ResponseParametersRaw( @SerialName("migrate_to_chat_id") - private val migrateToChatId: ChatId? = null, + private val migrateToChatId: IdChatIdentifier? = null, @SerialName("retry_after") private val retryAfter: Seconds? = null ) { 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 258604a209..41d015e32a 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 @@ -49,5 +49,5 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat { @Serializable(PreviewChatSerializer::class) @ClassCastsIncluded sealed interface Chat { - val id: ChatId + val id: IdChatIdentifier } 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 c211b909ba..2d2c175153 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 @@ -93,9 +93,9 @@ object PreviewChatSerializer : KSerializer { } @RiskFeature -object ExtendedChatSerializer : KSerializer { +sealed class ExtendedChatSerializer : KSerializer { @OptIn(InternalSerializationApi::class) - override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) + override val descriptor: SerialDescriptor = buildSerialDescriptor("ExtendedChatSerializer", PolymorphicKind.OPEN) override fun deserialize(decoder: Decoder): ExtendedChat { val decodedJson = JsonObject.serializer().deserialize(decoder) @@ -131,6 +131,22 @@ object ExtendedChatSerializer : KSerializer { is UnknownExtendedChat -> JsonObject.serializer().serialize(encoder, value.rawJson) } } + + class BasedOnForumThread(private val threadId: MessageThreadId) : ExtendedChatSerializer() { + override fun deserialize(decoder: Decoder): ExtendedChat { + return super.deserialize(decoder).let { + if (it is ExtendedForumChatImpl) { + it.copy( + id = (it.id as? ChatIdWithThreadId) ?: ChatIdWithThreadId(it.id.chatId, threadId) + ) + } else { + it + } + } + } + } + + companion object : ExtendedChatSerializer() } @RiskFeature 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 719d28c025..2ab307b473 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.json.JsonObject @Serializable data class ExtendedChannelChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String, @SerialName(usernameField) @@ -27,13 +27,13 @@ data class ExtendedChannelChatImpl( @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) override val pinnedMessage: Message? = null, @SerialName(linkedChatIdField) - override val linkedGroupChatId: ChatId? = null + override val linkedGroupChatId: IdChatIdentifier? = null ) : ExtendedChannelChat @Serializable data class ExtendedGroupChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String, @SerialName(photoField) @@ -52,7 +52,7 @@ data class ExtendedGroupChatImpl( @Serializable data class ExtendedPrivateChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(photoField) override val chatPhoto: ChatPhoto? = null, @SerialName(usernameField) @@ -78,7 +78,7 @@ typealias ExtendedUser = ExtendedPrivateChatImpl @Serializable data class ExtendedSupergroupChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String, @SerialName(usernameField) @@ -103,7 +103,7 @@ data class ExtendedSupergroupChatImpl( @SerialName(canSetStickerSetField) override val canSetStickerSet: Boolean = false, @SerialName(linkedChatIdField) - override val linkedChannelChatId: ChatId? = null, + override val linkedChannelChatId: IdChatIdentifier? = null, @SerialName(locationField) override val location: ChatLocation? = null, @SerialName(joinToSendMessagesField) @@ -115,7 +115,7 @@ data class ExtendedSupergroupChatImpl( @Serializable data class ExtendedForumChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String, @SerialName(usernameField) @@ -140,7 +140,7 @@ data class ExtendedForumChatImpl( @SerialName(canSetStickerSetField) override val canSetStickerSet: Boolean = false, @SerialName(linkedChatIdField) - override val linkedChannelChatId: ChatId? = null, + override val linkedChannelChatId: IdChatIdentifier? = null, @SerialName(locationField) override val location: ChatLocation? = null, @SerialName(joinToSendMessagesField) @@ -170,7 +170,7 @@ data class ExtendedBot( } data class UnknownExtendedChat( - override val id: ChatId, + override val id: IdChatIdentifier, val raw: String, val rawJson: JsonObject ) : ExtendedChat { 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 0f68e43802..f3e5cf61ca 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable @Serializable(ExtendedChatSerializer::class) sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername { - val linkedGroupChatId: ChatId? + val linkedGroupChatId: IdChatIdentifier? } @Serializable(ExtendedChatSerializer::class) @@ -38,7 +38,7 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext val slowModeDelay: Long? val stickerSetName: StickerSetName? val canSetStickerSet: Boolean - val linkedChannelChatId: ChatId? + val linkedChannelChatId: IdChatIdentifier? val location: ChatLocation? /** @@ -53,7 +53,7 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext } @Serializable(ExtendedChatSerializer::class) -sealed interface ExtendedForumChat : ExtendedSupergroupChat +sealed interface ExtendedForumChat : ExtendedSupergroupChat, ForumChat @Serializable(ExtendedChatSerializer::class) sealed interface ExtendedChat : Chat { 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 3af9d12774..5bd1fc3037 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class GroupChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String ) : GroupChat @@ -18,7 +18,7 @@ data class GroupChatImpl( @Serializable data class PrivateChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(usernameField) override val username: Username? = null, @SerialName(firstNameField) @@ -30,7 +30,7 @@ data class PrivateChatImpl( @Serializable data class SupergroupChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String, @SerialName(usernameField) @@ -40,7 +40,7 @@ data class SupergroupChatImpl( @Serializable data class ForumChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String, @SerialName(usernameField) @@ -50,7 +50,7 @@ data class ForumChatImpl( @Serializable data class ChannelChatImpl( @SerialName(idField) - override val id: ChatId, + override val id: IdChatIdentifier, @SerialName(titleField) override val title: String, @SerialName(usernameField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/UnknownChatType.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/UnknownChatType.kt index 5e9e9f4f01..87001ee2ca 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/UnknownChatType.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/UnknownChatType.kt @@ -1,10 +1,10 @@ package dev.inmo.tgbotapi.types.chat -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import kotlinx.serialization.json.JsonObject data class UnknownChatType( - override val id: ChatId, + override val id: IdChatIdentifier, val raw: String, val rawJson: JsonObject ) : Chat diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/GroupChatCreated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/GroupChatCreated.kt index 4ac21f5771..ecf55156f5 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/GroupChatCreated.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/GroupChatCreated.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent class GroupChatCreated( - val migratedTo: ChatId? + val migratedTo: IdChatIdentifier? ): GroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroup.kt index 276deeb0e1..39a2086132 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroup.kt @@ -1,11 +1,11 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent /** * This event is sent when a group is converted to a supergroup. */ data class MigratedToSupergroup( - val migratedFrom: ChatId + val migratedFrom: IdChatIdentifier ): SupergroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/SupergroupChatCreated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/SupergroupChatCreated.kt index 31830380cb..c3cc3a95c7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/SupergroupChatCreated.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/SupergroupChatCreated.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent class SupergroupChatCreated( - val migratedFrom: ChatId? + val migratedFrom: IdChatIdentifier? ): SupergroupEvent 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 2e63c28a71..5a98fdf863 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 @@ -81,8 +81,8 @@ internal data class RawMessage( private val group_chat_created: Boolean = false, private val supergroup_chat_created: Boolean = false, private val channel_chat_created: Boolean = false, - private val migrate_to_chat_id: ChatId? = null, - private val migrate_from_chat_id: ChatId? = null, + private val migrate_to_chat_id: IdChatIdentifier? = null, + private val migrate_from_chat_id: IdChatIdentifier? = null, private val pinned_message: RawMessage? = null, private val invoice: Invoice? = null, private val dice: Dice? = null, @@ -286,9 +286,17 @@ internal data class RawMessage( media_group_id ) is ForumChat -> if (messageThreadId != null) { + val chatId = ChatIdWithThreadId( + chat.id.chatId, + messageThreadId + ) + val actualForumChat = when (chat) { + is ExtendedForumChatImpl -> chat.copy(id = chatId) + is ForumChatImpl -> chat.copy(id = chatId) + } when (sender_chat) { is ChannelChat -> FromChannelForumContentMessageImpl( - chat, + actualForumChat, sender_chat, messageId, messageThreadId, @@ -304,7 +312,7 @@ internal data class RawMessage( media_group_id ) is GroupChat -> AnonymousForumContentMessageImpl( - chat, + actualForumChat, messageId, messageThreadId, date.asDate, @@ -319,7 +327,7 @@ internal data class RawMessage( media_group_id ) null -> CommonForumContentMessageImpl( - chat, + actualForumChat, messageId, messageThreadId, from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt index 5d796cab28..d74d88de2d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt @@ -1,19 +1,18 @@ package dev.inmo.tgbotapi.utils.extensions -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.utils.extensions.ChatIdWithThreadId.ByPair import kotlinx.serialization.Serializable import kotlin.Pair import kotlin.jvm.JvmInline /** - * Union to keep both [ChatId] and optionally [MessageThreadId] as an identifier of target for messages sending and + * Union to keep both [IdChatIdentifier] and optionally [MessageThreadId] as an identifier of target for messages sending and * other information */ sealed interface ChatIdWithThreadId { - val chatId: ChatId + val chatId: IdChatIdentifier val threadId: MessageThreadId? /** @@ -23,14 +22,14 @@ sealed interface ChatIdWithThreadId { value class ByMessage( val sourceMessage: Message ) : ChatIdWithThreadId { - override val chatId: ChatId + override val chatId: IdChatIdentifier get() = sourceMessage.chat.id override val threadId: MessageThreadId? get() = sourceMessage.threadIdOrNull } /** - * [Serializable] variant of [ChatIdWithThreadId] based on [Pair] of target [ChatId] and [MessageThreadId] + * [Serializable] variant of [ChatIdWithThreadId] based on [Pair] of target [IdChatIdentifier] and [MessageThreadId] * * @see invoke * @see serializable @@ -38,9 +37,9 @@ sealed interface ChatIdWithThreadId { @Serializable @JvmInline value class ByPair( - val pair: Pair + val pair: Pair ) : ChatIdWithThreadId { - override val chatId: ChatId + override val chatId: IdChatIdentifier get() = pair.first override val threadId: MessageThreadId? get() = pair.second @@ -61,7 +60,7 @@ sealed interface ChatIdWithThreadId { /** * Creates [ByPair] variant of [ChatIdWithThreadId] using incoming [pair] */ - inline fun serializable(pair: Pair) = ByPair(pair) + inline fun serializable(pair: Pair) = ByPair(pair) } } /** diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt index 4c243155a3..e771587cfc 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MigratedToSupergroupTest.kt @@ -3,13 +3,11 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate import dev.inmo.tgbotapi.extensions.utils.asMigratedToSupergroup -import dev.inmo.tgbotapi.extensions.utils.asSupergroupChatCreated import dev.inmo.tgbotapi.extensions.utils.asSupergroupEventMessage -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.update.abstracts.UpdateDeserializationStrategy import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.test.assertIs import kotlin.test.fail @@ -47,6 +45,6 @@ class MigratedToSupergroupTest { val data = message.data.asSupergroupEventMessage() ?: fail("message should be of SupergroupEventMessage subtype") val event = data.chatEvent.asMigratedToSupergroup() ?: fail("event should be of SupergroupChatCreated subtype") - assertEquals(ChatId(57005), event.migratedFrom) + assertEquals(IdChatIdentifier(57005), event.migratedFrom) } } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt index f2885049cf..2964fe0f57 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Message.kt @@ -160,10 +160,10 @@ inline val Message.supergroup_chat_created: Boolean inline val Message.channel_chat_created: Boolean get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated @RiskFeature(RawFieldsUsageWarning) -inline val Message.migrate_to_chat_id: ChatId? +inline val Message.migrate_to_chat_id: IdChatIdentifier? get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo @RiskFeature(RawFieldsUsageWarning) -inline val Message.migrate_from_chat_id: ChatId? +inline val Message.migrate_from_chat_id: IdChatIdentifier? get() = asChatEventMessage() ?.chatEvent ?.let { it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt index a86f1c8a41..493870f3e0 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt @@ -200,7 +200,7 @@ infix fun String.mention(parseMode: ParseMode): String = when (parseMode) { is MarkdownV2 -> mentionMarkdownV2() } -infix fun Pair.mention(parseMode: ParseMode): String = when (parseMode) { +infix fun Pair.mention(parseMode: ParseMode): String = when (parseMode) { is HTML -> first.textMentionHTML(second) is Markdown -> first.textMentionMarkdown(second) is MarkdownV2 -> first.textMentionMarkdownV2(second) 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 bf415ce45e..8c841836f5 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 @@ -1,16 +1,16 @@ package dev.inmo.tgbotapi.extensions.utils.updates -import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter /** - * [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] + * [Flow.filter] incoming [BaseMessageUpdate]s by their [IdChatIdentifier] */ -fun Flow.filterBaseMessageUpdatesByChatId(chatId: ChatId): Flow = filter { it.data.chat.id == chatId } +fun Flow.filterBaseMessageUpdatesByChatId(chatId: IdChatIdentifier): Flow = filter { it.data.chat.id == chatId } /** - * [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat] + * [Flow.filter] incoming [BaseMessageUpdate]s by their [IdChatIdentifier] using [Chat.id] of [chat] */ fun Flow.filterBaseMessageUpdatesByChat(chat: Chat): Flow = filterBaseMessageUpdatesByChatId(chat.id) From 925c4dae6cc1c5a66dc0f9103311cc9f2a910571 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 16:24:20 +0600 Subject: [PATCH 08/10] ChatIdWithThreadId, all chats ids now value classes, update chats ids hierarchy --- CHANGELOG.md | 8 + .../tgbotapi/extensions/api/ForwardMessage.kt | 13 +- .../extensions/api/LiveFlowLocation.kt | 6 +- .../extensions/api/LiveLocationProvider.kt | 13 +- .../extensions/api/send/CopyMessage.kt | 41 ++-- .../api/send/RepliesWithChatsAndMessages.kt | 136 ++++++------- .../extensions/api/send/SendContact.kt | 8 +- .../tgbotapi/extensions/api/send/SendDice.kt | 5 +- .../extensions/api/send/SendLiveLocation.kt | 16 +- .../extensions/api/send/SendMessage.kt | 32 +-- .../extensions/api/send/SendStaticLocation.kt | 17 +- .../tgbotapi/extensions/api/send/SendVenue.kt | 12 +- .../tgbotapi/extensions/api/send/Sends.kt | 185 +++++++++--------- .../extensions/api/send/games/SendGame.kt | 9 +- .../api/send/media/SendAnimation.kt | 17 +- .../extensions/api/send/media/SendAudio.kt | 17 +- .../extensions/api/send/media/SendDocument.kt | 17 +- .../api/send/media/SendMediaGroup.kt | 33 ++-- .../extensions/api/send/media/SendPhoto.kt | 25 +-- .../extensions/api/send/media/SendSticker.kt | 9 +- .../extensions/api/send/media/SendVideo.kt | 17 +- .../api/send/media/SendVideoNote.kt | 9 +- .../extensions/api/send/media/SendVoice.kt | 8 +- .../api/send/payments/SendInvoice.kt | 3 +- .../inmo/tgbotapi/requests/ForwardMessage.kt | 2 +- .../tgbotapi/requests/send/CopyMessage.kt | 10 +- .../tgbotapi/requests/send/SendContact.kt | 6 +- .../tgbotapi/requests/send/SendLocation.kt | 8 +- .../tgbotapi/requests/send/SendMessage.kt | 6 +- .../inmo/tgbotapi/requests/send/SendVenue.kt | 6 +- .../tgbotapi/requests/send/games/SendGame.kt | 2 +- .../requests/send/media/SendAnimation.kt | 6 +- .../tgbotapi/requests/send/media/SendAudio.kt | 6 +- .../requests/send/media/SendDocument.kt | 6 +- .../requests/send/media/SendMediaGroup.kt | 10 +- .../tgbotapi/requests/send/media/SendPhoto.kt | 6 +- .../requests/send/media/SendSticker.kt | 4 +- .../tgbotapi/requests/send/media/SendVideo.kt | 6 +- .../requests/send/media/SendVideoNote.kt | 4 +- .../tgbotapi/requests/send/media/SendVoice.kt | 6 +- .../tgbotapi/requests/send/polls/SendPoll.kt | 16 +- .../dev/inmo/tgbotapi/types/ChatIdentifier.kt | 2 + .../dev/inmo/tgbotapi/types/chat/Abstracts.kt | 4 +- .../dev/inmo/tgbotapi/types/chat/Extended.kt | 6 +- .../dev/inmo/tgbotapi/types/chat/Impls.kt | 6 +- .../types/message/content/Abstracts.kt | 3 +- .../extensions/ChatIdentifierWithThreadId.kt | 76 ------- .../extensions/utils/ClassCastsNew.kt | 39 ++++ 48 files changed, 445 insertions(+), 457 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index ce272c5b40..84309e4124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # TelegramBotAPI changelog +## 4.1.0 + +* `Core`: + * All the chats identifiers has been rewritten as value classes + * New chat identifier: `ChatIdWithThreadId` + * `RawMessage` will create `ChatIdWithThreadId` chat id under the hood by default + * All the methods which potentially using `threadId` will try to take it from `chatId` + ## 4.0.0 **!!! THIS UPDATE CONTAINS FULL REWORK OF MEDIA GROUPS FUNCTIONALITY !!!** 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 025419a86c..4893eb13c8 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 @@ -7,12 +7,13 @@ import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.threadId suspend fun TelegramBot.forwardMessage( fromChatId: ChatIdentifier, toChatId: ChatIdentifier, messageId: MessageId, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false ) = execute( @@ -23,7 +24,7 @@ suspend fun TelegramBot.forwardMessage( fromChat: Chat, toChatId: ChatIdentifier, messageId: MessageId, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false ) = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent) @@ -32,7 +33,7 @@ suspend fun TelegramBot.forwardMessage( fromChatId: ChatIdentifier, toChat: Chat, messageId: MessageId, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false ) = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent) @@ -41,7 +42,7 @@ suspend fun TelegramBot.forwardMessage( fromChat: Chat, toChat: Chat, messageId: MessageId, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false ) = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent) @@ -49,7 +50,7 @@ suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage( toChatId: ChatIdentifier, message: Message, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false ) = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent) @@ -57,7 +58,7 @@ suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage( toChat: Chat, message: Message, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false ) = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent) 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 76d59ce25e..aa168e30d1 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 @@ -41,7 +41,7 @@ suspend fun TelegramBot.handleLiveLocation( chatId: ChatIdentifier, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -98,7 +98,7 @@ suspend fun TelegramBot.handleLiveLocation( chatId: ChatIdentifier, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -135,7 +135,7 @@ suspend fun TelegramBot.handleLiveLocation( chatId: ChatIdentifier, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 9818e26730..2831be8eaa 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 @@ -15,6 +15,7 @@ import dev.inmo.tgbotapi.types.location.StaticLocation import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.LocationContent +import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull import io.ktor.utils.io.core.Closeable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @@ -90,7 +91,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -137,7 +138,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -172,7 +173,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -207,7 +208,7 @@ suspend fun TelegramBot.startLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -243,7 +244,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = to.threadIdOrNull, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -277,7 +278,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation( initHorizontalAccuracy: Meters? = null, initHeading: Degrees? = null, initProximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = to.threadIdOrNull, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt index c192394f92..40ee1f326d 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 @@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -21,7 +22,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -53,7 +54,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -71,7 +72,7 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -89,7 +90,7 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -107,7 +108,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -137,7 +138,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -154,7 +155,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChat: Chat, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -171,7 +172,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, toChat: Chat, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -188,7 +189,7 @@ suspend inline fun TelegramBot.copyMessage( message: Message, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -205,7 +206,7 @@ suspend inline fun TelegramBot.copyMessage( message: Message, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -221,7 +222,7 @@ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, message: Message, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -237,7 +238,7 @@ suspend inline fun TelegramBot.copyMessage( toChat: Chat, message: Message, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -255,7 +256,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -287,7 +288,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -317,7 +318,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -347,7 +348,7 @@ suspend inline fun TelegramBot.copyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -377,7 +378,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -407,7 +408,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, messageId: MessageId, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -435,7 +436,7 @@ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -463,7 +464,7 @@ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, messageId: MessageId, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 87e90fe760..d81c42fbc3 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,7 +47,7 @@ suspend inline fun TelegramBot.reply( phoneNumber: String, firstName: String, lastName: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -73,7 +73,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, contact: Contact, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -100,7 +100,7 @@ suspend inline fun TelegramBot.replyWithDice( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -115,7 +115,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, animationType: DiceAnimationType, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -134,7 +134,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -159,7 +159,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, location: StaticLocation, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -188,7 +188,7 @@ suspend inline fun TelegramBot.reply( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -215,7 +215,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -241,7 +241,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -258,7 +258,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, separator: String, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -284,7 +284,7 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -317,7 +317,7 @@ suspend inline fun TelegramBot.reply( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -344,7 +344,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, venue: Venue, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -367,7 +367,7 @@ suspend inline fun TelegramBot.replyWithGame( toChatId: IdChatIdentifier, toMessageId: MessageId, gameShortName: String, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -380,7 +380,7 @@ suspend inline fun TelegramBot.replyWithGame( toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -393,7 +393,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, game: Game, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -413,7 +413,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -444,7 +444,7 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -460,7 +460,7 @@ suspend inline fun TelegramBot.replyWithAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -489,7 +489,7 @@ suspend inline fun TelegramBot.reply( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -509,7 +509,7 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -523,7 +523,7 @@ suspend inline fun TelegramBot.reply( text: String? = null, parseMode: ParseMode? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -539,7 +539,7 @@ suspend inline fun TelegramBot.replyWithAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -552,7 +552,7 @@ suspend inline fun TelegramBot.reply( audio: AudioFile, entities: TextSourcesList, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -569,7 +569,7 @@ suspend inline fun TelegramBot.replyWithDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -583,7 +583,7 @@ suspend inline fun TelegramBot.reply( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -597,7 +597,7 @@ suspend inline fun TelegramBot.replyWithDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -610,7 +610,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, document: DocumentFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -626,7 +626,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -636,7 +636,7 @@ suspend inline fun TelegramBot.replyWithPlaylist( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -646,7 +646,7 @@ suspend inline fun TelegramBot.replyWithDocuments( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -656,7 +656,7 @@ suspend inline fun TelegramBot.replyWithGallery( toChatId: IdChatIdentifier, toMessageId: MessageId, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -671,7 +671,7 @@ suspend inline fun TelegramBot.replyWithPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -684,7 +684,7 @@ suspend inline fun TelegramBot.reply( photo: Photo, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -697,7 +697,7 @@ suspend inline fun TelegramBot.reply( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -710,7 +710,7 @@ suspend inline fun TelegramBot.replyWithPhoto( toMessageId: MessageId, fileId: InputFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -722,7 +722,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, photo: Photo, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -734,7 +734,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, photoSize: PhotoSize, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -748,7 +748,7 @@ suspend inline fun TelegramBot.replyWithSticker( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: InputFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -759,7 +759,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, sticker: Sticker, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -779,7 +779,7 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -792,7 +792,7 @@ suspend inline fun TelegramBot.reply( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -808,7 +808,7 @@ suspend inline fun TelegramBot.replyWithVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -820,7 +820,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, video: VideoFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -837,7 +837,7 @@ suspend inline fun TelegramBot.replyWithVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -848,7 +848,7 @@ suspend inline fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, videoNote: VideoNoteFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -865,7 +865,7 @@ suspend inline fun TelegramBot.replyWithVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -878,7 +878,7 @@ suspend inline fun TelegramBot.reply( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -892,7 +892,7 @@ suspend inline fun TelegramBot.replyWithVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -904,7 +904,7 @@ suspend inline fun TelegramBot.reply( toMessageId: MessageId, voice: VoiceFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -938,7 +938,7 @@ suspend inline fun TelegramBot.reply( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -957,7 +957,7 @@ suspend inline fun TelegramBot.reply( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -974,7 +974,7 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -992,7 +992,7 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1011,7 +1011,7 @@ suspend inline fun TelegramBot.reply( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1028,7 +1028,7 @@ suspend inline fun TelegramBot.reply( isAnonymous: Boolean = true, isClosed: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1046,7 +1046,7 @@ 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, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1063,7 +1063,7 @@ suspend inline fun TelegramBot.reply( options: List = poll.options.map { it.text }, isAnonymous: Boolean = poll.isAnonymous, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1112,7 +1112,7 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1138,7 +1138,7 @@ suspend inline fun TelegramBot.reply( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1151,7 +1151,7 @@ suspend inline fun TelegramBot.reply( copy: Message, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1162,7 +1162,7 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, content: MessageContent, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1191,7 +1191,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -1218,7 +1218,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -1247,7 +1247,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, locationsFlow: Flow>, liveTimeMillis: Long = defaultLivePeriodDelayMillis, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null @@ -1268,7 +1268,7 @@ suspend fun TelegramBot.reply( toChatId: IdChatIdentifier, toMessageId: MessageId, mediaFile: TelegramMediaFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1374,7 +1374,7 @@ suspend fun TelegramBot.reply( content: TextedMediaContent, text: String?, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -1461,7 +1461,7 @@ suspend fun TelegramBot.reply( toMessageId: MessageId, content: TextedMediaContent, entities: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, 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 b3ffe9138b..adaf50afa8 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,7 +15,7 @@ suspend fun TelegramBot.sendContact( phoneNumber: String, firstName: String, lastName: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -34,7 +34,7 @@ suspend fun TelegramBot.sendContact( suspend fun TelegramBot.sendContact( chatId: ChatIdentifier, contact: Contact, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -55,7 +55,7 @@ suspend fun TelegramBot.sendContact( phoneNumber: String, firstName: String, lastName: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -72,7 +72,7 @@ suspend fun TelegramBot.sendContact( suspend fun TelegramBot.sendContact( chat: Chat, contact: Contact, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 c5d7ce3cc9..e7094f1400 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 @@ -8,6 +8,7 @@ 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 +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -16,7 +17,7 @@ import dev.inmo.tgbotapi.types.dice.DiceAnimationType suspend fun TelegramBot.sendDice( chatId: ChatIdentifier, animationType: DiceAnimationType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -33,7 +34,7 @@ suspend fun TelegramBot.sendDice( suspend fun TelegramBot.sendDice( chat: Chat, animationType: DiceAnimationType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 d5666fd3b2..674b61d276 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,7 +19,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -54,7 +54,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -88,7 +88,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -121,7 +121,7 @@ suspend fun TelegramBot.sendLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -155,7 +155,7 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -174,7 +174,7 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -194,7 +194,7 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -213,7 +213,7 @@ suspend fun TelegramBot.sendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 0c267d18cd..9bdc7b1cbb 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,7 +20,7 @@ suspend fun TelegramBot.sendMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -50,7 +50,7 @@ suspend fun TelegramBot.sendTextMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -69,7 +69,7 @@ suspend fun TelegramBot.sendTextMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -87,7 +87,7 @@ suspend fun TelegramBot.sendMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -103,7 +103,7 @@ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -121,7 +121,7 @@ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -139,7 +139,7 @@ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, separator: String, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -156,7 +156,7 @@ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -174,7 +174,7 @@ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -192,7 +192,7 @@ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, separator: String, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -209,7 +209,7 @@ suspend fun TelegramBot.sendMessage( chat: Chat, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -225,7 +225,7 @@ suspend fun TelegramBot.sendMessage( chat: Chat, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -243,7 +243,7 @@ suspend fun TelegramBot.sendMessage( chat: Chat, separator: String, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -261,7 +261,7 @@ suspend fun TelegramBot.sendTextMessage( chat: Chat, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -277,7 +277,7 @@ suspend fun TelegramBot.sendTextMessage( chat: Chat, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -295,7 +295,7 @@ suspend fun TelegramBot.sendTextMessage( chat: Chat, separator: String, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 6f545ec428..d201c7cb42 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 @@ -8,6 +8,7 @@ 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 +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -17,7 +18,7 @@ suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -44,7 +45,7 @@ suspend fun TelegramBot.sendLocation( suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, location: Location, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -70,7 +71,7 @@ suspend fun TelegramBot.sendLocation( chat: Chat, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -95,7 +96,7 @@ suspend fun TelegramBot.sendLocation( suspend fun TelegramBot.sendLocation( chat: Chat, location: Location, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -121,7 +122,7 @@ suspend fun TelegramBot.sendStaticLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -136,7 +137,7 @@ suspend fun TelegramBot.sendStaticLocation( suspend fun TelegramBot.sendStaticLocation( chatId: ChatIdentifier, location: Location, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -152,7 +153,7 @@ suspend fun TelegramBot.sendStaticLocation( chat: Chat, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -167,7 +168,7 @@ suspend fun TelegramBot.sendStaticLocation( suspend fun TelegramBot.sendStaticLocation( chat: Chat, location: Location, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, 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 4549d6afcf..1025ac993f 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,7 +22,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -62,7 +62,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -99,7 +99,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -136,7 +136,7 @@ suspend fun TelegramBot.sendVenue( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -167,7 +167,7 @@ suspend fun TelegramBot.sendVenue( suspend fun TelegramBot.sendVenue( chatId: ChatIdentifier, venue: Venue, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -193,7 +193,7 @@ suspend fun TelegramBot.sendVenue( suspend fun TelegramBot.sendVenue( chat: Chat, venue: Venue, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 6f933f48b6..45cdac1c67 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 @@ -59,7 +59,7 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -80,7 +80,7 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -100,7 +100,7 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -120,7 +120,7 @@ suspend fun TelegramBot.send( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -139,7 +139,7 @@ suspend fun TelegramBot.send( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -158,7 +158,7 @@ suspend fun TelegramBot.send( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -176,7 +176,7 @@ suspend inline fun TelegramBot.send( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -194,7 +194,7 @@ suspend inline fun TelegramBot.send( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -212,7 +212,7 @@ suspend fun TelegramBot.send( phoneNumber: String, firstName: String, lastName: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -228,7 +228,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, contact: Contact, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -246,7 +246,7 @@ suspend fun TelegramBot.send( phoneNumber: String, firstName: String, lastName: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -262,7 +262,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, contact: Contact, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -278,7 +278,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, animationType: DiceAnimationType, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -294,7 +294,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, animationType: DiceAnimationType, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -312,7 +312,7 @@ suspend fun TelegramBot.send( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -331,7 +331,7 @@ suspend fun TelegramBot.send( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -349,7 +349,7 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, document: DocumentFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -367,7 +367,7 @@ suspend inline fun TelegramBot.send( chat: Chat, document: DocumentFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -384,7 +384,7 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, game: Game, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -400,7 +400,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, game: Game, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -432,7 +432,7 @@ suspend fun TelegramBot.send( shouldSendPhoneNumberToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false, priceDependOnShipAddress: Boolean = false, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -464,13 +464,12 @@ 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, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(user, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) /** * Will execute [sendStaticLocation] request @@ -481,7 +480,7 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -497,7 +496,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, location: StaticLocation, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -514,7 +513,7 @@ suspend fun TelegramBot.send( chat: Chat, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -530,7 +529,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, location: StaticLocation, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, @@ -548,7 +547,7 @@ suspend fun TelegramBot.send( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -566,7 +565,7 @@ suspend fun TelegramBot.send( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -583,7 +582,7 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -599,7 +598,7 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -617,7 +616,7 @@ suspend fun TelegramBot.send( chatId: ChatIdentifier, separator: String, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -636,7 +635,7 @@ suspend fun TelegramBot.send( chat: Chat, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -652,7 +651,7 @@ suspend fun TelegramBot.send( chat: Chat, separator: TextSource? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -670,7 +669,7 @@ suspend fun TelegramBot.send( chat: Chat, separator: String, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -689,7 +688,7 @@ suspend fun TelegramBot.send( photo: Photo, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -707,7 +706,7 @@ suspend fun TelegramBot.send( photo: Photo, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -725,7 +724,7 @@ suspend fun TelegramBot.send( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -743,7 +742,7 @@ suspend fun TelegramBot.send( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -760,7 +759,7 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, photo: Photo, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -777,7 +776,7 @@ suspend inline fun TelegramBot.send( chat: Chat, photo: Photo, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -794,7 +793,7 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, photoSize: PhotoSize, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -811,7 +810,7 @@ suspend inline fun TelegramBot.send( chat: Chat, photoSize: PhotoSize, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -832,7 +831,7 @@ suspend fun TelegramBot.send( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -854,7 +853,7 @@ suspend fun TelegramBot.send( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -875,7 +874,7 @@ suspend fun TelegramBot.send( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -897,7 +896,7 @@ suspend fun TelegramBot.send( isAnonymous: Boolean = poll.isAnonymous, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -920,7 +919,7 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -943,7 +942,7 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -967,7 +966,7 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -993,7 +992,7 @@ suspend fun TelegramBot.send( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1015,7 +1014,7 @@ suspend inline fun TelegramBot.send( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1037,7 +1036,7 @@ suspend inline fun TelegramBot.send( isClosed: Boolean = false, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1060,7 +1059,7 @@ suspend inline fun TelegramBot.send( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1083,7 +1082,7 @@ suspend inline fun TelegramBot.send( isAnonymous: Boolean = quizPoll.isAnonymous, entities: TextSourcesList, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1099,7 +1098,7 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, sticker: Sticker, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1115,7 +1114,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, sticker: Sticker, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1137,7 +1136,7 @@ suspend fun TelegramBot.send( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1171,7 +1170,7 @@ suspend fun TelegramBot.send( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1194,7 +1193,7 @@ suspend fun TelegramBot.send( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1216,7 +1215,7 @@ suspend fun TelegramBot.send( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1241,7 +1240,7 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1264,7 +1263,7 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1286,7 +1285,7 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1308,7 +1307,7 @@ suspend fun TelegramBot.send( foursquareType: FoursquareType? = null, googlePlaceId: GooglePlaceId? = null, googlePlaceType: GooglePlaceType? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1324,7 +1323,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, venue: Venue, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1340,7 +1339,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, venue: Venue, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1358,7 +1357,7 @@ suspend fun TelegramBot.send( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1376,7 +1375,7 @@ suspend fun TelegramBot.send( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1393,7 +1392,7 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, video: VideoFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1410,7 +1409,7 @@ suspend inline fun TelegramBot.send( chat: Chat, video: VideoFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1426,7 +1425,7 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, videoNote: VideoNoteFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1442,7 +1441,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, videoNote: VideoNoteFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1460,7 +1459,7 @@ suspend fun TelegramBot.send( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1478,7 +1477,7 @@ suspend fun TelegramBot.send( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1495,7 +1494,7 @@ suspend inline fun TelegramBot.send( chatId: ChatIdentifier, voice: VoiceFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1512,7 +1511,7 @@ suspend inline fun TelegramBot.send( chat: Chat, voice: VoiceFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1528,7 +1527,7 @@ suspend inline fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1543,7 +1542,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1558,7 +1557,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1573,7 +1572,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1587,7 +1586,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1601,7 +1600,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1615,7 +1614,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1629,7 +1628,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1643,7 +1642,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1657,7 +1656,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1671,7 +1670,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1685,7 +1684,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1699,7 +1698,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1713,7 +1712,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1727,7 +1726,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -1741,7 +1740,7 @@ suspend fun TelegramBot.send( suspend fun TelegramBot.send( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 2982753287..10e26f0527 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 @@ -8,6 +8,7 @@ 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 +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -16,7 +17,7 @@ import dev.inmo.tgbotapi.types.games.Game suspend fun TelegramBot.sendGame( chatId: ChatIdentifier, gameShortName: String, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -35,7 +36,7 @@ suspend fun TelegramBot.sendGame( suspend fun TelegramBot.sendGame( chat: Chat, gameShortName: String, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -52,7 +53,7 @@ suspend fun TelegramBot.sendGame( suspend fun TelegramBot.sendGame( chatId: ChatIdentifier, game: Game, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -69,7 +70,7 @@ suspend fun TelegramBot.sendGame( suspend fun TelegramBot.sendGame( chat: Chat, game: Game, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 1cc5ccffab..edfb5dfb29 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.AnimationFile +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -25,7 +26,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -62,7 +63,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -85,7 +86,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -105,7 +106,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -126,7 +127,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -161,7 +162,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -183,7 +184,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -202,7 +203,7 @@ suspend fun TelegramBot.sendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 a0e00630fd..a6752e3470 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.AudioFile +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -25,7 +26,7 @@ suspend fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -63,7 +64,7 @@ suspend fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -81,7 +82,7 @@ suspend fun TelegramBot.sendAudio( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -99,7 +100,7 @@ suspend fun TelegramBot.sendAudio( text: String? = null, parseMode: ParseMode? = null, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -120,7 +121,7 @@ suspend inline fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -156,7 +157,7 @@ suspend inline fun TelegramBot.sendAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -173,7 +174,7 @@ suspend inline fun TelegramBot.sendAudio( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -190,7 +191,7 @@ suspend inline fun TelegramBot.sendAudio( audio: AudioFile, entities: TextSourcesList, title: String? = audio.title, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 d23bb801da..7173129726 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.DocumentFile +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -22,7 +23,7 @@ suspend fun TelegramBot.sendDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -56,7 +57,7 @@ suspend fun TelegramBot.sendDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -74,7 +75,7 @@ suspend fun TelegramBot.sendDocument( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -94,7 +95,7 @@ suspend fun TelegramBot.sendDocument( document: DocumentFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -112,7 +113,7 @@ suspend inline fun TelegramBot.sendDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -144,7 +145,7 @@ suspend inline fun TelegramBot.sendDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -161,7 +162,7 @@ suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: DocumentFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -180,7 +181,7 @@ suspend inline fun TelegramBot.sendDocument( chat: Chat, document: DocumentFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 c89915764d..5b24700c0c 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.AudioContent import dev.inmo.tgbotapi.types.message.content.DocumentContent +import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.utils.RiskFeature import kotlin.jvm.JvmName @@ -21,7 +22,7 @@ import kotlin.jvm.JvmName suspend fun TelegramBot.sendMediaGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -39,7 +40,7 @@ suspend fun TelegramBot.sendMediaGroup( suspend fun TelegramBot.sendMediaGroup( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -56,7 +57,7 @@ suspend fun TelegramBot.sendMediaGroup( suspend fun TelegramBot.sendMediaGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -73,7 +74,7 @@ suspend fun TelegramBot.sendMediaGroup( suspend fun TelegramBot.sendMediaGroup( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -88,7 +89,7 @@ suspend fun TelegramBot.sendMediaGroup( suspend fun TelegramBot.sendPlaylist( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -105,7 +106,7 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendPlaylist( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -121,7 +122,7 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendPlaylist( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -137,7 +138,7 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendPlaylist( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -152,7 +153,7 @@ suspend fun TelegramBot.sendPlaylist( suspend fun TelegramBot.sendDocumentsGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -169,7 +170,7 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendDocumentsGroup( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -185,7 +186,7 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendDocumentsGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -201,7 +202,7 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendDocumentsGroup( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -216,7 +217,7 @@ suspend fun TelegramBot.sendDocumentsGroup( suspend fun TelegramBot.sendVisualMediaGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -233,7 +234,7 @@ suspend fun TelegramBot.sendVisualMediaGroup( suspend fun TelegramBot.sendVisualMediaGroup( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -249,7 +250,7 @@ suspend fun TelegramBot.sendVisualMediaGroup( suspend fun TelegramBot.sendVisualMediaGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -265,7 +266,7 @@ suspend fun TelegramBot.sendVisualMediaGroup( suspend fun TelegramBot.sendVisualMediaGroup( chat: Chat, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 e876006f71..c091231391 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.* +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -21,7 +22,7 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -51,7 +52,7 @@ suspend fun TelegramBot.sendPhoto( fileId: InputFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -68,7 +69,7 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -85,7 +86,7 @@ suspend fun TelegramBot.sendPhoto( photo: Photo, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -102,7 +103,7 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -119,7 +120,7 @@ suspend fun TelegramBot.sendPhoto( photoSize: PhotoSize, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -136,7 +137,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -164,7 +165,7 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -180,7 +181,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -196,7 +197,7 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -212,7 +213,7 @@ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photoSize: PhotoSize, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -228,7 +229,7 @@ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photoSize: PhotoSize, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 d77908e86f..f3e4812bd5 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 @@ -9,6 +9,7 @@ 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 +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -17,7 +18,7 @@ import dev.inmo.tgbotapi.types.files.Sticker suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: InputFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -34,7 +35,7 @@ suspend fun TelegramBot.sendSticker( suspend fun TelegramBot.sendSticker( chat: Chat, sticker: InputFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -49,7 +50,7 @@ suspend fun TelegramBot.sendSticker( suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: Sticker, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -64,7 +65,7 @@ suspend fun TelegramBot.sendSticker( suspend fun TelegramBot.sendSticker( chat: Chat, sticker: Sticker, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 9c9ba07fb4..c9123bab69 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 @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.files.VideoFile +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -25,7 +26,7 @@ suspend fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -60,7 +61,7 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -81,7 +82,7 @@ suspend fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -99,7 +100,7 @@ suspend fun TelegramBot.sendVideo( video: VideoFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -119,7 +120,7 @@ suspend inline fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -152,7 +153,7 @@ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -172,7 +173,7 @@ suspend inline fun TelegramBot.sendVideo( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -189,7 +190,7 @@ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 b7c101a6ca..5eb4b848b3 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 @@ -9,6 +9,7 @@ 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 +import dev.inmo.tgbotapi.types.threadId /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -20,7 +21,7 @@ suspend fun TelegramBot.sendVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -49,7 +50,7 @@ suspend fun TelegramBot.sendVideoNote( suspend fun TelegramBot.sendVideoNote( chatId: ChatIdentifier, videoNote: VideoNoteFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -69,7 +70,7 @@ suspend fun TelegramBot.sendVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -84,7 +85,7 @@ suspend fun TelegramBot.sendVideoNote( suspend fun TelegramBot.sendVideoNote( chat: Chat, videoNote: VideoNoteFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 641bb1a953..3be4a2435f 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 @@ -55,7 +55,7 @@ suspend fun TelegramBot.sendVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - threadId: MessageThreadId? = chatId.threadId, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -91,7 +91,7 @@ suspend fun TelegramBot.sendVoice( voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = chatId.threadId, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -139,7 +139,7 @@ suspend inline fun TelegramBot.sendVoice( voice: InputFile, entities: TextSourcesList, duration: Long? = null, - threadId: MessageThreadId? = chatId.threadId, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -172,7 +172,7 @@ suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: VoiceFile, entities: TextSourcesList, - threadId: MessageThreadId? = chatId.threadId, + threadId: MessageThreadId? = chat.id.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 8a0888298d..6fa583d15a 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 @@ -64,10 +64,9 @@ 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, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, null, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) 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 aa0aae7480..eca9e8706a 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 @@ -20,7 +20,7 @@ data class ForwardMessage( @SerialName(messageIdField) override val messageId: MessageId, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = toChatId.threadId, @SerialName(disableNotificationField) val disableNotification: Boolean = false, @SerialName(protectContentField) 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 39a9def570..710d152811 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 @@ -27,7 +27,7 @@ fun CopyMessage( messageId: MessageId, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -53,7 +53,7 @@ fun CopyMessage( fromChatId: ChatIdentifier, messageId: MessageId, entities: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -80,7 +80,7 @@ fun CopyMessage( toChatId: ChatIdentifier, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -106,7 +106,7 @@ fun CopyMessage( messageId: MessageId, toChatId: ChatIdentifier, entities: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = toChatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -142,7 +142,7 @@ data class CopyMessage internal constructor( @SerialName(captionEntitiesField) private val rawEntities: List? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = toChatId.threadId, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 cf12d44db3..2d10e109df 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 @@ -23,7 +23,7 @@ data class SendContact( @SerialName(lastNameField) val lastName: String? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -40,7 +40,7 @@ data class SendContact( constructor( chatId: ChatIdentifier, contact: Contact, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -68,7 +68,7 @@ data class SendContact( fun Contact.toRequest( chatId: ChatIdentifier, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 8631b754e2..43d3cafa00 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,7 +18,7 @@ fun SendLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -44,7 +44,7 @@ fun SendStaticLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -60,7 +60,7 @@ fun SendLiveLocation( horizontalAccuracy: Meters? = null, heading: Degrees? = null, proximityAlertRadius: Meters? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -99,7 +99,7 @@ data class SendLocation internal constructor( @SerialName(proximityAlertRadiusField) override val proximityAlertRadius: Meters? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 985c370832..85e69e7406 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,7 +25,7 @@ fun SendTextMessage( text: String, parseMode: ParseMode? = null, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -49,7 +49,7 @@ fun SendTextMessage( chatId: ChatIdentifier, entities: TextSourcesList, disableWebPagePreview: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -80,7 +80,7 @@ data class SendTextMessage internal constructor( @SerialName(entitiesField) private val rawEntities: List? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 ebfc14d123..2a4d0af6ca 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 @@ -33,7 +33,7 @@ data class SendVenue( @SerialName(googlePlaceTypeField) val googlePlaceType: GooglePlaceType? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -52,7 +52,7 @@ data class SendVenue( constructor( chatId: ChatIdentifier, venue: Venue, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -85,7 +85,7 @@ data class SendVenue( fun Venue.toRequest( chatId: ChatIdentifier, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, 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 b73451db82..43769a00a3 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 @@ -19,7 +19,7 @@ data class SendGame ( @SerialName(gameShortNameField) val gameShortName: String, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 2dd7f07681..576ab84087 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,7 +28,7 @@ fun SendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -76,7 +76,7 @@ fun SendAnimation( duration: Long? = null, width: Int? = null, height: Int? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -140,7 +140,7 @@ data class SendAnimationData internal constructor( @SerialName(heightField) override val height: Int? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 ea74af2e3c..b819e076af 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,7 +29,7 @@ fun SendAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -77,7 +77,7 @@ fun SendAudio( duration: Long? = null, performer: String? = null, title: String? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -141,7 +141,7 @@ data class SendAudioData internal constructor( @SerialName(titleField) override val title: String? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 977ac85e49..35b2ab3d93 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,7 +34,7 @@ fun SendDocument( thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -87,7 +87,7 @@ fun SendDocument( document: InputFile, thumb: InputFile? = null, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -153,7 +153,7 @@ data class SendDocumentData internal constructor( @SerialName(captionEntitiesField) private val rawEntities: List? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 c3c599aab9..506e7934fd 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 @@ -32,7 +32,7 @@ const val rawSendingMediaGroupsWarning = "Media groups contains restrictions rel fun SendMediaGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -82,7 +82,7 @@ fun SendMediaGroup( inline fun SendPlaylist( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -98,7 +98,7 @@ inline fun SendPlaylist( inline fun SendDocumentsGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -115,7 +115,7 @@ inline fun SendDocumentsGroup( inline fun SendVisualMediaGroup( chatId: ChatIdentifier, media: List, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -143,7 +143,7 @@ data class SendMediaGroupData internal constructor( override val chatId: ChatIdentifier, val media: List = emptyList(), @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) 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 6a65961780..e2a7dde628 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,7 +23,7 @@ fun SendPhoto( photo: InputFile, text: String? = null, parseMode: ParseMode? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -55,7 +55,7 @@ fun SendPhoto( chatId: ChatIdentifier, photo: InputFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -99,7 +99,7 @@ data class SendPhotoData internal constructor( @SerialName(captionEntitiesField) private val rawEntities: List? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 a29ccb529b..71bad4d3b8 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,7 +15,7 @@ import kotlinx.serialization.json.JsonObject fun SendSticker( chatId: ChatIdentifier, sticker: InputFile, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -47,7 +47,7 @@ data class SendStickerByFileId internal constructor( @SerialName(stickerField) val sticker: FileId? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 c3c3923cff..8f78a4c37b 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,7 +29,7 @@ fun SendVideo( width: Int? = null, height: Int? = null, supportStreaming: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -79,7 +79,7 @@ fun SendVideo( width: Int? = null, height: Int? = null, supportStreaming: Boolean? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -146,7 +146,7 @@ data class SendVideoData internal constructor( @SerialName(supportStreamingField) val supportStreaming: Boolean? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 0ef8e8d090..d80bd0679b 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,7 +17,7 @@ fun SendVideoNote( thumb: InputFile? = null, duration: Long? = null, size: Int? = null, // in documentation - length (size of video side) - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -69,7 +69,7 @@ data class SendVideoNoteData internal constructor( @SerialName(lengthField) override val width: Int? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 a84e655594..900632aea1 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,7 +25,7 @@ fun SendVoice( text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -64,7 +64,7 @@ fun SendVoice( chatId: ChatIdentifier, voice: InputFile, entities: TextSourcesList, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, duration: Long? = null, disableNotification: Boolean = false, protectContent: Boolean = false, @@ -118,7 +118,7 @@ data class SendVoiceData internal constructor( @SerialName(durationField) override val duration: Long? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @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 8982be33d4..19f24ccc85 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,7 +48,7 @@ fun SendPoll( options: List, isAnonymous: Boolean = true, isClosed: Boolean = false, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -74,7 +74,7 @@ fun SendPoll( */ fun Poll.createRequest( chatId: ChatIdentifier, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -202,7 +202,7 @@ data class SendRegularPoll( @SerialName(closeDateField) override val closeDate: LongSeconds?, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) @@ -232,7 +232,7 @@ fun SendRegularPoll( isClosed: Boolean = false, allowMultipleAnswers: Boolean = false, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -265,7 +265,7 @@ fun SendQuizPoll( explanation: String? = null, parseMode: ParseMode? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -299,7 +299,7 @@ fun SendQuizPoll( isClosed: Boolean = false, entities: List, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -335,7 +335,7 @@ internal fun SendQuizPoll( parseMode: ParseMode? = null, rawEntities: List? = null, closeInfo: ScheduledCloseInfo? = null, - threadId: MessageThreadId? = null, + threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, @@ -386,7 +386,7 @@ data class SendQuizPoll internal constructor( @SerialName(closeDateField) override val closeDate: LongSeconds? = null, @SerialName(messageThreadIdField) - override val threadId: MessageThreadId? = null, + override val threadId: MessageThreadId? = chatId.threadId, @SerialName(disableNotificationField) override val disableNotification: Boolean = false, @SerialName(protectContentField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt index ef52607f9f..42805b6d75 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types import dev.inmo.micro_utils.common.Warning import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.descriptors.SerialDescriptor @@ -15,6 +16,7 @@ import kotlin.jvm.JvmInline const val internalLinkBeginning = "https://t.me" @Serializable(ChatIdentifierSerializer::class) +@ClassCastsIncluded sealed interface ChatIdentifier /** 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 41d015e32a..0ddb3da843 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 @@ -25,7 +25,9 @@ sealed interface PublicChat : Chat { sealed interface SuperPublicChat : PublicChat, UsernameChat @Serializable(PreviewChatSerializer::class) -sealed interface ChannelChat : SuperPublicChat +sealed interface ChannelChat : SuperPublicChat { + override val id: ChatId +} @Serializable(PreviewChatSerializer::class) sealed interface GroupChat : PublicChat 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 2ab307b473..20ed573d34 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.json.JsonObject @Serializable data class ExtendedChannelChatImpl( @SerialName(idField) - override val id: IdChatIdentifier, + override val id: ChatId, @SerialName(titleField) override val title: String, @SerialName(usernameField) @@ -33,7 +33,7 @@ data class ExtendedChannelChatImpl( @Serializable data class ExtendedGroupChatImpl( @SerialName(idField) - override val id: IdChatIdentifier, + override val id: ChatId, @SerialName(titleField) override val title: String, @SerialName(photoField) @@ -78,7 +78,7 @@ typealias ExtendedUser = ExtendedPrivateChatImpl @Serializable data class ExtendedSupergroupChatImpl( @SerialName(idField) - override val id: IdChatIdentifier, + override val id: ChatId, @SerialName(titleField) override val title: String, @SerialName(usernameField) 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 5bd1fc3037..e329c3b015 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 @@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable @Serializable data class GroupChatImpl( @SerialName(idField) - override val id: IdChatIdentifier, + override val id: ChatId, @SerialName(titleField) override val title: String ) : GroupChat @@ -30,7 +30,7 @@ data class PrivateChatImpl( @Serializable data class SupergroupChatImpl( @SerialName(idField) - override val id: IdChatIdentifier, + override val id: ChatId, @SerialName(titleField) override val title: String, @SerialName(usernameField) @@ -50,7 +50,7 @@ data class ForumChatImpl( @Serializable data class ChannelChatImpl( @SerialName(idField) - override val id: IdChatIdentifier, + override val id: ChatId, @SerialName(titleField) override val title: String, @SerialName(usernameField) 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 4610948074..d7087fc5c7 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 @@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.message.abstracts.* +import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.modules.* @@ -114,7 +115,7 @@ sealed interface MediaContent: MessageContent { sealed interface ResendableContent { fun createResend( chatId: ChatIdentifier, - messageThreadId: MessageThreadId? = null, + messageThreadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, replyToMessageId: MessageId? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt deleted file mode 100644 index d74d88de2d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/ChatIdentifierWithThreadId.kt +++ /dev/null @@ -1,76 +0,0 @@ -package dev.inmo.tgbotapi.utils.extensions - -import dev.inmo.tgbotapi.types.IdChatIdentifier -import dev.inmo.tgbotapi.types.MessageThreadId -import dev.inmo.tgbotapi.types.message.abstracts.Message -import kotlinx.serialization.Serializable -import kotlin.Pair -import kotlin.jvm.JvmInline - -/** - * Union to keep both [IdChatIdentifier] and optionally [MessageThreadId] as an identifier of target for messages sending and - * other information - */ -sealed interface ChatIdWithThreadId { - val chatId: IdChatIdentifier - val threadId: MessageThreadId? - - /** - * Lightweight variant of [ChatIdWithThreadId] due to absence of any conversations - */ - @JvmInline - value class ByMessage( - val sourceMessage: Message - ) : ChatIdWithThreadId { - override val chatId: IdChatIdentifier - get() = sourceMessage.chat.id - override val threadId: MessageThreadId? - get() = sourceMessage.threadIdOrNull - } - - /** - * [Serializable] variant of [ChatIdWithThreadId] based on [Pair] of target [IdChatIdentifier] and [MessageThreadId] - * - * @see invoke - * @see serializable - */ - @Serializable - @JvmInline - value class ByPair( - val pair: Pair - ) : ChatIdWithThreadId { - override val chatId: IdChatIdentifier - get() = pair.first - override val threadId: MessageThreadId? - get() = pair.second - } - - companion object { - /** - * Creates lightweight [ByMessage] variant of [ChatIdWithThreadId] - */ - inline operator fun invoke(message: Message) = ByMessage(message) - - /** - * Creates [ByPair] variant of [ChatIdWithThreadId] using incoming [message] [Message.chat] and extension - * [Message.threadIdOrNull] - */ - inline fun serializable(message: Message) = ByPair(message.chat.id to message.threadIdOrNull) - - /** - * Creates [ByPair] variant of [ChatIdWithThreadId] using incoming [pair] - */ - inline fun serializable(pair: Pair) = ByPair(pair) - } -} -/** - * Creates [ChatIdWithThreadId.ByMessage] variant of [ChatIdWithThreadId] using [ChatIdWithThreadId.serializable] - */ -val Message.chatIdWithThreadId - get() = ChatIdWithThreadId(this) - -/** - * Creates [ChatIdWithThreadId.ByPair] variant of [ChatIdWithThreadId] using [ChatIdWithThreadId.serializable] - */ -val Message.serializableChatIdWithThreadId - get() = ChatIdWithThreadId.serializable(this) 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 2f2929d78d..60b258a418 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 @@ -14,10 +14,14 @@ import dev.inmo.tgbotapi.abstracts.FromUser import dev.inmo.tgbotapi.abstracts.WithUser import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink import dev.inmo.tgbotapi.requests.send.payments.SendInvoice +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdWithThreadId +import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatInviteLink import dev.inmo.tgbotapi.types.ChatInviteLinkUnlimited import dev.inmo.tgbotapi.types.ChatInviteLinkWithJoinRequest import dev.inmo.tgbotapi.types.ChatInviteLinkWithLimitedMembers +import dev.inmo.tgbotapi.types.IdChatIdentifier import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.BaseChosenInlineResult import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.LocationChosenInlineResult @@ -84,6 +88,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery import dev.inmo.tgbotapi.types.PrimaryInviteLink import dev.inmo.tgbotapi.types.SecondaryChatInviteLink +import dev.inmo.tgbotapi.types.Username import dev.inmo.tgbotapi.types.actions.BotAction import dev.inmo.tgbotapi.types.actions.ChooseStickerAction import dev.inmo.tgbotapi.types.actions.CustomBotAction @@ -986,6 +991,40 @@ public inline fun WithUser.ifMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T): T? = messageGameShortNameCallbackQueryOrNull() ?.let(block) +public inline fun ChatIdentifier.idChatIdentifierOrNull(): IdChatIdentifier? = this as? + dev.inmo.tgbotapi.types.IdChatIdentifier + +public inline fun ChatIdentifier.idChatIdentifierOrThrow(): IdChatIdentifier = this as + dev.inmo.tgbotapi.types.IdChatIdentifier + +public inline fun ChatIdentifier.ifIdChatIdentifier(block: (IdChatIdentifier) -> T): T? = + idChatIdentifierOrNull() ?.let(block) + +public inline fun ChatIdentifier.chatIdOrNull(): ChatId? = this as? dev.inmo.tgbotapi.types.ChatId + +public inline fun ChatIdentifier.chatIdOrThrow(): ChatId = this as dev.inmo.tgbotapi.types.ChatId + +public inline fun ChatIdentifier.ifChatId(block: (ChatId) -> T): T? = chatIdOrNull() + ?.let(block) + +public inline fun ChatIdentifier.chatIdWithThreadIdOrNull(): ChatIdWithThreadId? = this as? + dev.inmo.tgbotapi.types.ChatIdWithThreadId + +public inline fun ChatIdentifier.chatIdWithThreadIdOrThrow(): ChatIdWithThreadId = this as + dev.inmo.tgbotapi.types.ChatIdWithThreadId + +public inline fun ChatIdentifier.ifChatIdWithThreadId(block: (ChatIdWithThreadId) -> T): T? = + chatIdWithThreadIdOrNull() ?.let(block) + +public inline fun ChatIdentifier.usernameOrNull(): Username? = this as? + dev.inmo.tgbotapi.types.Username + +public inline fun ChatIdentifier.usernameOrThrow(): Username = this as + dev.inmo.tgbotapi.types.Username + +public inline fun ChatIdentifier.ifUsername(block: (Username) -> T): T? = usernameOrNull() + ?.let(block) + public inline fun InlineQueryResult.inlineQueryResultArticleOrNull(): InlineQueryResultArticle? = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle From a1ccbbdd510d68384cc189b7e926a977b05b1a23 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 16:48:10 +0600 Subject: [PATCH 09/10] small additions in changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84309e4124..70f8f4f733 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ * New chat identifier: `ChatIdWithThreadId` * `RawMessage` will create `ChatIdWithThreadId` chat id under the hood by default * All the methods which potentially using `threadId` will try to take it from `chatId` +* `API`: + * All default `threadId` null values has been replaced with auto-calculated threadId from chats/chat ids ## 4.0.0 From d167f10724c0c01b23c752af12cd61cf0bc48fad Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 10 Nov 2022 17:02:47 +0600 Subject: [PATCH 10/10] update dependencies --- CHANGELOG.md | 5 +++++ gradle/libs.versions.toml | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f8f4f733..23c6e41153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## 4.1.0 +* `Versions`: + * `Kotlin`: `1.7.20` -> `1.7.21` + * `MicroUtils`: `0.14.0` -> `0.14.1` + * `Korlibs`: `3.3.1` -> `3.4.0` + * `UUID`: `0.5.0` -> `0.6.0` * `Core`: * All the chats identifiers has been rewritten as value classes * New chat identifier: `ChatIdWithThreadId` diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4d57db84be..9695d5821a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,21 +1,22 @@ [versions] -kotlin = "1.7.20" +kotlin = "1.7.21" kotlin-serialization = "1.4.1" kotlin-coroutines = "1.6.4" javax-activation = "1.1.1" -korlibs = "3.3.1" -uuid = "0.5.0" +korlibs = "3.4.0" +uuid = "0.6.0" ktor = "2.1.3" -ksp = "1.7.20-1.0.8" +ksp = "1.7.21-1.0.8" kotlin-poet = "1.12.0" -microutils = "0.14.0" +microutils = "0.14.1" github-release-plugin = "2.4.1" +dokka = "1.7.20" [libraries] @@ -58,7 +59,7 @@ ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" } kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" } -kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "kotlin" } +kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } github-release-plugin = { module = "com.github.breadmoirai:github-release", version.ref = "github-release-plugin" } [plugins]