From 5f7633a57e4aa247d3b12b819e6954a282e8bc0f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 27 Jun 2020 09:30:25 +0600 Subject: [PATCH 01/11] start 0.27.8 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 491ddf25e6..e1c153ad99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ * `closePollExactAfter` * `closePollAfter` +### 0.27.8 + ### 0.27.7 * `TelegramBotAPI`: diff --git a/gradle.properties b/gradle.properties index 3194ec89b8..37399e77c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,6 @@ ktor_version=1.3.2 javax_activation_version=1.1.1 library_group=com.github.insanusmokrassar -library_version=0.27.7 +library_version=0.27.8 gradle_bintray_plugin_version=1.8.4 From 58943f250411a499be3c44956bb2f4f1050c09d3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 27 Jun 2020 09:31:29 +0600 Subject: [PATCH 02/11] small refactor of BaseMessagesUpdatesConversations --- .../BaseMessagesUpdatesConversations.kt | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt index 1280b4a397..0341007268 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt @@ -2,26 +2,19 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.mapNotNull +import kotlinx.coroutines.flow.* -fun Flow.onlyBaseMessageUpdates(): Flow = mapNotNull { - it as? BaseMessageUpdate -} +fun Flow.onlyBaseMessageUpdates(): Flow = filterIsInstance() /** * Converts flow to [Flow] of [BaseSentMessageUpdate] */ -fun Flow.onlySentMessageUpdates(): Flow = mapNotNull { - it as? BaseSentMessageUpdate -} +fun Flow.onlySentMessageUpdates(): Flow = filterIsInstance() /** * Converts flow to [Flow] of [BaseSentMessageUpdate] */ -fun Flow.onlyEditMessageUpdates(): Flow = mapNotNull { - it as? BaseEditMessageUpdate -} +fun Flow.onlyEditMessageUpdates(): Flow = filterIsInstance() /** * Converts flow to [Flow] of [MediaGroupUpdate]. Please, remember that it could be either [EditMediaGroupUpdate] @@ -30,20 +23,14 @@ fun Flow.onlyEditMessageUpdates(): Flow.onlyMediaGroupsUpdates(): Flow = mapNotNull { - it as? MediaGroupUpdate -} +fun Flow.onlyMediaGroupsUpdates(): Flow = filterIsInstance() /** * Converts flow to [Flow] of [SentMediaGroupUpdate] */ -fun Flow.onlySentMediaGroupUpdates(): Flow = mapNotNull { - it as? SentMediaGroupUpdate -} +fun Flow.onlySentMediaGroupUpdates(): Flow = filterIsInstance() /** * Converts flow to [Flow] of [EditMediaGroupUpdate] */ -fun Flow.onlyEditMediaGroupUpdates(): Flow = mapNotNull { - it as? EditMediaGroupUpdate -} +fun Flow.onlyEditMediaGroupUpdates(): Flow = filterIsInstance() From a9a3f55c8d54c40ad01b48adaa8dec0bf5d2ac20 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 27 Jun 2020 09:43:24 +0600 Subject: [PATCH 03/11] refactoring of FlowsUpdatesFilter --- CHANGELOG.md | 4 + .../TelegramBotAPI/types/update/RawUpdate.kt | 7 +- .../types/update/abstracts/Update.kt | 4 +- .../updateshandlers/FlowsUpdatesFilter.kt | 88 ++++++------------- .../updateshandlers/UpdatesFilter.kt | 9 +- 5 files changed, 41 insertions(+), 71 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1c153ad99..599c7d0ffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,10 @@ ### 0.27.8 +* `TelegramBotAPI`: + * `UnknownUpdateType` was renamed to `UnknownUpdate` + * Refactoring and optimization of `FlowsUpdatesFilter` + ### 0.27.7 * `TelegramBotAPI`: diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt index 809c0ea145..f37b9239aa 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt @@ -9,8 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuer import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll import com.github.insanusmokrassar.TelegramBotAPI.types.polls.PollAnswer -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField import kotlinx.serialization.* import kotlinx.serialization.json.JsonElement @@ -57,7 +56,7 @@ internal data class RawUpdate constructor( pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query) poll != null -> PollUpdate(updateId, poll) poll_answer != null -> PollAnswerUpdate(updateId, poll_answer) - else -> UnknownUpdateType( + else -> UnknownUpdate( updateId, raw.toString(), raw @@ -66,7 +65,7 @@ internal data class RawUpdate constructor( } catch (e: Error) { when (e) { is SerializationException, - is NotImplementedError -> UnknownUpdateType( + is NotImplementedError -> UnknownUpdate( updateId, raw.toString(), raw diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt index 874d3860fc..24be238958 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/abstracts/Update.kt @@ -12,11 +12,13 @@ interface Update { val data: Any } -data class UnknownUpdateType( +data class UnknownUpdate( override val updateId: UpdateIdentifier, override val data: String, val rawJson: JsonElement ) : Update +@Deprecated("Renamed", ReplaceWith("UnknownUpdate")) +typealias UnknownUpdateType = UnknownUpdate internal object UpdateSerializerWithoutSerialization : KSerializer { override val descriptor: SerialDescriptor = JsonElementSerializer.descriptor diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt index 052e1a8f03..203aa819fb 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt @@ -1,74 +1,40 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers +import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST import com.github.insanusmokrassar.TelegramBotAPI.types.update.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* import kotlinx.coroutines.channels.BroadcastChannel -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.asFlow - -@Suppress("EXPERIMENTAL_API_USAGE") -private fun BroadcastChannel.createUpdateReceiver(): UpdateReceiver = ::send +import kotlinx.coroutines.flow.* @Suppress("EXPERIMENTAL_API_USAGE", "unused") class FlowsUpdatesFilter( - broadcastChannelsSize: Int = 64 + broadcastChannelsSize: Int = 100 ): UpdatesFilter { - private val messageChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val messageMediaGroupChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val editedMessageChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val editedMessageMediaGroupChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val channelPostChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val channelPostMediaGroupChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val editedChannelPostChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val editedChannelPostMediaGroupChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val chosenInlineResultChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val inlineQueryChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val callbackQueryChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val shippingQueryChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val preCheckoutQueryChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val pollChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val pollAnswerChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) - private val unknownUpdateChannel: BroadcastChannel = BroadcastChannel(broadcastChannelsSize) + private val updatesReceivingChannel = BroadcastChannel(broadcastChannelsSize) + @Suppress("MemberVisibilityCanBePrivate") + val allUpdatesFlow: Flow = updatesReceivingChannel.asFlow() override val allowedUpdates: List - get() = filter.allowedUpdates - override val asUpdateReceiver: UpdateReceiver - get() = filter.asUpdateReceiver + get() = ALL_UPDATES_LIST + override val asUpdateReceiver: UpdateReceiver = { + updatesReceivingChannel.send(it) + } - val filter = SimpleUpdatesFilter( - messageChannel.createUpdateReceiver(), - messageMediaGroupChannel.createUpdateReceiver(), - editedMessageChannel.createUpdateReceiver(), - editedMessageMediaGroupChannel.createUpdateReceiver(), - channelPostChannel.createUpdateReceiver(), - channelPostMediaGroupChannel.createUpdateReceiver(), - editedChannelPostChannel.createUpdateReceiver(), - editedChannelPostMediaGroupChannel.createUpdateReceiver(), - chosenInlineResultChannel.createUpdateReceiver(), - inlineQueryChannel.createUpdateReceiver(), - callbackQueryChannel.createUpdateReceiver(), - shippingQueryChannel.createUpdateReceiver(), - preCheckoutQueryChannel.createUpdateReceiver(), - pollChannel.createUpdateReceiver(), - pollAnswerChannel.createUpdateReceiver(), - unknownUpdateChannel.createUpdateReceiver() - ) - - val messageFlow: Flow = messageChannel.asFlow() - val messageMediaGroupFlow: Flow = messageMediaGroupChannel.asFlow() - val editedMessageFlow: Flow = editedMessageChannel.asFlow() - val editedMessageMediaGroupFlow: Flow = editedMessageMediaGroupChannel.asFlow() - val channelPostFlow: Flow = channelPostChannel.asFlow() - val channelPostMediaGroupFlow: Flow = channelPostMediaGroupChannel.asFlow() - val editedChannelPostFlow: Flow = editedChannelPostChannel.asFlow() - val editedChannelPostMediaGroupFlow: Flow = editedChannelPostMediaGroupChannel.asFlow() - val chosenInlineResultFlow: Flow = chosenInlineResultChannel.asFlow() - val inlineQueryFlow: Flow = inlineQueryChannel.asFlow() - val callbackQueryFlow: Flow = callbackQueryChannel.asFlow() - val shippingQueryFlow: Flow = shippingQueryChannel.asFlow() - val preCheckoutQueryFlow: Flow = preCheckoutQueryChannel.asFlow() - val pollFlow: Flow = pollChannel.asFlow() - val pollAnswerFlow: Flow = pollAnswerChannel.asFlow() - val unknownUpdateTypeFlow: Flow = unknownUpdateChannel.asFlow() + val messageFlow: Flow = allUpdatesFlow.filterIsInstance() + val messageMediaGroupFlow: Flow = allUpdatesFlow.filterIsInstance() + val editedMessageFlow: Flow = allUpdatesFlow.filterIsInstance() + val editedMessageMediaGroupFlow: Flow = allUpdatesFlow.filterIsInstance() + val channelPostFlow: Flow = allUpdatesFlow.filterIsInstance() + val channelPostMediaGroupFlow: Flow = allUpdatesFlow.filterIsInstance() + val editedChannelPostFlow: Flow = allUpdatesFlow.filterIsInstance() + val editedChannelPostMediaGroupFlow: Flow = allUpdatesFlow.filterIsInstance() + val chosenInlineResultFlow: Flow = allUpdatesFlow.filterIsInstance() + val inlineQueryFlow: Flow = allUpdatesFlow.filterIsInstance() + val callbackQueryFlow: Flow = allUpdatesFlow.filterIsInstance() + val shippingQueryFlow: Flow = allUpdatesFlow.filterIsInstance() + val preCheckoutQueryFlow: Flow = allUpdatesFlow.filterIsInstance() + val pollFlow: Flow = allUpdatesFlow.filterIsInstance() + val pollAnswerFlow: Flow = allUpdatesFlow.filterIsInstance() + val unknownUpdateTypeFlow: Flow = allUpdatesFlow.filterIsInstance() } \ No newline at end of file diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt index 868484ccb1..91fedfc184 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt @@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* typealias UpdateReceiver = suspend (T) -> Unit @@ -29,7 +28,7 @@ data class SimpleUpdatesFilter( private val preCheckoutQueryCallback: UpdateReceiver? = null, private val pollUpdateCallback: UpdateReceiver? = null, private val pollAnswerUpdateCallback: UpdateReceiver? = null, - private val unknownUpdateTypeCallback: UpdateReceiver? = null + private val unknownUpdateTypeCallback: UpdateReceiver? = null ) : UpdatesFilter { override val asUpdateReceiver: UpdateReceiver = this::invoke override val allowedUpdates = listOfNotNull( @@ -83,7 +82,7 @@ data class SimpleUpdatesFilter( is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update) is PollUpdate -> pollUpdateCallback ?.invoke(update) is PollAnswerUpdate -> pollAnswerUpdateCallback ?.invoke(update) - is UnknownUpdateType -> unknownUpdateTypeCallback ?.invoke(update) + is UnknownUpdate -> unknownUpdateTypeCallback ?.invoke(update) } } } @@ -101,7 +100,7 @@ fun createSimpleUpdateFilter( preCheckoutQueryCallback: UpdateReceiver? = null, pollCallback: UpdateReceiver? = null, pollAnswerCallback: UpdateReceiver? = null, - unknownCallback: UpdateReceiver? = null + unknownCallback: UpdateReceiver? = null ): UpdatesFilter = SimpleUpdatesFilter( messageCallback = messageCallback, messageMediaGroupCallback = mediaGroupCallback, From ed9ed715a0519e589f28e896b53337962c31d347 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 27 Jun 2020 09:51:18 +0600 Subject: [PATCH 04/11] update defaults for new FlowsUpdatesFilter --- .../TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt | 2 +- .../extensions/utils/updates/FlowsUpdatesFactory.kt | 2 +- .../extensions/utils/updates/retrieving/LongPolling.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt index 4c05dc0a95..a27034cf96 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/updates/UpdatesPolling.kt @@ -76,7 +76,7 @@ fun RequestsExecutor.startGettingFlowsUpdates( timeoutSeconds: Seconds = 30, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: (suspend (Exception) -> Unit)? = null, - flowsUpdatesFilterUpdatesKeeperCount: Int = 64, + flowsUpdatesFilterUpdatesKeeperCount: Int = 100, flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit = {} ): FlowsUpdatesFilter = FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply { flowUpdatesPreset() diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/FlowsUpdatesFactory.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/FlowsUpdatesFactory.kt index 08d3cb7b77..f7fd6cbad2 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/FlowsUpdatesFactory.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/FlowsUpdatesFactory.kt @@ -8,7 +8,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.FlowsUpdatesFi * @see flowsUpdatesFilter */ inline fun flowsUpdatesFilter( - internalChannelsSizes: Int = 64, + internalChannelsSizes: Int = 100, block: FlowsUpdatesFilter.() -> Unit ): FlowsUpdatesFilter { val filter = FlowsUpdatesFilter(internalChannelsSizes) diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/LongPolling.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/LongPolling.kt index 10d9003d61..6fbd655048 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/LongPolling.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/LongPolling.kt @@ -76,7 +76,7 @@ fun RequestsExecutor.startGettingFlowsUpdatesByLongPolling( timeoutSeconds: Seconds = 30, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), exceptionsHandler: ExceptionHandler? = null, - flowsUpdatesFilterUpdatesKeeperCount: Int = 64, + flowsUpdatesFilterUpdatesKeeperCount: Int = 100, flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit = {} ): FlowsUpdatesFilter = FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply { flowUpdatesPreset() From 147889a66a48b484ed04fdef9cd5292887d971a2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 27 Jun 2020 09:59:57 +0600 Subject: [PATCH 05/11] update readme --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 642b9d1811..ab6fe369ba 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,7 @@ | Common info | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI.svg?branch=master)](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) | | -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| Useful links | • [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) | -| | • [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | -| | • [![Chat in Telegram](badges/chat.svg)](https://teleg.one/InMoTelegramBotAPI) | -| | • [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/docs/index.html) | +| Useful links | [![Chat in Telegram](badges/chat.svg)](https://teleg.one/InMoTelegramBotAPI) [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | | TelegramBotAPI status | [![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg)](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI) | | TelegramBotAPI Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/images/download.svg)](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api) | | TelegramBotAPI Util Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/images/download.svg)](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils) | From cfb7f35d207123bbc1b131592ef64ef5933e6e88 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 27 Jun 2020 10:11:03 +0600 Subject: [PATCH 06/11] add several makeLinkToMessage --- CHANGELOG.md | 2 ++ .../extensions/utils/formatting/LinksFormatting.kt | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 599c7d0ffc..5c9e146bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,8 @@ * `TelegramBotAPI`: * `UnknownUpdateType` was renamed to `UnknownUpdate` * Refactoring and optimization of `FlowsUpdatesFilter` +* `TelegramBotAPI-extensions-utils`: + * Several new functions `makeLinkToMessage` was added ### 0.27.7 diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt index 1bd86d26d5..3959d7a9b2 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/formatting/LinksFormatting.kt @@ -1,8 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting -import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.* -import com.github.insanusmokrassar.TelegramBotAPI.types.StickerSetName import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UsernameChat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat @@ -14,6 +13,14 @@ fun makeLinkToMessage( username: String, messageId: MessageIdentifier ): String = "$internalLinkBeginning/$username/$messageId" +fun makeLinkToMessage( + username: Username, + messageId: MessageIdentifier +): String = makeLinkToMessage(username.username, messageId) +fun makeLinkToMessage( + chat: UsernameChat, + messageId: MessageIdentifier +): String? = chat.username ?.let { makeLinkToMessage(it, messageId) } private val linkIdRedundantPartRegex = Regex("^-100") private val usernameBeginSymbolRegex = Regex("^@") From 975898660c49a166f9cada062f957ecaa3d8e97b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 1 Jul 2020 23:57:20 +0600 Subject: [PATCH 07/11] TelegramBotAPI Venue and foursquare additions --- CHANGELOG.md | 3 +++ .../TelegramBotAPI/types/Common.kt | 2 ++ .../TelegramBotAPI/types/Venue.kt | 19 +++--------------- .../TelegramBotAPI/types/venue/Venue.kt | 20 +++++++++++++++++++ 4 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c9e146bc3..f77ff85a60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,9 @@ * `TelegramBotAPI`: * `UnknownUpdateType` was renamed to `UnknownUpdate` * Refactoring and optimization of `FlowsUpdatesFilter` + * `Venue` type was replaced to a new package: `com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue` + * `Venue` type now implements `Locationed` and delegate realisation to its `location` field + * `FoursquareId` and `FoursquareType` typealiases were added * `TelegramBotAPI-extensions-utils`: * Several new functions `makeLinkToMessage` was added diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt index 2fb043f7bd..f1ad390052 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Common.kt @@ -22,6 +22,8 @@ typealias PollIdentifier = String typealias StickerSetName = String typealias FileUniqueId = String typealias DiceResult = Int +typealias FoursquareId = String +typealias FoursquareType = String typealias Seconds = Int typealias LongSeconds = Long diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Venue.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Venue.kt index ee6928b46c..6d6adef5e5 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Venue.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/Venue.kt @@ -1,19 +1,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types -import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CommonVenueData -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue -@Serializable -data class Venue( - @SerialName(locationField) - val location: Location, - @SerialName(titleField) - override val title: String, - @SerialName(addressField) - override val address: String, - @SerialName(foursquareIdField) - override val foursquareId: String? = null, - @SerialName(foursquareTypeField) - override val foursquareType: String? = null -) : CommonVenueData +@Deprecated("Replaced", ReplaceWith("Venue", "com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue")) +typealias Venue = Venue diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt new file mode 100644 index 0000000000..3a9a55d5a5 --- /dev/null +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt @@ -0,0 +1,20 @@ +package com.github.insanusmokrassar.TelegramBotAPI.types.venue + +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CommonVenueData +import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Locationed +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import kotlinx.serialization.* + +@Serializable +data class Venue( + @SerialName(locationField) + val location: Location, + @SerialName(titleField) + override val title: String, + @SerialName(addressField) + override val address: String, + @SerialName(foursquareIdField) + override val foursquareId: FoursquareId? = null, + @SerialName(foursquareTypeField) + override val foursquareType: FoursquareType? = null +) : CommonVenueData, Locationed by location From ff0b7faa48e2314b928921f436e50bb7703fe6fa Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 2 Jul 2020 00:52:52 +0600 Subject: [PATCH 08/11] Foursquare and fixes of deprecations in methods --- CHANGELOG.md | 3 +++ .../extensions/api/send/SendVenue.kt | 1 + .../utils/extensions/venue/Foursquare.kt | 26 +++++++++++++++++++ .../TelegramBotAPI/requests/send/SendVenue.kt | 1 + .../types/message/RawMessage.kt | 1 + .../types/message/content/VenueContent.kt | 1 + 6 files changed, 33 insertions(+) create mode 100644 TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/extensions/venue/Foursquare.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index f77ff85a60..b6a6c50975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,9 @@ * `FoursquareId` and `FoursquareType` typealiases were added * `TelegramBotAPI-extensions-utils`: * Several new functions `makeLinkToMessage` was added + * `Foursquare` data class was added + * Extension `Venue#foursquare` was added + * Factory function `Venue` with `Foursquare` parameter was added ### 0.27.7 diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt index 4f358d4ad3..aa22e5be36 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt @@ -5,6 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue suspend fun RequestsExecutor.sendVenue( chatId: ChatIdentifier, diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/extensions/venue/Foursquare.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/extensions/venue/Foursquare.kt new file mode 100644 index 0000000000..aa95e3ad40 --- /dev/null +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/extensions/venue/Foursquare.kt @@ -0,0 +1,26 @@ +package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.extensions.venue + +import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +val Venue.foursquare: Foursquare? + get() = foursquareId ?.let { + Foursquare(it, foursquareType) + } + +fun Venue( + location: Location, + title: String, + address: String, + foursquare: Foursquare +) = Venue(location, title, address, foursquare.id, foursquare.type) + +@Serializable +data class Foursquare( + @SerialName(foursquareIdField) + val id: FoursquareId, + @SerialName(foursquareTypeField) + val type: FoursquareType? = null +) diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt index 18e3931cfe..1ca4c91d01 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendVenue.kt @@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent +import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue import kotlinx.serialization.* private val commonResultDeserializer: DeserializationStrategy> diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt index 92ef9049ea..5786d90b4b 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/RawMessage.kt @@ -20,6 +20,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.Success import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice import com.github.insanusmokrassar.TelegramBotAPI.types.payments.SuccessfulPayment import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll +import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlin.reflect.KClass diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt index 27a191cf55..fa18109ff5 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt @@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent +import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue data class VenueContent( val venue: Venue From cba0e3071047f99d7a6a41cb14076287a6fdb7ab Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 2 Jul 2020 15:55:14 +0600 Subject: [PATCH 09/11] sendVenue with Location --- CHANGELOG.md | 2 ++ .../extensions/api/send/SendVenue.kt | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6a6c50975..42534de13f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,8 @@ * Operator function `unaryPlus` was added to `RowBuilder`. Now it is possible to write `row { +button }` * Function `flatMatrix` was added for single-row columns * Operator extension `RowBuilder#plus` was added to be able to write things like `row { this + button }` +* `TelegramBotAPI-extensions-api`: + * Extensions `RequestsExecutor#sendVenue` with `Location` args were added * `TelegramBotAPI-extensions-utils`: * Function `InlineKeyboardMarkup` for flat keyboards was added * Function `ReplyKeyboardMarkup` for flat keyboards was added diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt index aa22e5be36..39dd8e5dee 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt @@ -37,6 +37,34 @@ suspend fun RequestsExecutor.sendVenue( chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup ) +suspend fun RequestsExecutor.sendVenue( + chatId: ChatIdentifier, + location: Location, + title: String, + address: String, + foursquareId: String? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + SendVenue( + chatId, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup + ) +) + +suspend fun RequestsExecutor.sendVenue( + chat: Chat, + location: Location, + title: String, + address: String, + foursquareId: String? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendVenue( + chat.id, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup +) + suspend fun RequestsExecutor.sendVenue( chatId: ChatIdentifier, venue: Venue, From 1811a63a13c0c27620a9a561e35677e030b48220 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 2 Jul 2020 16:00:38 +0600 Subject: [PATCH 10/11] update last added sendVenue --- .../TelegramBotAPI/extensions/api/send/SendVenue.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt index 39dd8e5dee..f29e72b7cf 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt @@ -46,10 +46,8 @@ suspend fun RequestsExecutor.sendVenue( disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null -) = execute( - SendVenue( - chatId, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup - ) +) = sendVenue( + chatId, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup ) suspend fun RequestsExecutor.sendVenue( From c0a43077ad0b4f370446f5f834137a2fd35cda59 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 2 Jul 2020 16:15:06 +0600 Subject: [PATCH 11/11] optimize imports --- .../extensions/utils/shortcuts/MediaGroupsShortcuts.kt | 3 ++- .../extensions/utils/types/buttons/InlineKeyboardMarkup.kt | 4 ++-- .../extensions/utils/types/buttons/ReplyKeyboardMarkup.kt | 2 +- .../utils/updates/BaseMessagesUpdatesConversations.kt | 3 ++- .../extensions/utils/updates/retrieving/Webhook.kt | 3 ++- .../TelegramBotAPI/types/message/ChannelMessage.kt | 2 +- .../TelegramBotAPI/types/message/CommonMessageImpl.kt | 3 ++- .../TelegramBotAPI/types/message/content/VenueContent.kt | 3 ++- .../insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt | 3 ++- .../insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt | 3 ++- .../TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt | 3 ++- .../TelegramBotAPI/updateshandlers/UpdatesFilter.kt | 3 ++- 12 files changed, 22 insertions(+), 13 deletions(-) diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/shortcuts/MediaGroupsShortcuts.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/shortcuts/MediaGroupsShortcuts.kt index ea2fc6bfb8..208a7904b9 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/shortcuts/MediaGroupsShortcuts.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/shortcuts/MediaGroupsShortcuts.kt @@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendMediaG import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.SentMediaGroupUpdate val List.forwardInfo: ForwardInfo? diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/InlineKeyboardMarkup.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/InlineKeyboardMarkup.kt index 9752514036..af50542ebf 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/InlineKeyboardMarkup.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/InlineKeyboardMarkup.kt @@ -1,8 +1,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons -import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton -import com.github.insanusmokrassar.TelegramBotAPI.utils.* +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.utils.flatMatrix fun InlineKeyboardMarkup( vararg buttons: InlineKeyboardButton diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt index 473bc131ce..161543c25f 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt @@ -1,7 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons -import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.ReplyKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardButton +import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.ReplyKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.utils.flatMatrix fun ReplyKeyboardMarkup( diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt index 0341007268..493fae288f 100644 --- a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/BaseMessagesUpdatesConversations.kt @@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.filterIsInstance fun Flow.onlyBaseMessageUpdates(): Flow = filterIsInstance() diff --git a/TelegramBotAPI-extensions-utils/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/Webhook.kt b/TelegramBotAPI-extensions-utils/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/Webhook.kt index ef379eb7be..0434a385c9 100644 --- a/TelegramBotAPI-extensions-utils/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/Webhook.kt +++ b/TelegramBotAPI-extensions-utils/src/jvmMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/updates/retrieving/Webhook.kt @@ -18,7 +18,8 @@ import io.ktor.request.receiveText import io.ktor.response.respond import io.ktor.routing.* import io.ktor.server.engine.* -import kotlinx.coroutines.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.asCoroutineDispatcher import java.util.concurrent.Executors diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt index 15bea82224..3d1ecb22f1 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/ChannelMessage.kt @@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage import com.soywiz.klock.DateTime diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt index 08c2b32bab..357aa57d97 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/CommonMessageImpl.kt @@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat -import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.FromUserMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt index fa18109ff5..a95e1797c9 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/message/content/VenueContent.kt @@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue -import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier +import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt index f37b9239aa..b5e7f8f395 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/update/RawUpdate.kt @@ -9,7 +9,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuer import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll import com.github.insanusmokrassar.TelegramBotAPI.types.polls.PollAnswer -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdate +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField import kotlinx.serialization.* import kotlinx.serialization.json.JsonElement diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt index 3a9a55d5a5..9b3565e05d 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/venue/Venue.kt @@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.venue import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CommonVenueData import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Locationed import com.github.insanusmokrassar.TelegramBotAPI.types.* -import kotlinx.serialization.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable @Serializable data class Venue( diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt index 203aa819fb..dc95e3a6ea 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/FlowsUpdatesFilter.kt @@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST import com.github.insanusmokrassar.TelegramBotAPI.types.update.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdate +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.flow.* diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt index 91fedfc184..a36789497b 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt @@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* -import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.* +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdate +import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update typealias UpdateReceiver = suspend (T) -> Unit