diff --git a/CHANGELOG.md b/CHANGELOG.md index 00bc77e2e2..645421bf7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # TelegramBotAPI changelog +## 8.1.0 + +**PARTIALLY BREAKING CHANGES: Exclude `.*Impl` classcasts from `ClassCastsNew`** + +* `Version`: + * `MicroUtils`: `0.19.2` -> `0.19.4` +* `Utils`: + * Add deep links formatting for internal `tg://` prefix (thanks to [@klimatov](https://github.com/klimatov)) + * Exclude `.*Impl` classcasts from `ClassCastsNew` + ## 8.0.1 * `Version`: diff --git a/gradle.properties b/gradle.properties index 83e5b437c5..a8958ff8f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=8.0.1 +library_version=8.1.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 45dc446adf..0b02384517 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -kotlin = "1.8.21" +kotlin = "1.8.22" kotlin-serialization = "1.5.1" kotlin-coroutines = "1.6.4" @@ -10,10 +10,10 @@ korlibs = "4.0.3" uuid = "0.7.1" ktor = "2.3.1" -ksp = "1.8.21-1.0.11" +ksp = "1.8.22-1.0.11" kotlin-poet = "1.14.2" -microutils = "0.19.2" +microutils = "0.19.4" github-release-plugin = "2.4.1" dokka = "1.8.20" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt index 11f369737e..fb107ead22 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/WithUser.kt @@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.chat.User * * @see FromUser */ -@ClassCastsIncluded +@ClassCastsIncluded(excludeRegex = ".*Impl") interface WithUser { val user: User } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt index 9b02e6e873..5f04145dc1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/InlineQueryResult/abstracts/InlineQueryResult.kt @@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import kotlinx.serialization.Serializable @Serializable(InlineQueryResultSerializer::class) -@ClassCastsIncluded +@ClassCastsIncluded(excludeRegex = ".*Impl") interface InlineQueryResult { val type: String val id: InlineQueryIdentifier diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt index 0ddb3da843..d0d497e768 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt @@ -49,7 +49,7 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat { } @Serializable(PreviewChatSerializer::class) -@ClassCastsIncluded +@ClassCastsIncluded(excludeRegex = ".*Impl") sealed interface Chat { val id: IdChatIdentifier } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index fbc6f19f3d..5b9188e7de 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -3,11 +3,13 @@ package dev.inmo.tgbotapi.types.chat import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonObject @Serializable +@RiskFeature("This class is a subject of changes. It is better to use ExtendedChannelChat due") data class ExtendedChannelChatImpl( @SerialName(idField) override val id: ChatId, @@ -33,6 +35,7 @@ data class ExtendedChannelChatImpl( ) : ExtendedChannelChat @Serializable +@RiskFeature("This class is a subject of changes. It is better to use ExtendedGroupChat due") data class ExtendedGroupChatImpl( @SerialName(idField) override val id: ChatId, @@ -54,6 +57,7 @@ data class ExtendedGroupChatImpl( ) : ExtendedGroupChat @Serializable +@RiskFeature("This class is a subject of changes. It is better to use ExtendedPrivateChat due") data class ExtendedPrivateChatImpl( @SerialName(idField) override val id: UserId, @@ -80,6 +84,7 @@ data class ExtendedPrivateChatImpl( typealias ExtendedUser = ExtendedPrivateChatImpl @Serializable +@RiskFeature("This class is a subject of changes. It is better to use ExtendedSupergroupChat due") data class ExtendedSupergroupChatImpl( @SerialName(idField) override val id: ChatId, @@ -121,6 +126,7 @@ data class ExtendedSupergroupChatImpl( ) : ExtendedSupergroupChat @Serializable +@RiskFeature("This class is a subject of changes. It is better to use ExtendedForumChat due") data class ExtendedForumChatImpl( @SerialName(idField) override val id: IdChatIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt index fa1a075ace..0ccc48b172 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt @@ -4,10 +4,12 @@ import dev.inmo.micro_utils.language_codes.IetfLanguageCode import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable +@RiskFeature("This class is a subject of changes. It is better to use GroupChat due") data class GroupChatImpl( @SerialName(idField) override val id: ChatId, @@ -16,6 +18,7 @@ data class GroupChatImpl( ) : GroupChat @Serializable +@RiskFeature("This class is a subject of changes. It is better to use PrivateChat due") data class PrivateChatImpl( @SerialName(idField) override val id: UserId, @@ -28,6 +31,7 @@ data class PrivateChatImpl( ) : PrivateChat @Serializable +@RiskFeature("This class is a subject of changes. It is better to use SupergroupChat due") data class SupergroupChatImpl( @SerialName(idField) override val id: ChatId, @@ -38,6 +42,7 @@ data class SupergroupChatImpl( ) : SupergroupChat @Serializable +@RiskFeature("This class is a subject of changes. It is better to use ForumChat due") data class ForumChatImpl( @SerialName(idField) override val id: IdChatIdentifier, @@ -48,6 +53,7 @@ data class ForumChatImpl( ) : ForumChat @Serializable +@RiskFeature("This class is a subject of changes. It is better to use ChannelChat due") data class ChannelChatImpl( @SerialName(idField) override val id: ChatId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt index da30c0d9d7..eb922ce0db 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/Message.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -@ClassCastsIncluded +@ClassCastsIncluded(excludeRegex = ".*Impl") interface Message : WithChat { val messageId: MessageId val date: DateTime diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/ClassCastsIncluded.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/ClassCastsIncluded.kt index 1d50a976d1..b3b184352e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/ClassCastsIncluded.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/internal/ClassCastsIncluded.kt @@ -1,5 +1,13 @@ package dev.inmo.tgbotapi.utils.internal +import dev.inmo.tgbotapi.utils.RiskFeature + @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.SOURCE) -internal annotation class ClassCastsIncluded +@RiskFeature("It is internal API in tgbotapi.core and should not be used outside") +annotation class ClassCastsIncluded(val typesRegex: String = "", val excludeRegex: String = "") + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +@RiskFeature("It is internal API in tgbotapi.core and should not be used outside") +annotation class ClassCastsExcluded diff --git a/tgbotapi.ksp/build.gradle b/tgbotapi.ksp/build.gradle index fd1afa0516..bcf67a0160 100644 --- a/tgbotapi.ksp/build.gradle +++ b/tgbotapi.ksp/build.gradle @@ -9,4 +9,5 @@ repositories { dependencies { implementation libs.kotlin.poet implementation libs.ksp + implementation project(":tgbotapi.core") } diff --git a/tgbotapi.ksp/src/main/kotlin/TelegramBotAPISymbolProcessor.kt b/tgbotapi.ksp/src/main/kotlin/TelegramBotAPISymbolProcessor.kt index f47d626334..4eeff1ecc1 100644 --- a/tgbotapi.ksp/src/main/kotlin/TelegramBotAPISymbolProcessor.kt +++ b/tgbotapi.ksp/src/main/kotlin/TelegramBotAPISymbolProcessor.kt @@ -1,12 +1,21 @@ package dev.inmo.tgbotapi.ksp.processor +import com.google.devtools.ksp.KspExperimental import com.google.devtools.ksp.getAllSuperTypes +import com.google.devtools.ksp.getAnnotationsByType +import com.google.devtools.ksp.isAnnotationPresent import com.google.devtools.ksp.processing.* import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSClassDeclaration import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.asClassName +import com.squareup.kotlinpoet.ksp.toClassName import com.squareup.kotlinpoet.ksp.writeTo +import dev.inmo.tgbotapi.utils.RiskFeature +import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded +import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import java.io.File class TelegramBotAPISymbolProcessor( @@ -15,24 +24,51 @@ class TelegramBotAPISymbolProcessor( private val outputFile: String = "Output", private val outputFolder: String? = null ) : SymbolProcessor { + private val classCastsIncludedClassName = ClassCastsIncluded::class.asClassName() + @OptIn(KspExperimental::class, RiskFeature::class) override fun process(resolver: Resolver): List { - val classes = resolver.getSymbolsWithAnnotation("dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded").filterIsInstance() + val classes = resolver.getSymbolsWithAnnotation(classCastsIncludedClassName.canonicalName).filterIsInstance() + val classesRegexes: Map> = classes.mapNotNull { + it to (it.getAnnotationsByType(ClassCastsIncluded::class).firstNotNullOfOrNull { + it.typesRegex.takeIf { it.isNotEmpty() } ?.let(::Regex) to it.excludeRegex.takeIf { it.isNotEmpty() } ?.let(::Regex) + } ?: return@mapNotNull null) + }.toMap() val classesSubtypes = mutableMapOf>() resolver.getAllFiles().forEach { it.declarations.forEach { potentialSubtype -> - if (potentialSubtype is KSClassDeclaration) { + if ( + potentialSubtype is KSClassDeclaration + && potentialSubtype.isAnnotationPresent(ClassCastsExcluded::class).not() + ) { val allSupertypes = potentialSubtype.getAllSuperTypes().map { it.declaration } - classes.forEach { - if (it in allSupertypes) { - classesSubtypes.getOrPut(it) { mutableSetOf() }.add(potentialSubtype) + + for (currentClass in classes) { + val regexes = classesRegexes[currentClass] + val simpleName = potentialSubtype.simpleName.getShortName() + when { + currentClass !in allSupertypes + || regexes ?.first ?.matches(simpleName) == false + || regexes ?.second ?.matches(simpleName) == true -> continue + else -> { + classesSubtypes.getOrPut(currentClass) { mutableSetOf() }.add(potentialSubtype) + } } } } } } fun fillWithSealeds(source: KSClassDeclaration, current: KSClassDeclaration = source) { + val regexes = classesRegexes[source] current.getSealedSubclasses().forEach { + val simpleName = it.simpleName.getShortName() + if ( + regexes ?.first ?.matches(simpleName) == false + || regexes ?.second ?.matches(simpleName) == true + || it.isAnnotationPresent(ClassCastsExcluded::class) + ) { + return@forEach + } classesSubtypes.getOrPut(source) { mutableSetOf() }.add(it) fillWithSealeds(source, it) } diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index 72626842e5..d8cd7d52f4 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -28,25 +28,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.BaseChosenInline import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.LocationChosenInlineResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVenue -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.FileInlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult @@ -124,50 +110,37 @@ import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardRemove import dev.inmo.tgbotapi.types.chat.AbleToAddInAttachmentMenuChat import dev.inmo.tgbotapi.types.chat.Bot import dev.inmo.tgbotapi.types.chat.ChannelChat -import dev.inmo.tgbotapi.types.chat.ChannelChatImpl import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.ChatJoinRequest import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.ExtendedBot import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat -import dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl import dev.inmo.tgbotapi.types.chat.ExtendedChat import dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername import dev.inmo.tgbotapi.types.chat.ExtendedForumChat -import dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat -import dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat -import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat -import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl import dev.inmo.tgbotapi.types.chat.ForumChat -import dev.inmo.tgbotapi.types.chat.ForumChatImpl import dev.inmo.tgbotapi.types.chat.GroupChat -import dev.inmo.tgbotapi.types.chat.GroupChatImpl import dev.inmo.tgbotapi.types.chat.PossiblyPremiumChat import dev.inmo.tgbotapi.types.chat.PrivateChat -import dev.inmo.tgbotapi.types.chat.PrivateChatImpl import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.SuperPublicChat import dev.inmo.tgbotapi.types.chat.SupergroupChat -import dev.inmo.tgbotapi.types.chat.SupergroupChatImpl import dev.inmo.tgbotapi.types.chat.UnknownChatType import dev.inmo.tgbotapi.types.chat.UnknownExtendedChat import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.UsernameChat import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember -import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl import dev.inmo.tgbotapi.types.chat.member.BannedChatMember import dev.inmo.tgbotapi.types.chat.member.ChatMember import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated import dev.inmo.tgbotapi.types.chat.member.KickedChatMember import dev.inmo.tgbotapi.types.chat.member.LeftChatMember -import dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl import dev.inmo.tgbotapi.types.chat.member.MemberChatMember -import dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl import dev.inmo.tgbotapi.types.chat.member.OwnerChatMember import dev.inmo.tgbotapi.types.chat.member.RestrictedChatMember import dev.inmo.tgbotapi.types.chat.member.SpecialRightsChatMember @@ -228,9 +201,6 @@ import dev.inmo.tgbotapi.types.media.TelegramMediaVideo import dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia import dev.inmo.tgbotapi.types.media.TitledTelegramMedia import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia -import dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl -import dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl -import dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated import dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto @@ -266,17 +236,11 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatStarted -import dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl -import dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl import dev.inmo.tgbotapi.types.message.CommonGroupEventMessage import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage -import dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl import dev.inmo.tgbotapi.types.message.ForwardInfo -import dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl import dev.inmo.tgbotapi.types.message.PassportMessage -import dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl import dev.inmo.tgbotapi.types.message.PrivateEventMessage -import dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage @@ -635,16 +599,6 @@ public inline fun WithUser.administratorChatMemberOrThrow(): AdministratorChatMe public inline fun WithUser.ifAdministratorChatMember(block: (AdministratorChatMember) -> T): T? = administratorChatMemberOrNull() ?.let(block) -public inline fun WithUser.administratorChatMemberImplOrNull(): AdministratorChatMemberImpl? = this - as? dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl - -public inline fun WithUser.administratorChatMemberImplOrThrow(): AdministratorChatMemberImpl = this - as dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl - -public inline fun - WithUser.ifAdministratorChatMemberImpl(block: (AdministratorChatMemberImpl) -> T): T? = - administratorChatMemberImplOrNull() ?.let(block) - public inline fun WithUser.bannedChatMemberOrNull(): BannedChatMember? = this as? dev.inmo.tgbotapi.types.chat.member.BannedChatMember @@ -690,15 +644,6 @@ public inline fun WithUser.leftChatMemberOrThrow(): LeftChatMember = this as public inline fun WithUser.ifLeftChatMember(block: (LeftChatMember) -> T): T? = leftChatMemberOrNull() ?.let(block) -public inline fun WithUser.leftChatMemberImplOrNull(): LeftChatMemberImpl? = this as? - dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl - -public inline fun WithUser.leftChatMemberImplOrThrow(): LeftChatMemberImpl = this as - dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl - -public inline fun WithUser.ifLeftChatMemberImpl(block: (LeftChatMemberImpl) -> T): T? = - leftChatMemberImplOrNull() ?.let(block) - public inline fun WithUser.memberChatMemberOrNull(): MemberChatMember? = this as? dev.inmo.tgbotapi.types.chat.member.MemberChatMember @@ -708,15 +653,6 @@ public inline fun WithUser.memberChatMemberOrThrow(): MemberChatMember = this as public inline fun WithUser.ifMemberChatMember(block: (MemberChatMember) -> T): T? = memberChatMemberOrNull() ?.let(block) -public inline fun WithUser.memberChatMemberImplOrNull(): MemberChatMemberImpl? = this as? - dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl - -public inline fun WithUser.memberChatMemberImplOrThrow(): MemberChatMemberImpl = this as - dev.inmo.tgbotapi.types.chat.member.MemberChatMemberImpl - -public inline fun WithUser.ifMemberChatMemberImpl(block: (MemberChatMemberImpl) -> T): T? = - memberChatMemberImplOrNull() ?.let(block) - public inline fun WithUser.ownerChatMemberOrNull(): OwnerChatMember? = this as? dev.inmo.tgbotapi.types.chat.member.OwnerChatMember @@ -777,30 +713,6 @@ public inline fun WithUser.ifCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T): T? = commonSupergroupEventMessageOrNull() ?.let(block) -public inline fun WithUser.commonGroupContentMessageImplOrNull(): - CommonGroupContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl - -public inline fun WithUser.commonGroupContentMessageImplOrThrow(): - CommonGroupContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl - -public inline fun - WithUser.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl) -> T): - T? = commonGroupContentMessageImplOrNull() ?.let(block) - -public inline fun WithUser.commonForumContentMessageImplOrNull(): - CommonForumContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl - -public inline fun WithUser.commonForumContentMessageImplOrThrow(): - CommonForumContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl - -public inline fun - WithUser.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl) -> T): - T? = commonForumContentMessageImplOrNull() ?.let(block) - public inline fun WithUser.passportMessageOrNull(): PassportMessage? = this as? dev.inmo.tgbotapi.types.message.PassportMessage @@ -810,18 +722,6 @@ public inline fun WithUser.passportMessageOrThrow(): PassportMessage = this as public inline fun WithUser.ifPassportMessage(block: (PassportMessage) -> T): T? = passportMessageOrNull() ?.let(block) -public inline fun WithUser.privateContentMessageImplOrNull(): - PrivateContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl - -public inline fun WithUser.privateContentMessageImplOrThrow(): - PrivateContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl - -public inline fun - WithUser.ifPrivateContentMessageImpl(block: (PrivateContentMessageImpl) -> T): - T? = privateContentMessageImplOrNull() ?.let(block) - public inline fun WithUser.fromUserMessageOrNull(): FromUserMessage? = this as? dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage @@ -1127,28 +1027,6 @@ public inline fun InlineQueryResult.ifInlineQueryResultArticle(block: (InlineQueryResultArticle) -> T): T? = inlineQueryResultArticleOrNull() ?.let(block) -public inline fun InlineQueryResult.inlineQueryResultAudioCachedImplOrNull(): - InlineQueryResultAudioCachedImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl - -public inline fun InlineQueryResult.inlineQueryResultAudioCachedImplOrThrow(): - InlineQueryResultAudioCachedImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultAudioCachedImpl(block: (InlineQueryResultAudioCachedImpl) -> T): - T? = inlineQueryResultAudioCachedImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultAudioImplOrNull(): InlineQueryResultAudioImpl? - = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl - -public inline fun InlineQueryResult.inlineQueryResultAudioImplOrThrow(): InlineQueryResultAudioImpl - = this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultAudioImpl(block: (InlineQueryResultAudioImpl) -> T): T? = - inlineQueryResultAudioImplOrNull() ?.let(block) - public inline fun InlineQueryResult.inlineQueryResultContactOrNull(): InlineQueryResultContact? = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact @@ -1159,30 +1037,6 @@ public inline fun InlineQueryResult.ifInlineQueryResultContact(block: (InlineQueryResultContact) -> T): T? = inlineQueryResultContactOrNull() ?.let(block) -public inline fun InlineQueryResult.inlineQueryResultDocumentCachedImplOrNull(): - InlineQueryResultDocumentCachedImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl - -public inline fun InlineQueryResult.inlineQueryResultDocumentCachedImplOrThrow(): - InlineQueryResultDocumentCachedImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultDocumentCachedImpl(block: (InlineQueryResultDocumentCachedImpl) -> T): - T? = inlineQueryResultDocumentCachedImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultDocumentImplOrNull(): - InlineQueryResultDocumentImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl - -public inline fun InlineQueryResult.inlineQueryResultDocumentImplOrThrow(): - InlineQueryResultDocumentImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultDocumentImpl(block: (InlineQueryResultDocumentImpl) -> T): - T? = inlineQueryResultDocumentImplOrNull() ?.let(block) - public inline fun InlineQueryResult.inlineQueryResultGameOrNull(): InlineQueryResultGame? = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame @@ -1193,28 +1047,6 @@ public inline fun InlineQueryResult.ifInlineQueryResultGame(block: (InlineQueryResultGame) -> T): T? = inlineQueryResultGameOrNull() ?.let(block) -public inline fun InlineQueryResult.inlineQueryResultGifCachedImplOrNull(): - InlineQueryResultGifCachedImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl - -public inline fun InlineQueryResult.inlineQueryResultGifCachedImplOrThrow(): - InlineQueryResultGifCachedImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultGifCachedImpl(block: (InlineQueryResultGifCachedImpl) -> T): - T? = inlineQueryResultGifCachedImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultGifImplOrNull(): InlineQueryResultGifImpl? = - this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl - -public inline fun InlineQueryResult.inlineQueryResultGifImplOrThrow(): InlineQueryResultGifImpl = - this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultGifImpl(block: (InlineQueryResultGifImpl) -> T): T? = - inlineQueryResultGifImplOrNull() ?.let(block) - public inline fun InlineQueryResult.inlineQueryResultLocationOrNull(): InlineQueryResultLocation? = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation @@ -1225,52 +1057,6 @@ public inline fun InlineQueryResult.ifInlineQueryResultLocation(block: (InlineQueryResultLocation) -> T): T? = inlineQueryResultLocationOrNull() ?.let(block) -public inline fun InlineQueryResult.inlineQueryResultMpeg4GifCachedImplOrNull(): - InlineQueryResultMpeg4GifCachedImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl - -public inline fun InlineQueryResult.inlineQueryResultMpeg4GifCachedImplOrThrow(): - InlineQueryResultMpeg4GifCachedImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultMpeg4GifCachedImpl(block: (InlineQueryResultMpeg4GifCachedImpl) -> T): - T? = inlineQueryResultMpeg4GifCachedImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultMpeg4GifImplOrNull(): - InlineQueryResultMpeg4GifImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl - -public inline fun InlineQueryResult.inlineQueryResultMpeg4GifImplOrThrow(): - InlineQueryResultMpeg4GifImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultMpeg4GifImpl(block: (InlineQueryResultMpeg4GifImpl) -> T): - T? = inlineQueryResultMpeg4GifImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultPhotoCachedImplOrNull(): - InlineQueryResultPhotoCachedImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl - -public inline fun InlineQueryResult.inlineQueryResultPhotoCachedImplOrThrow(): - InlineQueryResultPhotoCachedImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultPhotoCachedImpl(block: (InlineQueryResultPhotoCachedImpl) -> T): - T? = inlineQueryResultPhotoCachedImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultPhotoImplOrNull(): InlineQueryResultPhotoImpl? - = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl - -public inline fun InlineQueryResult.inlineQueryResultPhotoImplOrThrow(): InlineQueryResultPhotoImpl - = this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultPhotoImpl(block: (InlineQueryResultPhotoImpl) -> T): T? = - inlineQueryResultPhotoImplOrNull() ?.let(block) - public inline fun InlineQueryResult.inlineQueryResultStickerCachedOrNull(): InlineQueryResultStickerCached? = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached @@ -1293,50 +1079,6 @@ public inline fun InlineQueryResult.ifInlineQueryResultVenue(block: (InlineQueryResultVenue) -> T): T? = inlineQueryResultVenueOrNull() ?.let(block) -public inline fun InlineQueryResult.inlineQueryResultVideoCachedImplOrNull(): - InlineQueryResultVideoCachedImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl - -public inline fun InlineQueryResult.inlineQueryResultVideoCachedImplOrThrow(): - InlineQueryResultVideoCachedImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultVideoCachedImpl(block: (InlineQueryResultVideoCachedImpl) -> T): - T? = inlineQueryResultVideoCachedImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultVideoImplOrNull(): InlineQueryResultVideoImpl? - = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl - -public inline fun InlineQueryResult.inlineQueryResultVideoImplOrThrow(): InlineQueryResultVideoImpl - = this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultVideoImpl(block: (InlineQueryResultVideoImpl) -> T): T? = - inlineQueryResultVideoImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultVoiceCachedImplOrNull(): - InlineQueryResultVoiceCachedImpl? = this as? - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl - -public inline fun InlineQueryResult.inlineQueryResultVoiceCachedImplOrThrow(): - InlineQueryResultVoiceCachedImpl = this as - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultVoiceCachedImpl(block: (InlineQueryResultVoiceCachedImpl) -> T): - T? = inlineQueryResultVoiceCachedImplOrNull() ?.let(block) - -public inline fun InlineQueryResult.inlineQueryResultVoiceImplOrNull(): InlineQueryResultVoiceImpl? - = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl - -public inline fun InlineQueryResult.inlineQueryResultVoiceImplOrThrow(): InlineQueryResultVoiceImpl - = this as dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl - -public inline fun - InlineQueryResult.ifInlineQueryResultVoiceImpl(block: (InlineQueryResultVoiceImpl) -> T): T? = - inlineQueryResultVoiceImplOrNull() ?.let(block) - public inline fun InlineQueryResult.describedInlineQueryResultOrNull(): DescribedInlineQueryResult? = this as? dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult @@ -2130,51 +1872,6 @@ public inline fun Chat.ifAbleToAddInAttachmentMenuChat(block: (AbleToAddInAttachmentMenuChat) -> T): T? = ableToAddInAttachmentMenuChatOrNull() ?.let(block) -public inline fun Chat.extendedChannelChatImplOrNull(): ExtendedChannelChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl - -public inline fun Chat.extendedChannelChatImplOrThrow(): ExtendedChannelChatImpl = this as - dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl - -public inline fun Chat.ifExtendedChannelChatImpl(block: (ExtendedChannelChatImpl) -> T): T? = - extendedChannelChatImplOrNull() ?.let(block) - -public inline fun Chat.extendedGroupChatImplOrNull(): ExtendedGroupChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl - -public inline fun Chat.extendedGroupChatImplOrThrow(): ExtendedGroupChatImpl = this as - dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl - -public inline fun Chat.ifExtendedGroupChatImpl(block: (ExtendedGroupChatImpl) -> T): T? = - extendedGroupChatImplOrNull() ?.let(block) - -public inline fun Chat.extendedPrivateChatImplOrNull(): ExtendedPrivateChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl - -public inline fun Chat.extendedPrivateChatImplOrThrow(): ExtendedPrivateChatImpl = this as - dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl - -public inline fun Chat.ifExtendedPrivateChatImpl(block: (ExtendedPrivateChatImpl) -> T): T? = - extendedPrivateChatImplOrNull() ?.let(block) - -public inline fun Chat.extendedSupergroupChatImplOrNull(): ExtendedSupergroupChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl - -public inline fun Chat.extendedSupergroupChatImplOrThrow(): ExtendedSupergroupChatImpl = this as - dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl - -public inline fun Chat.ifExtendedSupergroupChatImpl(block: (ExtendedSupergroupChatImpl) -> T): - T? = extendedSupergroupChatImplOrNull() ?.let(block) - -public inline fun Chat.extendedForumChatImplOrNull(): ExtendedForumChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl - -public inline fun Chat.extendedForumChatImplOrThrow(): ExtendedForumChatImpl = this as - dev.inmo.tgbotapi.types.chat.ExtendedForumChatImpl - -public inline fun Chat.ifExtendedForumChatImpl(block: (ExtendedForumChatImpl) -> T): T? = - extendedForumChatImplOrNull() ?.let(block) - public inline fun Chat.extendedBotOrNull(): ExtendedBot? = this as? dev.inmo.tgbotapi.types.chat.ExtendedBot @@ -2265,51 +1962,6 @@ public inline fun Chat.extendedChatWithUsernameOrThrow(): ExtendedChatWithUserna public inline fun Chat.ifExtendedChatWithUsername(block: (ExtendedChatWithUsername) -> T): T? = extendedChatWithUsernameOrNull() ?.let(block) -public inline fun Chat.groupChatImplOrNull(): GroupChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.GroupChatImpl - -public inline fun Chat.groupChatImplOrThrow(): GroupChatImpl = this as - dev.inmo.tgbotapi.types.chat.GroupChatImpl - -public inline fun Chat.ifGroupChatImpl(block: (GroupChatImpl) -> T): T? = groupChatImplOrNull() - ?.let(block) - -public inline fun Chat.privateChatImplOrNull(): PrivateChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.PrivateChatImpl - -public inline fun Chat.privateChatImplOrThrow(): PrivateChatImpl = this as - dev.inmo.tgbotapi.types.chat.PrivateChatImpl - -public inline fun Chat.ifPrivateChatImpl(block: (PrivateChatImpl) -> T): T? = - privateChatImplOrNull() ?.let(block) - -public inline fun Chat.supergroupChatImplOrNull(): SupergroupChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.SupergroupChatImpl - -public inline fun Chat.supergroupChatImplOrThrow(): SupergroupChatImpl = this as - dev.inmo.tgbotapi.types.chat.SupergroupChatImpl - -public inline fun Chat.ifSupergroupChatImpl(block: (SupergroupChatImpl) -> T): T? = - supergroupChatImplOrNull() ?.let(block) - -public inline fun Chat.forumChatImplOrNull(): ForumChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.ForumChatImpl - -public inline fun Chat.forumChatImplOrThrow(): ForumChatImpl = this as - dev.inmo.tgbotapi.types.chat.ForumChatImpl - -public inline fun Chat.ifForumChatImpl(block: (ForumChatImpl) -> T): T? = forumChatImplOrNull() - ?.let(block) - -public inline fun Chat.channelChatImplOrNull(): ChannelChatImpl? = this as? - dev.inmo.tgbotapi.types.chat.ChannelChatImpl - -public inline fun Chat.channelChatImplOrThrow(): ChannelChatImpl = this as - dev.inmo.tgbotapi.types.chat.ChannelChatImpl - -public inline fun Chat.ifChannelChatImpl(block: (ChannelChatImpl) -> T): T? = - channelChatImplOrNull() ?.let(block) - public inline fun Chat.userOrNull(): User? = this as? dev.inmo.tgbotapi.types.chat.User public inline fun Chat.userOrThrow(): User = this as dev.inmo.tgbotapi.types.chat.User @@ -3240,18 +2892,6 @@ public inline fun ForwardInfo.ifSentByChannel(block: (ForwardInfo.PublicChat.SentByChannel) -> T): T? = sentByChannelOrNull() ?.let(block) -public inline fun Message.channelContentMessageImplOrNull(): - ChannelContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl - -public inline fun Message.channelContentMessageImplOrThrow(): - ChannelContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.ChannelContentMessageImpl - -public inline fun - Message.ifChannelContentMessageImpl(block: (ChannelContentMessageImpl) -> T): T? - = channelContentMessageImplOrNull() ?.let(block) - public inline fun Message.channelEventMessageOrNull(): ChannelEventMessage? = this as? dev.inmo.tgbotapi.types.message.ChannelEventMessage @@ -3286,90 +2926,6 @@ public inline fun Message.ifCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T): T? = commonSupergroupEventMessageOrNull() ?.let(block) -public inline fun Message.connectedFromChannelGroupContentMessageImplOrNull(): - ConnectedFromChannelGroupContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl - -public inline fun Message.connectedFromChannelGroupContentMessageImplOrThrow(): - ConnectedFromChannelGroupContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.ConnectedFromChannelGroupContentMessageImpl - -public inline fun - Message.ifConnectedFromChannelGroupContentMessageImpl(block: (ConnectedFromChannelGroupContentMessageImpl) -> T): - T? = connectedFromChannelGroupContentMessageImplOrNull() ?.let(block) - -public inline fun Message.unconnectedFromChannelGroupContentMessageImplOrNull(): - UnconnectedFromChannelGroupContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl - -public inline fun Message.unconnectedFromChannelGroupContentMessageImplOrThrow(): - UnconnectedFromChannelGroupContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.UnconnectedFromChannelGroupContentMessageImpl - -public inline fun - Message.ifUnconnectedFromChannelGroupContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl) -> T): - T? = unconnectedFromChannelGroupContentMessageImplOrNull() ?.let(block) - -public inline fun Message.anonymousGroupContentMessageImplOrNull(): - AnonymousGroupContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl - -public inline fun Message.anonymousGroupContentMessageImplOrThrow(): - AnonymousGroupContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.AnonymousGroupContentMessageImpl - -public inline fun - Message.ifAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl) -> T): - T? = anonymousGroupContentMessageImplOrNull() ?.let(block) - -public inline fun Message.commonGroupContentMessageImplOrNull(): - CommonGroupContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl - -public inline fun Message.commonGroupContentMessageImplOrThrow(): - CommonGroupContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.CommonGroupContentMessageImpl - -public inline fun - Message.ifCommonGroupContentMessageImpl(block: (CommonGroupContentMessageImpl) -> T): - T? = commonGroupContentMessageImplOrNull() ?.let(block) - -public inline fun Message.fromChannelForumContentMessageImplOrNull(): - FromChannelForumContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl - -public inline fun Message.fromChannelForumContentMessageImplOrThrow(): - FromChannelForumContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.FromChannelForumContentMessageImpl - -public inline fun - Message.ifFromChannelForumContentMessageImpl(block: (FromChannelForumContentMessageImpl) -> T): - T? = fromChannelForumContentMessageImplOrNull() ?.let(block) - -public inline fun Message.anonymousForumContentMessageImplOrNull(): - AnonymousForumContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl - -public inline fun Message.anonymousForumContentMessageImplOrThrow(): - AnonymousForumContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.AnonymousForumContentMessageImpl - -public inline fun - Message.ifAnonymousForumContentMessageImpl(block: (AnonymousForumContentMessageImpl) -> T): - T? = anonymousForumContentMessageImplOrNull() ?.let(block) - -public inline fun Message.commonForumContentMessageImplOrNull(): - CommonForumContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl - -public inline fun Message.commonForumContentMessageImplOrThrow(): - CommonForumContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.CommonForumContentMessageImpl - -public inline fun - Message.ifCommonForumContentMessageImpl(block: (CommonForumContentMessageImpl) -> T): - T? = commonForumContentMessageImplOrNull() ?.let(block) - public inline fun Message.passportMessageOrNull(): PassportMessage? = this as? dev.inmo.tgbotapi.types.message.PassportMessage @@ -3379,18 +2935,6 @@ public inline fun Message.passportMessageOrThrow(): PassportMessage = this as public inline fun Message.ifPassportMessage(block: (PassportMessage) -> T): T? = passportMessageOrNull() ?.let(block) -public inline fun Message.privateContentMessageImplOrNull(): - PrivateContentMessageImpl? = this as? - dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl - -public inline fun Message.privateContentMessageImplOrThrow(): - PrivateContentMessageImpl = this as - dev.inmo.tgbotapi.types.message.PrivateContentMessageImpl - -public inline fun - Message.ifPrivateContentMessageImpl(block: (PrivateContentMessageImpl) -> T): T? - = privateContentMessageImplOrNull() ?.let(block) - public inline fun Message.privateEventMessageOrNull(): PrivateEventMessage? = this as? dev.inmo.tgbotapi.types.message.PrivateEventMessage diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt index a5df98590e..98bd0ccc5d 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt @@ -8,6 +8,7 @@ import io.ktor.http.encodeURLQueryComponent fun makeUsernameLink(username: String, threadId: MessageThreadId? = null) = "$internalLinkBeginning/$username${threadId ?.let { "/$it" } ?: ""}" +fun makeInternalTgUsernameLink(username: String) = "${internalTgAppLinksBeginning}resolve?domain=$username" fun makeUserLink(userId: UserId) = userId.userLink fun makeChatLink(identifier: Identifier, threadId: MessageThreadId? = null) = identifier.toString().replace( linkIdRedundantPartRegex, @@ -16,6 +17,7 @@ fun makeChatLink(identifier: Identifier, threadId: MessageThreadId? = null) = id "$internalLinkBeginning/c/$bareId${threadId ?.let { "/$it" } ?: ""}" } fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start=" +fun makeInternalTgUsernameDeepLinkPrefix(username: String) = "${makeInternalTgUsernameLink(username)}&start=" fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$username?startattach" fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}" inline val Username.usernameLink @@ -30,6 +32,9 @@ inline val Username.startattachPrefix get() = makeUsernameStartattachPrefix(usernameWithoutAt) inline fun makeLink(username: Username, threadId: MessageThreadId? = null) = username.link(threadId) inline fun makeTelegramDeepLink(username: String, startParameter: String) = "${makeUsernameDeepLinkPrefix(username)}$startParameter".encodeURLQueryComponent() +inline fun makeInternalTgDeepLink(username: String, startParameter: String) = "${makeInternalTgUsernameDeepLinkPrefix(username)}$startParameter".encodeURLQueryComponent() +inline fun makeInternalTgDeepLink(username: Username, startParameter: String) = + makeInternalTgDeepLink(username.usernameWithoutAt, startParameter) inline fun makeTelegramStartattach(username: String, data: String? = null) = makeUsernameStartattachLink(username, data) inline fun makeDeepLink(username: Username, startParameter: String) = makeTelegramDeepLink(username.usernameWithoutAt, startParameter) inline fun makeTelegramDeepLink(username: Username, startParameter: String) = makeDeepLink(username, startParameter)