From 69c5f1ae7d9b6b1d0b5ca3453f681a13acad00a9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 02:16:12 +0600 Subject: [PATCH 1/7] start 3.2.6 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2980780c81..fdc4de935c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 3.2.6 + ## 3.2.5 * `Common`: diff --git a/gradle.properties b/gradle.properties index 81d9914db5..7a9d06557d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=3.2.5 +library_version=3.2.6 From d450ed9126760ebaf49649497c3ab7bc6f2e76b8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 02:17:40 +0600 Subject: [PATCH 2/7] Fixes in ChatMemberSerializer#serialize method --- CHANGELOG.md | 3 +++ .../inmo/tgbotapi/types/chat/member/ChatMember.kt | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdc4de935c..2a5b753e50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 3.2.6 +* `Core`: + * Fixes in `ChatMemberSerializer#serialize` method + ## 3.2.5 * `Common`: diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt index 584606fe2f..112e078521 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt @@ -34,12 +34,12 @@ object ChatMemberSerializer : KSerializer { override fun serialize(encoder: Encoder, value: ChatMember) { when (value) { - is OwnerChatMember -> OwnerChatMember.serializer() - is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer() - is MemberChatMember -> MemberChatMemberImpl.serializer() - is RestrictedChatMember -> RestrictedChatMember.serializer() - is LeftChatMember -> LeftChatMemberImpl.serializer() - is KickedChatMember -> KickedChatMember.serializer() + is OwnerChatMember -> OwnerChatMember.serializer().serialize(encoder, value) + is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer().serialize(encoder, value) + is MemberChatMemberImpl -> MemberChatMemberImpl.serializer().serialize(encoder, value) + is RestrictedChatMember -> RestrictedChatMember.serializer().serialize(encoder, value) + is LeftChatMemberImpl -> LeftChatMemberImpl.serializer().serialize(encoder, value) + is KickedChatMember -> KickedChatMember.serializer().serialize(encoder, value) } } } From a4a82f69c6f7fcad106bbbc66ceb6319962901b0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 11:18:01 +0600 Subject: [PATCH 3/7] replace entities builder --- CHANGELOG.md | 3 + .../inmo/tgbotapi/utils/EntitiesBuilder.kt | 568 ++++++++++++++++++ .../inmo/tgbotapi/types/TextSourcesTests.kt | 2 +- .../utils/formatting/EntitiesBuilder.kt | 154 ++++- 4 files changed, 716 insertions(+), 11 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5b753e50..2c489d8497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ * `Core`: * Fixes in `ChatMemberSerializer#serialize` method + * Migration of `EntitiesBuilder` from `Utils` to `Core` +* `Utils`: + * Migration of `EntitiesBuilder` from `Utils` to `Core` ## 3.2.5 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt new file mode 100644 index 0000000000..8960195a75 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/EntitiesBuilder.kt @@ -0,0 +1,568 @@ +@file:Suppress("NOTHING_TO_INLINE", "unused") + +package dev.inmo.tgbotapi.utils + +import dev.inmo.micro_utils.common.joinTo +import dev.inmo.tgbotapi.types.CustomEmojiId +import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.message.textsources.* + +typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit +val newLine = regular("\n") + +inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build() +inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init) + +/** + * This builder can be used to provide building of [TextSource]s [List] + * + * @see buildEntities + */ +class EntitiesBuilder( + val separator: TextSource? = null +) { + private val entitiesList: MutableTextSourcesList = mutableListOf() + + /** + * It is not safe field which contains potentially changeable [List] + */ + val entities: TextSourcesList + get() = entitiesList + + /** + * @return New immutable list which will be deattached from this builder + */ + fun build(): TextSourcesList = if (separator != null) entities.joinTo(separator) else entities.toList() + + fun add(source: TextSource): EntitiesBuilder { + entitiesList.add(source) + return this + } + + fun addAll(sources: Iterable): EntitiesBuilder { + entitiesList.addAll(sources) + return this + } + + operator fun TextSource.unaryPlus() = add(this) + operator fun TextSourcesList.unaryPlus() = addAll(this) + operator fun invoke(vararg source: TextSource) = addAll(source.toList()) + + operator fun String.unaryPlus(): EntitiesBuilder { + add(dev.inmo.tgbotapi.types.message.textsources.regular(this)) + return this@EntitiesBuilder + } + + operator fun plus(text: String) = text.unaryPlus() + operator fun plus(source: TextSource) = add(source) + operator fun plus(sources: Iterable) = addAll(sources) + + operator fun plus(other: EntitiesBuilder) = if (other == this) { + // do nothing; assume user is using something like regular("Hello, ") + bold("world") in buildEntities + this + } else { + addAll(other.entitiesList) + } +} + +/** + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] + */ +inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.bold(parts)) +/** + * Version of [EntitiesBuilder.bold] with new line at the end + */ +inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine +/** + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.bold] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine +/** + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] + */ +inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.bold(*parts)) +/** + * Version of [EntitiesBuilder.bold] with new line at the end + */ +inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine +/** + * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] + */ +inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.bold(text)) +/** + * Version of [EntitiesBuilder.bold] with new line at the end + */ +inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine + +/** + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] + */ +inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(parts)) +/** + * Version of [EntitiesBuilder.spoiler] with new line at the end + */ +inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine +/** + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.spoiler] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine +/** + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] + */ +inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts)) +/** + * Version of [EntitiesBuilder.spoiler] with new line at the end + */ +inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine +/** + * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] + */ +inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(text)) +/** + * Version of [EntitiesBuilder.spoiler] with new line at the end + */ +inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine + + +/** + * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] + */ +inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(command)) +/** + * Version of [EntitiesBuilder.botCommand] with new line at the end + */ +inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine + + +/** + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] + */ +inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(parts)) +/** + * Version of [EntitiesBuilder.cashTag] with new line at the end + */ +inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine +/** + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.cashTag] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine +/** + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] + */ +inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts)) +/** + * Version of [EntitiesBuilder.cashTag] with new line at the end + */ +inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine +/** + * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] + */ +inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(text)) +/** + * Version of [EntitiesBuilder.cashTag] with new line at the end + */ +inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine + + +/** + * Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code] + */ +inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.code(code)) +/** + * Version of [EntitiesBuilder.code] with new line at the end + */ +inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine + + +/** + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] + */ +inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.email(parts)) +/** + * Version of [EntitiesBuilder.email] with new line at the end + */ +inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine +/** + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.email] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine +/** + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] + */ +inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.email(*parts)) +/** + * Version of [EntitiesBuilder.email] with new line at the end + */ +inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine +/** + * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] + */ +inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.email(emailAddress)) +/** + * Version of [EntitiesBuilder.email] with new line at the end + */ +inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + newLine + + +/** + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] + */ +inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(parts)) +/** + * Version of [EntitiesBuilder.hashtag] with new line at the end + */ +inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine +/** + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.hashtag] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine +/** + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] + */ +inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts)) +/** + * Version of [EntitiesBuilder.hashtag] with new line at the end + */ +inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine +/** + * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] + */ +inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(hashtag)) +/** + * Version of [EntitiesBuilder.hashtag] with new line at the end + */ +inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLine + + +/** + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] + */ +inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italic(parts)) +/** + * Version of [EntitiesBuilder.italic] with new line at the end + */ +inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine +/** + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.italic] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine +/** + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] + */ +inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italic(*parts)) +/** + * Version of [EntitiesBuilder.italic] with new line at the end + */ +inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine +/** + * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] + */ +inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italic(text)) +/** + * Version of [EntitiesBuilder.italic] with new line at the end + */ +inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine + + +/** + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] + */ +inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts)) +/** + * Version of [EntitiesBuilder.mention] with new line at the end + */ +inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine +/** + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.mention] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine +/** + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] + */ +inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mention(*parts)) +/** + * Version of [EntitiesBuilder.mention] with new line at the end + */ +inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine +/** + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] + */ +inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention)) +/** + * Version of [EntitiesBuilder.mention] with new line at the end + */ +inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine +/** + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] + */ +inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, user)) +/** + * Version of [EntitiesBuilder.mention] with new line at the end + */ +inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = mention(parts, user) + newLine +inline fun EntitiesBuilder.mention( + user: User, + vararg parts: TextSource +) = add(dev.inmo.tgbotapi.types.message.textsources.mention(user, *parts)) +/** + * Version of [EntitiesBuilder.mention] with new line at the end + */ +inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine +/** + * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] + */ +inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, user)) +/** + * Version of [EntitiesBuilder.mention] with new line at the end + */ +inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text, user) + newLine + + +/** + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] + */ +inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phone(parts)) +/** + * Version of [EntitiesBuilder.phone] with new line at the end + */ +inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine +/** + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.phone] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine +/** + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] + */ +inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phone(*parts)) +/** + * Version of [EntitiesBuilder.phone] with new line at the end + */ +inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine +/** + * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] + */ +inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phone(number)) +/** + * Version of [EntitiesBuilder.phone] with new line at the end + */ +inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine + + +/** + * Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre] + */ +inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.pre(code, language)) +/** + * Version of [EntitiesBuilder.pre] with new line at the end + */ +inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code, language) + newLine + +/** + * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] + * + * @see RegularTextSource + * @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln + */ +inline fun EntitiesBuilder.regular(text: String) = + add(dev.inmo.tgbotapi.types.message.textsources.regular(text)) +/** + * Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] and "\n" at the end + * + * @see RegularTextSource + * @see dev.inmo.tgbotapi.extensions.utils.formatting.regular + */ +inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine + + +/** + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] + */ +inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts)) +/** + * Version of [EntitiesBuilder.strikethrough] with new line at the end + */ +inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine +/** + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.strikethrough] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine +/** + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] + */ +inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts)) +/** + * Version of [EntitiesBuilder.strikethrough] with new line at the end + */ +inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine +/** + * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] + */ +inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(text)) +/** + * Version of [EntitiesBuilder.strikethrough] with new line at the end + */ +inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + newLine + + +/** + * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] + */ +inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(text, url)) +/** + * Version of [EntitiesBuilder.link] with new line at the end + */ +inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine +/** + * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] + */ +inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(url)) +/** + * Version of [EntitiesBuilder.link] with new line at the end + */ +inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine + + +/** + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] + */ +inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underline(parts)) +/** + * Version of [EntitiesBuilder.underline] with new line at the end + */ +inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine +/** + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline( + buildEntities(separator, init) +)) +/** + * Version of [EntitiesBuilder.underline] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine +/** + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] + */ +inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underline(*parts)) +/** + * Version of [EntitiesBuilder.underline] with new line at the end + */ +inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine +/** + * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] + */ +inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underline(text)) +/** + * Version of [EntitiesBuilder.underline] with new line at the end + */ +inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine + + +/** + * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] + */ +inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts)) +/** + * Version of [EntitiesBuilder.customEmoji] with new line at the end + */ +inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine +/** + * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init))) +/** + * Version of [EntitiesBuilder.customEmoji] with new line at the end. + * Will reuse separator config from [buildEntities] + */ +inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine +/** + * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] + */ +inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts)) +/** + * Version of [EntitiesBuilder.customEmoji] with new line at the end + */ +inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine +/** + * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] + */ +inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text)) +/** + * Version of [EntitiesBuilder.customEmoji] with new line at the end + */ +inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine diff --git a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt index ab4cba5547..c706df619a 100644 --- a/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt +++ b/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/TextSourcesTests.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types import dev.inmo.tgbotapi.TestsJsonFormat -import dev.inmo.tgbotapi.extensions.utils.formatting.* import dev.inmo.tgbotapi.types.message.textsources.TextSourceSerializer +import dev.inmo.tgbotapi.utils.* import dev.inmo.tgbotapi.utils.extensions.makeString import kotlinx.serialization.builtins.ListSerializer import kotlin.test.Test diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt index d8a809aa4f..c298ab53ed 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt @@ -8,10 +8,17 @@ import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.message.textsources.* import dev.inmo.tgbotapi.utils.RiskFeature +private const val ReplacedInCoreModuleReason = "Replaced in core module" +private const val CoreModulePackage = "dev.inmo.tgbotapi.utils" + +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilderBody", "$CoreModulePackage.EntitiesBuilderBody")) typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("newLine", "$CoreModulePackage.newLine")) val newLine = regular("\n") +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities", "$CoreModulePackage.buildEntities")) inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build() +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities", "$CoreModulePackage.buildEntities")) inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init) /** @@ -19,6 +26,7 @@ inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEn * * @see buildEntities */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilder", "$CoreModulePackage.EntitiesBuilder")) class EntitiesBuilder @RiskFeature constructor( val separator: TextSource? = null ) { @@ -69,280 +77,357 @@ class EntitiesBuilder @RiskFeature constructor( /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.bold(parts)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) +inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.bold] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.bold(*parts)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.bold(text)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(parts)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) +inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(text)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine /** * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommand", "$CoreModulePackage.botCommand")) inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(command)) /** * Version of [EntitiesBuilder.botCommand] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommandln", "$CoreModulePackage.botCommandln")) inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(parts)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) +inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(text)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine /** * Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("code", "$CoreModulePackage.code")) inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.code(code)) /** * Version of [EntitiesBuilder.code] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("codeln", "$CoreModulePackage.codeln")) inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.email(parts)) /** * Version of [EntitiesBuilder.email] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) +inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.email] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.email(*parts)) /** * Version of [EntitiesBuilder.email] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.email(emailAddress)) /** * Version of [EntitiesBuilder.email] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(parts)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) +inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(hashtag)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italic(parts)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) +inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.italic] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italic(*parts)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italic(text)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.mention] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mention(*parts)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, user)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = mention(parts) + newLine +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention( user: User, vararg parts: TextSource @@ -350,60 +435,75 @@ inline fun EntitiesBuilder.mention( /** * Version of [EntitiesBuilder.mention] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, user)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phone(parts)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) +inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.phone] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phone(*parts)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phone(number)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine /** * Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("pre", "$CoreModulePackage.pre")) inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.pre(code, language)) /** * Version of [EntitiesBuilder.pre] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("preln", "$CoreModulePackage.preln")) inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + newLine /** @@ -412,6 +512,7 @@ inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + * @see RegularTextSource * @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regular", "$CoreModulePackage.regular")) inline fun EntitiesBuilder.regular(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.regular(text)) /** @@ -420,130 +521,163 @@ inline fun EntitiesBuilder.regular(text: String) = * @see RegularTextSource * @see dev.inmo.tgbotapi.extensions.utils.formatting.regular */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regularln", "$CoreModulePackage.regularln")) inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) +inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(text)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + newLine /** * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link", "$CoreModulePackage.link")) inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(text, url)) /** * Version of [EntitiesBuilder.link] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln", "$CoreModulePackage.linkln")) inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine /** * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link", "$CoreModulePackage.link")) inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(url)) /** * Version of [EntitiesBuilder.link] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln", "$CoreModulePackage.linkln")) inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underline(parts)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]. * Will reuse separator config from [buildEntities] */ -inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline(buildEntities(separator, init))) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) +inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline( + buildEntities(separator, init) +)) /** * Version of [EntitiesBuilder.underline] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underline(*parts)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underline(text)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts)) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init))) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end. * Will reuse separator config from [buildEntities] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts)) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text)) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end */ +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine From 0aa58bd9f677503bb7a784514abb6def14c69c71 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 12:10:17 +0600 Subject: [PATCH 4/7] improve deprecation messages in old entities builder --- .../utils/formatting/EntitiesBuilder.kt | 263 ++++++++---------- 1 file changed, 109 insertions(+), 154 deletions(-) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt index c298ab53ed..a3d5e507d9 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt @@ -16,9 +16,9 @@ typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("newLine", "$CoreModulePackage.newLine")) val newLine = regular("\n") -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities", "$CoreModulePackage.buildEntities")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities")) inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build() -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities", "$CoreModulePackage.buildEntities")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities")) inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init) /** @@ -27,68 +27,23 @@ inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEn * @see buildEntities */ @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilder", "$CoreModulePackage.EntitiesBuilder")) -class EntitiesBuilder @RiskFeature constructor( - val separator: TextSource? = null -) { - private val entitiesList: MutableTextSourcesList = mutableListOf() - - /** - * It is not safe field which contains potentially changeable [List] - */ - val entities: TextSourcesList - get() = entitiesList - - /** - * @return New immutable list which will be deattached from this builder - */ - fun build(): TextSourcesList = if (separator != null) entities.joinTo(separator) else entities.toList() - - fun add(source: TextSource): EntitiesBuilder { - entitiesList.add(source) - return this - } - - fun addAll(sources: Iterable): EntitiesBuilder { - entitiesList.addAll(sources) - return this - } - - operator fun TextSource.unaryPlus() = add(this) - operator fun TextSourcesList.unaryPlus() = addAll(this) - operator fun invoke(vararg source: TextSource) = addAll(source.toList()) - - operator fun String.unaryPlus(): EntitiesBuilder { - add(dev.inmo.tgbotapi.types.message.textsources.regular(this)) - return this@EntitiesBuilder - } - - operator fun plus(text: String) = text.unaryPlus() - operator fun plus(source: TextSource) = add(source) - operator fun plus(sources: Iterable) = addAll(sources) - - operator fun plus(other: EntitiesBuilder) = if (other == this) { - // do nothing; assume user is using something like regular("Hello, ") + bold("world") in buildEntities - this - } else { - addAll(other.entitiesList) - } -} +typealias EntitiesBuilder = dev.inmo.tgbotapi.utils.EntitiesBuilder /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(parts)", "$CoreModulePackage.bold")) inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.bold(parts)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(parts)", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(init)", "$CoreModulePackage.bold")) inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold( buildEntities(separator, init) )) @@ -96,44 +51,44 @@ inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.in * Version of [EntitiesBuilder.bold] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(init)", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(parts)", "$CoreModulePackage.bold")) inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.bold(*parts)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(parts)", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine /** * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold", "$CoreModulePackage.bold")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(text)", "$CoreModulePackage.bold")) inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.bold(text)) /** * Version of [EntitiesBuilder.bold] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln", "$CoreModulePackage.boldln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(text)", "$CoreModulePackage.boldln")) inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(parts)", "$CoreModulePackage.spoiler")) inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(parts)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(parts)", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(init)", "$CoreModulePackage.spoiler")) inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler( buildEntities(separator, init) )) @@ -141,57 +96,57 @@ inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev * Version of [EntitiesBuilder.spoiler] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(init)", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(parts)", "$CoreModulePackage.spoiler")) inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(parts)", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine /** * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler", "$CoreModulePackage.spoiler")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(text)", "$CoreModulePackage.spoiler")) inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(text)) /** * Version of [EntitiesBuilder.spoiler] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln", "$CoreModulePackage.spoilerln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(text)", "$CoreModulePackage.spoilerln")) inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine /** * Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommand", "$CoreModulePackage.botCommand")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommand(command)", "$CoreModulePackage.botCommand")) inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(command)) /** * Version of [EntitiesBuilder.botCommand] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommandln", "$CoreModulePackage.botCommandln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommandln(command)", "$CoreModulePackage.botCommandln")) inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(parts)", "$CoreModulePackage.cashTag")) inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(parts)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(parts)", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(init)", "$CoreModulePackage.cashTag")) inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag( buildEntities(separator, init) )) @@ -199,57 +154,57 @@ inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev * Version of [EntitiesBuilder.cashTag] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(init)", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(parts)", "$CoreModulePackage.cashTag")) inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(parts)", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine /** * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag", "$CoreModulePackage.cashTag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(text)", "$CoreModulePackage.cashTag")) inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(text)) /** * Version of [EntitiesBuilder.cashTag] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln", "$CoreModulePackage.cashTagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(text)", "$CoreModulePackage.cashTagln")) inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine /** * Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("code", "$CoreModulePackage.code")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("code(code)", "$CoreModulePackage.code")) inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.code(code)) /** * Version of [EntitiesBuilder.code] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("codeln", "$CoreModulePackage.codeln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("codeln(code)", "$CoreModulePackage.codeln")) inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(parts)", "$CoreModulePackage.email")) inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.email(parts)) /** * Version of [EntitiesBuilder.email] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(parts)", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(init)", "$CoreModulePackage.email")) inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email( buildEntities(separator, init) )) @@ -257,45 +212,45 @@ inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.i * Version of [EntitiesBuilder.email] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(init)", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(parts)", "$CoreModulePackage.email")) inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.email(*parts)) /** * Version of [EntitiesBuilder.email] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(parts)", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine /** * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email", "$CoreModulePackage.email")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(emailAddress)", "$CoreModulePackage.email")) inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.email(emailAddress)) /** * Version of [EntitiesBuilder.email] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln", "$CoreModulePackage.emailln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(emailAddress)", "$CoreModulePackage.emailln")) inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(parts)", "$CoreModulePackage.hashtag")) inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(parts)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(parts)", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(init)", "$CoreModulePackage.hashtag")) inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag( buildEntities(separator, init) )) @@ -303,45 +258,45 @@ inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev * Version of [EntitiesBuilder.hashtag] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(init)", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(parts)", "$CoreModulePackage.hashtag")) inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(parts)", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine /** * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag", "$CoreModulePackage.hashtag")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(hashtag)", "$CoreModulePackage.hashtag")) inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(hashtag)) /** * Version of [EntitiesBuilder.hashtag] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln", "$CoreModulePackage.hashtagln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(hashtag)", "$CoreModulePackage.hashtagln")) inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(parts)", "$CoreModulePackage.italic")) inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italic(parts)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(parts)", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(init)", "$CoreModulePackage.italic")) inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic( buildEntities(separator, init) )) @@ -349,45 +304,45 @@ inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev. * Version of [EntitiesBuilder.italic] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(init)", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(parts)", "$CoreModulePackage.italic")) inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italic(*parts)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(parts)", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine /** * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic", "$CoreModulePackage.italic")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(text)", "$CoreModulePackage.italic")) inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italic(text)) /** * Version of [EntitiesBuilder.italic] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln", "$CoreModulePackage.italicln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(text)", "$CoreModulePackage.italicln")) inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts)", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(init)", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention( buildEntities(separator, init) )) @@ -395,39 +350,39 @@ inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev * Version of [EntitiesBuilder.mention] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(init)", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mention(*parts)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts)", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(whoToMention)", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(whoToMention)", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, user)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts, user)", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = mention(parts) + newLine -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(user, parts)", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention( user: User, vararg parts: TextSource @@ -435,35 +390,35 @@ inline fun EntitiesBuilder.mention( /** * Version of [EntitiesBuilder.mention] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(user, parts)", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine /** * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention", "$CoreModulePackage.mention")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(text, user)", "$CoreModulePackage.mention")) inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, user)) /** * Version of [EntitiesBuilder.mention] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln", "$CoreModulePackage.mentionln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(text, user)", "$CoreModulePackage.mentionln")) inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(parts)", "$CoreModulePackage.phone")) inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phone(parts)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(parts)", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(init)", "$CoreModulePackage.phone")) inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone( buildEntities(separator, init) )) @@ -471,39 +426,39 @@ inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.i * Version of [EntitiesBuilder.phone] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(init)", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(parts)", "$CoreModulePackage.phone")) inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phone(*parts)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(parts)", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine /** * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone", "$CoreModulePackage.phone")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(number)", "$CoreModulePackage.phone")) inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phone(number)) /** * Version of [EntitiesBuilder.phone] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln", "$CoreModulePackage.phoneln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(number)", "$CoreModulePackage.phoneln")) inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine /** * Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("pre", "$CoreModulePackage.pre")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("pre(code, language)", "$CoreModulePackage.pre")) inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.pre(code, language)) /** * Version of [EntitiesBuilder.pre] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("preln", "$CoreModulePackage.preln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("preln(code, language)", "$CoreModulePackage.preln")) inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + newLine /** @@ -512,7 +467,7 @@ inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + * @see RegularTextSource * @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regular", "$CoreModulePackage.regular")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regular(text)", "$CoreModulePackage.regular")) inline fun EntitiesBuilder.regular(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.regular(text)) /** @@ -521,25 +476,25 @@ inline fun EntitiesBuilder.regular(text: String) = * @see RegularTextSource * @see dev.inmo.tgbotapi.extensions.utils.formatting.regular */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regularln", "$CoreModulePackage.regularln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regularln(text)", "$CoreModulePackage.regularln")) inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(parts)", "$CoreModulePackage.strikethrough")) inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(parts)", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(init)", "$CoreModulePackage.strikethrough")) inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough( buildEntities(separator, init) )) @@ -547,67 +502,67 @@ inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = a * Version of [EntitiesBuilder.strikethrough] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(init)", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(parts)", "$CoreModulePackage.strikethrough")) inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(parts)", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine /** * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough", "$CoreModulePackage.strikethrough")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(text)", "$CoreModulePackage.strikethrough")) inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(text)) /** * Version of [EntitiesBuilder.strikethrough] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln", "$CoreModulePackage.strikethroughln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(text)", "$CoreModulePackage.strikethroughln")) inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + newLine /** * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link", "$CoreModulePackage.link")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link(text, url)", "$CoreModulePackage.link")) inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(text, url)) /** * Version of [EntitiesBuilder.link] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln", "$CoreModulePackage.linkln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln(text, url)", "$CoreModulePackage.linkln")) inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine /** * Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link", "$CoreModulePackage.link")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link(url)", "$CoreModulePackage.link")) inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(url)) /** * Version of [EntitiesBuilder.link] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln", "$CoreModulePackage.linkln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln(url)", "$CoreModulePackage.linkln")) inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(parts)", "$CoreModulePackage.underline")) inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underline(parts)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(parts)", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(init)", "$CoreModulePackage.underline")) inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline( buildEntities(separator, init) )) @@ -615,69 +570,69 @@ inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(d * Version of [EntitiesBuilder.underline] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(init)", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(parts)", "$CoreModulePackage.underline")) inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underline(*parts)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(parts)", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine /** * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline", "$CoreModulePackage.underline")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(text)", "$CoreModulePackage.underline")) inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underline(text)) /** * Version of [EntitiesBuilder.underline] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln", "$CoreModulePackage.underlineln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(text)", "$CoreModulePackage.underlineln")) inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, parts)", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts)) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, parts)", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, init)", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init))) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end. * Will reuse separator config from [buildEntities] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, init)", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, parts)", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts)) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, parts)", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine /** * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji", "$CoreModulePackage.customEmoji")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, text)", "$CoreModulePackage.customEmoji")) inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text)) /** * Version of [EntitiesBuilder.customEmoji] with new line at the end */ -@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln", "$CoreModulePackage.customEmojiln")) +@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, text)", "$CoreModulePackage.customEmojiln")) inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine From c460b4eacc3a32b79b2f18cb1504cf60a4af3967 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 12:57:22 +0600 Subject: [PATCH 5/7] small refactoring inside of entities builder --- .../extensions/utils/formatting/EntitiesBuilder.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt index a3d5e507d9..3c8f597ac9 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt @@ -6,20 +6,21 @@ import dev.inmo.micro_utils.common.joinTo import dev.inmo.tgbotapi.types.CustomEmojiId import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.message.textsources.* +import dev.inmo.tgbotapi.utils.EntitiesBuilderBody import dev.inmo.tgbotapi.utils.RiskFeature private const val ReplacedInCoreModuleReason = "Replaced in core module" private const val CoreModulePackage = "dev.inmo.tgbotapi.utils" @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilderBody", "$CoreModulePackage.EntitiesBuilderBody")) -typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit +typealias EntitiesBuilderBody = EntitiesBuilderBody @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("newLine", "$CoreModulePackage.newLine")) -val newLine = regular("\n") +val newLine = dev.inmo.tgbotapi.utils.newLine @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities")) -inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build() +inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = dev.inmo.tgbotapi.utils.buildEntities(separator, init) @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities")) -inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init) +inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = dev.inmo.tgbotapi.utils.buildEntities(regular(separator), init) /** * This builder can be used to provide building of [TextSource]s [List] From 7cd97ac77968d2cf23ee23734236b5e05bd08279 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 13:52:14 +0600 Subject: [PATCH 6/7] All the extensions related to text messages (replies, sending, editing) got their duplicates with buildEntities lambda and separator --- CHANGELOG.md | 2 + .../tgbotapi/extensions/api/edit/Edits.kt | 52 +++++++ .../api/edit/text/EditChatMessageText.kt | 105 ++++++++++++- .../api/edit/text/EditInlineMessageText.kt | 27 ++++ .../tgbotapi/extensions/api/send/Replies.kt | 36 ++++- .../api/send/RepliesWithChatsAndMessages.kt | 34 ++++- .../extensions/api/send/SendMessage.kt | 138 +++++++++++++++++- .../tgbotapi/extensions/api/send/Sends.kt | 70 ++++++++- 8 files changed, 456 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c489d8497..1f1db96895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * `Core`: * Fixes in `ChatMemberSerializer#serialize` method * Migration of `EntitiesBuilder` from `Utils` to `Core` +* `API`: + * All the extensions related to text messages (replies, sending, editing) got their duplicates with `buildEntities` lambda and separator * `Utils`: * Migration of `EntitiesBuilder` from `Utils` to `Core` diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt index 0464869a11..1a33610b38 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt @@ -18,6 +18,8 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList +import dev.inmo.tgbotapi.utils.EntitiesBuilderBody +import dev.inmo.tgbotapi.utils.buildEntities /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -208,6 +210,32 @@ suspend fun TelegramBot.edit( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.edit( + chatId: ChatIdentifier, + messageId: MessageId, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.edit( + chatId: ChatIdentifier, + messageId: MessageId, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * as a builder for that @@ -230,3 +258,27 @@ suspend fun TelegramBot.edit( disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + message: ContentMessage, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + message: ContentMessage, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt index 5b2267609d..c66886e28a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt @@ -11,7 +11,8 @@ import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.TextContent -import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.types.message.textsources.TextSource +import dev.inmo.tgbotapi.utils.* /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -67,6 +68,32 @@ suspend fun TelegramBot.editMessageText( EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + chatId: ChatIdentifier, + messageId: MessageId, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + chatId: ChatIdentifier, + messageId: MessageId, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * as a builder for that @@ -79,6 +106,32 @@ suspend fun TelegramBot.editMessageText( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + chat: Chat, + messageId: MessageId, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + chat: Chat, + messageId: MessageId, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * as a builder for that @@ -90,6 +143,30 @@ suspend fun TelegramBot.editMessageText( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + message: ContentMessage, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + message: ContentMessage, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * as a builder for that @@ -101,3 +178,29 @@ suspend fun TelegramBot.editMessageText( disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") +suspend fun TelegramBot.editMessageText( + message: Message, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") +suspend fun TelegramBot.editMessageText( + message: Message, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt index 8b38b3168f..47d24abe1c 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt @@ -6,6 +6,9 @@ import dev.inmo.tgbotapi.types.InlineMessageIdentifier import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +import dev.inmo.tgbotapi.types.message.textsources.TextSource +import dev.inmo.tgbotapi.utils.EntitiesBuilderBody +import dev.inmo.tgbotapi.utils.buildEntities /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] @@ -29,3 +32,27 @@ suspend fun TelegramBot.editMessageText( disableWebPagePreview: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup)) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + inlineMessageId: InlineMessageIdentifier, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.editMessageText( + inlineMessageId: InlineMessageIdentifier, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index dd8ee6ad6a..e9f4fdeebe 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -11,7 +11,6 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.rawSendingMediaGroupsWarning import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.media.* -import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup @@ -25,11 +24,12 @@ import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.* +import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.venue.Venue -import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.* import kotlinx.coroutines.flow.Flow import kotlin.js.JsName import kotlin.jvm.JvmName @@ -210,6 +210,36 @@ suspend inline fun TelegramBot.reply( replyMarkup ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.reply( + to: Message, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.reply( + to: Message, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) + // Venue @@ -1245,7 +1275,7 @@ suspend fun TelegramBot.reply( suspend fun TelegramBot.reply( to: Message, content: TextedMediaContent, - entities: List, + entities: TextSourcesList, disableNotification: Boolean = false, protectContent: Boolean = false, allowSendingWithoutReply: Boolean? = null, diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt index 82ff3b1cbc..0a754e2c52 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/RepliesWithChatsAndMessages.kt @@ -29,7 +29,7 @@ import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.venue.Venue -import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.* import kotlinx.coroutines.flow.Flow import kotlin.js.JsName import kotlin.jvm.JvmName @@ -218,6 +218,38 @@ suspend inline fun TelegramBot.reply( replyMarkup ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.reply( + toChatId: ChatId, + toMessageId: MessageId, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.reply( + toChatId: ChatId, + toMessageId: MessageId, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) + // Venue diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt index 94358003cd..52425acfd2 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt @@ -2,12 +2,14 @@ package dev.inmo.tgbotapi.extensions.api.send import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.SendTextMessage -import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.message.textsources.TextSource +import dev.inmo.tgbotapi.utils.EntitiesBuilderBody +import dev.inmo.tgbotapi.utils.buildEntities /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -95,6 +97,39 @@ suspend fun TelegramBot.sendMessage( SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendMessage( + chatId: ChatIdentifier, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendMessage( + chatId: ChatIdentifier, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param @@ -112,6 +147,39 @@ suspend fun TelegramBot.sendTextMessage( chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendTextMessage( + chatId: ChatIdentifier, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendTextMessage( + chatId: ChatIdentifier, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param @@ -127,6 +195,39 @@ suspend fun TelegramBot.sendMessage( replyMarkup: KeyboardMarkup? = null ) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendMessage( + chat: Chat, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendMessage( + chat: Chat, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + /** * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -142,3 +243,36 @@ suspend fun TelegramBot.sendTextMessage( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendTextMessage( + chat: Chat, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.sendTextMessage( + chat: Chat, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt index 9e6c32c47c..46305fbd0a 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Sends.kt @@ -20,12 +20,13 @@ import dev.inmo.tgbotapi.types.location.StaticLocation import dev.inmo.tgbotapi.types.media.* import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.content.* +import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.venue.Venue -import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.* import kotlin.jvm.JvmName /** @@ -560,6 +561,40 @@ suspend fun TelegramBot.send( replyMarkup: KeyboardMarkup? = null ) = sendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.send( + chatId: ChatIdentifier, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.send( + chatId: ChatIdentifier, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + /** * Will execute [sendTextMessage] request * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or @@ -576,6 +611,39 @@ suspend fun TelegramBot.send( replyMarkup: KeyboardMarkup? = null ) = sendTextMessage(chat, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.send( + chat: Chat, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.send( + chat: Chat, + separator: String, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + protectContent: Boolean = false, + replyToMessageId: MessageId? = null, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) + /** * Will execute [sendPhoto] request * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or From 3a9cf03958177d8c3c4286d8b98ec2e0c7d80368 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 19 Sep 2022 14:34:19 +0600 Subject: [PATCH 7/7] add edit extensions with builders of text sources --- .../tgbotapi/extensions/api/edit/Edits.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt index 1a33610b38..4cd890c605 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/Edits.kt @@ -259,6 +259,30 @@ suspend fun TelegramBot.edit( replyMarkup: InlineKeyboardMarkup? = null ) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.edit( + message: ContentMessage, + separator: TextSource? = null, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ +suspend fun TelegramBot.edit( + message: ContentMessage, + separator: String, + disableWebPagePreview: Boolean? = null, + replyMarkup: InlineKeyboardMarkup? = null, + builderBody: EntitiesBuilderBody +) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup) + /** * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * as a builder for that