From f6e566463215a5837dfada7d46455db6dacb86cf Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 16:31:02 +0600 Subject: [PATCH 01/12] start 0.30.4 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d217da284..a569e7e2a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.30.4 + ## 0.30.3 * `Common`: diff --git a/gradle.properties b/gradle.properties index b78605ad23..4c5d621461 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ micro_utils_version=0.3.1 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.30.3 +library_version=0.30.4 gradle_bintray_plugin_version=1.8.5 github_release_plugin_version=2.2.12 From 0121e3a104414dc4a62e72e378c97d9643704f50 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 16:33:48 +0600 Subject: [PATCH 02/12] update micro_utils --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a569e7e2a9..8f12276ad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.30.4 +* `Common`: + * `Version`: + * `MicroUtils`: `0.3.1` -> `0.3.2` + ## 0.30.3 * `Common`: diff --git a/gradle.properties b/gradle.properties index 4c5d621461..865aaa403b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=1.12.1 uuid_version=0.2.2 ktor_version=1.4.2 -micro_utils_version=0.3.1 +micro_utils_version=0.3.2 javax_activation_version=1.1.1 From b2fa7fee9d840d6434c2b3e47cc0aa3e476ebbbe Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 16:37:17 +0600 Subject: [PATCH 03/12] rename MultilevelTextSource#textSources --- CHANGELOG.md | 2 ++ .../tgbotapi/CommonAbstracts/TextSource.kt | 5 +++- .../textsources/BoldTextSource.kt | 2 +- .../textsources/CashTagTextSource.kt | 2 +- .../textsources/EMailTextSource.kt | 2 +- .../textsources/HashTagTextSource.kt | 2 +- .../textsources/ItalicTextSource.kt | 2 +- .../textsources/MentionTextSource.kt | 2 +- .../textsources/PhoneNumberTextSource.kt | 2 +- .../textsources/StrikethroughTextSource.kt | 2 +- .../textsources/TextMentionTextSource.kt | 2 +- .../textsources/UnderlineTextSource.kt | 2 +- .../MultilevelTextSourceFormatting.kt | 28 +++++++++---------- .../types/MessageEntity/EntitiesTestText.kt | 8 +++--- 14 files changed, 34 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f12276ad5..62b60c594d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * `Common`: * `Version`: * `MicroUtils`: `0.3.1` -> `0.3.2` +* `Core`: + * `MultilevelTextSource#textSources` has been safely renamed to `subsources` ## 0.30.3 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt index aac31893f5..6f067adeff 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt @@ -36,7 +36,10 @@ interface MultilevelTextSource : TextSource { @Deprecated("Will be removed in near major release") val textParts: List get() = textParts(0) + val subsources: List + @Deprecated("Will be removed in near major release", ReplaceWith("subsources")) val textSources: List + get() = subsources } data class TextPart( @@ -46,7 +49,7 @@ data class TextPart( fun List.justTextSources() = map { it.source } fun List.makeString() = joinToString("") { it.source } -internal fun MultilevelTextSource.textParts(offset: Int): List = textSources.toTextParts(offset) +internal fun MultilevelTextSource.textParts(offset: Int): List = subsources.toTextParts(offset) fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null): List> { if (isEmpty()) { return emptyList() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt index 64c1d3dee4..d5098f72f0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BoldTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.boldMarkdownV2 */ data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.boldMarkdown() } override val asMarkdownV2Source: String by lazy { boldMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt index 221fd5712e..5b016c0fd1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CashTagTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.cashTagMarkdownV2 */ data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.cashTagMarkdown() } override val asMarkdownV2Source: String by lazy { cashTagMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt index 77704d1e69..850cbefcd9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/EMailTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.emailMarkdownV2 */ data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.emailMarkdown() } override val asMarkdownV2Source: String by lazy { emailMarkdownV2(source) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt index 37ecbe8861..04af45a2e3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/HashTagTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.hashTagMarkdownV2 */ data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.hashTagMarkdown() } override val asMarkdownV2Source: String by lazy { hashTagMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt index 887238f2bb..870fc8c7fc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/ItalicTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.italicMarkdownV2 */ data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.italicMarkdown() } override val asMarkdownV2Source: String by lazy { italicMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt index ef17ac5632..f56ca0a13e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/MentionTextSource.kt @@ -18,7 +18,7 @@ private val String.withoutCommercialAt */ data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.mentionMarkdown() } override val asMarkdownV2Source: String by lazy { mentionMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt index 321fb3f6f5..c6950f0889 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PhoneNumberTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.phoneMarkdownV2 */ data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.phoneMarkdown() } override val asMarkdownV2Source: String by lazy { phoneMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt index b273b012c0..58e8e18dbd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/StrikethroughTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.strikethroughMarkdownV2 */ data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asHtmlSource: String by lazy { strikethroughHTML() } override val asMarkdownV2Source: String by lazy { strikethroughMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt index 4ef48dbee6..acf2902cfa 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextMentionTextSource.kt @@ -13,7 +13,7 @@ import dev.inmo.tgbotapi.utils.internal.textMentionMarkdownV2 data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, val user: User, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.textMentionMarkdown(user.id) } override val asMarkdownV2Source: String by lazy { textMentionMarkdownV2(user.id) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt index 3523f12496..db6dd52efa 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/UnderlineTextSource.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.utils.internal.underlineMarkdownV2 */ data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( override val source: String, - override val textSources: List + override val subsources: List ) : MultilevelTextSource { override val asMarkdownSource: String by lazy { source.underlineMarkdown() } override val asMarkdownV2Source: String by lazy { underlineMarkdownV2() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt index 69e44e5d6c..31ef7e5136 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/MultilevelTextSourceFormatting.kt @@ -83,19 +83,19 @@ private fun List.joinSubSourcesHtml() = joinToString("") { internal fun MultilevelTextSource.markdownV2Default( openControlSymbol: String, closeControlSymbol: String = openControlSymbol -) = "$openControlSymbol${textSources.joinSubSourcesMarkdownV2()}$closeControlSymbol" +) = "$openControlSymbol${subsources.joinSubSourcesMarkdownV2()}$closeControlSymbol" internal fun MultilevelTextSource.htmlDefault( openControlSymbol: String, closeControlSymbol: String = openControlSymbol -) = "<$openControlSymbol>${textSources.joinSubSourcesHtml()}" +) = "<$openControlSymbol>${subsources.joinSubSourcesHtml()}" internal fun MultilevelTextSource.linkMarkdownV2( link: String -) = "[${textSources.joinSubSourcesMarkdownV2()}](${link.escapeMarkdownV2Link()})" +) = "[${subsources.joinSubSourcesMarkdownV2()}](${link.escapeMarkdownV2Link()})" internal fun MultilevelTextSource.linkHTML( link: String -) = "${textSources.joinSubSourcesHtml()}" +) = "${subsources.joinSubSourcesHtml()}" internal fun MultilevelTextSource.optionalPrefix( @@ -116,8 +116,8 @@ internal fun MultilevelTextSource.boldMarkdownV2(): String = markdownV2Default(m internal fun MultilevelTextSource.boldHTML(): String = htmlDefault(htmlBoldControl) -internal fun MultilevelTextSource.cashTagMarkdownV2(): String = textSources.joinSubSourcesMarkdownV2() -internal fun MultilevelTextSource.cashTagHTML(): String = textSources.joinSubSourcesHtml() +internal fun MultilevelTextSource.cashTagMarkdownV2(): String = subsources.joinSubSourcesMarkdownV2() +internal fun MultilevelTextSource.cashTagHTML(): String = subsources.joinSubSourcesHtml() internal fun MultilevelTextSource.italicMarkdownV2(): String = markdownV2Default(markdownItalicControl) @@ -135,21 +135,21 @@ internal fun MultilevelTextSource.underlineHTML(): String = htmlDefault(htmlUnde internal fun MultilevelTextSource.textMentionMarkdownV2(userId: UserId): String = linkMarkdownV2(userId.link) internal fun MultilevelTextSource.textMentionHTML(userId: UserId): String = linkHTML(userId.link) -internal fun MultilevelTextSource.mentionMarkdownV2(): String = optionalPrefix("@") + textSources.joinSubSourcesMarkdownV2() -internal fun MultilevelTextSource.mentionHTML(): String = optionalPrefix("@") + textSources.joinSubSourcesHtml() +internal fun MultilevelTextSource.mentionMarkdownV2(): String = optionalPrefix("@") + subsources.joinSubSourcesMarkdownV2() +internal fun MultilevelTextSource.mentionHTML(): String = optionalPrefix("@") + subsources.joinSubSourcesHtml() internal fun MultilevelTextSource.hashTagMarkdownV2(): String = when { source.startsWith("\\#") || source.startsWith("#") -> "" else -> "\\#" -} + textSources.joinSubSourcesMarkdownV2() -internal fun MultilevelTextSource.hashTagHTML(): String = optionalPrefix("#") + textSources.joinSubSourcesHtml() +} + subsources.joinSubSourcesMarkdownV2() +internal fun MultilevelTextSource.hashTagHTML(): String = optionalPrefix("#") + subsources.joinSubSourcesHtml() -internal fun MultilevelTextSource.phoneMarkdownV2(): String = textSources.joinSubSourcesMarkdownV2() -internal fun MultilevelTextSource.phoneHTML(): String = textSources.joinSubSourcesHtml() +internal fun MultilevelTextSource.phoneMarkdownV2(): String = subsources.joinSubSourcesMarkdownV2() +internal fun MultilevelTextSource.phoneHTML(): String = subsources.joinSubSourcesHtml() -internal fun MultilevelTextSource.commandMarkdownV2(): String = optionalPrefix("/") + textSources.joinSubSourcesMarkdownV2() -internal fun MultilevelTextSource.commandHTML(): String = optionalPrefix("/") + textSources.joinSubSourcesHtml() +internal fun MultilevelTextSource.commandMarkdownV2(): String = optionalPrefix("/") + subsources.joinSubSourcesMarkdownV2() +internal fun MultilevelTextSource.commandHTML(): String = optionalPrefix("/") + subsources.joinSubSourcesHtml() diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt index e754be23b6..b75814dcf1 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt @@ -49,8 +49,8 @@ fun List.testTextParts() { assertTrue (get(5).source is MentionTextSource) val boldSource = get(1).source as BoldTextSource - assertTrue (boldSource.textSources.first() is ItalicTextSource) - assertTrue (boldSource.textSources[1] is RegularTextSource) - assertTrue (boldSource.textSources[2] is StrikethroughTextSource) - assertTrue ((boldSource.textSources[2] as StrikethroughTextSource).textSources.first() is UnderlineTextSource) + assertTrue (boldSource.subsources.first() is ItalicTextSource) + assertTrue (boldSource.subsources[1] is RegularTextSource) + assertTrue (boldSource.subsources[2] is StrikethroughTextSource) + assertTrue ((boldSource.subsources[2] as StrikethroughTextSource).subsources.first() is UnderlineTextSource) } From 8764f18ca82b5041a4521c2bbff6a77489bddc94 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 16:57:32 +0600 Subject: [PATCH 04/12] TextContent now implements TextedInput --- CHANGELOG.md | 3 +++ .../types/message/content/TextContent.kt | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62b60c594d..e7c5e4c7ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ * `MicroUtils`: `0.3.1` -> `0.3.2` * `Core`: * `MultilevelTextSource#textSources` has been safely renamed to `subsources` + * `TextContent#fullEntitiesList` has been deprecated + * Now `TextContent` implements `TextedInput` + * `TextContent#entities` has been deprecated ## 0.30.3 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt index 08a2d23a34..304ace106a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/TextContent.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.types.message.content -import dev.inmo.tgbotapi.CommonAbstracts.TextSourcesList -import dev.inmo.tgbotapi.CommonAbstracts.TextPart +import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.types.ChatIdentifier @@ -15,13 +14,13 @@ import dev.inmo.tgbotapi.utils.internal.fullListOfSubSource import dev.inmo.tgbotapi.utils.internal.toMarkdownTexts data class TextContent( - val text: String, - /** - * Not full list of entities. This list WILL NOT contain [TextPart]s with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] - * @see [TextContent.fullEntitiesList] - */ - val entities: List = emptyList() -) : MessageContent { + override val text: String, + override val textEntities: List = emptyList() +) : MessageContent, TextedInput { + @Deprecated("Has been renamed", ReplaceWith("textEntities")) + val entities: List + get() = textEntities + override fun createResend( chatId: ChatIdentifier, disableNotification: Boolean, @@ -83,4 +82,5 @@ data class TextContent( * Convert its [TextContent.entities] to list of [dev.inmo.tgbotapi.CommonAbstracts.TextSource] * with [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] */ +@Deprecated("Useless due to the fact that currently every message contains full list of sources") fun TextContent.fullEntitiesList(): TextSourcesList = text.fullListOfSubSource(entities).map { it.source } From e4ce6f8fc7c2eebb873259459daaff98b55f0797 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 17:44:33 +0600 Subject: [PATCH 05/12] fixes in events --- CHANGELOG.md | 2 ++ .../types/message/ChatEvents/abstracts/SupergroupEvent.kt | 2 +- .../tgbotapi/types/message/abstracts/GroupEventMessage.kt | 6 +++++- .../types/message/abstracts/SupergroupEventMessage.kt | 6 +++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7c5e4c7ca..05fd2c1807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ * `TextContent#fullEntitiesList` has been deprecated * Now `TextContent` implements `TextedInput` * `TextContent#entities` has been deprecated + * `GroupEventMessage` now overrides `chatEvent` with type `GroupEvent` + * `SupergroupEventMessage` now overrides `chatEvent` with type `SupergroupEvent` ## 0.30.3 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/SupergroupEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/SupergroupEvent.kt index d57d4a969f..cd0bfe9b53 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/SupergroupEvent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/SupergroupEvent.kt @@ -1,3 +1,3 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts -interface SupergroupEvent: ChatEvent \ No newline at end of file +interface SupergroupEvent: GroupEvent \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt index 2cc84379d1..2ca03698de 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt @@ -1,3 +1,7 @@ package dev.inmo.tgbotapi.types.message.abstracts -interface GroupEventMessage : ChatEventMessage, FromUserMessage +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent + +interface GroupEventMessage : ChatEventMessage, FromUserMessage { + override val chatEvent: GroupEvent +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt index b0fdfd456d..d923fd0904 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt @@ -1,3 +1,7 @@ package dev.inmo.tgbotapi.types.message.abstracts -interface SupergroupEventMessage : GroupEventMessage +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent + +interface SupergroupEventMessage : GroupEventMessage { + override val chatEvent: SupergroupEvent +} From 33b50c6c681a20976e9127723548179b58b1a8e4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 21:17:11 +0600 Subject: [PATCH 06/12] events filters --- .../types/message/ChannelEventMessage.kt | 7 +- .../types/message/CommonGroupEventMessage.kt | 8 +- .../message/CommonSupergroupEventMessage.kt | 9 ++- .../message/abstracts/ChatEventMessage.kt | 4 +- .../message/abstracts/GroupEventMessage.kt | 4 +- .../abstracts/SupergroupEventMessage.kt | 4 +- .../utils/shortcuts/CommandsShortcuts.kt | 7 +- .../utils/shortcuts/EventsShortcuts.kt | 74 +++++++++++++++++++ 8 files changed, 95 insertions(+), 22 deletions(-) create mode 100644 tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt index ce972e7d52..009dd19ef7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChannelEventMessage.kt @@ -4,11 +4,12 @@ import com.soywiz.klock.DateTime import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage -data class ChannelEventMessage( +data class ChannelEventMessage( override val messageId: MessageIdentifier, override val chat: ChannelChat, - override val chatEvent: ChannelEvent, + override val chatEvent: T, override val date: DateTime -) : ChatEventMessage +) : ChatEventMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt index d55134b6c5..d3c2edb7a4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt @@ -8,12 +8,12 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage @Deprecated("Renamed", ReplaceWith("CommonGroupEventMessage")) -typealias GroupEventMessage = CommonGroupEventMessage +typealias GroupEventMessage = CommonGroupEventMessage<*> -data class CommonGroupEventMessage( +data class CommonGroupEventMessage( override val messageId: MessageIdentifier, override val user: User, override val chat: GroupChat, - override val chatEvent: GroupEvent, + override val chatEvent: T, override val date: DateTime -) : GroupEventMessage +) : GroupEventMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt index f5a382888e..d79212f169 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt @@ -4,16 +4,17 @@ import com.soywiz.klock.DateTime import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage @Deprecated("Renamed", ReplaceWith("CommonSupergroupEventMessage")) -typealias SupergroupEventMessage = CommonSupergroupEventMessage +typealias SupergroupEventMessage = CommonSupergroupEventMessage<*> -data class CommonSupergroupEventMessage( +data class CommonSupergroupEventMessage( override val messageId: MessageIdentifier, override val user: User, override val chat: SupergroupChat, - override val chatEvent: SupergroupEvent, + override val chatEvent: T, override val date: DateTime -) : SupergroupEventMessage +) : SupergroupEventMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt index abef861c5d..c409d53a0e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/ChatEventMessage.kt @@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent -interface ChatEventMessage : Message { - val chatEvent: ChatEvent +interface ChatEventMessage : Message { + val chatEvent: T } \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt index 2ca03698de..f8988d489d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupEventMessage.kt @@ -2,6 +2,4 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent -interface GroupEventMessage : ChatEventMessage, FromUserMessage { - override val chatEvent: GroupEvent -} +interface GroupEventMessage : ChatEventMessage, FromUserMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt index d923fd0904..0e111cec2c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/SupergroupEventMessage.kt @@ -2,6 +2,4 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent -interface SupergroupEventMessage : GroupEventMessage { - override val chatEvent: SupergroupEvent -} +interface SupergroupEventMessage : GroupEventMessage diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt index 5a8181819e..f23f1aae33 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.extensions.utils.shortcuts import dev.inmo.tgbotapi.CommonAbstracts.TextSource +import dev.inmo.tgbotapi.CommonAbstracts.textSources import dev.inmo.tgbotapi.extensions.utils.onlyTextContentMessages import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow import dev.inmo.tgbotapi.types.MessageEntity.textsources.BotCommandTextSource @@ -27,7 +28,7 @@ import kotlinx.coroutines.flow.* fun > Flow.filterExactCommands( commandRegex: Regex ) = filter { contentMessage -> - (contentMessage.content.fullEntitiesList().singleOrNull() as? BotCommandTextSource) ?.let { commandRegex.matches(it.command) } == true + (contentMessage.content.textSources.singleOrNull() as? BotCommandTextSource) ?.let { commandRegex.matches(it.command) } == true } /** @@ -46,7 +47,7 @@ fun > Flow.filterExactCommands( fun > Flow.filterCommandsInsideTextMessages( commandRegex: Regex ) = filter { contentMessage -> - contentMessage.content.fullEntitiesList().any { + contentMessage.content.textSources.any { (it as? BotCommandTextSource) ?.let { commandRegex.matches(it.command) } == true } } @@ -70,7 +71,7 @@ fun > Flow.filterCommandsInsideTextMessages( fun > Flow.filterCommandsWithArgs( commandRegex: Regex ) = mapNotNull { contentMessage -> - val allEntities = contentMessage.content.fullEntitiesList() + val allEntities = contentMessage.content.textSources (allEntities.firstOrNull() as? BotCommandTextSource) ?.let { if (commandRegex.matches(it.command)) { contentMessage to allEntities.flatMap { diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt new file mode 100644 index 0000000000..4f3493d206 --- /dev/null +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -0,0 +1,74 @@ +package dev.inmo.tgbotapi.extensions.utils.shortcuts + +import dev.inmo.tgbotapi.extensions.utils.aggregateFlows +import dev.inmo.tgbotapi.types.message.ChannelEventMessage +import dev.inmo.tgbotapi.types.message.ChatEvents.* +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.abstracts.* +import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent +import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.RiskFeature +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.* + +/** + * @param scopeToIncludeChannels This parameter is required when you want to include [textMessages] for channels too. + * In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messageFlow] and + * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping + */ +@Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE") +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.filterChannelEvents(): Flow> = channelPostFlow.mapNotNull { + it.data as? ChannelEventMessage<*> +} + +/** + * @param scopeToIncludeChannels This parameter is required when you want to include [textMessages] for channels too. + * In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messageFlow] and + * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping + */ +@Suppress("UNCHECKED_CAST") +@RiskFeature("Use with caution") +inline fun > FlowsUpdatesFilter.filterGroupEvents(): Flow = messageFlow.mapNotNull { + it.data as? T +} + +@RiskFeature("Use with caution") +inline fun > Flow>.filterByChatEvent(): Flow = mapNotNull { + if (it.chatEvent is T) { + it as? O + } else { + null + } +} + +@RiskFeature("Use with caution") +inline fun Flow>.channelEvents() = filterByChatEvent>() +inline fun Flow>.channelCreatedEvents() = channelEvents() +inline fun Flow>.deletedChannelPhotoEvents() = channelEvents() +inline fun Flow>.newChannelPhotoEvents() = channelEvents() +inline fun Flow>.newChannelTitleEvents() = channelEvents() +inline fun Flow>.newChannelPinnedMessageEvents() = channelEvents() + +@RiskFeature("Use with caution") +inline fun Flow>.groupEvents() = filterByChatEvent>() +inline fun Flow>.groupCreatedEvents() = groupEvents() +inline fun Flow>.deletedGroupPhotoEvents() = groupEvents() +inline fun Flow>.newGroupMembersEvents() = groupEvents() +inline fun Flow>.leftGroupMemberEvents() = groupEvents() +inline fun Flow>.newGroupPhotoEvents() = groupEvents() +inline fun Flow>.newGroupTitleEvents() = groupEvents() +inline fun Flow>.newGroupPinnedMessageEvents() = groupEvents() +inline fun Flow>.proximityAlertTriggeredInGroupEvents() = groupEvents() + + +@RiskFeature("Use with caution") +inline fun Flow>.supergroupEvents() = filterByChatEvent>() +inline fun Flow>.supergroupCreatedEvents() = supergroupEvents() +inline fun Flow>.deletedSupergroupPhotoEvents() = supergroupEvents() +inline fun Flow>.newSupergroupMembersEvents() = supergroupEvents() +inline fun Flow>.leftSupergroupMemberEvents() = supergroupEvents() +inline fun Flow>.newSupergroupPhotoEvents() = supergroupEvents() +inline fun Flow>.newSupergroupTitleEvents() = supergroupEvents() +inline fun Flow>.newSupergroupPinnedMessageEvents() = supergroupEvents() +inline fun Flow>.proximityAlertTriggeredInSupergroupEvents() = supergroupEvents() From e7199e745129bda547ee4e6c2bf401f550526f49 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 21:46:33 +0600 Subject: [PATCH 07/12] fix use user in group messages --- .../kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt | 1 + .../dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt index 8a72fc3393..bf919049d8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt @@ -38,6 +38,7 @@ data class AnonymousGroupMessageImpl( data class CommonGroupMessageImpl( override val chat: GroupChat, override val messageId: MessageIdentifier, + override val user: User, override val date: DateTime, override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, 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 cfccea7958..a51e011d8a 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 @@ -296,6 +296,7 @@ internal data class RawMessage( null -> CommonGroupMessageImpl( chat, messageId, + from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), date.asDate, forwarded, edit_date ?.asDate, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt index 0338591bcb..5b0df8433a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt @@ -17,4 +17,4 @@ interface AnonymousGroupMessage : GroupMessage, SignedMes override val senderChat: GroupChat get() = chat } -interface CommonGroupMessage : GroupMessage +interface CommonGroupMessage : GroupMessage, FromUserMessage From 98f68a9e1ebbc56054af489a7700833831de0c73 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 21:54:14 +0600 Subject: [PATCH 08/12] filling of changelog --- CHANGELOG.md | 3 +++ .../utils/shortcuts/EventsShortcuts.kt | 21 ++++--------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05fd2c1807..5f6ffa0f19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ * `TextContent#entities` has been deprecated * `GroupEventMessage` now overrides `chatEvent` with type `GroupEvent` * `SupergroupEventMessage` now overrides `chatEvent` with type `SupergroupEvent` + * Any `ChatEventMessage` now have generic type of its `chatEvent` (just like messages) +* `Utils`: + * A lot of extensions for `Flow` has been added ## 0.30.3 diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index 4f3493d206..24f83fcae4 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -1,35 +1,22 @@ +@file:Suppress("NOTHING_TO_INLINE", "unused") + package dev.inmo.tgbotapi.extensions.utils.shortcuts -import dev.inmo.tgbotapi.extensions.utils.aggregateFlows import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.* -import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature -import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.* -/** - * @param scopeToIncludeChannels This parameter is required when you want to include [textMessages] for channels too. - * In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messageFlow] and - * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping - */ -@Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE") @RiskFeature("Use with caution") -inline fun FlowsUpdatesFilter.filterChannelEvents(): Flow> = channelPostFlow.mapNotNull { +inline fun FlowsUpdatesFilter.channelEvents(): Flow> = channelPostFlow.mapNotNull { it.data as? ChannelEventMessage<*> } -/** - * @param scopeToIncludeChannels This parameter is required when you want to include [textMessages] for channels too. - * In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messageFlow] and - * [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping - */ -@Suppress("UNCHECKED_CAST") @RiskFeature("Use with caution") -inline fun > FlowsUpdatesFilter.filterGroupEvents(): Flow = messageFlow.mapNotNull { +inline fun > FlowsUpdatesFilter.groupEvents(): Flow = messageFlow.mapNotNull { it.data as? T } From 71dac706351e46a85e566dd64075361d73196441 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 22:02:06 +0600 Subject: [PATCH 09/12] deprecations in old functions --- .../ChatEventsSourcesConversations.kt | 16 +++++++++++----- .../utils/shortcuts/EventsShortcuts.kt | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt index eabe98cddc..af0a1bad5c 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt @@ -1,13 +1,16 @@ package dev.inmo.tgbotapi.extensions.utils.chat_events +import dev.inmo.tgbotapi.extensions.utils.shortcuts.* import dev.inmo.tgbotapi.types.message.* +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.mapNotNull import kotlin.reflect.KClass - -fun Flow.divideBySource(contentType: KClass) = mapNotNull { +@Deprecated("Refactored, replaced and renamed", ReplaceWith("filterByChatEvent", "dev.inmo.tgbotapi.extensions.utils.shortcuts.filterByChatEvent")) +fun > Flow>.divideBySource(contentType: KClass) = mapNotNull { if (contentType.isInstance(it)) { @Suppress("UNCHECKED_CAST") it as T @@ -16,6 +19,9 @@ fun Flow.divideBySource(contentType: KC } } -fun Flow.onlyChannelEvents() = divideBySource(ChannelEventMessage::class) -fun Flow.onlyGroupEvents() = divideBySource(CommonGroupEventMessage::class) -fun Flow.onlySupergroupEvents() = divideBySource(CommonSupergroupEventMessage::class) +@Deprecated("Replaced and renamed", ReplaceWith("allChannelEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allChannelEvents")) +fun Flow>.onlyChannelEvents() = allChannelEvents() +@Deprecated("Replaced and renamed", ReplaceWith("allGroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allGroupEvents")) +fun Flow>.onlyGroupEvents() = allGroupEvents() +@Deprecated("Replaced and renamed", ReplaceWith("allSupergroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allSupergroupEvents")) +fun Flow>.onlySupergroupEvents() = allSupergroupEvents() diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index 24f83fcae4..21a093595a 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -36,6 +36,7 @@ inline fun Flow>.deletedChannelPhotoEvents() = channelEvents inline fun Flow>.newChannelPhotoEvents() = channelEvents() inline fun Flow>.newChannelTitleEvents() = channelEvents() inline fun Flow>.newChannelPinnedMessageEvents() = channelEvents() +inline fun Flow>.allChannelEvents() = channelEvents() @RiskFeature("Use with caution") inline fun Flow>.groupEvents() = filterByChatEvent>() @@ -47,6 +48,7 @@ inline fun Flow>.newGroupPhotoEvents() = groupEvents>.newGroupTitleEvents() = groupEvents() inline fun Flow>.newGroupPinnedMessageEvents() = groupEvents() inline fun Flow>.proximityAlertTriggeredInGroupEvents() = groupEvents() +inline fun Flow>.allGroupEvents() = groupEvents() @RiskFeature("Use with caution") @@ -59,3 +61,4 @@ inline fun Flow>.newSupergroupPhotoEvents() = supergroupEven inline fun Flow>.newSupergroupTitleEvents() = supergroupEvents() inline fun Flow>.newSupergroupPinnedMessageEvents() = supergroupEvents() inline fun Flow>.proximityAlertTriggeredInSupergroupEvents() = supergroupEvents() +inline fun Flow>.allSupergroupEvents() = supergroupEvents() From f6ec82b44942d3615becd5550e3ed6e27cef3a51 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 22:04:34 +0600 Subject: [PATCH 10/12] deprecate old asChatEventsFlow --- .../utils/updates/SentMessageUpdatesConversations.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt index 1e4549b09f..4ee4c8fc40 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt @@ -19,12 +19,15 @@ fun Flow.asCommonMessagesFlow() = mapNotNull { it.data as? CommonMessage<*> } +@Suppress("NOTHING_TO_INLINE") +inline fun Flow.chatEvents() = mapNotNull { + it.data as? ChatEventMessage<*> +} /** * Will map incoming [BaseSentMessageUpdate]s to [ChatEventMessage] from [BaseSentMessageUpdate.data] */ -fun Flow.asChatEventsFlow() = mapNotNull { - it.data as? ChatEventMessage -} +@Deprecated("Renamed", ReplaceWith("chatEvents", "dev.inmo.tgbotapi.extensions.utils.updates.chatEvents")) +fun Flow.asChatEventsFlow() = chatEvents() /** * Will map incoming [BaseSentMessageUpdate]s to [UnknownMessageType] from [BaseSentMessageUpdate.data] From b0219389fc178d8a4cb53d40eefbc6c5ea3dad2f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 22:23:10 +0600 Subject: [PATCH 11/12] add several functions and changelog notes --- CHANGELOG.md | 10 ++++++++-- gradle.properties | 2 +- .../extensions/utils/shortcuts/EventsShortcuts.kt | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f6ffa0f19..1445175932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * `Common`: * `Version`: - * `MicroUtils`: `0.3.1` -> `0.3.2` + * `MicroUtils`: `0.3.1` -> `0.3.3` * `Core`: * `MultilevelTextSource#textSources` has been safely renamed to `subsources` * `TextContent#fullEntitiesList` has been deprecated @@ -14,7 +14,13 @@ * `SupergroupEventMessage` now overrides `chatEvent` with type `SupergroupEvent` * Any `ChatEventMessage` now have generic type of its `chatEvent` (just like messages) * `Utils`: - * A lot of extensions for `Flow` has been added + * Old extensions related to chat events are deprecated: + * `Flow>#divideBySource` + * `Flow>#onlyChannelEvents` + * `Flow>#onlyGroupEvents` + * `Flow>#onlySupergroupEvents` + * A lot of extensions for `Flow` has been added: + * `FlowsUpdatesFilter#channelEvents` ## 0.30.3 diff --git a/gradle.properties b/gradle.properties index 865aaa403b..59e7102e0a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=1.12.1 uuid_version=0.2.2 ktor_version=1.4.2 -micro_utils_version=0.3.2 +micro_utils_version=0.3.3 javax_activation_version=1.1.1 diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index 21a093595a..381af8efa4 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.shortcuts +import dev.inmo.micro_utils.coroutines.plus import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -10,14 +11,24 @@ import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.coroutines.flow.* +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.events(): Flow> { + return channelPostFlow.mapNotNull { it.data as? ChatEventMessage<*> } + messageFlow.mapNotNull { it.data as? ChatEventMessage<*> } +} + @RiskFeature("Use with caution") inline fun FlowsUpdatesFilter.channelEvents(): Flow> = channelPostFlow.mapNotNull { it.data as? ChannelEventMessage<*> } @RiskFeature("Use with caution") -inline fun > FlowsUpdatesFilter.groupEvents(): Flow = messageFlow.mapNotNull { - it.data as? T +inline fun FlowsUpdatesFilter.groupEvents(): Flow> = messageFlow.mapNotNull { + it.data as? GroupEventMessage<*> +} + +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.supergroupEvents(): Flow> = messageFlow.mapNotNull { + it.data as? SupergroupEventMessage<*> } @RiskFeature("Use with caution") From 1f40ce1a819469a42fb1048a7f949c83dbf75d48 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 12 Nov 2020 22:35:27 +0600 Subject: [PATCH 12/12] add a lot of shortcuts for events --- CHANGELOG.md | 4 + .../ChatEventsSourcesConversations.kt | 15 ++-- .../utils/shortcuts/EventsShortcuts.kt | 89 ++++++++++++------- 3 files changed, 66 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1445175932..fd46ba7a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,11 @@ * `Flow>#onlyGroupEvents` * `Flow>#onlySupergroupEvents` * A lot of extensions for `Flow` has been added: + * `FlowsUpdatesFilter#events` * `FlowsUpdatesFilter#channelEvents` + * `FlowsUpdatesFilter#groupEvents` + * `FlowsUpdatesFilter#supergroupEvents` + * And a lot of other filters with specific types ## 0.30.3 diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt index af0a1bad5c..43504fef31 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/chat_events/ChatEventsSourcesConversations.kt @@ -1,9 +1,6 @@ package dev.inmo.tgbotapi.extensions.utils.chat_events import dev.inmo.tgbotapi.extensions.utils.shortcuts.* -import dev.inmo.tgbotapi.types.message.* -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.mapNotNull @@ -19,9 +16,9 @@ fun > Flow>.divideBySource(contentTy } } -@Deprecated("Replaced and renamed", ReplaceWith("allChannelEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allChannelEvents")) -fun Flow>.onlyChannelEvents() = allChannelEvents() -@Deprecated("Replaced and renamed", ReplaceWith("allGroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allGroupEvents")) -fun Flow>.onlyGroupEvents() = allGroupEvents() -@Deprecated("Replaced and renamed", ReplaceWith("allSupergroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.allSupergroupEvents")) -fun Flow>.onlySupergroupEvents() = allSupergroupEvents() +@Deprecated("Replaced and renamed", ReplaceWith("channelEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.channelEvents")) +fun Flow>.onlyChannelEvents() = channelEvents() +@Deprecated("Replaced and renamed", ReplaceWith("groupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.groupEvents")) +fun Flow>.onlyGroupEvents() = groupEvents() +@Deprecated("Replaced and renamed", ReplaceWith("supergroupEvents", "dev.inmo.tgbotapi.extensions.utils.shortcuts.supergroupEvents")) +fun Flow>.onlySupergroupEvents() = supergroupEvents() diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index 381af8efa4..c9f0831301 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -1,4 +1,4 @@ -@file:Suppress("NOTHING_TO_INLINE", "unused") +@file:Suppress("NOTHING_TO_INLINE", "unused", "EXPERIMENTAL_API_USAGE") package dev.inmo.tgbotapi.extensions.utils.shortcuts @@ -33,43 +33,66 @@ inline fun FlowsUpdatesFilter.supergroupEvents(): Flow @RiskFeature("Use with caution") inline fun > Flow>.filterByChatEvent(): Flow = mapNotNull { - if (it.chatEvent is T) { - it as? O - } else { - null - } + if (it.chatEvent is T) it as? O else null } @RiskFeature("Use with caution") -inline fun Flow>.channelEvents() = filterByChatEvent>() -inline fun Flow>.channelCreatedEvents() = channelEvents() -inline fun Flow>.deletedChannelPhotoEvents() = channelEvents() -inline fun Flow>.newChannelPhotoEvents() = channelEvents() -inline fun Flow>.newChannelTitleEvents() = channelEvents() -inline fun Flow>.newChannelPinnedMessageEvents() = channelEvents() -inline fun Flow>.allChannelEvents() = channelEvents() +inline fun Flow>.filterChannelEvents() = filterByChatEvent>() +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.filterChannelEvents() = channelEvents().filterChannelEvents() +inline fun Flow>.channelCreatedEvents() = filterChannelEvents() +inline fun FlowsUpdatesFilter.channelCreatedEvents() = filterChannelEvents() +inline fun Flow>.deletedChannelPhotoEvents() = filterChannelEvents() +inline fun FlowsUpdatesFilter.deletedChannelPhotoEvents() = filterChannelEvents() +inline fun Flow>.newChannelPhotoEvents() = filterChannelEvents() +inline fun FlowsUpdatesFilter.newChannelPhotoEvents() = filterChannelEvents() +inline fun Flow>.newChannelTitleEvents() = filterChannelEvents() +inline fun FlowsUpdatesFilter.newChannelTitleEvents() = filterChannelEvents() +inline fun Flow>.newChannelPinnedMessageEvents() = filterChannelEvents() +inline fun FlowsUpdatesFilter.newChannelPinnedMessageEvents() = filterChannelEvents() +inline fun Flow>.channelEvents() = filterChannelEvents() @RiskFeature("Use with caution") -inline fun Flow>.groupEvents() = filterByChatEvent>() -inline fun Flow>.groupCreatedEvents() = groupEvents() -inline fun Flow>.deletedGroupPhotoEvents() = groupEvents() -inline fun Flow>.newGroupMembersEvents() = groupEvents() -inline fun Flow>.leftGroupMemberEvents() = groupEvents() -inline fun Flow>.newGroupPhotoEvents() = groupEvents() -inline fun Flow>.newGroupTitleEvents() = groupEvents() -inline fun Flow>.newGroupPinnedMessageEvents() = groupEvents() -inline fun Flow>.proximityAlertTriggeredInGroupEvents() = groupEvents() -inline fun Flow>.allGroupEvents() = groupEvents() +inline fun Flow>.filterGroupEvents() = filterByChatEvent>() +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.filterGroupEvents() = groupEvents().filterByChatEvent>() +inline fun Flow>.groupCreatedEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.groupCreatedEvents() = filterGroupEvents() +inline fun Flow>.deletedGroupPhotoEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.deletedGroupPhotoEvents() = filterGroupEvents() +inline fun Flow>.newGroupMembersEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.newGroupMembersEvents() = filterGroupEvents() +inline fun Flow>.leftGroupMemberEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.leftGroupMemberEvents() = filterGroupEvents() +inline fun Flow>.newGroupPhotoEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.newGroupPhotoEvents() = filterGroupEvents() +inline fun Flow>.newGroupTitleEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.newGroupTitleEvents() = filterGroupEvents() +inline fun Flow>.newGroupPinnedMessageEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.newGroupPinnedMessageEvents() = filterGroupEvents() +inline fun Flow>.proximityAlertTriggeredInGroupEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.proximityAlertTriggeredInGroupEvents() = filterGroupEvents() +inline fun Flow>.groupEvents() = filterGroupEvents() @RiskFeature("Use with caution") -inline fun Flow>.supergroupEvents() = filterByChatEvent>() -inline fun Flow>.supergroupCreatedEvents() = supergroupEvents() -inline fun Flow>.deletedSupergroupPhotoEvents() = supergroupEvents() -inline fun Flow>.newSupergroupMembersEvents() = supergroupEvents() -inline fun Flow>.leftSupergroupMemberEvents() = supergroupEvents() -inline fun Flow>.newSupergroupPhotoEvents() = supergroupEvents() -inline fun Flow>.newSupergroupTitleEvents() = supergroupEvents() -inline fun Flow>.newSupergroupPinnedMessageEvents() = supergroupEvents() -inline fun Flow>.proximityAlertTriggeredInSupergroupEvents() = supergroupEvents() -inline fun Flow>.allSupergroupEvents() = supergroupEvents() +inline fun Flow>.filterSupergroupEvents() = filterByChatEvent>() +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.filterSupergroupEvents() = supergroupEvents().filterByChatEvent>() +inline fun Flow>.supergroupCreatedEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.supergroupCreatedEvents() = filterSupergroupEvents() +inline fun Flow>.deletedSupergroupPhotoEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.deletedSupergroupPhotoEvents() = filterSupergroupEvents() +inline fun Flow>.newSupergroupMembersEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.newSupergroupMembersEvents() = filterSupergroupEvents() +inline fun Flow>.leftSupergroupMemberEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.leftSupergroupMemberEvents() = filterSupergroupEvents() +inline fun Flow>.newSupergroupPhotoEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.newSupergroupPhotoEvents() = filterSupergroupEvents() +inline fun Flow>.newSupergroupTitleEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.newSupergroupTitleEvents() = filterSupergroupEvents() +inline fun Flow>.newSupergroupPinnedMessageEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.newSupergroupPinnedMessageEvents() = filterSupergroupEvents() +inline fun Flow>.proximityAlertTriggeredInSupergroupEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.proximityAlertTriggeredInSupergroupEvents() = filterSupergroupEvents() +inline fun Flow>.supergroupEvents() = filterSupergroupEvents()