From 6690fffe69638df699e4c3ce1b62ddbc70dd4160 Mon Sep 17 00:00:00 2001 From: Jey Date: Sun, 8 Sep 2024 16:29:30 +0300 Subject: [PATCH] 7.3.1 (#236) * Add missing `user` and `text` references for `PurchasedPaidMediaUpdate`. --- CHANGELOG.md | 4 + README.md | 3 +- .../kotlin/eu/vendeli/ksp/ApiProcessor.kt | 13 +- .../eu/vendeli/ksp/ActivityCollectors.kt | 95 +++++++------- .../eu/vendeli/ksp/ActivityProcessor.kt | 18 ++- .../eu/vendeli/ksp/InvocationLambdaBuilder.kt | 16 ++- .../eu/vendeli/ksp/utils/HelperUtils.kt | 51 ++++--- telegram-bot/api/telegram-bot.api | 4 +- .../tgbot/types/internal/ProcessedUpdate.kt | 7 +- .../vendeli/tgbot/utils/FunctionalDSLUtils.kt | 124 +++++++++++------- .../eu/vendeli/tgbot/utils/TypeAliases.kt | 47 ------- 11 files changed, 203 insertions(+), 179 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f605551a7..3e8d3aec75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Telegram-bot (KtGram) Changelog +### 7.3.1 + +* Add missing `user` and `text` references for `PurchasedPaidMediaUpdate`. + ## 7.3.0 * Supported Telegram API [7.10](https://core.telegram.org/bots/api-changelog#september-6-2024) diff --git a/README.md b/README.md index 61b4c2345e..d940fc7250 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,8 @@ methods [ ### Additional resources -> There is a [wiki](https://github.com/vendelieu/telegram-bot/wiki) section that have helpful information. +* There is a [wiki](https://github.com/vendelieu/telegram-bot/wiki) section that has helpful information. +* [API reference](https://vendelieu.github.io/telegram-bot/) ### Questions diff --git a/helper/src/jvmMain/kotlin/eu/vendeli/ksp/ApiProcessor.kt b/helper/src/jvmMain/kotlin/eu/vendeli/ksp/ApiProcessor.kt index ed70ec5012..b0342606ee 100644 --- a/helper/src/jvmMain/kotlin/eu/vendeli/ksp/ApiProcessor.kt +++ b/helper/src/jvmMain/kotlin/eu/vendeli/ksp/ApiProcessor.kt @@ -115,14 +115,15 @@ class ApiProcessor( val fdslType = FunctionalHandlingDsl::class.asTypeName() val blockType = ActivityCtx::class.asTypeName() addImport("eu.vendeli.tgbot.types.internal", "UpdateType") - addImport("eu.vendeli.tgbot.utils", "cast") UpdateType.entries.forEach { type -> - val funName = type.name + val nameRef = type.name .lowercase() .snakeToCamelCase() + .replace("editMessage", "editedMessage") + val funName = nameRef .beginWithUpperCase() - .replace("EditMessage", "EditedMessage") + val pUpdateType = funName + "Update" addImport("eu.vendeli.tgbot.types.internal", pUpdateType) @@ -134,8 +135,10 @@ class ApiProcessor( FunSpec .builder("on$funName") .receiver(fdslType) - .addKdoc("Action that is performed on the presence of $funName in the Update.") - .addParameter(ParameterSpec.builder("block", blockTypeRef).build()) + .addKdoc( + "Action that is performed on the presence of " + + "[eu.vendeli.tgbot.types.Update.$nameRef] in the [eu.vendeli.tgbot.types.Update].", + ).addParameter(ParameterSpec.builder("block", blockTypeRef).build()) .addCode("functionalActivities.onUpdateActivities[$type] = block.cast()") .build(), ) diff --git a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityCollectors.kt b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityCollectors.kt index 7aefed6ac8..fcb41a96ee 100644 --- a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityCollectors.kt +++ b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityCollectors.kt @@ -14,7 +14,7 @@ import com.squareup.kotlinpoet.buildCodeBlock import eu.vendeli.ksp.dto.CollectorsContext import eu.vendeli.ksp.dto.CommonAnnotationData import eu.vendeli.ksp.utils.addMap -import eu.vendeli.ksp.utils.addVarStatement +import eu.vendeli.ksp.utils.buildMeta import eu.vendeli.ksp.utils.commonMatcherClass import eu.vendeli.ksp.utils.invocableType import eu.vendeli.ksp.utils.parseAsCommandHandler @@ -25,10 +25,7 @@ import eu.vendeli.tgbot.annotations.CommandHandler import eu.vendeli.tgbot.annotations.CommandHandler.CallbackQuery import eu.vendeli.tgbot.annotations.InputHandler import eu.vendeli.tgbot.annotations.UpdateHandler -import eu.vendeli.tgbot.implementations.DefaultArgParser -import eu.vendeli.tgbot.implementations.DefaultGuard import eu.vendeli.tgbot.types.internal.UpdateType -import eu.vendeli.tgbot.utils.fullName internal fun collectCommandActivities( symbols: Sequence, @@ -63,24 +60,21 @@ internal fun collectCommandActivities( annotationData.scope.forEach { updT -> logger.info("Command: $it UpdateType: ${updT.name} --> ${function.qualifiedName?.asString()}") - addVarStatement(postFix = "\n)),") { - add("(\"$it\" to %L)" to updT) - add( - " to (%L to InvocationMeta(\n" to activitiesFile.buildInvocationLambdaCodeBlock( - function, - injectableTypes, - pkg, + addStatement( + "(\"$it\" to %L) to %L,", updT, + activitiesFile.buildInvocationLambdaCodeBlock( + function, + injectableTypes, + pkg, + buildMeta( + qualifier = function.qualifiedName!!.getQualifier(), + function = function.simpleName.asString(), + rateLimits = annotationData.rateLimits.toRateLimits(), + guardClass = annotationData.guardClass, + argParserClass = annotationData.argParserClass ), - ) - add("qualifier = \"%L\"" to function.qualifiedName!!.getQualifier()) - add(",\n function = \"%L\"" to function.simpleName.asString()) - if (annotationData.rateLimits.first > 0 || annotationData.rateLimits.second > 0) - add(",\n rateLimits = %L" to annotationData.rateLimits.toRateLimits()) - if (annotationData.guardClass != DefaultGuard::class.fullName) - add(",\n guard = %L::class" to annotationData.guardClass) - if (annotationData.argParserClass != DefaultArgParser::class.fullName) - add(",\n argParser = %L::class" to annotationData.argParserClass) - } + ), + ) } } } @@ -107,21 +101,22 @@ internal fun collectInputActivities( .parseAsInputHandler() annotationData.first.forEach { logger.info("Input: $it --> ${function.qualifiedName?.asString()}") - addVarStatement(postFix = "\n)),") { - add( - "\"$it\" to (%L to InvocationMeta(\n" to activitiesFile.buildInvocationLambdaCodeBlock( - function, - injectableTypes, - pkg, + + addStatement( + "\"$it\" to %L,", + activitiesFile.buildInvocationLambdaCodeBlock( + function, + injectableTypes, + pkg, + buildMeta( + qualifier = function.qualifiedName!!.getQualifier(), + function = function.simpleName.asString(), + rateLimits = annotationData.second.toRateLimits(), + guardClass = annotationData.third, + argParserClass = null ), - ) - add("qualifier = \"%L\"" to function.qualifiedName!!.getQualifier()) - add(",\n function = \"%L\"" to function.simpleName.asString()) - if (annotationData.second.first > 0 || annotationData.second.second > 0) - add(",\n rateLimits = %L" to annotationData.second.toRateLimits()) - if (annotationData.third != DefaultGuard::class.fullName) - add(",\n guard = %L::class" to annotationData.third) - } + ), + ) } } } @@ -171,22 +166,22 @@ internal fun collectCommonActivities( .apply { add("mapOf(\n") data.forEach { - addVarStatement(postFix = "\n)),") { - add("%L to " to it.value.toCommonMatcher(it.filter, it.scope)) - add( - "(%L to InvocationMeta(\n" to activitiesFile.buildInvocationLambdaCodeBlock( - it.funDeclaration, - injectableTypes, - pkg, + addStatement( + "%L to %L,", + it.value.toCommonMatcher(it.filter, it.scope), + activitiesFile.buildInvocationLambdaCodeBlock( + it.funDeclaration, + injectableTypes, + pkg, + buildMeta( + qualifier = it.funQualifier, + function = it.funSimpleName, + rateLimits = it.rateLimits, + argParserClass = it.argParser, + guardClass = null, ), - ) - add("qualifier = \"%L\"" to it.funQualifier) - add(",\n function = \"%L\"" to it.funSimpleName) - if (it.rateLimits.rate > 0 || it.rateLimits.period > 0) - add(",\n rateLimits = %L" to it.rateLimits) - if (it.argParser != DefaultArgParser::class.fullName) - add(",\n argParser = %L::class" to it.argParser) - } + ), + ) } add(")\n") }.build(), diff --git a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityProcessor.kt b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityProcessor.kt index 7d4e5d50c6..527c590f60 100644 --- a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityProcessor.kt +++ b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/ActivityProcessor.kt @@ -53,6 +53,7 @@ class ActivityProcessor( addImport("eu.vendeli.tgbot.types.internal.configuration", "RateLimits") addSuspendCallFun() + addSuspendCallFun(true) addImport("eu.vendeli.tgbot.utils", "getInstance") } @@ -190,11 +191,17 @@ class ActivityProcessor( ) } - private fun FileBuilder.addSuspendCallFun() = addFunction( + private fun FileBuilder.addSuspendCallFun(withMeta: Boolean = false) = addFunction( FunSpec .builder("suspendCall") .apply { addModifiers(KModifier.PRIVATE, KModifier.INLINE) + if (withMeta) addParameter( + ParameterSpec.builder( + "meta", + TypeVariableName("InvocationMeta"), + ).build(), + ) addParameter( ParameterSpec .builder( @@ -203,8 +210,13 @@ class ActivityProcessor( KModifier.NOINLINE, ).build(), ) - returns(TypeVariableName("InvocationLambda")) - addStatement("return block") + if (!withMeta) { + returns(TypeVariableName("InvocationLambda")) + addStatement("return block") + } else { + returns(TypeVariableName("Invocable")) + addStatement("return block to meta") + } }.build(), ) } diff --git a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/InvocationLambdaBuilder.kt b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/InvocationLambdaBuilder.kt index 04d4bae4bd..d11e14ab7f 100644 --- a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/InvocationLambdaBuilder.kt +++ b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/InvocationLambdaBuilder.kt @@ -77,6 +77,7 @@ internal fun FileBuilder.buildInvocationLambdaCodeBlock( function: KSFunctionDeclaration, injectableTypes: Map, pkg: String? = null, + meta: Pair>? = null, ) = buildCodeBlock { val isTopLvl = function.functionKind == FunctionKind.TOP_LEVEL val funQualifier = function.qualifiedName!!.getQualifier() @@ -88,7 +89,14 @@ internal fun FileBuilder.buildInvocationLambdaCodeBlock( } val isObject = (function.parent as? KSClassDeclaration)?.classKind == ClassKind.OBJECT - beginControlFlow("suspendCall { classManager, update, user, bot, parameters ->") + val lambda = meta?.let { + beginControlFlow( + "suspendCall(\n\t${it.first}\n) { classManager, update, user, bot, parameters ->", + *it.second, + ) + } ?: beginControlFlow("suspendCall { classManager, update, user, bot, parameters ->") + + lambda .apply { var parametersEnumeration = "" if (!isTopLvl && !isObject && function.functionKind != FunctionKind.STATIC) { @@ -109,9 +117,9 @@ internal fun FileBuilder.buildInvocationLambdaCodeBlock( }?.let { i -> i.arguments.first { a -> a.name?.asString() == "name" }.value as? String } ?: parameter.name!!.getShortName() - ).let { - "parameters[\"$it\"]" - } + ).let { + "parameters[\"$it\"]" + } val parameterTypeName = parameter.type.toTypeName() val typeName = parameterTypeName.copy(false) val nullabilityMark = if (parameterTypeName.isNullable) "" else "!!" diff --git a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/utils/HelperUtils.kt b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/utils/HelperUtils.kt index f7803270a2..662e36d96d 100644 --- a/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/utils/HelperUtils.kt +++ b/ksp/src/jvmMain/kotlin/eu/vendeli/ksp/utils/HelperUtils.kt @@ -19,6 +19,8 @@ import com.squareup.kotlinpoet.asClassName import com.squareup.kotlinpoet.asTypeName import eu.vendeli.tgbot.TelegramBot import eu.vendeli.tgbot.implementations.ClassDataImpl +import eu.vendeli.tgbot.implementations.DefaultArgParser +import eu.vendeli.tgbot.implementations.DefaultGuard import eu.vendeli.tgbot.implementations.UserDataMapImpl import eu.vendeli.tgbot.interfaces.ctx.ClassData import eu.vendeli.tgbot.interfaces.ctx.UserData @@ -123,6 +125,38 @@ internal inline fun Any?.safeCast(): R? = this as? R internal fun Pair.toRateLimits(): RateLimits = RateLimits(first, second) +@Suppress("NOTHING_TO_INLINE") +internal inline fun buildMeta( + qualifier: String, + function: String, + rateLimits: RateLimits, + guardClass: String? = null, + argParserClass: String? = null, +): Pair> { + val parametersList = mutableListOf( + qualifier, + function + ) + + return buildString { + append("InvocationMeta(\n\tqualifier = \"%L\",\n\tfunction = \"%L\"") + if (rateLimits.period > 0 || rateLimits.rate > 0) { + append(",\n\trateLimits = %L") + parametersList.add(rateLimits) + } + + if (guardClass != null && guardClass != DefaultGuard::class.fullName) { + append(",\n\tguard = %L::class") + parametersList.add(guardClass) + } + if (argParserClass != null && argParserClass != DefaultArgParser::class.fullName) { + append(",\n\targParser = %L::class") + parametersList.add(argParserClass) + } + append("\n\t)") + } to parametersList.toTypedArray() +} + internal fun Resolver.getAnnotatedFnSymbols( targetPackage: String? = null, vararg kClasses: KClass, @@ -142,23 +176,6 @@ internal fun Resolver.getAnnotatedFnSymbols( } } -internal fun CodeBlock.Builder.addVarStatement( - prefix: String? = null, - postFix: String? = null, - builder: MutableList>.() -> Unit, -) { - val pairList = buildList(builder) - - val format = buildString { - prefix?.also(::append) - pairList.forEach { - append(it.first) - } - postFix?.also(::append) - } - addStatement(format, *pairList.map { it.second }.toTypedArray()) -} - internal fun Resolver.getAnnotatedClassSymbols(clazz: KClass, targetPackage: String? = null) = if (targetPackage == null) getSymbolsWithAnnotation(clazz.qualifiedName!!).filterIsInstance() else getSymbolsWithAnnotation(clazz.qualifiedName!!) diff --git a/telegram-bot/api/telegram-bot.api b/telegram-bot/api/telegram-bot.api index b4f6ceb785..f959f6fed7 100644 --- a/telegram-bot/api/telegram-bot.api +++ b/telegram-bot/api/telegram-bot.api @@ -7825,7 +7825,7 @@ public final class eu/vendeli/tgbot/types/internal/ProcessedUpdateKt { public static final fun getUserOrNull (Leu/vendeli/tgbot/types/internal/ProcessedUpdate;)Leu/vendeli/tgbot/types/User; } -public final class eu/vendeli/tgbot/types/internal/PurchasedPaidMediaUpdate : eu/vendeli/tgbot/types/internal/ProcessedUpdate { +public final class eu/vendeli/tgbot/types/internal/PurchasedPaidMediaUpdate : eu/vendeli/tgbot/types/internal/ProcessedUpdate, eu/vendeli/tgbot/types/internal/TextReference, eu/vendeli/tgbot/types/internal/UserReference { public fun (ILeu/vendeli/tgbot/types/Update;Leu/vendeli/tgbot/types/media/PaidMediaPurchased;)V public final fun component1 ()I public final fun component2 ()Leu/vendeli/tgbot/types/Update; @@ -7835,7 +7835,9 @@ public final class eu/vendeli/tgbot/types/internal/PurchasedPaidMediaUpdate : eu public fun equals (Ljava/lang/Object;)Z public fun getOrigin ()Leu/vendeli/tgbot/types/Update; public final fun getPurchasedPaidMedia ()Leu/vendeli/tgbot/types/media/PaidMediaPurchased; + public fun getText ()Ljava/lang/String; public fun getUpdateId ()I + public fun getUser ()Leu/vendeli/tgbot/types/User; public fun hashCode ()I public fun toString ()Ljava/lang/String; } diff --git a/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/types/internal/ProcessedUpdate.kt b/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/types/internal/ProcessedUpdate.kt index d34247c40f..e626495e97 100644 --- a/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/types/internal/ProcessedUpdate.kt +++ b/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/types/internal/ProcessedUpdate.kt @@ -309,7 +309,12 @@ data class PurchasedPaidMediaUpdate( override val updateId: Int, override val origin: Update, val purchasedPaidMedia: PaidMediaPurchased, -) : ProcessedUpdate(updateId, origin, UpdateType.PURCHASED_PAID_MEDIA) { +) : ProcessedUpdate(updateId, origin, UpdateType.PURCHASED_PAID_MEDIA), + UserReference, + TextReference { + override val user: User = purchasedPaidMedia.from + override val text: String = purchasedPaidMedia.paidMediaPayload + internal companion object : UpdateSerializer() } diff --git a/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/FunctionalDSLUtils.kt b/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/FunctionalDSLUtils.kt index 96f71f62e1..262a778c49 100644 --- a/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/FunctionalDSLUtils.kt +++ b/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/FunctionalDSLUtils.kt @@ -1,41 +1,44 @@ package eu.vendeli.tgbot.utils import eu.vendeli.tgbot.core.FunctionalHandlingDsl -import eu.vendeli.tgbot.types.internal.ActivityCtx -import eu.vendeli.tgbot.types.internal.BusinessConnectionUpdate -import eu.vendeli.tgbot.types.internal.BusinessMessageUpdate -import eu.vendeli.tgbot.types.internal.CallbackQueryUpdate -import eu.vendeli.tgbot.types.internal.ChannelPostUpdate -import eu.vendeli.tgbot.types.internal.ChatBoostUpdate -import eu.vendeli.tgbot.types.internal.ChatJoinRequestUpdate -import eu.vendeli.tgbot.types.internal.ChatMemberUpdate -import eu.vendeli.tgbot.types.internal.ChosenInlineResultUpdate -import eu.vendeli.tgbot.types.internal.DeletedBusinessMessagesUpdate -import eu.vendeli.tgbot.types.internal.EditedBusinessMessageUpdate -import eu.vendeli.tgbot.types.internal.EditedChannelPostUpdate -import eu.vendeli.tgbot.types.internal.EditedMessageUpdate -import eu.vendeli.tgbot.types.internal.InlineQueryUpdate -import eu.vendeli.tgbot.types.internal.MessageReactionCountUpdate -import eu.vendeli.tgbot.types.internal.MessageReactionUpdate -import eu.vendeli.tgbot.types.internal.MessageUpdate -import eu.vendeli.tgbot.types.internal.MyChatMemberUpdate -import eu.vendeli.tgbot.types.internal.PollAnswerUpdate -import eu.vendeli.tgbot.types.internal.PollUpdate -import eu.vendeli.tgbot.types.internal.PreCheckoutQueryUpdate -import eu.vendeli.tgbot.types.internal.PurchasedPaidMediaUpdate -import eu.vendeli.tgbot.types.internal.RemovedChatBoostUpdate -import eu.vendeli.tgbot.types.internal.ShippingQueryUpdate -import eu.vendeli.tgbot.types.internal.UpdateType - -/** - * Action that is performed on the presence of Message in the Update. +import eu.vendeli.tgbot.types.`internal`.ActivityCtx +import eu.vendeli.tgbot.types.`internal`.BusinessConnectionUpdate +import eu.vendeli.tgbot.types.`internal`.BusinessMessageUpdate +import eu.vendeli.tgbot.types.`internal`.CallbackQueryUpdate +import eu.vendeli.tgbot.types.`internal`.ChannelPostUpdate +import eu.vendeli.tgbot.types.`internal`.ChatBoostUpdate +import eu.vendeli.tgbot.types.`internal`.ChatJoinRequestUpdate +import eu.vendeli.tgbot.types.`internal`.ChatMemberUpdate +import eu.vendeli.tgbot.types.`internal`.ChosenInlineResultUpdate +import eu.vendeli.tgbot.types.`internal`.DeletedBusinessMessagesUpdate +import eu.vendeli.tgbot.types.`internal`.EditedBusinessMessageUpdate +import eu.vendeli.tgbot.types.`internal`.EditedChannelPostUpdate +import eu.vendeli.tgbot.types.`internal`.EditedMessageUpdate +import eu.vendeli.tgbot.types.`internal`.InlineQueryUpdate +import eu.vendeli.tgbot.types.`internal`.MessageReactionCountUpdate +import eu.vendeli.tgbot.types.`internal`.MessageReactionUpdate +import eu.vendeli.tgbot.types.`internal`.MessageUpdate +import eu.vendeli.tgbot.types.`internal`.MyChatMemberUpdate +import eu.vendeli.tgbot.types.`internal`.PollAnswerUpdate +import eu.vendeli.tgbot.types.`internal`.PollUpdate +import eu.vendeli.tgbot.types.`internal`.PreCheckoutQueryUpdate +import eu.vendeli.tgbot.types.`internal`.PurchasedPaidMediaUpdate +import eu.vendeli.tgbot.types.`internal`.RemovedChatBoostUpdate +import eu.vendeli.tgbot.types.`internal`.ShippingQueryUpdate +import eu.vendeli.tgbot.types.`internal`.UpdateType +import kotlin.Unit + +/** + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.message] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onMessage(block: suspend ActivityCtx.() -> Unit) { functionalActivities.onUpdateActivities[UpdateType.MESSAGE] = block.cast() } /** - * Action that is performed on the presence of EditedMessage in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.editedMessage] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onEditedMessage(block: suspend ActivityCtx.() -> Unit) { @@ -43,7 +46,8 @@ public } /** - * Action that is performed on the presence of ChannelPost in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.channelPost] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onChannelPost(block: suspend ActivityCtx.() -> Unit) { @@ -51,7 +55,8 @@ public } /** - * Action that is performed on the presence of EditedChannelPost in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.editedChannelPost] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onEditedChannelPost(block: suspend ActivityCtx.() -> Unit) { @@ -59,7 +64,8 @@ public } /** - * Action that is performed on the presence of BusinessConnection in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.businessConnection] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onBusinessConnection(block: suspend ActivityCtx.() -> Unit) { @@ -67,7 +73,8 @@ public } /** - * Action that is performed on the presence of BusinessMessage in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.businessMessage] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onBusinessMessage(block: suspend ActivityCtx.() -> Unit) { @@ -75,7 +82,8 @@ public } /** - * Action that is performed on the presence of EditedBusinessMessage in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.editedBusinessMessage] + * in the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onEditedBusinessMessage(block: suspend ActivityCtx.() -> Unit) { @@ -83,7 +91,8 @@ public } /** - * Action that is performed on the presence of DeletedBusinessMessages in the Update. + * Action that is performed on the presence of + * [eu.vendeli.tgbot.types.Update.deletedBusinessMessages] in the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onDeletedBusinessMessages(block: suspend ActivityCtx.() -> Unit) { @@ -91,7 +100,8 @@ public } /** - * Action that is performed on the presence of MessageReaction in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.messageReaction] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onMessageReaction(block: suspend ActivityCtx.() -> Unit) { @@ -99,7 +109,8 @@ public } /** - * Action that is performed on the presence of MessageReactionCount in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.messageReactionCount] + * in the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onMessageReactionCount(block: suspend ActivityCtx.() -> Unit) { @@ -107,7 +118,8 @@ public } /** - * Action that is performed on the presence of InlineQuery in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.inlineQuery] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onInlineQuery(block: suspend ActivityCtx.() -> Unit) { @@ -115,7 +127,8 @@ public } /** - * Action that is performed on the presence of ChosenInlineResult in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.chosenInlineResult] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onChosenInlineResult(block: suspend ActivityCtx.() -> Unit) { @@ -123,7 +136,8 @@ public } /** - * Action that is performed on the presence of CallbackQuery in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.callbackQuery] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onCallbackQuery(block: suspend ActivityCtx.() -> Unit) { @@ -131,7 +145,8 @@ public } /** - * Action that is performed on the presence of ShippingQuery in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.shippingQuery] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onShippingQuery(block: suspend ActivityCtx.() -> Unit) { @@ -139,7 +154,8 @@ public } /** - * Action that is performed on the presence of PreCheckoutQuery in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.preCheckoutQuery] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onPreCheckoutQuery(block: suspend ActivityCtx.() -> Unit) { @@ -147,14 +163,16 @@ public } /** - * Action that is performed on the presence of Poll in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.poll] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onPoll(block: suspend ActivityCtx.() -> Unit) { functionalActivities.onUpdateActivities[UpdateType.POLL] = block.cast() } /** - * Action that is performed on the presence of PollAnswer in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.pollAnswer] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onPollAnswer(block: suspend ActivityCtx.() -> Unit) { @@ -162,7 +180,8 @@ public } /** - * Action that is performed on the presence of MyChatMember in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.myChatMember] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onMyChatMember(block: suspend ActivityCtx.() -> Unit) { @@ -170,7 +189,8 @@ public } /** - * Action that is performed on the presence of ChatMember in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.chatMember] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onChatMember(block: suspend ActivityCtx.() -> Unit) { @@ -178,7 +198,8 @@ public } /** - * Action that is performed on the presence of ChatJoinRequest in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.chatJoinRequest] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onChatJoinRequest(block: suspend ActivityCtx.() -> Unit) { @@ -186,7 +207,8 @@ public } /** - * Action that is performed on the presence of ChatBoost in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.chatBoost] in the + * [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onChatBoost(block: suspend ActivityCtx.() -> Unit) { @@ -194,7 +216,8 @@ public } /** - * Action that is performed on the presence of RemovedChatBoost in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.removedChatBoost] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onRemovedChatBoost(block: suspend ActivityCtx.() -> Unit) { @@ -202,7 +225,8 @@ public } /** - * Action that is performed on the presence of PurchasedPaidMedia in the Update. + * Action that is performed on the presence of [eu.vendeli.tgbot.types.Update.purchasedPaidMedia] in + * the [eu.vendeli.tgbot.types.Update]. */ public fun FunctionalHandlingDsl.onPurchasedPaidMedia(block: suspend ActivityCtx.() -> Unit) { diff --git a/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/TypeAliases.kt b/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/TypeAliases.kt index 4c852e78ad..13f6e48e89 100644 --- a/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/TypeAliases.kt +++ b/telegram-bot/src/commonMain/kotlin/eu/vendeli/tgbot/utils/TypeAliases.kt @@ -6,34 +6,11 @@ import eu.vendeli.tgbot.core.TgUpdateHandler import eu.vendeli.tgbot.interfaces.ctx.ClassManager import eu.vendeli.tgbot.types.User import eu.vendeli.tgbot.types.internal.ActivityCtx -import eu.vendeli.tgbot.types.internal.BusinessConnectionUpdate -import eu.vendeli.tgbot.types.internal.BusinessMessageUpdate -import eu.vendeli.tgbot.types.internal.CallbackQueryUpdate -import eu.vendeli.tgbot.types.internal.ChannelPostUpdate -import eu.vendeli.tgbot.types.internal.ChatBoostUpdate -import eu.vendeli.tgbot.types.internal.ChatJoinRequestUpdate -import eu.vendeli.tgbot.types.internal.ChatMemberUpdate -import eu.vendeli.tgbot.types.internal.ChosenInlineResultUpdate import eu.vendeli.tgbot.types.internal.CommandContext import eu.vendeli.tgbot.types.internal.CommonMatcher -import eu.vendeli.tgbot.types.internal.DeletedBusinessMessagesUpdate -import eu.vendeli.tgbot.types.internal.EditedBusinessMessageUpdate -import eu.vendeli.tgbot.types.internal.EditedChannelPostUpdate -import eu.vendeli.tgbot.types.internal.EditedMessageUpdate import eu.vendeli.tgbot.types.internal.FunctionalInvocation -import eu.vendeli.tgbot.types.internal.InlineQueryUpdate import eu.vendeli.tgbot.types.internal.InvocationMeta -import eu.vendeli.tgbot.types.internal.MessageReactionCountUpdate -import eu.vendeli.tgbot.types.internal.MessageReactionUpdate -import eu.vendeli.tgbot.types.internal.MessageUpdate -import eu.vendeli.tgbot.types.internal.MyChatMemberUpdate -import eu.vendeli.tgbot.types.internal.PollAnswerUpdate -import eu.vendeli.tgbot.types.internal.PollUpdate -import eu.vendeli.tgbot.types.internal.PreCheckoutQueryUpdate import eu.vendeli.tgbot.types.internal.ProcessedUpdate -import eu.vendeli.tgbot.types.internal.PurchasedPaidMediaUpdate -import eu.vendeli.tgbot.types.internal.RemovedChatBoostUpdate -import eu.vendeli.tgbot.types.internal.ShippingQueryUpdate import eu.vendeli.tgbot.types.internal.SingleInputChain import eu.vendeli.tgbot.types.internal.UpdateType import eu.vendeli.tgbot.types.internal.configuration.BotConfiguration @@ -41,30 +18,6 @@ import io.ktor.client.plugins.HttpRequestRetry import io.ktor.client.request.HttpRequest import io.ktor.client.statement.HttpResponse -typealias OnMessageActivity = suspend ActivityCtx.() -> Unit -typealias OnEditedMessageActivity = suspend ActivityCtx.() -> Unit -typealias OnPollAnswerActivity = suspend ActivityCtx.() -> Unit -typealias OnCallbackQueryActivity = suspend ActivityCtx.() -> Unit -typealias OnPollActivity = suspend ActivityCtx.() -> Unit -typealias OnChatJoinRequestActivity = suspend ActivityCtx.() -> Unit -typealias OnChatMemberActivity = suspend ActivityCtx.() -> Unit -typealias OnMyChatMemberActivity = suspend ActivityCtx.() -> Unit -typealias OnChannelPostActivity = suspend ActivityCtx.() -> Unit -typealias OnEditedChannelPostActivity = suspend ActivityCtx.() -> Unit -typealias OnChosenInlineResultActivity = suspend ActivityCtx.() -> Unit -typealias OnInlineQueryActivity = suspend ActivityCtx.() -> Unit -typealias OnPreCheckoutQueryActivity = suspend ActivityCtx.() -> Unit -typealias OnShippingQueryActivity = suspend ActivityCtx.() -> Unit -typealias OnMessageReactionActivity = suspend ActivityCtx.() -> Unit -typealias OnMessageReactionCountActivity = suspend ActivityCtx.() -> Unit -typealias OnChatBoostActivity = suspend ActivityCtx.() -> Unit -typealias OnRemovedChatBoostActivity = suspend ActivityCtx.() -> Unit -typealias OnBusinessConnectionActivity = suspend ActivityCtx.() -> Unit -typealias OnBusinessMessageActivity = suspend ActivityCtx.() -> Unit -typealias OnEditedBusinessMessageActivity = suspend ActivityCtx.() -> Unit -typealias OnDeletedBusinessMessagesActivity = suspend ActivityCtx.() -> Unit -typealias OnPurchasedPaidMediaActivity = suspend ActivityCtx.() -> Unit - typealias WhenNotHandledActivity = suspend ProcessedUpdate.() -> Unit typealias OnCommandActivity = suspend CommandContext.() -> Unit typealias OnInputActivity = suspend ActivityCtx.() -> Unit