From 25f8d15a4b0dea10efb01b600a219602c677e98c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 00:16:11 +0600 Subject: [PATCH 01/10] start 0.3.12 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c6f52ed7f..d11e624e44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.30.12 + ## 0.30.11 * `Common`: diff --git a/gradle.properties b/gradle.properties index 23af372a53..cba108e2dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.15 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.30.11 +library_version=0.30.12 github_release_plugin_version=2.2.12 From 599d5a51e31dfd4e85088f909072be9a8c352a70 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 01:36:52 +0600 Subject: [PATCH 02/10] add klassindex --- tgbotapi.core/build.gradle | 31 +++ tgbotapi.core/src/jvmTest/kotlin/Temporal.kt | 271 +++++++++++++++++++ 2 files changed, 302 insertions(+) create mode 100644 tgbotapi.core/src/jvmTest/kotlin/Temporal.kt diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index 9d12635f6c..f0b7bb9a2c 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -3,6 +3,7 @@ buildscript { mavenLocal() jcenter() mavenCentral() + maven { url "https://plugins.gradle.org/m2/" } } dependencies { @@ -14,6 +15,7 @@ buildscript { plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" + id "org.jetbrains.kotlin.kapt" } project.version = "$library_version" @@ -26,6 +28,7 @@ repositories { jcenter() mavenCentral() maven { url "https://kotlin.bintray.com/kotlinx" } + maven { url 'https://jitpack.io' } } kotlin { @@ -49,6 +52,7 @@ kotlin { api "dev.inmo:micro_utils.coroutines:$micro_utils_version" api "io.ktor:ktor-client-core:$ktor_version" + api "com.github.matfax.klassindex:library:4.+" } } commonTest { @@ -90,3 +94,30 @@ kotlin { } } } + +dependencies { + kapt "com.github.matfax.klassindex:processor:4.+" +} + +kapt { + useBuildCache = false + arguments { + arg( + "com.github.matfax.klassindex.IndexSubclasses", + "dev.inmo.tgbotapi.types.chat.abstracts.Chat", +// "dev.inmo.tgbotapi.types.message.abstracts.Message", +// "dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery", +// "dev.inmo.tgbotapi.types.buttons.KeyboardMarkup", +// "dev.inmo.tgbotapi.types.actions.BotAction", +// "dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton", +// "dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember", +// "dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile", +// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery", +// "dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult", +// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent", +// "dev.inmo.tgbotapi.types.InputMedia.InputMedia", +// "dev.inmo.tgbotapi.types.polls.Poll", +// "dev.inmo.tgbotapi.types.update.abstracts.Update" + ) + } +} diff --git a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt new file mode 100644 index 0000000000..df429bd193 --- /dev/null +++ b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt @@ -0,0 +1,271 @@ +import com.github.matfax.klassindex.KlassIndex +import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery +import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult +import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InputMedia.InputMedia +import dev.inmo.tgbotapi.types.actions.BotAction +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.chat.abstracts.Chat +import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.polls.Poll +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlin.reflect.KClass + +fun printlnInstanceSubclassesFuns(kclass: KClass<*>) { + KlassIndex.getSubclasses(Message::class).forEach { subclass -> + println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}") + } +} + +fun printlnInstancesSubclassesFuns(kclass: KClass<*>, subclasses: Set>) { + subclasses.forEach { subclass -> + println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}") + } +} + +val result = mutableMapOf, Set>>() + + +fun main() { + result[dev.inmo.tgbotapi.types.chat.abstracts.Chat::class] = + setOf(dev.inmo.tgbotapi.types.Bot::class, + dev.inmo.tgbotapi.types.CommonBot::class, + dev.inmo.tgbotapi.types.CommonUser::class, + dev.inmo.tgbotapi.types.ExtendedBot::class, + dev.inmo.tgbotapi.types.User::class, + dev.inmo.tgbotapi.types.chat.ChannelChatImpl::class, + dev.inmo.tgbotapi.types.chat.GroupChatImpl::class, + dev.inmo.tgbotapi.types.chat.PrivateChatImpl::class, + dev.inmo.tgbotapi.types.chat.SupergroupChatImpl::class, + dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.GroupChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.PublicChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.SuperPublicChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.UnknownChatType::class, + dev.inmo.tgbotapi.types.chat.abstracts.UsernameChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChannelChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedGroupChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPrivateChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPublicChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedSupergroupChat::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedChannelChatImpl::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedGroupChatImpl::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedSupergroupChatImpl::class) + result[dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery::class] = + setOf(dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.GameShortNameCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdDataCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdGameShortNameCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.MessageCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.MessageDataCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.MessageGameShortNameCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.UnknownCallbackQueryType::class) + result[dev.inmo.tgbotapi.types.message.abstracts.Message::class] = + setOf(dev.inmo.tgbotapi.types.message.AnonymousGroupMessageImpl::class, + dev.inmo.tgbotapi.types.message.ChannelEventMessage::class, + dev.inmo.tgbotapi.types.message.ChannelMediaGroupMessage::class, + dev.inmo.tgbotapi.types.message.ChannelMessageImpl::class, + dev.inmo.tgbotapi.types.message.CommonGroupEventMessage::class, + dev.inmo.tgbotapi.types.message.CommonGroupMessageImpl::class, + dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage::class, + dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage::class, + dev.inmo.tgbotapi.types.message.FromChannelGroupMessageImpl::class, + dev.inmo.tgbotapi.types.message.PrivateMessageImpl::class, + dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.ChannelMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.CommonGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.CommonMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.ContentMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.GroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PrivateMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PublicMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.SignedMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType::class, + dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage::class) + result[dev.inmo.tgbotapi.types.actions.BotAction::class] = + setOf(dev.inmo.tgbotapi.types.actions.FindLocationAction::class, + dev.inmo.tgbotapi.types.actions.RecordAudioAction::class, + dev.inmo.tgbotapi.types.actions.RecordVideoAction::class, + dev.inmo.tgbotapi.types.actions.RecordVideoNoteAction::class, + dev.inmo.tgbotapi.types.actions.TypingAction::class, + dev.inmo.tgbotapi.types.actions.UploadAudioAction::class, + dev.inmo.tgbotapi.types.actions.UploadDocumentAction::class, + dev.inmo.tgbotapi.types.actions.UploadPhotoAction::class, + dev.inmo.tgbotapi.types.actions.UploadVideoAction::class, + dev.inmo.tgbotapi.types.actions.UploadVideoNoteAction::class) + result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery::class] = + setOf(dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery::class, + dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery::class) + result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent::class] = + setOf(dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputContactMessageContent::class, + dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputLocationMessageContent::class, + dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent::class, + dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputVenueMessageContent::class) + result[dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult::class] = + setOf(dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVenue::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.FileInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.OptionallyTitledInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.SizedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbSizedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedWithMimeTypeInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.TitledInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.UrlInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCommon::class) + result[dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember::class] = + setOf(dev.inmo.tgbotapi.types.ChatMember.AdministratorChatMemberImpl::class, + dev.inmo.tgbotapi.types.ChatMember.CreatorChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.KickedChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.LeftChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.MemberChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.RestrictedChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.abstracts.SpecialRightsChatMember::class) + result[dev.inmo.tgbotapi.types.InputMedia.InputMedia::class] = + setOf(dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.DocumentMediaGroupMemberInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.DuratedInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaAnimation::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaPhoto::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo::class, + dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.SizedInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.ThumbedInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.TitledInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia::class) + result[dev.inmo.tgbotapi.types.update.abstracts.Update::class] = + setOf(dev.inmo.tgbotapi.types.update.CallbackQueryUpdate::class, + dev.inmo.tgbotapi.types.update.ChannelPostUpdate::class, + dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate::class, + dev.inmo.tgbotapi.types.update.EditChannelPostUpdate::class, + dev.inmo.tgbotapi.types.update.EditMessageUpdate::class, + dev.inmo.tgbotapi.types.update.InlineQueryUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.ChannelPostMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditChannelPostMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMessageMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MessageMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MessageUpdate::class, + dev.inmo.tgbotapi.types.update.PollAnswerUpdate::class, + dev.inmo.tgbotapi.types.update.PollUpdate::class, + dev.inmo.tgbotapi.types.update.PreCheckoutQueryUpdate::class, + dev.inmo.tgbotapi.types.update.ShippingQueryUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate::class) + result[dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile::class] = + setOf(dev.inmo.tgbotapi.types.files.AnimationFile::class, + dev.inmo.tgbotapi.types.files.AudioFile::class, + dev.inmo.tgbotapi.types.files.DocumentFile::class, + dev.inmo.tgbotapi.types.files.File::class, + dev.inmo.tgbotapi.types.files.PathedFile::class, + dev.inmo.tgbotapi.types.files.PhotoSize::class, + dev.inmo.tgbotapi.types.files.Sticker::class, + dev.inmo.tgbotapi.types.files.VideoFile::class, + dev.inmo.tgbotapi.types.files.VideoNoteFile::class, + dev.inmo.tgbotapi.types.files.VoiceFile::class, + dev.inmo.tgbotapi.types.files.abstracts.MimedMediaFile::class, + dev.inmo.tgbotapi.types.files.abstracts.PlayableMediaFile::class, + dev.inmo.tgbotapi.types.files.abstracts.SizedMediaFile::class, + dev.inmo.tgbotapi.types.files.abstracts.ThumbedMediaFile::class) + result[dev.inmo.tgbotapi.types.buttons.KeyboardMarkup::class] = + setOf(dev.inmo.tgbotapi.types.buttons.ForceReply::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup::class, + dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup::class, + dev.inmo.tgbotapi.types.buttons.ReplyKeyboardRemove::class) + result[dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton::class] = + setOf(dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.LoginURLInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryCurrentChatInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton::class) + result[dev.inmo.tgbotapi.types.polls.Poll::class] = + setOf(dev.inmo.tgbotapi.types.polls.MultipleAnswersPoll::class, + dev.inmo.tgbotapi.types.polls.QuizPoll::class, + dev.inmo.tgbotapi.types.polls.RegularPoll::class, + dev.inmo.tgbotapi.types.polls.UnknownPollType::class) + result.keys.forEach { + printlnInstancesSubclassesFuns(it, result.getValue(it)) + } +// printlnInstanceSubclassesFuns(Message::class) +// printlnInstanceSubclassesFuns(Chat::class) +// printlnInstanceSubclassesFuns(CallbackQuery::class) +// printlnInstanceSubclassesFuns(KeyboardMarkup::class) +// printlnInstanceSubclassesFuns(BotAction::class) +// printlnInstanceSubclassesFuns(InlineKeyboardButton::class) +// printlnInstanceSubclassesFuns(ChatMember::class) +// printlnInstanceSubclassesFuns(TelegramMediaFile::class) +// printlnInstanceSubclassesFuns(InlineQuery::class) +// printlnInstanceSubclassesFuns(InlineQueryResult::class) +// printlnInstanceSubclassesFuns(InputMessageContent::class) +// printlnInstanceSubclassesFuns(InputMedia::class) +// printlnInstanceSubclassesFuns(Poll::class) +// printlnInstanceSubclassesFuns(Update::class) +} \ No newline at end of file From 28a9bbd3104e6fceb70a4c20a9f76623e7348e08 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 01:37:01 +0600 Subject: [PATCH 03/10] Revert "add klassindex" This reverts commit 599d5a51e31dfd4e85088f909072be9a8c352a70. --- tgbotapi.core/build.gradle | 31 --- tgbotapi.core/src/jvmTest/kotlin/Temporal.kt | 271 ------------------- 2 files changed, 302 deletions(-) delete mode 100644 tgbotapi.core/src/jvmTest/kotlin/Temporal.kt diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index f0b7bb9a2c..9d12635f6c 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -3,7 +3,6 @@ buildscript { mavenLocal() jcenter() mavenCentral() - maven { url "https://plugins.gradle.org/m2/" } } dependencies { @@ -15,7 +14,6 @@ buildscript { plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" - id "org.jetbrains.kotlin.kapt" } project.version = "$library_version" @@ -28,7 +26,6 @@ repositories { jcenter() mavenCentral() maven { url "https://kotlin.bintray.com/kotlinx" } - maven { url 'https://jitpack.io' } } kotlin { @@ -52,7 +49,6 @@ kotlin { api "dev.inmo:micro_utils.coroutines:$micro_utils_version" api "io.ktor:ktor-client-core:$ktor_version" - api "com.github.matfax.klassindex:library:4.+" } } commonTest { @@ -94,30 +90,3 @@ kotlin { } } } - -dependencies { - kapt "com.github.matfax.klassindex:processor:4.+" -} - -kapt { - useBuildCache = false - arguments { - arg( - "com.github.matfax.klassindex.IndexSubclasses", - "dev.inmo.tgbotapi.types.chat.abstracts.Chat", -// "dev.inmo.tgbotapi.types.message.abstracts.Message", -// "dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery", -// "dev.inmo.tgbotapi.types.buttons.KeyboardMarkup", -// "dev.inmo.tgbotapi.types.actions.BotAction", -// "dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton", -// "dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember", -// "dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile", -// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery", -// "dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult", -// "dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent", -// "dev.inmo.tgbotapi.types.InputMedia.InputMedia", -// "dev.inmo.tgbotapi.types.polls.Poll", -// "dev.inmo.tgbotapi.types.update.abstracts.Update" - ) - } -} diff --git a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt deleted file mode 100644 index df429bd193..0000000000 --- a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt +++ /dev/null @@ -1,271 +0,0 @@ -import com.github.matfax.klassindex.KlassIndex -import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery -import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent -import dev.inmo.tgbotapi.types.InputMedia.InputMedia -import dev.inmo.tgbotapi.types.actions.BotAction -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton -import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup -import dev.inmo.tgbotapi.types.chat.abstracts.Chat -import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile -import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.types.polls.Poll -import dev.inmo.tgbotapi.types.update.abstracts.Update -import kotlin.reflect.KClass - -fun printlnInstanceSubclassesFuns(kclass: KClass<*>) { - KlassIndex.getSubclasses(Message::class).forEach { subclass -> - println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}") - } -} - -fun printlnInstancesSubclassesFuns(kclass: KClass<*>, subclasses: Set>) { - subclasses.forEach { subclass -> - println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}") - } -} - -val result = mutableMapOf, Set>>() - - -fun main() { - result[dev.inmo.tgbotapi.types.chat.abstracts.Chat::class] = - setOf(dev.inmo.tgbotapi.types.Bot::class, - dev.inmo.tgbotapi.types.CommonBot::class, - dev.inmo.tgbotapi.types.CommonUser::class, - dev.inmo.tgbotapi.types.ExtendedBot::class, - dev.inmo.tgbotapi.types.User::class, - dev.inmo.tgbotapi.types.chat.ChannelChatImpl::class, - dev.inmo.tgbotapi.types.chat.GroupChatImpl::class, - dev.inmo.tgbotapi.types.chat.PrivateChatImpl::class, - dev.inmo.tgbotapi.types.chat.SupergroupChatImpl::class, - dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.GroupChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.PublicChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.SuperPublicChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.UnknownChatType::class, - dev.inmo.tgbotapi.types.chat.abstracts.UsernameChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChannelChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedGroupChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPrivateChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPublicChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedSupergroupChat::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedChannelChatImpl::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedGroupChatImpl::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedSupergroupChatImpl::class) - result[dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery::class] = - setOf(dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.GameShortNameCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdDataCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdGameShortNameCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.MessageCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.MessageDataCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.MessageGameShortNameCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.UnknownCallbackQueryType::class) - result[dev.inmo.tgbotapi.types.message.abstracts.Message::class] = - setOf(dev.inmo.tgbotapi.types.message.AnonymousGroupMessageImpl::class, - dev.inmo.tgbotapi.types.message.ChannelEventMessage::class, - dev.inmo.tgbotapi.types.message.ChannelMediaGroupMessage::class, - dev.inmo.tgbotapi.types.message.ChannelMessageImpl::class, - dev.inmo.tgbotapi.types.message.CommonGroupEventMessage::class, - dev.inmo.tgbotapi.types.message.CommonGroupMessageImpl::class, - dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage::class, - dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage::class, - dev.inmo.tgbotapi.types.message.FromChannelGroupMessageImpl::class, - dev.inmo.tgbotapi.types.message.PrivateMessageImpl::class, - dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.ChannelMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.CommonGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.CommonMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.ContentMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.GroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PrivateMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PublicMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.SignedMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType::class, - dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage::class) - result[dev.inmo.tgbotapi.types.actions.BotAction::class] = - setOf(dev.inmo.tgbotapi.types.actions.FindLocationAction::class, - dev.inmo.tgbotapi.types.actions.RecordAudioAction::class, - dev.inmo.tgbotapi.types.actions.RecordVideoAction::class, - dev.inmo.tgbotapi.types.actions.RecordVideoNoteAction::class, - dev.inmo.tgbotapi.types.actions.TypingAction::class, - dev.inmo.tgbotapi.types.actions.UploadAudioAction::class, - dev.inmo.tgbotapi.types.actions.UploadDocumentAction::class, - dev.inmo.tgbotapi.types.actions.UploadPhotoAction::class, - dev.inmo.tgbotapi.types.actions.UploadVideoAction::class, - dev.inmo.tgbotapi.types.actions.UploadVideoNoteAction::class) - result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery::class] = - setOf(dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery::class, - dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery::class) - result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent::class] = - setOf(dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputContactMessageContent::class, - dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputLocationMessageContent::class, - dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent::class, - dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputVenueMessageContent::class) - result[dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult::class] = - setOf(dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVenue::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.FileInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.OptionallyTitledInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.SizedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbSizedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedWithMimeTypeInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.TitledInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.UrlInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCommon::class) - result[dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember::class] = - setOf(dev.inmo.tgbotapi.types.ChatMember.AdministratorChatMemberImpl::class, - dev.inmo.tgbotapi.types.ChatMember.CreatorChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.KickedChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.LeftChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.MemberChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.RestrictedChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.abstracts.SpecialRightsChatMember::class) - result[dev.inmo.tgbotapi.types.InputMedia.InputMedia::class] = - setOf(dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.DocumentMediaGroupMemberInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.DuratedInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaAnimation::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaPhoto::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo::class, - dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.SizedInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.ThumbedInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.TitledInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia::class) - result[dev.inmo.tgbotapi.types.update.abstracts.Update::class] = - setOf(dev.inmo.tgbotapi.types.update.CallbackQueryUpdate::class, - dev.inmo.tgbotapi.types.update.ChannelPostUpdate::class, - dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate::class, - dev.inmo.tgbotapi.types.update.EditChannelPostUpdate::class, - dev.inmo.tgbotapi.types.update.EditMessageUpdate::class, - dev.inmo.tgbotapi.types.update.InlineQueryUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.ChannelPostMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditChannelPostMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMessageMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MessageMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MessageUpdate::class, - dev.inmo.tgbotapi.types.update.PollAnswerUpdate::class, - dev.inmo.tgbotapi.types.update.PollUpdate::class, - dev.inmo.tgbotapi.types.update.PreCheckoutQueryUpdate::class, - dev.inmo.tgbotapi.types.update.ShippingQueryUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate::class) - result[dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile::class] = - setOf(dev.inmo.tgbotapi.types.files.AnimationFile::class, - dev.inmo.tgbotapi.types.files.AudioFile::class, - dev.inmo.tgbotapi.types.files.DocumentFile::class, - dev.inmo.tgbotapi.types.files.File::class, - dev.inmo.tgbotapi.types.files.PathedFile::class, - dev.inmo.tgbotapi.types.files.PhotoSize::class, - dev.inmo.tgbotapi.types.files.Sticker::class, - dev.inmo.tgbotapi.types.files.VideoFile::class, - dev.inmo.tgbotapi.types.files.VideoNoteFile::class, - dev.inmo.tgbotapi.types.files.VoiceFile::class, - dev.inmo.tgbotapi.types.files.abstracts.MimedMediaFile::class, - dev.inmo.tgbotapi.types.files.abstracts.PlayableMediaFile::class, - dev.inmo.tgbotapi.types.files.abstracts.SizedMediaFile::class, - dev.inmo.tgbotapi.types.files.abstracts.ThumbedMediaFile::class) - result[dev.inmo.tgbotapi.types.buttons.KeyboardMarkup::class] = - setOf(dev.inmo.tgbotapi.types.buttons.ForceReply::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup::class, - dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup::class, - dev.inmo.tgbotapi.types.buttons.ReplyKeyboardRemove::class) - result[dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton::class] = - setOf(dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.LoginURLInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryCurrentChatInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton::class) - result[dev.inmo.tgbotapi.types.polls.Poll::class] = - setOf(dev.inmo.tgbotapi.types.polls.MultipleAnswersPoll::class, - dev.inmo.tgbotapi.types.polls.QuizPoll::class, - dev.inmo.tgbotapi.types.polls.RegularPoll::class, - dev.inmo.tgbotapi.types.polls.UnknownPollType::class) - result.keys.forEach { - printlnInstancesSubclassesFuns(it, result.getValue(it)) - } -// printlnInstanceSubclassesFuns(Message::class) -// printlnInstanceSubclassesFuns(Chat::class) -// printlnInstanceSubclassesFuns(CallbackQuery::class) -// printlnInstanceSubclassesFuns(KeyboardMarkup::class) -// printlnInstanceSubclassesFuns(BotAction::class) -// printlnInstanceSubclassesFuns(InlineKeyboardButton::class) -// printlnInstanceSubclassesFuns(ChatMember::class) -// printlnInstanceSubclassesFuns(TelegramMediaFile::class) -// printlnInstanceSubclassesFuns(InlineQuery::class) -// printlnInstanceSubclassesFuns(InlineQueryResult::class) -// printlnInstanceSubclassesFuns(InputMessageContent::class) -// printlnInstanceSubclassesFuns(InputMedia::class) -// printlnInstanceSubclassesFuns(Poll::class) -// printlnInstanceSubclassesFuns(Update::class) -} \ No newline at end of file From f974e5787fd81cdfe95e7a502798de27229d61bb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 11:09:11 +0600 Subject: [PATCH 04/10] one more update of klassindex --- tgbotapi.core/src/jvmTest/kotlin/Temporal.kt | 274 +++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 tgbotapi.core/src/jvmTest/kotlin/Temporal.kt diff --git a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt new file mode 100644 index 0000000000..70ba32f659 --- /dev/null +++ b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt @@ -0,0 +1,274 @@ +import com.github.matfax.klassindex.KlassIndex +import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery +import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult +import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InputMedia.InputMedia +import dev.inmo.tgbotapi.types.actions.BotAction +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.chat.abstracts.Chat +import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile +import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.polls.Poll +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlin.reflect.KClass + +fun printlnInstanceSubclassesFuns(kclass: KClass<*>) { + KlassIndex.getSubclasses(Message::class).forEach { subclass -> + println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}") + } +} + +fun printlnInstancesSubclassesFuns(kclass: KClass<*>, subclasses: Set>): List> { + return subclasses.map { subclass -> + "${subclass.qualifiedName}" to "inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}" + } +} + +val result = mutableMapOf, Set>>() + + +fun main() { + result[dev.inmo.tgbotapi.types.chat.abstracts.Chat::class] = + setOf(dev.inmo.tgbotapi.types.Bot::class, + dev.inmo.tgbotapi.types.CommonBot::class, + dev.inmo.tgbotapi.types.CommonUser::class, + dev.inmo.tgbotapi.types.ExtendedBot::class, + dev.inmo.tgbotapi.types.User::class, + dev.inmo.tgbotapi.types.chat.ChannelChatImpl::class, + dev.inmo.tgbotapi.types.chat.GroupChatImpl::class, + dev.inmo.tgbotapi.types.chat.PrivateChatImpl::class, + dev.inmo.tgbotapi.types.chat.SupergroupChatImpl::class, + dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.GroupChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.PublicChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.SuperPublicChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.UnknownChatType::class, + dev.inmo.tgbotapi.types.chat.abstracts.UsernameChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChannelChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedGroupChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPrivateChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPublicChat::class, + dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedSupergroupChat::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedChannelChatImpl::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedGroupChatImpl::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl::class, + dev.inmo.tgbotapi.types.chat.extended.ExtendedSupergroupChatImpl::class) + result[dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery::class] = + setOf(dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.GameShortNameCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdDataCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdGameShortNameCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.MessageCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.MessageDataCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.MessageGameShortNameCallbackQuery::class, + dev.inmo.tgbotapi.types.CallbackQuery.UnknownCallbackQueryType::class) + result[dev.inmo.tgbotapi.types.message.abstracts.Message::class] = + setOf(dev.inmo.tgbotapi.types.message.AnonymousGroupMessageImpl::class, + dev.inmo.tgbotapi.types.message.ChannelEventMessage::class, + dev.inmo.tgbotapi.types.message.ChannelMediaGroupMessage::class, + dev.inmo.tgbotapi.types.message.ChannelMessageImpl::class, + dev.inmo.tgbotapi.types.message.CommonGroupEventMessage::class, + dev.inmo.tgbotapi.types.message.CommonGroupMessageImpl::class, + dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage::class, + dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage::class, + dev.inmo.tgbotapi.types.message.FromChannelGroupMessageImpl::class, + dev.inmo.tgbotapi.types.message.PrivateMessageImpl::class, + dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.ChannelMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.CommonGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.CommonMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.ContentMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.GroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PrivateMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.PublicMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.SignedMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage::class, + dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType::class, + dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage::class) + result[dev.inmo.tgbotapi.types.actions.BotAction::class] = + setOf(dev.inmo.tgbotapi.types.actions.FindLocationAction::class, + dev.inmo.tgbotapi.types.actions.RecordAudioAction::class, + dev.inmo.tgbotapi.types.actions.RecordVideoAction::class, + dev.inmo.tgbotapi.types.actions.RecordVideoNoteAction::class, + dev.inmo.tgbotapi.types.actions.TypingAction::class, + dev.inmo.tgbotapi.types.actions.UploadAudioAction::class, + dev.inmo.tgbotapi.types.actions.UploadDocumentAction::class, + dev.inmo.tgbotapi.types.actions.UploadPhotoAction::class, + dev.inmo.tgbotapi.types.actions.UploadVideoAction::class, + dev.inmo.tgbotapi.types.actions.UploadVideoNoteAction::class) + result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery::class] = + setOf(dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery::class, + dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery::class) + result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent::class] = + setOf(dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputContactMessageContent::class, + dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputLocationMessageContent::class, + dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent::class, + dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputVenueMessageContent::class) + result[dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult::class] = + setOf(dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVenue::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.FileInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.OptionallyTitledInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.SizedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbSizedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedWithMimeTypeInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.TitledInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.UrlInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCommon::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached::class, + dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCommon::class) + result[dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember::class] = + setOf(dev.inmo.tgbotapi.types.ChatMember.AdministratorChatMemberImpl::class, + dev.inmo.tgbotapi.types.ChatMember.CreatorChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.KickedChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.LeftChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.MemberChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.RestrictedChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember::class, + dev.inmo.tgbotapi.types.ChatMember.abstracts.SpecialRightsChatMember::class) + result[dev.inmo.tgbotapi.types.InputMedia.InputMedia::class] = + setOf(dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.DocumentMediaGroupMemberInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.DuratedInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaAnimation::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaPhoto::class, + dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo::class, + dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.SizedInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.ThumbedInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.TitledInputMedia::class, + dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia::class) + result[dev.inmo.tgbotapi.types.update.abstracts.Update::class] = + setOf(dev.inmo.tgbotapi.types.update.CallbackQueryUpdate::class, + dev.inmo.tgbotapi.types.update.ChannelPostUpdate::class, + dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate::class, + dev.inmo.tgbotapi.types.update.EditChannelPostUpdate::class, + dev.inmo.tgbotapi.types.update.EditMessageUpdate::class, + dev.inmo.tgbotapi.types.update.InlineQueryUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.ChannelPostMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditChannelPostMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMessageMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MessageMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate::class, + dev.inmo.tgbotapi.types.update.MessageUpdate::class, + dev.inmo.tgbotapi.types.update.PollAnswerUpdate::class, + dev.inmo.tgbotapi.types.update.PollUpdate::class, + dev.inmo.tgbotapi.types.update.PreCheckoutQueryUpdate::class, + dev.inmo.tgbotapi.types.update.ShippingQueryUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate::class, + dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate::class) + result[dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile::class] = + setOf(dev.inmo.tgbotapi.types.files.AnimationFile::class, + dev.inmo.tgbotapi.types.files.AudioFile::class, + dev.inmo.tgbotapi.types.files.DocumentFile::class, + dev.inmo.tgbotapi.types.files.File::class, + dev.inmo.tgbotapi.types.files.PathedFile::class, + dev.inmo.tgbotapi.types.files.PhotoSize::class, + dev.inmo.tgbotapi.types.files.Sticker::class, + dev.inmo.tgbotapi.types.files.VideoFile::class, + dev.inmo.tgbotapi.types.files.VideoNoteFile::class, + dev.inmo.tgbotapi.types.files.VoiceFile::class, + dev.inmo.tgbotapi.types.files.abstracts.MimedMediaFile::class, + dev.inmo.tgbotapi.types.files.abstracts.PlayableMediaFile::class, + dev.inmo.tgbotapi.types.files.abstracts.SizedMediaFile::class, + dev.inmo.tgbotapi.types.files.abstracts.ThumbedMediaFile::class) + result[dev.inmo.tgbotapi.types.buttons.KeyboardMarkup::class] = + setOf(dev.inmo.tgbotapi.types.buttons.ForceReply::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup::class, + dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup::class, + dev.inmo.tgbotapi.types.buttons.ReplyKeyboardRemove::class) + result[dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton::class] = + setOf(dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.LoginURLInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryCurrentChatInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardButton::class, + dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton::class) + result[dev.inmo.tgbotapi.types.polls.Poll::class] = + setOf(dev.inmo.tgbotapi.types.polls.MultipleAnswersPoll::class, + dev.inmo.tgbotapi.types.polls.QuizPoll::class, + dev.inmo.tgbotapi.types.polls.RegularPoll::class, + dev.inmo.tgbotapi.types.polls.UnknownPollType::class) + val importsToFuns = result.keys.flatMap { + printlnInstancesSubclassesFuns(it, result.getValue(it)) + } + importsToFuns.forEach { println("import ${it.first}") } + println() + importsToFuns.forEach { println(it.second) } +// printlnInstanceSubclassesFuns(Message::class) +// printlnInstanceSubclassesFuns(Chat::class) +// printlnInstanceSubclassesFuns(CallbackQuery::class) +// printlnInstanceSubclassesFuns(KeyboardMarkup::class) +// printlnInstanceSubclassesFuns(BotAction::class) +// printlnInstanceSubclassesFuns(InlineKeyboardButton::class) +// printlnInstanceSubclassesFuns(ChatMember::class) +// printlnInstanceSubclassesFuns(TelegramMediaFile::class) +// printlnInstanceSubclassesFuns(InlineQuery::class) +// printlnInstanceSubclassesFuns(InlineQueryResult::class) +// printlnInstanceSubclassesFuns(InputMessageContent::class) +// printlnInstanceSubclassesFuns(InputMedia::class) +// printlnInstanceSubclassesFuns(Poll::class) +// printlnInstanceSubclassesFuns(Update::class) +} \ No newline at end of file From 6407ad1a938b241ed5d3e8648e03f0c8782e1af9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 11:11:50 +0600 Subject: [PATCH 05/10] Revert "one more update of klassindex" This reverts commit f974e5787fd81cdfe95e7a502798de27229d61bb. --- tgbotapi.core/src/jvmTest/kotlin/Temporal.kt | 274 ------------------- 1 file changed, 274 deletions(-) delete mode 100644 tgbotapi.core/src/jvmTest/kotlin/Temporal.kt diff --git a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt b/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt deleted file mode 100644 index 70ba32f659..0000000000 --- a/tgbotapi.core/src/jvmTest/kotlin/Temporal.kt +++ /dev/null @@ -1,274 +0,0 @@ -import com.github.matfax.klassindex.KlassIndex -import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery -import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember -import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery -import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent -import dev.inmo.tgbotapi.types.InputMedia.InputMedia -import dev.inmo.tgbotapi.types.actions.BotAction -import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton -import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup -import dev.inmo.tgbotapi.types.chat.abstracts.Chat -import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile -import dev.inmo.tgbotapi.types.message.abstracts.Message -import dev.inmo.tgbotapi.types.polls.Poll -import dev.inmo.tgbotapi.types.update.abstracts.Update -import kotlin.reflect.KClass - -fun printlnInstanceSubclassesFuns(kclass: KClass<*>) { - KlassIndex.getSubclasses(Message::class).forEach { subclass -> - println("inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}") - } -} - -fun printlnInstancesSubclassesFuns(kclass: KClass<*>, subclasses: Set>): List> { - return subclasses.map { subclass -> - "${subclass.qualifiedName}" to "inline fun ${kclass.simpleName}.as${subclass.simpleName}(): ${subclass.simpleName}? = this as? ${subclass.simpleName}" - } -} - -val result = mutableMapOf, Set>>() - - -fun main() { - result[dev.inmo.tgbotapi.types.chat.abstracts.Chat::class] = - setOf(dev.inmo.tgbotapi.types.Bot::class, - dev.inmo.tgbotapi.types.CommonBot::class, - dev.inmo.tgbotapi.types.CommonUser::class, - dev.inmo.tgbotapi.types.ExtendedBot::class, - dev.inmo.tgbotapi.types.User::class, - dev.inmo.tgbotapi.types.chat.ChannelChatImpl::class, - dev.inmo.tgbotapi.types.chat.GroupChatImpl::class, - dev.inmo.tgbotapi.types.chat.PrivateChatImpl::class, - dev.inmo.tgbotapi.types.chat.SupergroupChatImpl::class, - dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.GroupChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.PublicChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.SuperPublicChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.UnknownChatType::class, - dev.inmo.tgbotapi.types.chat.abstracts.UsernameChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChannelChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedGroupChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPrivateChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedPublicChat::class, - dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedSupergroupChat::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedChannelChatImpl::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedGroupChatImpl::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl::class, - dev.inmo.tgbotapi.types.chat.extended.ExtendedSupergroupChatImpl::class) - result[dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery::class] = - setOf(dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.GameShortNameCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdDataCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.InlineMessageIdGameShortNameCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.MessageCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.MessageDataCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.MessageGameShortNameCallbackQuery::class, - dev.inmo.tgbotapi.types.CallbackQuery.UnknownCallbackQueryType::class) - result[dev.inmo.tgbotapi.types.message.abstracts.Message::class] = - setOf(dev.inmo.tgbotapi.types.message.AnonymousGroupMessageImpl::class, - dev.inmo.tgbotapi.types.message.ChannelEventMessage::class, - dev.inmo.tgbotapi.types.message.ChannelMediaGroupMessage::class, - dev.inmo.tgbotapi.types.message.ChannelMessageImpl::class, - dev.inmo.tgbotapi.types.message.CommonGroupEventMessage::class, - dev.inmo.tgbotapi.types.message.CommonGroupMessageImpl::class, - dev.inmo.tgbotapi.types.message.CommonMediaGroupMessage::class, - dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage::class, - dev.inmo.tgbotapi.types.message.FromChannelGroupMessageImpl::class, - dev.inmo.tgbotapi.types.message.PrivateMessageImpl::class, - dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.ChannelMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.CommonGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.CommonMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.ContentMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.GroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PrivateMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.PublicMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.SignedMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage::class, - dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType::class, - dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage::class) - result[dev.inmo.tgbotapi.types.actions.BotAction::class] = - setOf(dev.inmo.tgbotapi.types.actions.FindLocationAction::class, - dev.inmo.tgbotapi.types.actions.RecordAudioAction::class, - dev.inmo.tgbotapi.types.actions.RecordVideoAction::class, - dev.inmo.tgbotapi.types.actions.RecordVideoNoteAction::class, - dev.inmo.tgbotapi.types.actions.TypingAction::class, - dev.inmo.tgbotapi.types.actions.UploadAudioAction::class, - dev.inmo.tgbotapi.types.actions.UploadDocumentAction::class, - dev.inmo.tgbotapi.types.actions.UploadPhotoAction::class, - dev.inmo.tgbotapi.types.actions.UploadVideoAction::class, - dev.inmo.tgbotapi.types.actions.UploadVideoNoteAction::class) - result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery::class] = - setOf(dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery::class, - dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery::class) - result[dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent::class] = - setOf(dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputContactMessageContent::class, - dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputLocationMessageContent::class, - dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent::class, - dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputVenueMessageContent::class) - result[dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult::class] = - setOf(dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultAudioImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultContact::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultDocumentImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGame::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultGifImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultLocation::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultMpeg4GifImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultPhotoImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultStickerCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVenue::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVideoImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceCachedImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultVoiceImpl::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.DescribedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.FileInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.OptionallyTitledInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.SizedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbSizedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.ThumbedWithMimeTypeInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.TitledInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.UrlInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCommon::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached::class, - dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCommon::class) - result[dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember::class] = - setOf(dev.inmo.tgbotapi.types.ChatMember.AdministratorChatMemberImpl::class, - dev.inmo.tgbotapi.types.ChatMember.CreatorChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.KickedChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.LeftChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.MemberChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.RestrictedChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.abstracts.BannedChatMember::class, - dev.inmo.tgbotapi.types.ChatMember.abstracts.SpecialRightsChatMember::class) - result[dev.inmo.tgbotapi.types.InputMedia.InputMedia::class] = - setOf(dev.inmo.tgbotapi.types.InputMedia.AudioMediaGroupMemberInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.DocumentMediaGroupMemberInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.DuratedInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaAnimation::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaDocument::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaPhoto::class, - dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo::class, - dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.SizedInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.ThumbedInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.TitledInputMedia::class, - dev.inmo.tgbotapi.types.InputMedia.VisualMediaGroupMemberInputMedia::class) - result[dev.inmo.tgbotapi.types.update.abstracts.Update::class] = - setOf(dev.inmo.tgbotapi.types.update.CallbackQueryUpdate::class, - dev.inmo.tgbotapi.types.update.ChannelPostUpdate::class, - dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate::class, - dev.inmo.tgbotapi.types.update.EditChannelPostUpdate::class, - dev.inmo.tgbotapi.types.update.EditMessageUpdate::class, - dev.inmo.tgbotapi.types.update.InlineQueryUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.ChannelPostMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditChannelPostMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.EditMessageMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MessageMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate::class, - dev.inmo.tgbotapi.types.update.MessageUpdate::class, - dev.inmo.tgbotapi.types.update.PollAnswerUpdate::class, - dev.inmo.tgbotapi.types.update.PollUpdate::class, - dev.inmo.tgbotapi.types.update.PreCheckoutQueryUpdate::class, - dev.inmo.tgbotapi.types.update.ShippingQueryUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate::class, - dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate::class) - result[dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile::class] = - setOf(dev.inmo.tgbotapi.types.files.AnimationFile::class, - dev.inmo.tgbotapi.types.files.AudioFile::class, - dev.inmo.tgbotapi.types.files.DocumentFile::class, - dev.inmo.tgbotapi.types.files.File::class, - dev.inmo.tgbotapi.types.files.PathedFile::class, - dev.inmo.tgbotapi.types.files.PhotoSize::class, - dev.inmo.tgbotapi.types.files.Sticker::class, - dev.inmo.tgbotapi.types.files.VideoFile::class, - dev.inmo.tgbotapi.types.files.VideoNoteFile::class, - dev.inmo.tgbotapi.types.files.VoiceFile::class, - dev.inmo.tgbotapi.types.files.abstracts.MimedMediaFile::class, - dev.inmo.tgbotapi.types.files.abstracts.PlayableMediaFile::class, - dev.inmo.tgbotapi.types.files.abstracts.SizedMediaFile::class, - dev.inmo.tgbotapi.types.files.abstracts.ThumbedMediaFile::class) - result[dev.inmo.tgbotapi.types.buttons.KeyboardMarkup::class] = - setOf(dev.inmo.tgbotapi.types.buttons.ForceReply::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup::class, - dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup::class, - dev.inmo.tgbotapi.types.buttons.ReplyKeyboardRemove::class) - result[dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton::class] = - setOf(dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.LoginURLInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.PayInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryCurrentChatInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.SwitchInlineQueryInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardButton::class, - dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton::class) - result[dev.inmo.tgbotapi.types.polls.Poll::class] = - setOf(dev.inmo.tgbotapi.types.polls.MultipleAnswersPoll::class, - dev.inmo.tgbotapi.types.polls.QuizPoll::class, - dev.inmo.tgbotapi.types.polls.RegularPoll::class, - dev.inmo.tgbotapi.types.polls.UnknownPollType::class) - val importsToFuns = result.keys.flatMap { - printlnInstancesSubclassesFuns(it, result.getValue(it)) - } - importsToFuns.forEach { println("import ${it.first}") } - println() - importsToFuns.forEach { println(it.second) } -// printlnInstanceSubclassesFuns(Message::class) -// printlnInstanceSubclassesFuns(Chat::class) -// printlnInstanceSubclassesFuns(CallbackQuery::class) -// printlnInstanceSubclassesFuns(KeyboardMarkup::class) -// printlnInstanceSubclassesFuns(BotAction::class) -// printlnInstanceSubclassesFuns(InlineKeyboardButton::class) -// printlnInstanceSubclassesFuns(ChatMember::class) -// printlnInstanceSubclassesFuns(TelegramMediaFile::class) -// printlnInstanceSubclassesFuns(InlineQuery::class) -// printlnInstanceSubclassesFuns(InlineQueryResult::class) -// printlnInstanceSubclassesFuns(InputMessageContent::class) -// printlnInstanceSubclassesFuns(InputMedia::class) -// printlnInstanceSubclassesFuns(Poll::class) -// printlnInstanceSubclassesFuns(Update::class) -} \ No newline at end of file From 3dc4e9dda422fd16c2649fe8497e3c327365781f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 11:54:02 +0600 Subject: [PATCH 06/10] preview of solution for #145 --- CHANGELOG.md | 4 + .../tgbotapi/extensions/utils/ClassCasts.kt | 246 ++++++++++++++++++ 2 files changed, 250 insertions(+) create mode 100644 tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d11e624e44..f7077cac42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.30.12 +* `Utils`: + * Class casts has been added. Now you can write something like `message.asGroupMessage() ?.let { ... }` instead of + `(message as? GroupMessage<*>) ?.let { ... }` + ## 0.30.11 * `Common`: diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt new file mode 100644 index 0000000000..ac8b582d41 --- /dev/null +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -0,0 +1,246 @@ +@file:Suppress("NOTHING_TO_INLINE") + +package dev.inmo.tgbotapi.extensions.utils + +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.CallbackQuery.* +import dev.inmo.tgbotapi.types.ChatMember.* +import dev.inmo.tgbotapi.types.ChatMember.abstracts.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.* +import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.* +import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.* +import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent +import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery +import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery +import dev.inmo.tgbotapi.types.InputMedia.* +import dev.inmo.tgbotapi.types.actions.* +import dev.inmo.tgbotapi.types.buttons.* +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* +import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.chat.abstracts.* +import dev.inmo.tgbotapi.types.chat.abstracts.extended.* +import dev.inmo.tgbotapi.types.chat.extended.* +import dev.inmo.tgbotapi.types.files.* +import dev.inmo.tgbotapi.types.files.abstracts.* +import dev.inmo.tgbotapi.types.message.* +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.abstracts.* +import dev.inmo.tgbotapi.types.message.abstracts.ChannelMessage +import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage +import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage +import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent +import dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage +import dev.inmo.tgbotapi.types.polls.* +import dev.inmo.tgbotapi.types.update.* +import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* +import dev.inmo.tgbotapi.types.update.abstracts.* + +inline fun Chat.asBot(): Bot? = this as? Bot +inline fun Chat.asCommonBot(): CommonBot? = this as? CommonBot +inline fun Chat.asCommonUser(): CommonUser? = this as? CommonUser +inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot +inline fun Chat.asUser(): User? = this as? User +inline fun Chat.asChannelChatImpl(): ChannelChatImpl? = this as? ChannelChatImpl +inline fun Chat.asGroupChatImpl(): GroupChatImpl? = this as? GroupChatImpl +inline fun Chat.asPrivateChatImpl(): PrivateChatImpl? = this as? PrivateChatImpl +inline fun Chat.asSupergroupChatImpl(): SupergroupChatImpl? = this as? SupergroupChatImpl +inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat +inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat +inline fun Chat.asPrivateChat(): PrivateChat? = this as? PrivateChat +inline fun Chat.asPublicChat(): PublicChat? = this as? PublicChat +inline fun Chat.asSuperPublicChat(): SuperPublicChat? = this as? SuperPublicChat +inline fun Chat.asSupergroupChat(): SupergroupChat? = this as? SupergroupChat +inline fun Chat.asUnknownChatType(): UnknownChatType? = this as? UnknownChatType +inline fun Chat.asUsernameChat(): UsernameChat? = this as? UsernameChat +inline fun Chat.asExtendedChannelChat(): ExtendedChannelChat? = this as? ExtendedChannelChat +inline fun Chat.asExtendedChat(): ExtendedChat? = this as? ExtendedChat +inline fun Chat.asExtendedGroupChat(): ExtendedGroupChat? = this as? ExtendedGroupChat +inline fun Chat.asExtendedPrivateChat(): ExtendedPrivateChat? = this as? ExtendedPrivateChat +inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedPublicChat +inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? ExtendedSupergroupChat +inline fun Chat.asExtendedChannelChatImpl(): ExtendedChannelChatImpl? = this as? ExtendedChannelChatImpl +inline fun Chat.asExtendedGroupChatImpl(): ExtendedGroupChatImpl? = this as? ExtendedGroupChatImpl +inline fun Chat.asExtendedPrivateChatImpl(): ExtendedPrivateChatImpl? = this as? ExtendedPrivateChatImpl +inline fun Chat.asExtendedSupergroupChatImpl(): ExtendedSupergroupChatImpl? = this as? ExtendedSupergroupChatImpl +inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? DataCallbackQuery +inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? = this as? GameShortNameCallbackQuery +inline fun CallbackQuery.asInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery? = this as? InlineMessageIdCallbackQuery +inline fun CallbackQuery.asInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery? = this as? InlineMessageIdDataCallbackQuery +inline fun CallbackQuery.asInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery? = this as? InlineMessageIdGameShortNameCallbackQuery +inline fun CallbackQuery.asMessageCallbackQuery(): MessageCallbackQuery? = this as? MessageCallbackQuery +inline fun CallbackQuery.asMessageDataCallbackQuery(): MessageDataCallbackQuery? = this as? MessageDataCallbackQuery +inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery? = this as? MessageGameShortNameCallbackQuery +inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType? = this as? UnknownCallbackQueryType +inline fun Message.asChannelEventMessage(): ChannelEventMessage? = (this as? ChannelEventMessage<*>) ?.let { it as ChannelEventMessage } +inline fun Message.asChannelMediaGroupMessage(): ChannelMediaGroupMessage? = this as? ChannelMediaGroupMessage +inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = (this as? CommonGroupEventMessage<*>) ?.let { it as CommonGroupEventMessage } +inline fun Message.asCommonMediaGroupMessage(): CommonMediaGroupMessage? = this as? CommonMediaGroupMessage +inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = (this as? CommonSupergroupEventMessage<*>) ?.let { it as CommonSupergroupEventMessage } +inline fun Message.asAnonymousGroupMessage(): AnonymousGroupMessage? = (this as? AnonymousGroupMessage<*>) ?.let { it as AnonymousGroupMessage } +inline fun Message.asChannelMessage(): ChannelMessage? = (this as? ChannelMessage<*>) ?.let { it as ChannelMessage } +inline fun Message.asChatEventMessage(): ChatEventMessage? = (this as? ChatEventMessage<*>) ?.let { it as ChatEventMessage } +inline fun Message.asCommonGroupMessage(): CommonGroupMessage? = (this as? CommonGroupMessage<*>) ?.let { it as CommonGroupMessage } +inline fun Message.asCommonMessage(): CommonMessage? = (this as? CommonMessage<*>) ?.let { it as CommonMessage } +inline fun Message.asContentMessage(): ContentMessage? = (this as? ContentMessage<*>) ?.let { it as ContentMessage } +inline fun Message.asFromChannelGroupMessage(): FromChannelGroupMessage? = (this as? FromChannelGroupMessage<*>) ?.let { it as FromChannelGroupMessage } +inline fun Message.asGroupEventMessage(): GroupEventMessage? = (this as? GroupEventMessage<*>) ?.let { it as GroupEventMessage } +inline fun Message.asGroupMessage(): GroupMessage? = (this as? GroupMessage<*>) ?.let { it as GroupMessage } +inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = this as? MediaGroupMessage +inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage +inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage +inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage +inline fun Message.asPrivateMessage(): PrivateMessage? = (this as? PrivateMessage<*>) ?.let { it as PrivateMessage } +inline fun Message.asPublicMessage(): PublicMessage? = (this as? PublicMessage<*>) ?.let { it as PublicMessage } +inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage +inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = (this as? SupergroupEventMessage<*>) ?.let { it as SupergroupEventMessage } +inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType +inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = (this as? PossiblySentViaBotCommonMessage<*>) ?.let { it as PossiblySentViaBotCommonMessage } +inline fun BotAction.asFindLocationAction(): FindLocationAction? = this as? FindLocationAction +inline fun BotAction.asRecordAudioAction(): RecordAudioAction? = this as? RecordAudioAction +inline fun BotAction.asRecordVideoAction(): RecordVideoAction? = this as? RecordVideoAction +inline fun BotAction.asRecordVideoNoteAction(): RecordVideoNoteAction? = this as? RecordVideoNoteAction +inline fun BotAction.asTypingAction(): TypingAction? = this as? TypingAction +inline fun BotAction.asUploadAudioAction(): UploadAudioAction? = this as? UploadAudioAction +inline fun BotAction.asUploadDocumentAction(): UploadDocumentAction? = this as? UploadDocumentAction +inline fun BotAction.asUploadPhotoAction(): UploadPhotoAction? = this as? UploadPhotoAction +inline fun BotAction.asUploadVideoAction(): UploadVideoAction? = this as? UploadVideoAction +inline fun BotAction.asUploadVideoNoteAction(): UploadVideoNoteAction? = this as? UploadVideoNoteAction +inline fun InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = this as? BaseInlineQuery +inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = this as? LocationInlineQuery +inline fun InputMessageContent.asInputContactMessageContent(): InputContactMessageContent? = this as? InputContactMessageContent +inline fun InputMessageContent.asInputLocationMessageContent(): InputLocationMessageContent? = this as? InputLocationMessageContent +inline fun InputMessageContent.asInputTextMessageContent(): InputTextMessageContent? = this as? InputTextMessageContent +inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageContent? = this as? InputVenueMessageContent +inline fun InlineQueryResult.asInlineQueryResultArticle(): InlineQueryResultArticle? = this as? InlineQueryResultArticle +inline fun InlineQueryResult.asInlineQueryResultAudioCachedImpl(): InlineQueryResultAudioCachedImpl? = this as? InlineQueryResultAudioCachedImpl +inline fun InlineQueryResult.asInlineQueryResultAudioImpl(): InlineQueryResultAudioImpl? = this as? InlineQueryResultAudioImpl +inline fun InlineQueryResult.asInlineQueryResultContact(): InlineQueryResultContact? = this as? InlineQueryResultContact +inline fun InlineQueryResult.asInlineQueryResultDocumentCachedImpl(): InlineQueryResultDocumentCachedImpl? = this as? InlineQueryResultDocumentCachedImpl +inline fun InlineQueryResult.asInlineQueryResultDocumentImpl(): InlineQueryResultDocumentImpl? = this as? InlineQueryResultDocumentImpl +inline fun InlineQueryResult.asInlineQueryResultGame(): InlineQueryResultGame? = this as? InlineQueryResultGame +inline fun InlineQueryResult.asInlineQueryResultGifCachedImpl(): InlineQueryResultGifCachedImpl? = this as? InlineQueryResultGifCachedImpl +inline fun InlineQueryResult.asInlineQueryResultGifImpl(): InlineQueryResultGifImpl? = this as? InlineQueryResultGifImpl +inline fun InlineQueryResult.asInlineQueryResultLocation(): InlineQueryResultLocation? = this as? InlineQueryResultLocation +inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCachedImpl(): InlineQueryResultMpeg4GifCachedImpl? = this as? InlineQueryResultMpeg4GifCachedImpl +inline fun InlineQueryResult.asInlineQueryResultMpeg4GifImpl(): InlineQueryResultMpeg4GifImpl? = this as? InlineQueryResultMpeg4GifImpl +inline fun InlineQueryResult.asInlineQueryResultPhotoCachedImpl(): InlineQueryResultPhotoCachedImpl? = this as? InlineQueryResultPhotoCachedImpl +inline fun InlineQueryResult.asInlineQueryResultPhotoImpl(): InlineQueryResultPhotoImpl? = this as? InlineQueryResultPhotoImpl +inline fun InlineQueryResult.asInlineQueryResultStickerCached(): InlineQueryResultStickerCached? = this as? InlineQueryResultStickerCached +inline fun InlineQueryResult.asInlineQueryResultVenue(): InlineQueryResultVenue? = this as? InlineQueryResultVenue +inline fun InlineQueryResult.asInlineQueryResultVideoCachedImpl(): InlineQueryResultVideoCachedImpl? = this as? InlineQueryResultVideoCachedImpl +inline fun InlineQueryResult.asInlineQueryResultVideoImpl(): InlineQueryResultVideoImpl? = this as? InlineQueryResultVideoImpl +inline fun InlineQueryResult.asInlineQueryResultVoiceCachedImpl(): InlineQueryResultVoiceCachedImpl? = this as? InlineQueryResultVoiceCachedImpl +inline fun InlineQueryResult.asInlineQueryResultVoiceImpl(): InlineQueryResultVoiceImpl? = this as? InlineQueryResultVoiceImpl +inline fun InlineQueryResult.asDescribedInlineQueryResult(): DescribedInlineQueryResult? = this as? DescribedInlineQueryResult +inline fun InlineQueryResult.asFileInlineQueryResult(): FileInlineQueryResult? = this as? FileInlineQueryResult +inline fun InlineQueryResult.asOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult? = this as? OptionallyTitledInlineQueryResult +inline fun InlineQueryResult.asSizedInlineQueryResult(): SizedInlineQueryResult? = this as? SizedInlineQueryResult +inline fun InlineQueryResult.asThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult? = this as? ThumbSizedInlineQueryResult +inline fun InlineQueryResult.asThumbedInlineQueryResult(): ThumbedInlineQueryResult? = this as? ThumbedInlineQueryResult +inline fun InlineQueryResult.asThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult? = this as? ThumbedWithMimeTypeInlineQueryResult +inline fun InlineQueryResult.asTitledInlineQueryResult(): TitledInlineQueryResult? = this as? TitledInlineQueryResult +inline fun InlineQueryResult.asUrlInlineQueryResult(): UrlInlineQueryResult? = this as? UrlInlineQueryResult +inline fun InlineQueryResult.asWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult? = this as? WithInputMessageContentInlineQueryResult +inline fun InlineQueryResult.asInlineQueryResultAudio(): InlineQueryResultAudio? = this as? InlineQueryResultAudio +inline fun InlineQueryResult.asInlineQueryResultAudioCached(): InlineQueryResultAudioCached? = this as? InlineQueryResultAudioCached +inline fun InlineQueryResult.asInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon? = this as? InlineQueryResultAudioCommon +inline fun InlineQueryResult.asInlineQueryResultDocument(): InlineQueryResultDocument? = this as? InlineQueryResultDocument +inline fun InlineQueryResult.asInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached? = this as? InlineQueryResultDocumentCached +inline fun InlineQueryResult.asInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon? = this as? InlineQueryResultDocumentCommon +inline fun InlineQueryResult.asInlineQueryResultGif(): InlineQueryResultGif? = this as? InlineQueryResultGif +inline fun InlineQueryResult.asInlineQueryResultGifCached(): InlineQueryResultGifCached? = this as? InlineQueryResultGifCached +inline fun InlineQueryResult.asInlineQueryResultGifCommon(): InlineQueryResultGifCommon? = this as? InlineQueryResultGifCommon +inline fun InlineQueryResult.asInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif? = this as? InlineQueryResultMpeg4Gif +inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached? = this as? InlineQueryResultMpeg4GifCached +inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon? = this as? InlineQueryResultMpeg4GifCommon +inline fun InlineQueryResult.asInlineQueryResultPhoto(): InlineQueryResultPhoto? = this as? InlineQueryResultPhoto +inline fun InlineQueryResult.asInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached? = this as? InlineQueryResultPhotoCached +inline fun InlineQueryResult.asInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon? = this as? InlineQueryResultPhotoCommon +inline fun InlineQueryResult.asInlineQueryResultVideo(): InlineQueryResultVideo? = this as? InlineQueryResultVideo +inline fun InlineQueryResult.asInlineQueryResultVideoCached(): InlineQueryResultVideoCached? = this as? InlineQueryResultVideoCached +inline fun InlineQueryResult.asInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon? = this as? InlineQueryResultVideoCommon +inline fun InlineQueryResult.asInlineQueryResultVoice(): InlineQueryResultVoice? = this as? InlineQueryResultVoice +inline fun InlineQueryResult.asInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached? = this as? InlineQueryResultVoiceCached +inline fun InlineQueryResult.asInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon? = this as? InlineQueryResultVoiceCommon +inline fun ChatMember.asAdministratorChatMemberImpl(): AdministratorChatMemberImpl? = this as? AdministratorChatMemberImpl +inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember +inline fun ChatMember.asKickedChatMember(): KickedChatMember? = this as? KickedChatMember +inline fun ChatMember.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember +inline fun ChatMember.asMemberChatMember(): MemberChatMember? = this as? MemberChatMember +inline fun ChatMember.asRestrictedChatMember(): RestrictedChatMember? = this as? RestrictedChatMember +inline fun ChatMember.asAdministratorChatMember(): AdministratorChatMember? = this as? AdministratorChatMember +inline fun ChatMember.asBannedChatMember(): BannedChatMember? = this as? BannedChatMember +inline fun ChatMember.asSpecialRightsChatMember(): SpecialRightsChatMember? = this as? SpecialRightsChatMember +inline fun InputMedia.asAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia? = this as? AudioMediaGroupMemberInputMedia +inline fun InputMedia.asDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia? = this as? DocumentMediaGroupMemberInputMedia +inline fun InputMedia.asDuratedInputMedia(): DuratedInputMedia? = this as? DuratedInputMedia +inline fun InputMedia.asInputMediaAnimation(): InputMediaAnimation? = this as? InputMediaAnimation +inline fun InputMedia.asInputMediaAudio(): InputMediaAudio? = this as? InputMediaAudio +inline fun InputMedia.asInputMediaDocument(): InputMediaDocument? = this as? InputMediaDocument +inline fun InputMedia.asInputMediaPhoto(): InputMediaPhoto? = this as? InputMediaPhoto +inline fun InputMedia.asInputMediaVideo(): InputMediaVideo? = this as? InputMediaVideo +inline fun InputMedia.asMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia? = this as? MediaGroupMemberInputMedia +inline fun InputMedia.asSizedInputMedia(): SizedInputMedia? = this as? SizedInputMedia +inline fun InputMedia.asThumbedInputMedia(): ThumbedInputMedia? = this as? ThumbedInputMedia +inline fun InputMedia.asTitledInputMedia(): TitledInputMedia? = this as? TitledInputMedia +inline fun InputMedia.asVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia? = this as? VisualMediaGroupMemberInputMedia +inline fun Update.asCallbackQueryUpdate(): CallbackQueryUpdate? = this as? CallbackQueryUpdate +inline fun Update.asChannelPostUpdate(): ChannelPostUpdate? = this as? ChannelPostUpdate +inline fun Update.asChosenInlineResultUpdate(): ChosenInlineResultUpdate? = this as? ChosenInlineResultUpdate +inline fun Update.asEditChannelPostUpdate(): EditChannelPostUpdate? = this as? EditChannelPostUpdate +inline fun Update.asEditMessageUpdate(): EditMessageUpdate? = this as? EditMessageUpdate +inline fun Update.asInlineQueryUpdate(): InlineQueryUpdate? = this as? InlineQueryUpdate +inline fun Update.asChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate? = this as? ChannelPostMediaGroupUpdate +inline fun Update.asEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate? = this as? EditChannelPostMediaGroupUpdate +inline fun Update.asEditMediaGroupUpdate(): EditMediaGroupUpdate? = this as? EditMediaGroupUpdate +inline fun Update.asEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate? = this as? EditMessageMediaGroupUpdate +inline fun Update.asMediaGroupUpdate(): MediaGroupUpdate? = this as? MediaGroupUpdate +inline fun Update.asMessageMediaGroupUpdate(): MessageMediaGroupUpdate? = this as? MessageMediaGroupUpdate +inline fun Update.asSentMediaGroupUpdate(): SentMediaGroupUpdate? = this as? SentMediaGroupUpdate +inline fun Update.asMessageUpdate(): MessageUpdate? = this as? MessageUpdate +inline fun Update.asPollAnswerUpdate(): PollAnswerUpdate? = this as? PollAnswerUpdate +inline fun Update.asPollUpdate(): PollUpdate? = this as? PollUpdate +inline fun Update.asPreCheckoutQueryUpdate(): PreCheckoutQueryUpdate? = this as? PreCheckoutQueryUpdate +inline fun Update.asShippingQueryUpdate(): ShippingQueryUpdate? = this as? ShippingQueryUpdate +inline fun Update.asBaseEditMessageUpdate(): BaseEditMessageUpdate? = this as? BaseEditMessageUpdate +inline fun Update.asBaseMessageUpdate(): BaseMessageUpdate? = this as? BaseMessageUpdate +inline fun Update.asBaseSentMessageUpdate(): BaseSentMessageUpdate? = this as? BaseSentMessageUpdate +inline fun Update.asUnknownUpdate(): UnknownUpdate? = this as? UnknownUpdate +inline fun TelegramMediaFile.asAnimationFile(): AnimationFile? = this as? AnimationFile +inline fun TelegramMediaFile.asAudioFile(): AudioFile? = this as? AudioFile +inline fun TelegramMediaFile.asDocumentFile(): DocumentFile? = this as? DocumentFile +inline fun TelegramMediaFile.asFile(): File? = this as? File +inline fun TelegramMediaFile.asPathedFile(): PathedFile? = this as? PathedFile +inline fun TelegramMediaFile.asPhotoSize(): PhotoSize? = this as? PhotoSize +inline fun TelegramMediaFile.asSticker(): Sticker? = this as? Sticker +inline fun TelegramMediaFile.asVideoFile(): VideoFile? = this as? VideoFile +inline fun TelegramMediaFile.asVideoNoteFile(): VideoNoteFile? = this as? VideoNoteFile +inline fun TelegramMediaFile.asVoiceFile(): VoiceFile? = this as? VoiceFile +inline fun TelegramMediaFile.asMimedMediaFile(): MimedMediaFile? = this as? MimedMediaFile +inline fun TelegramMediaFile.asPlayableMediaFile(): PlayableMediaFile? = this as? PlayableMediaFile +inline fun TelegramMediaFile.asSizedMediaFile(): SizedMediaFile? = this as? SizedMediaFile +inline fun TelegramMediaFile.asThumbedMediaFile(): ThumbedMediaFile? = this as? ThumbedMediaFile +inline fun KeyboardMarkup.asForceReply(): ForceReply? = this as? ForceReply +inline fun KeyboardMarkup.asInlineKeyboardMarkup(): InlineKeyboardMarkup? = this as? InlineKeyboardMarkup +inline fun KeyboardMarkup.asReplyKeyboardMarkup(): ReplyKeyboardMarkup? = this as? ReplyKeyboardMarkup +inline fun KeyboardMarkup.asReplyKeyboardRemove(): ReplyKeyboardRemove? = this as? ReplyKeyboardRemove +inline fun InlineKeyboardButton.asCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton? = this as? CallbackDataInlineKeyboardButton +inline fun InlineKeyboardButton.asCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton? = this as? CallbackGameInlineKeyboardButton +inline fun InlineKeyboardButton.asLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton? = this as? LoginURLInlineKeyboardButton +inline fun InlineKeyboardButton.asPayInlineKeyboardButton(): PayInlineKeyboardButton? = this as? PayInlineKeyboardButton +inline fun InlineKeyboardButton.asSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton? = this as? SwitchInlineQueryCurrentChatInlineKeyboardButton +inline fun InlineKeyboardButton.asSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton? = this as? SwitchInlineQueryInlineKeyboardButton +inline fun InlineKeyboardButton.asURLInlineKeyboardButton(): URLInlineKeyboardButton? = this as? URLInlineKeyboardButton +inline fun InlineKeyboardButton.asUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton? = this as? UnknownInlineKeyboardButton +inline fun Poll.asMultipleAnswersPoll(): MultipleAnswersPoll? = this as? MultipleAnswersPoll +inline fun Poll.asQuizPoll(): QuizPoll? = this as? QuizPoll +inline fun Poll.asRegularPoll(): RegularPoll? = this as? RegularPoll +inline fun Poll.asUnknownPollType(): UnknownPollType? = this as? UnknownPollType From 6cf8d47cbf43ac4d8a8cb9b3a1afd9e073ff2ca3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 22:27:42 +0600 Subject: [PATCH 07/10] update classcasts --- .../tgbotapi/extensions/utils/ClassCasts.kt | 245 ++++++++++++++++-- 1 file changed, 228 insertions(+), 17 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index ac8b582d41..cd4595312c 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -1,4 +1,4 @@ -@file:Suppress("NOTHING_TO_INLINE") +@file:Suppress("NOTHING_TO_INLINE", "unused") package dev.inmo.tgbotapi.extensions.utils @@ -44,203 +44,414 @@ import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* import dev.inmo.tgbotapi.types.update.abstracts.* inline fun Chat.asBot(): Bot? = this as? Bot +inline fun Chat.requireBot(): Bot = this as Bot inline fun Chat.asCommonBot(): CommonBot? = this as? CommonBot +inline fun Chat.requireCommonBot(): CommonBot = this as CommonBot inline fun Chat.asCommonUser(): CommonUser? = this as? CommonUser +inline fun Chat.requireCommonUser(): CommonUser = this as CommonUser inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot +inline fun Chat.requireExtendedBot(): ExtendedBot = this as ExtendedBot inline fun Chat.asUser(): User? = this as? User +inline fun Chat.requireUser(): User = this as User inline fun Chat.asChannelChatImpl(): ChannelChatImpl? = this as? ChannelChatImpl +inline fun Chat.requireChannelChatImpl(): ChannelChatImpl = this as ChannelChatImpl inline fun Chat.asGroupChatImpl(): GroupChatImpl? = this as? GroupChatImpl +inline fun Chat.requireGroupChatImpl(): GroupChatImpl = this as GroupChatImpl inline fun Chat.asPrivateChatImpl(): PrivateChatImpl? = this as? PrivateChatImpl +inline fun Chat.requirePrivateChatImpl(): PrivateChatImpl = this as PrivateChatImpl inline fun Chat.asSupergroupChatImpl(): SupergroupChatImpl? = this as? SupergroupChatImpl +inline fun Chat.requireSupergroupChatImpl(): SupergroupChatImpl = this as SupergroupChatImpl inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat +inline fun Chat.requireChannelChat(): ChannelChat = this as ChannelChat inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat +inline fun Chat.requireGroupChat(): GroupChat = this as GroupChat inline fun Chat.asPrivateChat(): PrivateChat? = this as? PrivateChat +inline fun Chat.requirePrivateChat(): PrivateChat = this as PrivateChat inline fun Chat.asPublicChat(): PublicChat? = this as? PublicChat +inline fun Chat.requirePublicChat(): PublicChat = this as PublicChat inline fun Chat.asSuperPublicChat(): SuperPublicChat? = this as? SuperPublicChat +inline fun Chat.requireSuperPublicChat(): SuperPublicChat = this as SuperPublicChat inline fun Chat.asSupergroupChat(): SupergroupChat? = this as? SupergroupChat +inline fun Chat.requireSupergroupChat(): SupergroupChat = this as SupergroupChat inline fun Chat.asUnknownChatType(): UnknownChatType? = this as? UnknownChatType +inline fun Chat.requireUnknownChatType(): UnknownChatType = this as UnknownChatType inline fun Chat.asUsernameChat(): UsernameChat? = this as? UsernameChat +inline fun Chat.requireUsernameChat(): UsernameChat = this as UsernameChat inline fun Chat.asExtendedChannelChat(): ExtendedChannelChat? = this as? ExtendedChannelChat +inline fun Chat.requireExtendedChannelChat(): ExtendedChannelChat = this as ExtendedChannelChat inline fun Chat.asExtendedChat(): ExtendedChat? = this as? ExtendedChat +inline fun Chat.requireExtendedChat(): ExtendedChat = this as ExtendedChat inline fun Chat.asExtendedGroupChat(): ExtendedGroupChat? = this as? ExtendedGroupChat +inline fun Chat.requireExtendedGroupChat(): ExtendedGroupChat = this as ExtendedGroupChat inline fun Chat.asExtendedPrivateChat(): ExtendedPrivateChat? = this as? ExtendedPrivateChat +inline fun Chat.requireExtendedPrivateChat(): ExtendedPrivateChat = this as ExtendedPrivateChat inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedPublicChat +inline fun Chat.requireExtendedPublicChat(): ExtendedPublicChat = this as ExtendedPublicChat inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? ExtendedSupergroupChat +inline fun Chat.requireExtendedSupergroupChat(): ExtendedSupergroupChat = this as ExtendedSupergroupChat inline fun Chat.asExtendedChannelChatImpl(): ExtendedChannelChatImpl? = this as? ExtendedChannelChatImpl +inline fun Chat.requireExtendedChannelChatImpl(): ExtendedChannelChatImpl = this as ExtendedChannelChatImpl inline fun Chat.asExtendedGroupChatImpl(): ExtendedGroupChatImpl? = this as? ExtendedGroupChatImpl +inline fun Chat.requireExtendedGroupChatImpl(): ExtendedGroupChatImpl = this as ExtendedGroupChatImpl inline fun Chat.asExtendedPrivateChatImpl(): ExtendedPrivateChatImpl? = this as? ExtendedPrivateChatImpl +inline fun Chat.requireExtendedPrivateChatImpl(): ExtendedPrivateChatImpl = this as ExtendedPrivateChatImpl inline fun Chat.asExtendedSupergroupChatImpl(): ExtendedSupergroupChatImpl? = this as? ExtendedSupergroupChatImpl +inline fun Chat.requireExtendedSupergroupChatImpl(): ExtendedSupergroupChatImpl = this as ExtendedSupergroupChatImpl inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? DataCallbackQuery +inline fun CallbackQuery.requireDataCallbackQuery(): DataCallbackQuery = this as DataCallbackQuery inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? = this as? GameShortNameCallbackQuery +inline fun CallbackQuery.requireGameShortNameCallbackQuery(): GameShortNameCallbackQuery = this as GameShortNameCallbackQuery inline fun CallbackQuery.asInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery? = this as? InlineMessageIdCallbackQuery +inline fun CallbackQuery.requireInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery = this as InlineMessageIdCallbackQuery inline fun CallbackQuery.asInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery? = this as? InlineMessageIdDataCallbackQuery +inline fun CallbackQuery.requireInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery = this as InlineMessageIdDataCallbackQuery inline fun CallbackQuery.asInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery? = this as? InlineMessageIdGameShortNameCallbackQuery +inline fun CallbackQuery.requireInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery = this as InlineMessageIdGameShortNameCallbackQuery inline fun CallbackQuery.asMessageCallbackQuery(): MessageCallbackQuery? = this as? MessageCallbackQuery +inline fun CallbackQuery.requireMessageCallbackQuery(): MessageCallbackQuery = this as MessageCallbackQuery inline fun CallbackQuery.asMessageDataCallbackQuery(): MessageDataCallbackQuery? = this as? MessageDataCallbackQuery +inline fun CallbackQuery.requireMessageDataCallbackQuery(): MessageDataCallbackQuery = this as MessageDataCallbackQuery inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery? = this as? MessageGameShortNameCallbackQuery +inline fun CallbackQuery.requireMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery = this as MessageGameShortNameCallbackQuery inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType? = this as? UnknownCallbackQueryType -inline fun Message.asChannelEventMessage(): ChannelEventMessage? = (this as? ChannelEventMessage<*>) ?.let { it as ChannelEventMessage } +inline fun CallbackQuery.requireUnknownCallbackQueryType(): UnknownCallbackQueryType = this as UnknownCallbackQueryType +inline fun Message.asAnonymousGroupMessageImpl(): AnonymousGroupMessageImpl? = this as? AnonymousGroupMessageImpl +inline fun Message.requireAnonymousGroupMessageImpl(): AnonymousGroupMessageImpl = this as AnonymousGroupMessageImpl +inline fun Message.asChannelEventMessage(): ChannelEventMessage? = this as? ChannelEventMessage +inline fun Message.requireChannelEventMessage(): ChannelEventMessage = this as ChannelEventMessage inline fun Message.asChannelMediaGroupMessage(): ChannelMediaGroupMessage? = this as? ChannelMediaGroupMessage -inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = (this as? CommonGroupEventMessage<*>) ?.let { it as CommonGroupEventMessage } +inline fun Message.requireChannelMediaGroupMessage(): ChannelMediaGroupMessage = this as ChannelMediaGroupMessage +inline fun Message.asChannelMessageImpl(): ChannelMessageImpl? = this as? ChannelMessageImpl +inline fun Message.requireChannelMessageImpl(): ChannelMessageImpl = this as ChannelMessageImpl +inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = this as? CommonGroupEventMessage +inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage = this as CommonGroupEventMessage +inline fun Message.asCommonGroupMessageImpl(): CommonGroupMessageImpl? = this as? CommonGroupMessageImpl +inline fun Message.requireCommonGroupMessageImpl(): CommonGroupMessageImpl = this as CommonGroupMessageImpl inline fun Message.asCommonMediaGroupMessage(): CommonMediaGroupMessage? = this as? CommonMediaGroupMessage -inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = (this as? CommonSupergroupEventMessage<*>) ?.let { it as CommonSupergroupEventMessage } -inline fun Message.asAnonymousGroupMessage(): AnonymousGroupMessage? = (this as? AnonymousGroupMessage<*>) ?.let { it as AnonymousGroupMessage } -inline fun Message.asChannelMessage(): ChannelMessage? = (this as? ChannelMessage<*>) ?.let { it as ChannelMessage } -inline fun Message.asChatEventMessage(): ChatEventMessage? = (this as? ChatEventMessage<*>) ?.let { it as ChatEventMessage } -inline fun Message.asCommonGroupMessage(): CommonGroupMessage? = (this as? CommonGroupMessage<*>) ?.let { it as CommonGroupMessage } -inline fun Message.asCommonMessage(): CommonMessage? = (this as? CommonMessage<*>) ?.let { it as CommonMessage } -inline fun Message.asContentMessage(): ContentMessage? = (this as? ContentMessage<*>) ?.let { it as ContentMessage } -inline fun Message.asFromChannelGroupMessage(): FromChannelGroupMessage? = (this as? FromChannelGroupMessage<*>) ?.let { it as FromChannelGroupMessage } -inline fun Message.asGroupEventMessage(): GroupEventMessage? = (this as? GroupEventMessage<*>) ?.let { it as GroupEventMessage } -inline fun Message.asGroupMessage(): GroupMessage? = (this as? GroupMessage<*>) ?.let { it as GroupMessage } +inline fun Message.requireCommonMediaGroupMessage(): CommonMediaGroupMessage = this as CommonMediaGroupMessage +inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = this as? CommonSupergroupEventMessage +inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = this as CommonSupergroupEventMessage +inline fun Message.asFromChannelGroupMessageImpl(): FromChannelGroupMessageImpl? = this as? FromChannelGroupMessageImpl +inline fun Message.requireFromChannelGroupMessageImpl(): FromChannelGroupMessageImpl = this as FromChannelGroupMessageImpl +inline fun Message.asPrivateMessageImpl(): PrivateMessageImpl? = this as? PrivateMessageImpl +inline fun Message.requirePrivateMessageImpl(): PrivateMessageImpl = this as PrivateMessageImpl +inline fun Message.asAnonymousGroupMessage(): AnonymousGroupMessage? = this as? AnonymousGroupMessage +inline fun Message.requireAnonymousGroupMessage(): AnonymousGroupMessage = this as AnonymousGroupMessage +inline fun Message.asChannelMessage(): ChannelMessage? = this as? ChannelMessage +inline fun Message.requireChannelMessage(): ChannelMessage = this as ChannelMessage +inline fun Message.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage +inline fun Message.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage +inline fun Message.asCommonGroupMessage(): CommonGroupMessage? = this as? CommonGroupMessage +inline fun Message.requireCommonGroupMessage(): CommonGroupMessage = this as CommonGroupMessage +inline fun Message.asCommonMessage(): CommonMessage? = this as? CommonMessage +inline fun Message.requireCommonMessage(): CommonMessage = this as CommonMessage +inline fun Message.asContentMessage(): ContentMessage? = this as? ContentMessage +inline fun Message.requireContentMessage(): ContentMessage = this as ContentMessage +inline fun Message.asFromChannelGroupMessage(): FromChannelGroupMessage? = this as? FromChannelGroupMessage +inline fun Message.requireFromChannelGroupMessage(): FromChannelGroupMessage = this as FromChannelGroupMessage +inline fun Message.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage +inline fun Message.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage +inline fun Message.asGroupMessage(): GroupMessage? = this as? GroupMessage +inline fun Message.requireGroupMessage(): GroupMessage = this as GroupMessage inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = this as? MediaGroupMessage +inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = this as MediaGroupMessage inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage +inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage +inline fun Message.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage -inline fun Message.asPrivateMessage(): PrivateMessage? = (this as? PrivateMessage<*>) ?.let { it as PrivateMessage } -inline fun Message.asPublicMessage(): PublicMessage? = (this as? PublicMessage<*>) ?.let { it as PublicMessage } +inline fun Message.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage +inline fun Message.asPrivateMessage(): PrivateMessage? = this as? PrivateMessage +inline fun Message.requirePrivateMessage(): PrivateMessage = this as PrivateMessage +inline fun Message.asPublicMessage(): PublicMessage? = this as? PublicMessage +inline fun Message.requirePublicMessage(): PublicMessage = this as PublicMessage inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage -inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = (this as? SupergroupEventMessage<*>) ?.let { it as SupergroupEventMessage } +inline fun Message.requireSignedMessage(): SignedMessage = this as SignedMessage +inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = this as? SupergroupEventMessage +inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage = this as SupergroupEventMessage inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType -inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = (this as? PossiblySentViaBotCommonMessage<*>) ?.let { it as PossiblySentViaBotCommonMessage } +inline fun Message.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType +inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = this as? PossiblySentViaBotCommonMessage +inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = this as PossiblySentViaBotCommonMessage inline fun BotAction.asFindLocationAction(): FindLocationAction? = this as? FindLocationAction +inline fun BotAction.requireFindLocationAction(): FindLocationAction = this as FindLocationAction inline fun BotAction.asRecordAudioAction(): RecordAudioAction? = this as? RecordAudioAction +inline fun BotAction.requireRecordAudioAction(): RecordAudioAction = this as RecordAudioAction inline fun BotAction.asRecordVideoAction(): RecordVideoAction? = this as? RecordVideoAction +inline fun BotAction.requireRecordVideoAction(): RecordVideoAction = this as RecordVideoAction inline fun BotAction.asRecordVideoNoteAction(): RecordVideoNoteAction? = this as? RecordVideoNoteAction +inline fun BotAction.requireRecordVideoNoteAction(): RecordVideoNoteAction = this as RecordVideoNoteAction inline fun BotAction.asTypingAction(): TypingAction? = this as? TypingAction +inline fun BotAction.requireTypingAction(): TypingAction = this as TypingAction inline fun BotAction.asUploadAudioAction(): UploadAudioAction? = this as? UploadAudioAction +inline fun BotAction.requireUploadAudioAction(): UploadAudioAction = this as UploadAudioAction inline fun BotAction.asUploadDocumentAction(): UploadDocumentAction? = this as? UploadDocumentAction +inline fun BotAction.requireUploadDocumentAction(): UploadDocumentAction = this as UploadDocumentAction inline fun BotAction.asUploadPhotoAction(): UploadPhotoAction? = this as? UploadPhotoAction +inline fun BotAction.requireUploadPhotoAction(): UploadPhotoAction = this as UploadPhotoAction inline fun BotAction.asUploadVideoAction(): UploadVideoAction? = this as? UploadVideoAction +inline fun BotAction.requireUploadVideoAction(): UploadVideoAction = this as UploadVideoAction inline fun BotAction.asUploadVideoNoteAction(): UploadVideoNoteAction? = this as? UploadVideoNoteAction +inline fun BotAction.requireUploadVideoNoteAction(): UploadVideoNoteAction = this as UploadVideoNoteAction inline fun InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = this as? BaseInlineQuery +inline fun InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = this as BaseInlineQuery inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = this as? LocationInlineQuery +inline fun InlineQuery.requireLocationInlineQuery(): LocationInlineQuery = this as LocationInlineQuery inline fun InputMessageContent.asInputContactMessageContent(): InputContactMessageContent? = this as? InputContactMessageContent +inline fun InputMessageContent.requireInputContactMessageContent(): InputContactMessageContent = this as InputContactMessageContent inline fun InputMessageContent.asInputLocationMessageContent(): InputLocationMessageContent? = this as? InputLocationMessageContent +inline fun InputMessageContent.requireInputLocationMessageContent(): InputLocationMessageContent = this as InputLocationMessageContent inline fun InputMessageContent.asInputTextMessageContent(): InputTextMessageContent? = this as? InputTextMessageContent +inline fun InputMessageContent.requireInputTextMessageContent(): InputTextMessageContent = this as InputTextMessageContent inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageContent? = this as? InputVenueMessageContent +inline fun InputMessageContent.requireInputVenueMessageContent(): InputVenueMessageContent = this as InputVenueMessageContent inline fun InlineQueryResult.asInlineQueryResultArticle(): InlineQueryResultArticle? = this as? InlineQueryResultArticle +inline fun InlineQueryResult.requireInlineQueryResultArticle(): InlineQueryResultArticle = this as InlineQueryResultArticle inline fun InlineQueryResult.asInlineQueryResultAudioCachedImpl(): InlineQueryResultAudioCachedImpl? = this as? InlineQueryResultAudioCachedImpl +inline fun InlineQueryResult.requireInlineQueryResultAudioCachedImpl(): InlineQueryResultAudioCachedImpl = this as InlineQueryResultAudioCachedImpl inline fun InlineQueryResult.asInlineQueryResultAudioImpl(): InlineQueryResultAudioImpl? = this as? InlineQueryResultAudioImpl +inline fun InlineQueryResult.requireInlineQueryResultAudioImpl(): InlineQueryResultAudioImpl = this as InlineQueryResultAudioImpl inline fun InlineQueryResult.asInlineQueryResultContact(): InlineQueryResultContact? = this as? InlineQueryResultContact +inline fun InlineQueryResult.requireInlineQueryResultContact(): InlineQueryResultContact = this as InlineQueryResultContact inline fun InlineQueryResult.asInlineQueryResultDocumentCachedImpl(): InlineQueryResultDocumentCachedImpl? = this as? InlineQueryResultDocumentCachedImpl +inline fun InlineQueryResult.requireInlineQueryResultDocumentCachedImpl(): InlineQueryResultDocumentCachedImpl = this as InlineQueryResultDocumentCachedImpl inline fun InlineQueryResult.asInlineQueryResultDocumentImpl(): InlineQueryResultDocumentImpl? = this as? InlineQueryResultDocumentImpl +inline fun InlineQueryResult.requireInlineQueryResultDocumentImpl(): InlineQueryResultDocumentImpl = this as InlineQueryResultDocumentImpl inline fun InlineQueryResult.asInlineQueryResultGame(): InlineQueryResultGame? = this as? InlineQueryResultGame +inline fun InlineQueryResult.requireInlineQueryResultGame(): InlineQueryResultGame = this as InlineQueryResultGame inline fun InlineQueryResult.asInlineQueryResultGifCachedImpl(): InlineQueryResultGifCachedImpl? = this as? InlineQueryResultGifCachedImpl +inline fun InlineQueryResult.requireInlineQueryResultGifCachedImpl(): InlineQueryResultGifCachedImpl = this as InlineQueryResultGifCachedImpl inline fun InlineQueryResult.asInlineQueryResultGifImpl(): InlineQueryResultGifImpl? = this as? InlineQueryResultGifImpl +inline fun InlineQueryResult.requireInlineQueryResultGifImpl(): InlineQueryResultGifImpl = this as InlineQueryResultGifImpl inline fun InlineQueryResult.asInlineQueryResultLocation(): InlineQueryResultLocation? = this as? InlineQueryResultLocation +inline fun InlineQueryResult.requireInlineQueryResultLocation(): InlineQueryResultLocation = this as InlineQueryResultLocation inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCachedImpl(): InlineQueryResultMpeg4GifCachedImpl? = this as? InlineQueryResultMpeg4GifCachedImpl +inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCachedImpl(): InlineQueryResultMpeg4GifCachedImpl = this as InlineQueryResultMpeg4GifCachedImpl inline fun InlineQueryResult.asInlineQueryResultMpeg4GifImpl(): InlineQueryResultMpeg4GifImpl? = this as? InlineQueryResultMpeg4GifImpl +inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifImpl(): InlineQueryResultMpeg4GifImpl = this as InlineQueryResultMpeg4GifImpl inline fun InlineQueryResult.asInlineQueryResultPhotoCachedImpl(): InlineQueryResultPhotoCachedImpl? = this as? InlineQueryResultPhotoCachedImpl +inline fun InlineQueryResult.requireInlineQueryResultPhotoCachedImpl(): InlineQueryResultPhotoCachedImpl = this as InlineQueryResultPhotoCachedImpl inline fun InlineQueryResult.asInlineQueryResultPhotoImpl(): InlineQueryResultPhotoImpl? = this as? InlineQueryResultPhotoImpl +inline fun InlineQueryResult.requireInlineQueryResultPhotoImpl(): InlineQueryResultPhotoImpl = this as InlineQueryResultPhotoImpl inline fun InlineQueryResult.asInlineQueryResultStickerCached(): InlineQueryResultStickerCached? = this as? InlineQueryResultStickerCached +inline fun InlineQueryResult.requireInlineQueryResultStickerCached(): InlineQueryResultStickerCached = this as InlineQueryResultStickerCached inline fun InlineQueryResult.asInlineQueryResultVenue(): InlineQueryResultVenue? = this as? InlineQueryResultVenue +inline fun InlineQueryResult.requireInlineQueryResultVenue(): InlineQueryResultVenue = this as InlineQueryResultVenue inline fun InlineQueryResult.asInlineQueryResultVideoCachedImpl(): InlineQueryResultVideoCachedImpl? = this as? InlineQueryResultVideoCachedImpl +inline fun InlineQueryResult.requireInlineQueryResultVideoCachedImpl(): InlineQueryResultVideoCachedImpl = this as InlineQueryResultVideoCachedImpl inline fun InlineQueryResult.asInlineQueryResultVideoImpl(): InlineQueryResultVideoImpl? = this as? InlineQueryResultVideoImpl +inline fun InlineQueryResult.requireInlineQueryResultVideoImpl(): InlineQueryResultVideoImpl = this as InlineQueryResultVideoImpl inline fun InlineQueryResult.asInlineQueryResultVoiceCachedImpl(): InlineQueryResultVoiceCachedImpl? = this as? InlineQueryResultVoiceCachedImpl +inline fun InlineQueryResult.requireInlineQueryResultVoiceCachedImpl(): InlineQueryResultVoiceCachedImpl = this as InlineQueryResultVoiceCachedImpl inline fun InlineQueryResult.asInlineQueryResultVoiceImpl(): InlineQueryResultVoiceImpl? = this as? InlineQueryResultVoiceImpl +inline fun InlineQueryResult.requireInlineQueryResultVoiceImpl(): InlineQueryResultVoiceImpl = this as InlineQueryResultVoiceImpl inline fun InlineQueryResult.asDescribedInlineQueryResult(): DescribedInlineQueryResult? = this as? DescribedInlineQueryResult +inline fun InlineQueryResult.requireDescribedInlineQueryResult(): DescribedInlineQueryResult = this as DescribedInlineQueryResult inline fun InlineQueryResult.asFileInlineQueryResult(): FileInlineQueryResult? = this as? FileInlineQueryResult +inline fun InlineQueryResult.requireFileInlineQueryResult(): FileInlineQueryResult = this as FileInlineQueryResult inline fun InlineQueryResult.asOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult? = this as? OptionallyTitledInlineQueryResult +inline fun InlineQueryResult.requireOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult = this as OptionallyTitledInlineQueryResult inline fun InlineQueryResult.asSizedInlineQueryResult(): SizedInlineQueryResult? = this as? SizedInlineQueryResult +inline fun InlineQueryResult.requireSizedInlineQueryResult(): SizedInlineQueryResult = this as SizedInlineQueryResult inline fun InlineQueryResult.asThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult? = this as? ThumbSizedInlineQueryResult +inline fun InlineQueryResult.requireThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult = this as ThumbSizedInlineQueryResult inline fun InlineQueryResult.asThumbedInlineQueryResult(): ThumbedInlineQueryResult? = this as? ThumbedInlineQueryResult +inline fun InlineQueryResult.requireThumbedInlineQueryResult(): ThumbedInlineQueryResult = this as ThumbedInlineQueryResult inline fun InlineQueryResult.asThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult? = this as? ThumbedWithMimeTypeInlineQueryResult +inline fun InlineQueryResult.requireThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult = this as ThumbedWithMimeTypeInlineQueryResult inline fun InlineQueryResult.asTitledInlineQueryResult(): TitledInlineQueryResult? = this as? TitledInlineQueryResult +inline fun InlineQueryResult.requireTitledInlineQueryResult(): TitledInlineQueryResult = this as TitledInlineQueryResult inline fun InlineQueryResult.asUrlInlineQueryResult(): UrlInlineQueryResult? = this as? UrlInlineQueryResult +inline fun InlineQueryResult.requireUrlInlineQueryResult(): UrlInlineQueryResult = this as UrlInlineQueryResult inline fun InlineQueryResult.asWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult? = this as? WithInputMessageContentInlineQueryResult +inline fun InlineQueryResult.requireWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult = this as WithInputMessageContentInlineQueryResult inline fun InlineQueryResult.asInlineQueryResultAudio(): InlineQueryResultAudio? = this as? InlineQueryResultAudio +inline fun InlineQueryResult.requireInlineQueryResultAudio(): InlineQueryResultAudio = this as InlineQueryResultAudio inline fun InlineQueryResult.asInlineQueryResultAudioCached(): InlineQueryResultAudioCached? = this as? InlineQueryResultAudioCached +inline fun InlineQueryResult.requireInlineQueryResultAudioCached(): InlineQueryResultAudioCached = this as InlineQueryResultAudioCached inline fun InlineQueryResult.asInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon? = this as? InlineQueryResultAudioCommon +inline fun InlineQueryResult.requireInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon = this as InlineQueryResultAudioCommon inline fun InlineQueryResult.asInlineQueryResultDocument(): InlineQueryResultDocument? = this as? InlineQueryResultDocument +inline fun InlineQueryResult.requireInlineQueryResultDocument(): InlineQueryResultDocument = this as InlineQueryResultDocument inline fun InlineQueryResult.asInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached? = this as? InlineQueryResultDocumentCached +inline fun InlineQueryResult.requireInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached = this as InlineQueryResultDocumentCached inline fun InlineQueryResult.asInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon? = this as? InlineQueryResultDocumentCommon +inline fun InlineQueryResult.requireInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon = this as InlineQueryResultDocumentCommon inline fun InlineQueryResult.asInlineQueryResultGif(): InlineQueryResultGif? = this as? InlineQueryResultGif +inline fun InlineQueryResult.requireInlineQueryResultGif(): InlineQueryResultGif = this as InlineQueryResultGif inline fun InlineQueryResult.asInlineQueryResultGifCached(): InlineQueryResultGifCached? = this as? InlineQueryResultGifCached +inline fun InlineQueryResult.requireInlineQueryResultGifCached(): InlineQueryResultGifCached = this as InlineQueryResultGifCached inline fun InlineQueryResult.asInlineQueryResultGifCommon(): InlineQueryResultGifCommon? = this as? InlineQueryResultGifCommon +inline fun InlineQueryResult.requireInlineQueryResultGifCommon(): InlineQueryResultGifCommon = this as InlineQueryResultGifCommon inline fun InlineQueryResult.asInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif? = this as? InlineQueryResultMpeg4Gif +inline fun InlineQueryResult.requireInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif = this as InlineQueryResultMpeg4Gif inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached? = this as? InlineQueryResultMpeg4GifCached +inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached = this as InlineQueryResultMpeg4GifCached inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon? = this as? InlineQueryResultMpeg4GifCommon +inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon = this as InlineQueryResultMpeg4GifCommon inline fun InlineQueryResult.asInlineQueryResultPhoto(): InlineQueryResultPhoto? = this as? InlineQueryResultPhoto +inline fun InlineQueryResult.requireInlineQueryResultPhoto(): InlineQueryResultPhoto = this as InlineQueryResultPhoto inline fun InlineQueryResult.asInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached? = this as? InlineQueryResultPhotoCached +inline fun InlineQueryResult.requireInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached = this as InlineQueryResultPhotoCached inline fun InlineQueryResult.asInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon? = this as? InlineQueryResultPhotoCommon +inline fun InlineQueryResult.requireInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon = this as InlineQueryResultPhotoCommon inline fun InlineQueryResult.asInlineQueryResultVideo(): InlineQueryResultVideo? = this as? InlineQueryResultVideo +inline fun InlineQueryResult.requireInlineQueryResultVideo(): InlineQueryResultVideo = this as InlineQueryResultVideo inline fun InlineQueryResult.asInlineQueryResultVideoCached(): InlineQueryResultVideoCached? = this as? InlineQueryResultVideoCached +inline fun InlineQueryResult.requireInlineQueryResultVideoCached(): InlineQueryResultVideoCached = this as InlineQueryResultVideoCached inline fun InlineQueryResult.asInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon? = this as? InlineQueryResultVideoCommon +inline fun InlineQueryResult.requireInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon = this as InlineQueryResultVideoCommon inline fun InlineQueryResult.asInlineQueryResultVoice(): InlineQueryResultVoice? = this as? InlineQueryResultVoice +inline fun InlineQueryResult.requireInlineQueryResultVoice(): InlineQueryResultVoice = this as InlineQueryResultVoice inline fun InlineQueryResult.asInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached? = this as? InlineQueryResultVoiceCached +inline fun InlineQueryResult.requireInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached = this as InlineQueryResultVoiceCached inline fun InlineQueryResult.asInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon? = this as? InlineQueryResultVoiceCommon +inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon = this as InlineQueryResultVoiceCommon inline fun ChatMember.asAdministratorChatMemberImpl(): AdministratorChatMemberImpl? = this as? AdministratorChatMemberImpl +inline fun ChatMember.requireAdministratorChatMemberImpl(): AdministratorChatMemberImpl = this as AdministratorChatMemberImpl inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember +inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember inline fun ChatMember.asKickedChatMember(): KickedChatMember? = this as? KickedChatMember +inline fun ChatMember.requireKickedChatMember(): KickedChatMember = this as KickedChatMember inline fun ChatMember.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember +inline fun ChatMember.requireLeftChatMember(): LeftChatMember = this as LeftChatMember inline fun ChatMember.asMemberChatMember(): MemberChatMember? = this as? MemberChatMember +inline fun ChatMember.requireMemberChatMember(): MemberChatMember = this as MemberChatMember inline fun ChatMember.asRestrictedChatMember(): RestrictedChatMember? = this as? RestrictedChatMember +inline fun ChatMember.requireRestrictedChatMember(): RestrictedChatMember = this as RestrictedChatMember inline fun ChatMember.asAdministratorChatMember(): AdministratorChatMember? = this as? AdministratorChatMember +inline fun ChatMember.requireAdministratorChatMember(): AdministratorChatMember = this as AdministratorChatMember inline fun ChatMember.asBannedChatMember(): BannedChatMember? = this as? BannedChatMember +inline fun ChatMember.requireBannedChatMember(): BannedChatMember = this as BannedChatMember inline fun ChatMember.asSpecialRightsChatMember(): SpecialRightsChatMember? = this as? SpecialRightsChatMember +inline fun ChatMember.requireSpecialRightsChatMember(): SpecialRightsChatMember = this as SpecialRightsChatMember inline fun InputMedia.asAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia? = this as? AudioMediaGroupMemberInputMedia +inline fun InputMedia.requireAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia = this as AudioMediaGroupMemberInputMedia inline fun InputMedia.asDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia? = this as? DocumentMediaGroupMemberInputMedia +inline fun InputMedia.requireDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia = this as DocumentMediaGroupMemberInputMedia inline fun InputMedia.asDuratedInputMedia(): DuratedInputMedia? = this as? DuratedInputMedia +inline fun InputMedia.requireDuratedInputMedia(): DuratedInputMedia = this as DuratedInputMedia inline fun InputMedia.asInputMediaAnimation(): InputMediaAnimation? = this as? InputMediaAnimation +inline fun InputMedia.requireInputMediaAnimation(): InputMediaAnimation = this as InputMediaAnimation inline fun InputMedia.asInputMediaAudio(): InputMediaAudio? = this as? InputMediaAudio +inline fun InputMedia.requireInputMediaAudio(): InputMediaAudio = this as InputMediaAudio inline fun InputMedia.asInputMediaDocument(): InputMediaDocument? = this as? InputMediaDocument +inline fun InputMedia.requireInputMediaDocument(): InputMediaDocument = this as InputMediaDocument inline fun InputMedia.asInputMediaPhoto(): InputMediaPhoto? = this as? InputMediaPhoto +inline fun InputMedia.requireInputMediaPhoto(): InputMediaPhoto = this as InputMediaPhoto inline fun InputMedia.asInputMediaVideo(): InputMediaVideo? = this as? InputMediaVideo +inline fun InputMedia.requireInputMediaVideo(): InputMediaVideo = this as InputMediaVideo inline fun InputMedia.asMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia? = this as? MediaGroupMemberInputMedia +inline fun InputMedia.requireMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = this as MediaGroupMemberInputMedia inline fun InputMedia.asSizedInputMedia(): SizedInputMedia? = this as? SizedInputMedia +inline fun InputMedia.requireSizedInputMedia(): SizedInputMedia = this as SizedInputMedia inline fun InputMedia.asThumbedInputMedia(): ThumbedInputMedia? = this as? ThumbedInputMedia +inline fun InputMedia.requireThumbedInputMedia(): ThumbedInputMedia = this as ThumbedInputMedia inline fun InputMedia.asTitledInputMedia(): TitledInputMedia? = this as? TitledInputMedia +inline fun InputMedia.requireTitledInputMedia(): TitledInputMedia = this as TitledInputMedia inline fun InputMedia.asVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia? = this as? VisualMediaGroupMemberInputMedia +inline fun InputMedia.requireVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia = this as VisualMediaGroupMemberInputMedia inline fun Update.asCallbackQueryUpdate(): CallbackQueryUpdate? = this as? CallbackQueryUpdate +inline fun Update.requireCallbackQueryUpdate(): CallbackQueryUpdate = this as CallbackQueryUpdate inline fun Update.asChannelPostUpdate(): ChannelPostUpdate? = this as? ChannelPostUpdate +inline fun Update.requireChannelPostUpdate(): ChannelPostUpdate = this as ChannelPostUpdate inline fun Update.asChosenInlineResultUpdate(): ChosenInlineResultUpdate? = this as? ChosenInlineResultUpdate +inline fun Update.requireChosenInlineResultUpdate(): ChosenInlineResultUpdate = this as ChosenInlineResultUpdate inline fun Update.asEditChannelPostUpdate(): EditChannelPostUpdate? = this as? EditChannelPostUpdate +inline fun Update.requireEditChannelPostUpdate(): EditChannelPostUpdate = this as EditChannelPostUpdate inline fun Update.asEditMessageUpdate(): EditMessageUpdate? = this as? EditMessageUpdate +inline fun Update.requireEditMessageUpdate(): EditMessageUpdate = this as EditMessageUpdate inline fun Update.asInlineQueryUpdate(): InlineQueryUpdate? = this as? InlineQueryUpdate +inline fun Update.requireInlineQueryUpdate(): InlineQueryUpdate = this as InlineQueryUpdate inline fun Update.asChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate? = this as? ChannelPostMediaGroupUpdate +inline fun Update.requireChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate = this as ChannelPostMediaGroupUpdate inline fun Update.asEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate? = this as? EditChannelPostMediaGroupUpdate +inline fun Update.requireEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate = this as EditChannelPostMediaGroupUpdate inline fun Update.asEditMediaGroupUpdate(): EditMediaGroupUpdate? = this as? EditMediaGroupUpdate +inline fun Update.requireEditMediaGroupUpdate(): EditMediaGroupUpdate = this as EditMediaGroupUpdate inline fun Update.asEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate? = this as? EditMessageMediaGroupUpdate +inline fun Update.requireEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate = this as EditMessageMediaGroupUpdate inline fun Update.asMediaGroupUpdate(): MediaGroupUpdate? = this as? MediaGroupUpdate +inline fun Update.requireMediaGroupUpdate(): MediaGroupUpdate = this as MediaGroupUpdate inline fun Update.asMessageMediaGroupUpdate(): MessageMediaGroupUpdate? = this as? MessageMediaGroupUpdate +inline fun Update.requireMessageMediaGroupUpdate(): MessageMediaGroupUpdate = this as MessageMediaGroupUpdate inline fun Update.asSentMediaGroupUpdate(): SentMediaGroupUpdate? = this as? SentMediaGroupUpdate +inline fun Update.requireSentMediaGroupUpdate(): SentMediaGroupUpdate = this as SentMediaGroupUpdate inline fun Update.asMessageUpdate(): MessageUpdate? = this as? MessageUpdate +inline fun Update.requireMessageUpdate(): MessageUpdate = this as MessageUpdate inline fun Update.asPollAnswerUpdate(): PollAnswerUpdate? = this as? PollAnswerUpdate +inline fun Update.requirePollAnswerUpdate(): PollAnswerUpdate = this as PollAnswerUpdate inline fun Update.asPollUpdate(): PollUpdate? = this as? PollUpdate +inline fun Update.requirePollUpdate(): PollUpdate = this as PollUpdate inline fun Update.asPreCheckoutQueryUpdate(): PreCheckoutQueryUpdate? = this as? PreCheckoutQueryUpdate +inline fun Update.requirePreCheckoutQueryUpdate(): PreCheckoutQueryUpdate = this as PreCheckoutQueryUpdate inline fun Update.asShippingQueryUpdate(): ShippingQueryUpdate? = this as? ShippingQueryUpdate +inline fun Update.requireShippingQueryUpdate(): ShippingQueryUpdate = this as ShippingQueryUpdate inline fun Update.asBaseEditMessageUpdate(): BaseEditMessageUpdate? = this as? BaseEditMessageUpdate +inline fun Update.requireBaseEditMessageUpdate(): BaseEditMessageUpdate = this as BaseEditMessageUpdate inline fun Update.asBaseMessageUpdate(): BaseMessageUpdate? = this as? BaseMessageUpdate +inline fun Update.requireBaseMessageUpdate(): BaseMessageUpdate = this as BaseMessageUpdate inline fun Update.asBaseSentMessageUpdate(): BaseSentMessageUpdate? = this as? BaseSentMessageUpdate +inline fun Update.requireBaseSentMessageUpdate(): BaseSentMessageUpdate = this as BaseSentMessageUpdate inline fun Update.asUnknownUpdate(): UnknownUpdate? = this as? UnknownUpdate +inline fun Update.requireUnknownUpdate(): UnknownUpdate = this as UnknownUpdate inline fun TelegramMediaFile.asAnimationFile(): AnimationFile? = this as? AnimationFile +inline fun TelegramMediaFile.requireAnimationFile(): AnimationFile = this as AnimationFile inline fun TelegramMediaFile.asAudioFile(): AudioFile? = this as? AudioFile +inline fun TelegramMediaFile.requireAudioFile(): AudioFile = this as AudioFile inline fun TelegramMediaFile.asDocumentFile(): DocumentFile? = this as? DocumentFile +inline fun TelegramMediaFile.requireDocumentFile(): DocumentFile = this as DocumentFile inline fun TelegramMediaFile.asFile(): File? = this as? File +inline fun TelegramMediaFile.requireFile(): File = this as File inline fun TelegramMediaFile.asPathedFile(): PathedFile? = this as? PathedFile +inline fun TelegramMediaFile.requirePathedFile(): PathedFile = this as PathedFile inline fun TelegramMediaFile.asPhotoSize(): PhotoSize? = this as? PhotoSize +inline fun TelegramMediaFile.requirePhotoSize(): PhotoSize = this as PhotoSize inline fun TelegramMediaFile.asSticker(): Sticker? = this as? Sticker +inline fun TelegramMediaFile.requireSticker(): Sticker = this as Sticker inline fun TelegramMediaFile.asVideoFile(): VideoFile? = this as? VideoFile +inline fun TelegramMediaFile.requireVideoFile(): VideoFile = this as VideoFile inline fun TelegramMediaFile.asVideoNoteFile(): VideoNoteFile? = this as? VideoNoteFile +inline fun TelegramMediaFile.requireVideoNoteFile(): VideoNoteFile = this as VideoNoteFile inline fun TelegramMediaFile.asVoiceFile(): VoiceFile? = this as? VoiceFile +inline fun TelegramMediaFile.requireVoiceFile(): VoiceFile = this as VoiceFile inline fun TelegramMediaFile.asMimedMediaFile(): MimedMediaFile? = this as? MimedMediaFile +inline fun TelegramMediaFile.requireMimedMediaFile(): MimedMediaFile = this as MimedMediaFile inline fun TelegramMediaFile.asPlayableMediaFile(): PlayableMediaFile? = this as? PlayableMediaFile +inline fun TelegramMediaFile.requirePlayableMediaFile(): PlayableMediaFile = this as PlayableMediaFile inline fun TelegramMediaFile.asSizedMediaFile(): SizedMediaFile? = this as? SizedMediaFile +inline fun TelegramMediaFile.requireSizedMediaFile(): SizedMediaFile = this as SizedMediaFile inline fun TelegramMediaFile.asThumbedMediaFile(): ThumbedMediaFile? = this as? ThumbedMediaFile +inline fun TelegramMediaFile.requireThumbedMediaFile(): ThumbedMediaFile = this as ThumbedMediaFile inline fun KeyboardMarkup.asForceReply(): ForceReply? = this as? ForceReply +inline fun KeyboardMarkup.requireForceReply(): ForceReply = this as ForceReply inline fun KeyboardMarkup.asInlineKeyboardMarkup(): InlineKeyboardMarkup? = this as? InlineKeyboardMarkup +inline fun KeyboardMarkup.requireInlineKeyboardMarkup(): InlineKeyboardMarkup = this as InlineKeyboardMarkup inline fun KeyboardMarkup.asReplyKeyboardMarkup(): ReplyKeyboardMarkup? = this as? ReplyKeyboardMarkup +inline fun KeyboardMarkup.requireReplyKeyboardMarkup(): ReplyKeyboardMarkup = this as ReplyKeyboardMarkup inline fun KeyboardMarkup.asReplyKeyboardRemove(): ReplyKeyboardRemove? = this as? ReplyKeyboardRemove +inline fun KeyboardMarkup.requireReplyKeyboardRemove(): ReplyKeyboardRemove = this as ReplyKeyboardRemove inline fun InlineKeyboardButton.asCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton? = this as? CallbackDataInlineKeyboardButton +inline fun InlineKeyboardButton.requireCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton = this as CallbackDataInlineKeyboardButton inline fun InlineKeyboardButton.asCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton? = this as? CallbackGameInlineKeyboardButton +inline fun InlineKeyboardButton.requireCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton = this as CallbackGameInlineKeyboardButton inline fun InlineKeyboardButton.asLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton? = this as? LoginURLInlineKeyboardButton +inline fun InlineKeyboardButton.requireLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton = this as LoginURLInlineKeyboardButton inline fun InlineKeyboardButton.asPayInlineKeyboardButton(): PayInlineKeyboardButton? = this as? PayInlineKeyboardButton +inline fun InlineKeyboardButton.requirePayInlineKeyboardButton(): PayInlineKeyboardButton = this as PayInlineKeyboardButton inline fun InlineKeyboardButton.asSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton? = this as? SwitchInlineQueryCurrentChatInlineKeyboardButton +inline fun InlineKeyboardButton.requireSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton = this as SwitchInlineQueryCurrentChatInlineKeyboardButton inline fun InlineKeyboardButton.asSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton? = this as? SwitchInlineQueryInlineKeyboardButton +inline fun InlineKeyboardButton.requireSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton = this as SwitchInlineQueryInlineKeyboardButton inline fun InlineKeyboardButton.asURLInlineKeyboardButton(): URLInlineKeyboardButton? = this as? URLInlineKeyboardButton +inline fun InlineKeyboardButton.requireURLInlineKeyboardButton(): URLInlineKeyboardButton = this as URLInlineKeyboardButton inline fun InlineKeyboardButton.asUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton? = this as? UnknownInlineKeyboardButton +inline fun InlineKeyboardButton.requireUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton = this as UnknownInlineKeyboardButton inline fun Poll.asMultipleAnswersPoll(): MultipleAnswersPoll? = this as? MultipleAnswersPoll +inline fun Poll.requireMultipleAnswersPoll(): MultipleAnswersPoll = this as MultipleAnswersPoll inline fun Poll.asQuizPoll(): QuizPoll? = this as? QuizPoll +inline fun Poll.requireQuizPoll(): QuizPoll = this as QuizPoll inline fun Poll.asRegularPoll(): RegularPoll? = this as? RegularPoll +inline fun Poll.requireRegularPoll(): RegularPoll = this as RegularPoll inline fun Poll.asUnknownPollType(): UnknownPollType? = this as? UnknownPollType +inline fun Poll.requireUnknownPollType(): UnknownPollType = this as UnknownPollType From c091098feb71945c9538f3c3652a05f58c54d074 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 22:37:52 +0600 Subject: [PATCH 08/10] remove *Impl casts --- .../tgbotapi/extensions/utils/ClassCasts.kt | 56 ------------------- 1 file changed, 56 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index cd4595312c..d743948ac7 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -53,14 +53,6 @@ inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot inline fun Chat.requireExtendedBot(): ExtendedBot = this as ExtendedBot inline fun Chat.asUser(): User? = this as? User inline fun Chat.requireUser(): User = this as User -inline fun Chat.asChannelChatImpl(): ChannelChatImpl? = this as? ChannelChatImpl -inline fun Chat.requireChannelChatImpl(): ChannelChatImpl = this as ChannelChatImpl -inline fun Chat.asGroupChatImpl(): GroupChatImpl? = this as? GroupChatImpl -inline fun Chat.requireGroupChatImpl(): GroupChatImpl = this as GroupChatImpl -inline fun Chat.asPrivateChatImpl(): PrivateChatImpl? = this as? PrivateChatImpl -inline fun Chat.requirePrivateChatImpl(): PrivateChatImpl = this as PrivateChatImpl -inline fun Chat.asSupergroupChatImpl(): SupergroupChatImpl? = this as? SupergroupChatImpl -inline fun Chat.requireSupergroupChatImpl(): SupergroupChatImpl = this as SupergroupChatImpl inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat inline fun Chat.requireChannelChat(): ChannelChat = this as ChannelChat inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat @@ -89,14 +81,6 @@ inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedP inline fun Chat.requireExtendedPublicChat(): ExtendedPublicChat = this as ExtendedPublicChat inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? ExtendedSupergroupChat inline fun Chat.requireExtendedSupergroupChat(): ExtendedSupergroupChat = this as ExtendedSupergroupChat -inline fun Chat.asExtendedChannelChatImpl(): ExtendedChannelChatImpl? = this as? ExtendedChannelChatImpl -inline fun Chat.requireExtendedChannelChatImpl(): ExtendedChannelChatImpl = this as ExtendedChannelChatImpl -inline fun Chat.asExtendedGroupChatImpl(): ExtendedGroupChatImpl? = this as? ExtendedGroupChatImpl -inline fun Chat.requireExtendedGroupChatImpl(): ExtendedGroupChatImpl = this as ExtendedGroupChatImpl -inline fun Chat.asExtendedPrivateChatImpl(): ExtendedPrivateChatImpl? = this as? ExtendedPrivateChatImpl -inline fun Chat.requireExtendedPrivateChatImpl(): ExtendedPrivateChatImpl = this as ExtendedPrivateChatImpl -inline fun Chat.asExtendedSupergroupChatImpl(): ExtendedSupergroupChatImpl? = this as? ExtendedSupergroupChatImpl -inline fun Chat.requireExtendedSupergroupChatImpl(): ExtendedSupergroupChatImpl = this as ExtendedSupergroupChatImpl inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? DataCallbackQuery inline fun CallbackQuery.requireDataCallbackQuery(): DataCallbackQuery = this as DataCallbackQuery inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? = this as? GameShortNameCallbackQuery @@ -115,26 +99,16 @@ inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShort inline fun CallbackQuery.requireMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery = this as MessageGameShortNameCallbackQuery inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType? = this as? UnknownCallbackQueryType inline fun CallbackQuery.requireUnknownCallbackQueryType(): UnknownCallbackQueryType = this as UnknownCallbackQueryType -inline fun Message.asAnonymousGroupMessageImpl(): AnonymousGroupMessageImpl? = this as? AnonymousGroupMessageImpl -inline fun Message.requireAnonymousGroupMessageImpl(): AnonymousGroupMessageImpl = this as AnonymousGroupMessageImpl inline fun Message.asChannelEventMessage(): ChannelEventMessage? = this as? ChannelEventMessage inline fun Message.requireChannelEventMessage(): ChannelEventMessage = this as ChannelEventMessage inline fun Message.asChannelMediaGroupMessage(): ChannelMediaGroupMessage? = this as? ChannelMediaGroupMessage inline fun Message.requireChannelMediaGroupMessage(): ChannelMediaGroupMessage = this as ChannelMediaGroupMessage -inline fun Message.asChannelMessageImpl(): ChannelMessageImpl? = this as? ChannelMessageImpl -inline fun Message.requireChannelMessageImpl(): ChannelMessageImpl = this as ChannelMessageImpl inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = this as? CommonGroupEventMessage inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage = this as CommonGroupEventMessage -inline fun Message.asCommonGroupMessageImpl(): CommonGroupMessageImpl? = this as? CommonGroupMessageImpl -inline fun Message.requireCommonGroupMessageImpl(): CommonGroupMessageImpl = this as CommonGroupMessageImpl inline fun Message.asCommonMediaGroupMessage(): CommonMediaGroupMessage? = this as? CommonMediaGroupMessage inline fun Message.requireCommonMediaGroupMessage(): CommonMediaGroupMessage = this as CommonMediaGroupMessage inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = this as? CommonSupergroupEventMessage inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = this as CommonSupergroupEventMessage -inline fun Message.asFromChannelGroupMessageImpl(): FromChannelGroupMessageImpl? = this as? FromChannelGroupMessageImpl -inline fun Message.requireFromChannelGroupMessageImpl(): FromChannelGroupMessageImpl = this as FromChannelGroupMessageImpl -inline fun Message.asPrivateMessageImpl(): PrivateMessageImpl? = this as? PrivateMessageImpl -inline fun Message.requirePrivateMessageImpl(): PrivateMessageImpl = this as PrivateMessageImpl inline fun Message.asAnonymousGroupMessage(): AnonymousGroupMessage? = this as? AnonymousGroupMessage inline fun Message.requireAnonymousGroupMessage(): AnonymousGroupMessage = this as AnonymousGroupMessage inline fun Message.asChannelMessage(): ChannelMessage? = this as? ChannelMessage @@ -207,44 +181,16 @@ inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageCo inline fun InputMessageContent.requireInputVenueMessageContent(): InputVenueMessageContent = this as InputVenueMessageContent inline fun InlineQueryResult.asInlineQueryResultArticle(): InlineQueryResultArticle? = this as? InlineQueryResultArticle inline fun InlineQueryResult.requireInlineQueryResultArticle(): InlineQueryResultArticle = this as InlineQueryResultArticle -inline fun InlineQueryResult.asInlineQueryResultAudioCachedImpl(): InlineQueryResultAudioCachedImpl? = this as? InlineQueryResultAudioCachedImpl -inline fun InlineQueryResult.requireInlineQueryResultAudioCachedImpl(): InlineQueryResultAudioCachedImpl = this as InlineQueryResultAudioCachedImpl -inline fun InlineQueryResult.asInlineQueryResultAudioImpl(): InlineQueryResultAudioImpl? = this as? InlineQueryResultAudioImpl -inline fun InlineQueryResult.requireInlineQueryResultAudioImpl(): InlineQueryResultAudioImpl = this as InlineQueryResultAudioImpl inline fun InlineQueryResult.asInlineQueryResultContact(): InlineQueryResultContact? = this as? InlineQueryResultContact inline fun InlineQueryResult.requireInlineQueryResultContact(): InlineQueryResultContact = this as InlineQueryResultContact -inline fun InlineQueryResult.asInlineQueryResultDocumentCachedImpl(): InlineQueryResultDocumentCachedImpl? = this as? InlineQueryResultDocumentCachedImpl -inline fun InlineQueryResult.requireInlineQueryResultDocumentCachedImpl(): InlineQueryResultDocumentCachedImpl = this as InlineQueryResultDocumentCachedImpl -inline fun InlineQueryResult.asInlineQueryResultDocumentImpl(): InlineQueryResultDocumentImpl? = this as? InlineQueryResultDocumentImpl -inline fun InlineQueryResult.requireInlineQueryResultDocumentImpl(): InlineQueryResultDocumentImpl = this as InlineQueryResultDocumentImpl inline fun InlineQueryResult.asInlineQueryResultGame(): InlineQueryResultGame? = this as? InlineQueryResultGame inline fun InlineQueryResult.requireInlineQueryResultGame(): InlineQueryResultGame = this as InlineQueryResultGame -inline fun InlineQueryResult.asInlineQueryResultGifCachedImpl(): InlineQueryResultGifCachedImpl? = this as? InlineQueryResultGifCachedImpl -inline fun InlineQueryResult.requireInlineQueryResultGifCachedImpl(): InlineQueryResultGifCachedImpl = this as InlineQueryResultGifCachedImpl -inline fun InlineQueryResult.asInlineQueryResultGifImpl(): InlineQueryResultGifImpl? = this as? InlineQueryResultGifImpl -inline fun InlineQueryResult.requireInlineQueryResultGifImpl(): InlineQueryResultGifImpl = this as InlineQueryResultGifImpl inline fun InlineQueryResult.asInlineQueryResultLocation(): InlineQueryResultLocation? = this as? InlineQueryResultLocation inline fun InlineQueryResult.requireInlineQueryResultLocation(): InlineQueryResultLocation = this as InlineQueryResultLocation -inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCachedImpl(): InlineQueryResultMpeg4GifCachedImpl? = this as? InlineQueryResultMpeg4GifCachedImpl -inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCachedImpl(): InlineQueryResultMpeg4GifCachedImpl = this as InlineQueryResultMpeg4GifCachedImpl -inline fun InlineQueryResult.asInlineQueryResultMpeg4GifImpl(): InlineQueryResultMpeg4GifImpl? = this as? InlineQueryResultMpeg4GifImpl -inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifImpl(): InlineQueryResultMpeg4GifImpl = this as InlineQueryResultMpeg4GifImpl -inline fun InlineQueryResult.asInlineQueryResultPhotoCachedImpl(): InlineQueryResultPhotoCachedImpl? = this as? InlineQueryResultPhotoCachedImpl -inline fun InlineQueryResult.requireInlineQueryResultPhotoCachedImpl(): InlineQueryResultPhotoCachedImpl = this as InlineQueryResultPhotoCachedImpl -inline fun InlineQueryResult.asInlineQueryResultPhotoImpl(): InlineQueryResultPhotoImpl? = this as? InlineQueryResultPhotoImpl -inline fun InlineQueryResult.requireInlineQueryResultPhotoImpl(): InlineQueryResultPhotoImpl = this as InlineQueryResultPhotoImpl inline fun InlineQueryResult.asInlineQueryResultStickerCached(): InlineQueryResultStickerCached? = this as? InlineQueryResultStickerCached inline fun InlineQueryResult.requireInlineQueryResultStickerCached(): InlineQueryResultStickerCached = this as InlineQueryResultStickerCached inline fun InlineQueryResult.asInlineQueryResultVenue(): InlineQueryResultVenue? = this as? InlineQueryResultVenue inline fun InlineQueryResult.requireInlineQueryResultVenue(): InlineQueryResultVenue = this as InlineQueryResultVenue -inline fun InlineQueryResult.asInlineQueryResultVideoCachedImpl(): InlineQueryResultVideoCachedImpl? = this as? InlineQueryResultVideoCachedImpl -inline fun InlineQueryResult.requireInlineQueryResultVideoCachedImpl(): InlineQueryResultVideoCachedImpl = this as InlineQueryResultVideoCachedImpl -inline fun InlineQueryResult.asInlineQueryResultVideoImpl(): InlineQueryResultVideoImpl? = this as? InlineQueryResultVideoImpl -inline fun InlineQueryResult.requireInlineQueryResultVideoImpl(): InlineQueryResultVideoImpl = this as InlineQueryResultVideoImpl -inline fun InlineQueryResult.asInlineQueryResultVoiceCachedImpl(): InlineQueryResultVoiceCachedImpl? = this as? InlineQueryResultVoiceCachedImpl -inline fun InlineQueryResult.requireInlineQueryResultVoiceCachedImpl(): InlineQueryResultVoiceCachedImpl = this as InlineQueryResultVoiceCachedImpl -inline fun InlineQueryResult.asInlineQueryResultVoiceImpl(): InlineQueryResultVoiceImpl? = this as? InlineQueryResultVoiceImpl -inline fun InlineQueryResult.requireInlineQueryResultVoiceImpl(): InlineQueryResultVoiceImpl = this as InlineQueryResultVoiceImpl inline fun InlineQueryResult.asDescribedInlineQueryResult(): DescribedInlineQueryResult? = this as? DescribedInlineQueryResult inline fun InlineQueryResult.requireDescribedInlineQueryResult(): DescribedInlineQueryResult = this as DescribedInlineQueryResult inline fun InlineQueryResult.asFileInlineQueryResult(): FileInlineQueryResult? = this as? FileInlineQueryResult @@ -307,8 +253,6 @@ inline fun InlineQueryResult.asInlineQueryResultVoiceCached(): InlineQueryResult inline fun InlineQueryResult.requireInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached = this as InlineQueryResultVoiceCached inline fun InlineQueryResult.asInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon? = this as? InlineQueryResultVoiceCommon inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon = this as InlineQueryResultVoiceCommon -inline fun ChatMember.asAdministratorChatMemberImpl(): AdministratorChatMemberImpl? = this as? AdministratorChatMemberImpl -inline fun ChatMember.requireAdministratorChatMemberImpl(): AdministratorChatMemberImpl = this as AdministratorChatMemberImpl inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember inline fun ChatMember.asKickedChatMember(): KickedChatMember? = this as? KickedChatMember From 2006e45b57589b78ebce7b6c42b38630e45d2010 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 23:02:00 +0600 Subject: [PATCH 09/10] last update of classcasts --- .../tgbotapi/extensions/utils/ClassCasts.kt | 360 +++++++++++++++++- 1 file changed, 357 insertions(+), 3 deletions(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index d743948ac7..8d93c335d6 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -1,7 +1,6 @@ @file:Suppress("NOTHING_TO_INLINE", "unused") package dev.inmo.tgbotapi.extensions.utils - import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.CallbackQuery.* import dev.inmo.tgbotapi.types.ChatMember.* @@ -24,10 +23,8 @@ import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.actions.* import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* -import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.abstracts.* import dev.inmo.tgbotapi.types.chat.abstracts.extended.* -import dev.inmo.tgbotapi.types.chat.extended.* import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.abstracts.* import dev.inmo.tgbotapi.types.message.* @@ -42,360 +39,717 @@ import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* import dev.inmo.tgbotapi.types.update.abstracts.* +import dev.inmo.tgbotapi.utils.PreviewFeature +@PreviewFeature inline fun Chat.asBot(): Bot? = this as? Bot +@PreviewFeature inline fun Chat.requireBot(): Bot = this as Bot +@PreviewFeature inline fun Chat.asCommonBot(): CommonBot? = this as? CommonBot +@PreviewFeature inline fun Chat.requireCommonBot(): CommonBot = this as CommonBot +@PreviewFeature inline fun Chat.asCommonUser(): CommonUser? = this as? CommonUser +@PreviewFeature inline fun Chat.requireCommonUser(): CommonUser = this as CommonUser +@PreviewFeature inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot +@PreviewFeature inline fun Chat.requireExtendedBot(): ExtendedBot = this as ExtendedBot +@PreviewFeature inline fun Chat.asUser(): User? = this as? User +@PreviewFeature inline fun Chat.requireUser(): User = this as User +@PreviewFeature inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat +@PreviewFeature inline fun Chat.requireChannelChat(): ChannelChat = this as ChannelChat +@PreviewFeature inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat +@PreviewFeature inline fun Chat.requireGroupChat(): GroupChat = this as GroupChat +@PreviewFeature inline fun Chat.asPrivateChat(): PrivateChat? = this as? PrivateChat +@PreviewFeature inline fun Chat.requirePrivateChat(): PrivateChat = this as PrivateChat +@PreviewFeature inline fun Chat.asPublicChat(): PublicChat? = this as? PublicChat +@PreviewFeature inline fun Chat.requirePublicChat(): PublicChat = this as PublicChat +@PreviewFeature inline fun Chat.asSuperPublicChat(): SuperPublicChat? = this as? SuperPublicChat +@PreviewFeature inline fun Chat.requireSuperPublicChat(): SuperPublicChat = this as SuperPublicChat +@PreviewFeature inline fun Chat.asSupergroupChat(): SupergroupChat? = this as? SupergroupChat +@PreviewFeature inline fun Chat.requireSupergroupChat(): SupergroupChat = this as SupergroupChat +@PreviewFeature inline fun Chat.asUnknownChatType(): UnknownChatType? = this as? UnknownChatType +@PreviewFeature inline fun Chat.requireUnknownChatType(): UnknownChatType = this as UnknownChatType +@PreviewFeature inline fun Chat.asUsernameChat(): UsernameChat? = this as? UsernameChat +@PreviewFeature inline fun Chat.requireUsernameChat(): UsernameChat = this as UsernameChat +@PreviewFeature inline fun Chat.asExtendedChannelChat(): ExtendedChannelChat? = this as? ExtendedChannelChat +@PreviewFeature inline fun Chat.requireExtendedChannelChat(): ExtendedChannelChat = this as ExtendedChannelChat +@PreviewFeature inline fun Chat.asExtendedChat(): ExtendedChat? = this as? ExtendedChat +@PreviewFeature inline fun Chat.requireExtendedChat(): ExtendedChat = this as ExtendedChat +@PreviewFeature inline fun Chat.asExtendedGroupChat(): ExtendedGroupChat? = this as? ExtendedGroupChat +@PreviewFeature inline fun Chat.requireExtendedGroupChat(): ExtendedGroupChat = this as ExtendedGroupChat +@PreviewFeature inline fun Chat.asExtendedPrivateChat(): ExtendedPrivateChat? = this as? ExtendedPrivateChat +@PreviewFeature inline fun Chat.requireExtendedPrivateChat(): ExtendedPrivateChat = this as ExtendedPrivateChat +@PreviewFeature inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedPublicChat +@PreviewFeature inline fun Chat.requireExtendedPublicChat(): ExtendedPublicChat = this as ExtendedPublicChat +@PreviewFeature inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? ExtendedSupergroupChat +@PreviewFeature inline fun Chat.requireExtendedSupergroupChat(): ExtendedSupergroupChat = this as ExtendedSupergroupChat +@PreviewFeature inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? DataCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireDataCallbackQuery(): DataCallbackQuery = this as DataCallbackQuery +@PreviewFeature inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? = this as? GameShortNameCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireGameShortNameCallbackQuery(): GameShortNameCallbackQuery = this as GameShortNameCallbackQuery +@PreviewFeature inline fun CallbackQuery.asInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery? = this as? InlineMessageIdCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery = this as InlineMessageIdCallbackQuery +@PreviewFeature inline fun CallbackQuery.asInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery? = this as? InlineMessageIdDataCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery = this as InlineMessageIdDataCallbackQuery +@PreviewFeature inline fun CallbackQuery.asInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery? = this as? InlineMessageIdGameShortNameCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery = this as InlineMessageIdGameShortNameCallbackQuery +@PreviewFeature inline fun CallbackQuery.asMessageCallbackQuery(): MessageCallbackQuery? = this as? MessageCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireMessageCallbackQuery(): MessageCallbackQuery = this as MessageCallbackQuery +@PreviewFeature inline fun CallbackQuery.asMessageDataCallbackQuery(): MessageDataCallbackQuery? = this as? MessageDataCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireMessageDataCallbackQuery(): MessageDataCallbackQuery = this as MessageDataCallbackQuery +@PreviewFeature inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery? = this as? MessageGameShortNameCallbackQuery +@PreviewFeature inline fun CallbackQuery.requireMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery = this as MessageGameShortNameCallbackQuery +@PreviewFeature inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType? = this as? UnknownCallbackQueryType +@PreviewFeature inline fun CallbackQuery.requireUnknownCallbackQueryType(): UnknownCallbackQueryType = this as UnknownCallbackQueryType +@PreviewFeature inline fun Message.asChannelEventMessage(): ChannelEventMessage? = this as? ChannelEventMessage +@PreviewFeature inline fun Message.requireChannelEventMessage(): ChannelEventMessage = this as ChannelEventMessage +@PreviewFeature inline fun Message.asChannelMediaGroupMessage(): ChannelMediaGroupMessage? = this as? ChannelMediaGroupMessage +@PreviewFeature inline fun Message.requireChannelMediaGroupMessage(): ChannelMediaGroupMessage = this as ChannelMediaGroupMessage +@PreviewFeature inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? = this as? CommonGroupEventMessage +@PreviewFeature inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage = this as CommonGroupEventMessage +@PreviewFeature inline fun Message.asCommonMediaGroupMessage(): CommonMediaGroupMessage? = this as? CommonMediaGroupMessage +@PreviewFeature inline fun Message.requireCommonMediaGroupMessage(): CommonMediaGroupMessage = this as CommonMediaGroupMessage +@PreviewFeature inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? = this as? CommonSupergroupEventMessage +@PreviewFeature inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage = this as CommonSupergroupEventMessage +@PreviewFeature inline fun Message.asAnonymousGroupMessage(): AnonymousGroupMessage? = this as? AnonymousGroupMessage +@PreviewFeature inline fun Message.requireAnonymousGroupMessage(): AnonymousGroupMessage = this as AnonymousGroupMessage +@PreviewFeature inline fun Message.asChannelMessage(): ChannelMessage? = this as? ChannelMessage +@PreviewFeature inline fun Message.requireChannelMessage(): ChannelMessage = this as ChannelMessage +@PreviewFeature inline fun Message.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage +@PreviewFeature inline fun Message.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage +@PreviewFeature inline fun Message.asCommonGroupMessage(): CommonGroupMessage? = this as? CommonGroupMessage +@PreviewFeature inline fun Message.requireCommonGroupMessage(): CommonGroupMessage = this as CommonGroupMessage +@PreviewFeature inline fun Message.asCommonMessage(): CommonMessage? = this as? CommonMessage +@PreviewFeature inline fun Message.requireCommonMessage(): CommonMessage = this as CommonMessage +@PreviewFeature inline fun Message.asContentMessage(): ContentMessage? = this as? ContentMessage +@PreviewFeature inline fun Message.requireContentMessage(): ContentMessage = this as ContentMessage +@PreviewFeature inline fun Message.asFromChannelGroupMessage(): FromChannelGroupMessage? = this as? FromChannelGroupMessage +@PreviewFeature inline fun Message.requireFromChannelGroupMessage(): FromChannelGroupMessage = this as FromChannelGroupMessage +@PreviewFeature inline fun Message.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage +@PreviewFeature inline fun Message.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage +@PreviewFeature inline fun Message.asGroupMessage(): GroupMessage? = this as? GroupMessage +@PreviewFeature inline fun Message.requireGroupMessage(): GroupMessage = this as GroupMessage +@PreviewFeature inline fun Message.asMediaGroupMessage(): MediaGroupMessage? = this as? MediaGroupMessage +@PreviewFeature inline fun Message.requireMediaGroupMessage(): MediaGroupMessage = this as MediaGroupMessage +@PreviewFeature inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage +@PreviewFeature inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage +@PreviewFeature inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage +@PreviewFeature inline fun Message.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage +@PreviewFeature inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage +@PreviewFeature inline fun Message.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage +@PreviewFeature inline fun Message.asPrivateMessage(): PrivateMessage? = this as? PrivateMessage +@PreviewFeature inline fun Message.requirePrivateMessage(): PrivateMessage = this as PrivateMessage +@PreviewFeature inline fun Message.asPublicMessage(): PublicMessage? = this as? PublicMessage +@PreviewFeature inline fun Message.requirePublicMessage(): PublicMessage = this as PublicMessage +@PreviewFeature inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage +@PreviewFeature inline fun Message.requireSignedMessage(): SignedMessage = this as SignedMessage +@PreviewFeature inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? = this as? SupergroupEventMessage +@PreviewFeature inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage = this as SupergroupEventMessage +@PreviewFeature inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType +@PreviewFeature inline fun Message.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType +@PreviewFeature inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? = this as? PossiblySentViaBotCommonMessage +@PreviewFeature inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage = this as PossiblySentViaBotCommonMessage +@PreviewFeature inline fun BotAction.asFindLocationAction(): FindLocationAction? = this as? FindLocationAction +@PreviewFeature inline fun BotAction.requireFindLocationAction(): FindLocationAction = this as FindLocationAction +@PreviewFeature inline fun BotAction.asRecordAudioAction(): RecordAudioAction? = this as? RecordAudioAction +@PreviewFeature inline fun BotAction.requireRecordAudioAction(): RecordAudioAction = this as RecordAudioAction +@PreviewFeature inline fun BotAction.asRecordVideoAction(): RecordVideoAction? = this as? RecordVideoAction +@PreviewFeature inline fun BotAction.requireRecordVideoAction(): RecordVideoAction = this as RecordVideoAction +@PreviewFeature inline fun BotAction.asRecordVideoNoteAction(): RecordVideoNoteAction? = this as? RecordVideoNoteAction +@PreviewFeature inline fun BotAction.requireRecordVideoNoteAction(): RecordVideoNoteAction = this as RecordVideoNoteAction +@PreviewFeature inline fun BotAction.asTypingAction(): TypingAction? = this as? TypingAction +@PreviewFeature inline fun BotAction.requireTypingAction(): TypingAction = this as TypingAction +@PreviewFeature inline fun BotAction.asUploadAudioAction(): UploadAudioAction? = this as? UploadAudioAction +@PreviewFeature inline fun BotAction.requireUploadAudioAction(): UploadAudioAction = this as UploadAudioAction +@PreviewFeature inline fun BotAction.asUploadDocumentAction(): UploadDocumentAction? = this as? UploadDocumentAction +@PreviewFeature inline fun BotAction.requireUploadDocumentAction(): UploadDocumentAction = this as UploadDocumentAction +@PreviewFeature inline fun BotAction.asUploadPhotoAction(): UploadPhotoAction? = this as? UploadPhotoAction +@PreviewFeature inline fun BotAction.requireUploadPhotoAction(): UploadPhotoAction = this as UploadPhotoAction +@PreviewFeature inline fun BotAction.asUploadVideoAction(): UploadVideoAction? = this as? UploadVideoAction +@PreviewFeature inline fun BotAction.requireUploadVideoAction(): UploadVideoAction = this as UploadVideoAction +@PreviewFeature inline fun BotAction.asUploadVideoNoteAction(): UploadVideoNoteAction? = this as? UploadVideoNoteAction +@PreviewFeature inline fun BotAction.requireUploadVideoNoteAction(): UploadVideoNoteAction = this as UploadVideoNoteAction +@PreviewFeature inline fun InlineQuery.asBaseInlineQuery(): BaseInlineQuery? = this as? BaseInlineQuery +@PreviewFeature inline fun InlineQuery.requireBaseInlineQuery(): BaseInlineQuery = this as BaseInlineQuery +@PreviewFeature inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? = this as? LocationInlineQuery +@PreviewFeature inline fun InlineQuery.requireLocationInlineQuery(): LocationInlineQuery = this as LocationInlineQuery +@PreviewFeature inline fun InputMessageContent.asInputContactMessageContent(): InputContactMessageContent? = this as? InputContactMessageContent +@PreviewFeature inline fun InputMessageContent.requireInputContactMessageContent(): InputContactMessageContent = this as InputContactMessageContent +@PreviewFeature inline fun InputMessageContent.asInputLocationMessageContent(): InputLocationMessageContent? = this as? InputLocationMessageContent +@PreviewFeature inline fun InputMessageContent.requireInputLocationMessageContent(): InputLocationMessageContent = this as InputLocationMessageContent +@PreviewFeature inline fun InputMessageContent.asInputTextMessageContent(): InputTextMessageContent? = this as? InputTextMessageContent +@PreviewFeature inline fun InputMessageContent.requireInputTextMessageContent(): InputTextMessageContent = this as InputTextMessageContent +@PreviewFeature inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageContent? = this as? InputVenueMessageContent +@PreviewFeature inline fun InputMessageContent.requireInputVenueMessageContent(): InputVenueMessageContent = this as InputVenueMessageContent +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultArticle(): InlineQueryResultArticle? = this as? InlineQueryResultArticle +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultArticle(): InlineQueryResultArticle = this as InlineQueryResultArticle +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultContact(): InlineQueryResultContact? = this as? InlineQueryResultContact +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultContact(): InlineQueryResultContact = this as InlineQueryResultContact +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultGame(): InlineQueryResultGame? = this as? InlineQueryResultGame +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultGame(): InlineQueryResultGame = this as InlineQueryResultGame +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultLocation(): InlineQueryResultLocation? = this as? InlineQueryResultLocation +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultLocation(): InlineQueryResultLocation = this as InlineQueryResultLocation +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultStickerCached(): InlineQueryResultStickerCached? = this as? InlineQueryResultStickerCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultStickerCached(): InlineQueryResultStickerCached = this as InlineQueryResultStickerCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVenue(): InlineQueryResultVenue? = this as? InlineQueryResultVenue +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVenue(): InlineQueryResultVenue = this as InlineQueryResultVenue +@PreviewFeature inline fun InlineQueryResult.asDescribedInlineQueryResult(): DescribedInlineQueryResult? = this as? DescribedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireDescribedInlineQueryResult(): DescribedInlineQueryResult = this as DescribedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asFileInlineQueryResult(): FileInlineQueryResult? = this as? FileInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireFileInlineQueryResult(): FileInlineQueryResult = this as FileInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult? = this as? OptionallyTitledInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireOptionallyTitledInlineQueryResult(): OptionallyTitledInlineQueryResult = this as OptionallyTitledInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asSizedInlineQueryResult(): SizedInlineQueryResult? = this as? SizedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireSizedInlineQueryResult(): SizedInlineQueryResult = this as SizedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult? = this as? ThumbSizedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireThumbSizedInlineQueryResult(): ThumbSizedInlineQueryResult = this as ThumbSizedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asThumbedInlineQueryResult(): ThumbedInlineQueryResult? = this as? ThumbedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireThumbedInlineQueryResult(): ThumbedInlineQueryResult = this as ThumbedInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult? = this as? ThumbedWithMimeTypeInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireThumbedWithMimeTypeInlineQueryResult(): ThumbedWithMimeTypeInlineQueryResult = this as ThumbedWithMimeTypeInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asTitledInlineQueryResult(): TitledInlineQueryResult? = this as? TitledInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireTitledInlineQueryResult(): TitledInlineQueryResult = this as TitledInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asUrlInlineQueryResult(): UrlInlineQueryResult? = this as? UrlInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireUrlInlineQueryResult(): UrlInlineQueryResult = this as UrlInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult? = this as? WithInputMessageContentInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.requireWithInputMessageContentInlineQueryResult(): WithInputMessageContentInlineQueryResult = this as WithInputMessageContentInlineQueryResult +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultAudio(): InlineQueryResultAudio? = this as? InlineQueryResultAudio +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultAudio(): InlineQueryResultAudio = this as InlineQueryResultAudio +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultAudioCached(): InlineQueryResultAudioCached? = this as? InlineQueryResultAudioCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultAudioCached(): InlineQueryResultAudioCached = this as InlineQueryResultAudioCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon? = this as? InlineQueryResultAudioCommon +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultAudioCommon(): InlineQueryResultAudioCommon = this as InlineQueryResultAudioCommon +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultDocument(): InlineQueryResultDocument? = this as? InlineQueryResultDocument +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultDocument(): InlineQueryResultDocument = this as InlineQueryResultDocument +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached? = this as? InlineQueryResultDocumentCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultDocumentCached(): InlineQueryResultDocumentCached = this as InlineQueryResultDocumentCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon? = this as? InlineQueryResultDocumentCommon +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultDocumentCommon(): InlineQueryResultDocumentCommon = this as InlineQueryResultDocumentCommon +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultGif(): InlineQueryResultGif? = this as? InlineQueryResultGif +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultGif(): InlineQueryResultGif = this as InlineQueryResultGif +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultGifCached(): InlineQueryResultGifCached? = this as? InlineQueryResultGifCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultGifCached(): InlineQueryResultGifCached = this as InlineQueryResultGifCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultGifCommon(): InlineQueryResultGifCommon? = this as? InlineQueryResultGifCommon +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultGifCommon(): InlineQueryResultGifCommon = this as InlineQueryResultGifCommon +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif? = this as? InlineQueryResultMpeg4Gif +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultMpeg4Gif(): InlineQueryResultMpeg4Gif = this as InlineQueryResultMpeg4Gif +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached? = this as? InlineQueryResultMpeg4GifCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCached(): InlineQueryResultMpeg4GifCached = this as InlineQueryResultMpeg4GifCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon? = this as? InlineQueryResultMpeg4GifCommon +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultMpeg4GifCommon(): InlineQueryResultMpeg4GifCommon = this as InlineQueryResultMpeg4GifCommon +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultPhoto(): InlineQueryResultPhoto? = this as? InlineQueryResultPhoto +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultPhoto(): InlineQueryResultPhoto = this as InlineQueryResultPhoto +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached? = this as? InlineQueryResultPhotoCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultPhotoCached(): InlineQueryResultPhotoCached = this as InlineQueryResultPhotoCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon? = this as? InlineQueryResultPhotoCommon +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultPhotoCommon(): InlineQueryResultPhotoCommon = this as InlineQueryResultPhotoCommon +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVideo(): InlineQueryResultVideo? = this as? InlineQueryResultVideo +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVideo(): InlineQueryResultVideo = this as InlineQueryResultVideo +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVideoCached(): InlineQueryResultVideoCached? = this as? InlineQueryResultVideoCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVideoCached(): InlineQueryResultVideoCached = this as InlineQueryResultVideoCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon? = this as? InlineQueryResultVideoCommon +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVideoCommon(): InlineQueryResultVideoCommon = this as InlineQueryResultVideoCommon +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVoice(): InlineQueryResultVoice? = this as? InlineQueryResultVoice +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVoice(): InlineQueryResultVoice = this as InlineQueryResultVoice +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached? = this as? InlineQueryResultVoiceCached +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVoiceCached(): InlineQueryResultVoiceCached = this as InlineQueryResultVoiceCached +@PreviewFeature inline fun InlineQueryResult.asInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon? = this as? InlineQueryResultVoiceCommon +@PreviewFeature inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryResultVoiceCommon = this as InlineQueryResultVoiceCommon +@PreviewFeature inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember +@PreviewFeature inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember +@PreviewFeature inline fun ChatMember.asKickedChatMember(): KickedChatMember? = this as? KickedChatMember +@PreviewFeature inline fun ChatMember.requireKickedChatMember(): KickedChatMember = this as KickedChatMember +@PreviewFeature inline fun ChatMember.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember +@PreviewFeature inline fun ChatMember.requireLeftChatMember(): LeftChatMember = this as LeftChatMember +@PreviewFeature inline fun ChatMember.asMemberChatMember(): MemberChatMember? = this as? MemberChatMember +@PreviewFeature inline fun ChatMember.requireMemberChatMember(): MemberChatMember = this as MemberChatMember +@PreviewFeature inline fun ChatMember.asRestrictedChatMember(): RestrictedChatMember? = this as? RestrictedChatMember +@PreviewFeature inline fun ChatMember.requireRestrictedChatMember(): RestrictedChatMember = this as RestrictedChatMember +@PreviewFeature inline fun ChatMember.asAdministratorChatMember(): AdministratorChatMember? = this as? AdministratorChatMember +@PreviewFeature inline fun ChatMember.requireAdministratorChatMember(): AdministratorChatMember = this as AdministratorChatMember +@PreviewFeature inline fun ChatMember.asBannedChatMember(): BannedChatMember? = this as? BannedChatMember +@PreviewFeature inline fun ChatMember.requireBannedChatMember(): BannedChatMember = this as BannedChatMember +@PreviewFeature inline fun ChatMember.asSpecialRightsChatMember(): SpecialRightsChatMember? = this as? SpecialRightsChatMember +@PreviewFeature inline fun ChatMember.requireSpecialRightsChatMember(): SpecialRightsChatMember = this as SpecialRightsChatMember +@PreviewFeature inline fun InputMedia.asAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia? = this as? AudioMediaGroupMemberInputMedia +@PreviewFeature inline fun InputMedia.requireAudioMediaGroupMemberInputMedia(): AudioMediaGroupMemberInputMedia = this as AudioMediaGroupMemberInputMedia +@PreviewFeature inline fun InputMedia.asDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia? = this as? DocumentMediaGroupMemberInputMedia +@PreviewFeature inline fun InputMedia.requireDocumentMediaGroupMemberInputMedia(): DocumentMediaGroupMemberInputMedia = this as DocumentMediaGroupMemberInputMedia +@PreviewFeature inline fun InputMedia.asDuratedInputMedia(): DuratedInputMedia? = this as? DuratedInputMedia +@PreviewFeature inline fun InputMedia.requireDuratedInputMedia(): DuratedInputMedia = this as DuratedInputMedia +@PreviewFeature inline fun InputMedia.asInputMediaAnimation(): InputMediaAnimation? = this as? InputMediaAnimation +@PreviewFeature inline fun InputMedia.requireInputMediaAnimation(): InputMediaAnimation = this as InputMediaAnimation +@PreviewFeature inline fun InputMedia.asInputMediaAudio(): InputMediaAudio? = this as? InputMediaAudio +@PreviewFeature inline fun InputMedia.requireInputMediaAudio(): InputMediaAudio = this as InputMediaAudio +@PreviewFeature inline fun InputMedia.asInputMediaDocument(): InputMediaDocument? = this as? InputMediaDocument +@PreviewFeature inline fun InputMedia.requireInputMediaDocument(): InputMediaDocument = this as InputMediaDocument +@PreviewFeature inline fun InputMedia.asInputMediaPhoto(): InputMediaPhoto? = this as? InputMediaPhoto +@PreviewFeature inline fun InputMedia.requireInputMediaPhoto(): InputMediaPhoto = this as InputMediaPhoto +@PreviewFeature inline fun InputMedia.asInputMediaVideo(): InputMediaVideo? = this as? InputMediaVideo +@PreviewFeature inline fun InputMedia.requireInputMediaVideo(): InputMediaVideo = this as InputMediaVideo +@PreviewFeature inline fun InputMedia.asMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia? = this as? MediaGroupMemberInputMedia +@PreviewFeature inline fun InputMedia.requireMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = this as MediaGroupMemberInputMedia +@PreviewFeature inline fun InputMedia.asSizedInputMedia(): SizedInputMedia? = this as? SizedInputMedia +@PreviewFeature inline fun InputMedia.requireSizedInputMedia(): SizedInputMedia = this as SizedInputMedia +@PreviewFeature inline fun InputMedia.asThumbedInputMedia(): ThumbedInputMedia? = this as? ThumbedInputMedia +@PreviewFeature inline fun InputMedia.requireThumbedInputMedia(): ThumbedInputMedia = this as ThumbedInputMedia +@PreviewFeature inline fun InputMedia.asTitledInputMedia(): TitledInputMedia? = this as? TitledInputMedia +@PreviewFeature inline fun InputMedia.requireTitledInputMedia(): TitledInputMedia = this as TitledInputMedia +@PreviewFeature inline fun InputMedia.asVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia? = this as? VisualMediaGroupMemberInputMedia +@PreviewFeature inline fun InputMedia.requireVisualMediaGroupMemberInputMedia(): VisualMediaGroupMemberInputMedia = this as VisualMediaGroupMemberInputMedia +@PreviewFeature inline fun Update.asCallbackQueryUpdate(): CallbackQueryUpdate? = this as? CallbackQueryUpdate +@PreviewFeature inline fun Update.requireCallbackQueryUpdate(): CallbackQueryUpdate = this as CallbackQueryUpdate +@PreviewFeature inline fun Update.asChannelPostUpdate(): ChannelPostUpdate? = this as? ChannelPostUpdate +@PreviewFeature inline fun Update.requireChannelPostUpdate(): ChannelPostUpdate = this as ChannelPostUpdate +@PreviewFeature inline fun Update.asChosenInlineResultUpdate(): ChosenInlineResultUpdate? = this as? ChosenInlineResultUpdate +@PreviewFeature inline fun Update.requireChosenInlineResultUpdate(): ChosenInlineResultUpdate = this as ChosenInlineResultUpdate +@PreviewFeature inline fun Update.asEditChannelPostUpdate(): EditChannelPostUpdate? = this as? EditChannelPostUpdate +@PreviewFeature inline fun Update.requireEditChannelPostUpdate(): EditChannelPostUpdate = this as EditChannelPostUpdate +@PreviewFeature inline fun Update.asEditMessageUpdate(): EditMessageUpdate? = this as? EditMessageUpdate +@PreviewFeature inline fun Update.requireEditMessageUpdate(): EditMessageUpdate = this as EditMessageUpdate +@PreviewFeature inline fun Update.asInlineQueryUpdate(): InlineQueryUpdate? = this as? InlineQueryUpdate +@PreviewFeature inline fun Update.requireInlineQueryUpdate(): InlineQueryUpdate = this as InlineQueryUpdate +@PreviewFeature inline fun Update.asChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate? = this as? ChannelPostMediaGroupUpdate +@PreviewFeature inline fun Update.requireChannelPostMediaGroupUpdate(): ChannelPostMediaGroupUpdate = this as ChannelPostMediaGroupUpdate +@PreviewFeature inline fun Update.asEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate? = this as? EditChannelPostMediaGroupUpdate +@PreviewFeature inline fun Update.requireEditChannelPostMediaGroupUpdate(): EditChannelPostMediaGroupUpdate = this as EditChannelPostMediaGroupUpdate +@PreviewFeature inline fun Update.asEditMediaGroupUpdate(): EditMediaGroupUpdate? = this as? EditMediaGroupUpdate +@PreviewFeature inline fun Update.requireEditMediaGroupUpdate(): EditMediaGroupUpdate = this as EditMediaGroupUpdate +@PreviewFeature inline fun Update.asEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate? = this as? EditMessageMediaGroupUpdate +@PreviewFeature inline fun Update.requireEditMessageMediaGroupUpdate(): EditMessageMediaGroupUpdate = this as EditMessageMediaGroupUpdate +@PreviewFeature inline fun Update.asMediaGroupUpdate(): MediaGroupUpdate? = this as? MediaGroupUpdate +@PreviewFeature inline fun Update.requireMediaGroupUpdate(): MediaGroupUpdate = this as MediaGroupUpdate +@PreviewFeature inline fun Update.asMessageMediaGroupUpdate(): MessageMediaGroupUpdate? = this as? MessageMediaGroupUpdate +@PreviewFeature inline fun Update.requireMessageMediaGroupUpdate(): MessageMediaGroupUpdate = this as MessageMediaGroupUpdate +@PreviewFeature inline fun Update.asSentMediaGroupUpdate(): SentMediaGroupUpdate? = this as? SentMediaGroupUpdate +@PreviewFeature inline fun Update.requireSentMediaGroupUpdate(): SentMediaGroupUpdate = this as SentMediaGroupUpdate +@PreviewFeature inline fun Update.asMessageUpdate(): MessageUpdate? = this as? MessageUpdate +@PreviewFeature inline fun Update.requireMessageUpdate(): MessageUpdate = this as MessageUpdate +@PreviewFeature inline fun Update.asPollAnswerUpdate(): PollAnswerUpdate? = this as? PollAnswerUpdate +@PreviewFeature inline fun Update.requirePollAnswerUpdate(): PollAnswerUpdate = this as PollAnswerUpdate +@PreviewFeature inline fun Update.asPollUpdate(): PollUpdate? = this as? PollUpdate +@PreviewFeature inline fun Update.requirePollUpdate(): PollUpdate = this as PollUpdate +@PreviewFeature inline fun Update.asPreCheckoutQueryUpdate(): PreCheckoutQueryUpdate? = this as? PreCheckoutQueryUpdate +@PreviewFeature inline fun Update.requirePreCheckoutQueryUpdate(): PreCheckoutQueryUpdate = this as PreCheckoutQueryUpdate +@PreviewFeature inline fun Update.asShippingQueryUpdate(): ShippingQueryUpdate? = this as? ShippingQueryUpdate +@PreviewFeature inline fun Update.requireShippingQueryUpdate(): ShippingQueryUpdate = this as ShippingQueryUpdate +@PreviewFeature inline fun Update.asBaseEditMessageUpdate(): BaseEditMessageUpdate? = this as? BaseEditMessageUpdate +@PreviewFeature inline fun Update.requireBaseEditMessageUpdate(): BaseEditMessageUpdate = this as BaseEditMessageUpdate +@PreviewFeature inline fun Update.asBaseMessageUpdate(): BaseMessageUpdate? = this as? BaseMessageUpdate +@PreviewFeature inline fun Update.requireBaseMessageUpdate(): BaseMessageUpdate = this as BaseMessageUpdate +@PreviewFeature inline fun Update.asBaseSentMessageUpdate(): BaseSentMessageUpdate? = this as? BaseSentMessageUpdate +@PreviewFeature inline fun Update.requireBaseSentMessageUpdate(): BaseSentMessageUpdate = this as BaseSentMessageUpdate +@PreviewFeature inline fun Update.asUnknownUpdate(): UnknownUpdate? = this as? UnknownUpdate +@PreviewFeature inline fun Update.requireUnknownUpdate(): UnknownUpdate = this as UnknownUpdate +@PreviewFeature inline fun TelegramMediaFile.asAnimationFile(): AnimationFile? = this as? AnimationFile +@PreviewFeature inline fun TelegramMediaFile.requireAnimationFile(): AnimationFile = this as AnimationFile +@PreviewFeature inline fun TelegramMediaFile.asAudioFile(): AudioFile? = this as? AudioFile +@PreviewFeature inline fun TelegramMediaFile.requireAudioFile(): AudioFile = this as AudioFile +@PreviewFeature inline fun TelegramMediaFile.asDocumentFile(): DocumentFile? = this as? DocumentFile +@PreviewFeature inline fun TelegramMediaFile.requireDocumentFile(): DocumentFile = this as DocumentFile +@PreviewFeature inline fun TelegramMediaFile.asFile(): File? = this as? File +@PreviewFeature inline fun TelegramMediaFile.requireFile(): File = this as File +@PreviewFeature inline fun TelegramMediaFile.asPathedFile(): PathedFile? = this as? PathedFile +@PreviewFeature inline fun TelegramMediaFile.requirePathedFile(): PathedFile = this as PathedFile +@PreviewFeature inline fun TelegramMediaFile.asPhotoSize(): PhotoSize? = this as? PhotoSize +@PreviewFeature inline fun TelegramMediaFile.requirePhotoSize(): PhotoSize = this as PhotoSize +@PreviewFeature inline fun TelegramMediaFile.asSticker(): Sticker? = this as? Sticker +@PreviewFeature inline fun TelegramMediaFile.requireSticker(): Sticker = this as Sticker +@PreviewFeature inline fun TelegramMediaFile.asVideoFile(): VideoFile? = this as? VideoFile +@PreviewFeature inline fun TelegramMediaFile.requireVideoFile(): VideoFile = this as VideoFile +@PreviewFeature inline fun TelegramMediaFile.asVideoNoteFile(): VideoNoteFile? = this as? VideoNoteFile +@PreviewFeature inline fun TelegramMediaFile.requireVideoNoteFile(): VideoNoteFile = this as VideoNoteFile +@PreviewFeature inline fun TelegramMediaFile.asVoiceFile(): VoiceFile? = this as? VoiceFile +@PreviewFeature inline fun TelegramMediaFile.requireVoiceFile(): VoiceFile = this as VoiceFile +@PreviewFeature inline fun TelegramMediaFile.asMimedMediaFile(): MimedMediaFile? = this as? MimedMediaFile +@PreviewFeature inline fun TelegramMediaFile.requireMimedMediaFile(): MimedMediaFile = this as MimedMediaFile +@PreviewFeature inline fun TelegramMediaFile.asPlayableMediaFile(): PlayableMediaFile? = this as? PlayableMediaFile +@PreviewFeature inline fun TelegramMediaFile.requirePlayableMediaFile(): PlayableMediaFile = this as PlayableMediaFile +@PreviewFeature inline fun TelegramMediaFile.asSizedMediaFile(): SizedMediaFile? = this as? SizedMediaFile +@PreviewFeature inline fun TelegramMediaFile.requireSizedMediaFile(): SizedMediaFile = this as SizedMediaFile +@PreviewFeature inline fun TelegramMediaFile.asThumbedMediaFile(): ThumbedMediaFile? = this as? ThumbedMediaFile +@PreviewFeature inline fun TelegramMediaFile.requireThumbedMediaFile(): ThumbedMediaFile = this as ThumbedMediaFile +@PreviewFeature inline fun KeyboardMarkup.asForceReply(): ForceReply? = this as? ForceReply +@PreviewFeature inline fun KeyboardMarkup.requireForceReply(): ForceReply = this as ForceReply +@PreviewFeature inline fun KeyboardMarkup.asInlineKeyboardMarkup(): InlineKeyboardMarkup? = this as? InlineKeyboardMarkup +@PreviewFeature inline fun KeyboardMarkup.requireInlineKeyboardMarkup(): InlineKeyboardMarkup = this as InlineKeyboardMarkup +@PreviewFeature inline fun KeyboardMarkup.asReplyKeyboardMarkup(): ReplyKeyboardMarkup? = this as? ReplyKeyboardMarkup +@PreviewFeature inline fun KeyboardMarkup.requireReplyKeyboardMarkup(): ReplyKeyboardMarkup = this as ReplyKeyboardMarkup +@PreviewFeature inline fun KeyboardMarkup.asReplyKeyboardRemove(): ReplyKeyboardRemove? = this as? ReplyKeyboardRemove +@PreviewFeature inline fun KeyboardMarkup.requireReplyKeyboardRemove(): ReplyKeyboardRemove = this as ReplyKeyboardRemove +@PreviewFeature inline fun InlineKeyboardButton.asCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton? = this as? CallbackDataInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requireCallbackDataInlineKeyboardButton(): CallbackDataInlineKeyboardButton = this as CallbackDataInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.asCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton? = this as? CallbackGameInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requireCallbackGameInlineKeyboardButton(): CallbackGameInlineKeyboardButton = this as CallbackGameInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.asLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton? = this as? LoginURLInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requireLoginURLInlineKeyboardButton(): LoginURLInlineKeyboardButton = this as LoginURLInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.asPayInlineKeyboardButton(): PayInlineKeyboardButton? = this as? PayInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requirePayInlineKeyboardButton(): PayInlineKeyboardButton = this as PayInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.asSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton? = this as? SwitchInlineQueryCurrentChatInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requireSwitchInlineQueryCurrentChatInlineKeyboardButton(): SwitchInlineQueryCurrentChatInlineKeyboardButton = this as SwitchInlineQueryCurrentChatInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.asSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton? = this as? SwitchInlineQueryInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requireSwitchInlineQueryInlineKeyboardButton(): SwitchInlineQueryInlineKeyboardButton = this as SwitchInlineQueryInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.asURLInlineKeyboardButton(): URLInlineKeyboardButton? = this as? URLInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requireURLInlineKeyboardButton(): URLInlineKeyboardButton = this as URLInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.asUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton? = this as? UnknownInlineKeyboardButton +@PreviewFeature inline fun InlineKeyboardButton.requireUnknownInlineKeyboardButton(): UnknownInlineKeyboardButton = this as UnknownInlineKeyboardButton +@PreviewFeature inline fun Poll.asMultipleAnswersPoll(): MultipleAnswersPoll? = this as? MultipleAnswersPoll +@PreviewFeature inline fun Poll.requireMultipleAnswersPoll(): MultipleAnswersPoll = this as MultipleAnswersPoll +@PreviewFeature inline fun Poll.asQuizPoll(): QuizPoll? = this as? QuizPoll +@PreviewFeature inline fun Poll.requireQuizPoll(): QuizPoll = this as QuizPoll +@PreviewFeature inline fun Poll.asRegularPoll(): RegularPoll? = this as? RegularPoll +@PreviewFeature inline fun Poll.requireRegularPoll(): RegularPoll = this as RegularPoll +@PreviewFeature inline fun Poll.asUnknownPollType(): UnknownPollType? = this as? UnknownPollType +@PreviewFeature inline fun Poll.requireUnknownPollType(): UnknownPollType = this as UnknownPollType From b22118b400eda4d36ddcae87b416fdd1401dff3c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Jan 2021 23:04:09 +0600 Subject: [PATCH 10/10] add suppressing of unchecked casts --- .../kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 8d93c335d6..4ce0fb76a7 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -1,4 +1,4 @@ -@file:Suppress("NOTHING_TO_INLINE", "unused") +@file:Suppress("NOTHING_TO_INLINE", "unused", "UNCHECKED_CAST") package dev.inmo.tgbotapi.extensions.utils import dev.inmo.tgbotapi.types.*