diff --git a/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api b/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api index 69e311efa2..e729c14dd0 100644 --- a/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api +++ b/tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api @@ -506,6 +506,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W public static synthetic fun waitEditedAudio$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; public static final fun waitEditedAudioMediaGroupContent (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow; public static synthetic fun waitEditedAudioMediaGroupContent$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public static final fun waitEditedChecklistContent (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun waitEditedChecklistContent$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; public static final fun waitEditedContact (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow; public static synthetic fun waitEditedContact$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; public static final fun waitEditedContentMessage (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow; @@ -1283,6 +1285,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handl public static synthetic fun onEditedAudio$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; public static final fun onEditedAudioMediaGroup (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job; public static synthetic fun onEditedAudioMediaGroup$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; + public static final fun onEditedChecklist (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job; + public static synthetic fun onEditedChecklist$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; public static final fun onEditedContact (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job; public static synthetic fun onEditedContact$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job; public static final fun onEditedContentMessage (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job; diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index b41a87811b..133c86af7d 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -128,3 +128,8 @@ fun BehaviourContext.waitEditedGiveawayPublicResultsContent( errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContent(initRequest, errorFactory) +fun BehaviourContext.waitEditedChecklistContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, errorFactory) + diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index 9321510cae..ff0de098bc 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -591,3 +591,31 @@ fun BC.onEditedInvoice( additionalSubcontextInitialAction, scenarioReceiver ) + + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream". + * [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for + * "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +fun BC.onEditedChecklist( + initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + markerFactory: MarkerFactory? = ByChatMessageMarkerFactory, + additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver? = null, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +)= onEditedContent( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + additionalSubcontextInitialAction, + scenarioReceiver +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksAdded.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksAdded.kt index 0fa05967ff..21ce951edd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksAdded.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksAdded.kt @@ -4,7 +4,10 @@ import dev.inmo.tgbotapi.types.checklistMessageField import dev.inmo.tgbotapi.types.markedAsDoneTaskIdsField import dev.inmo.tgbotapi.types.markedAsNotDoneTaskIdsField import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.RawMessage import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass +import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass import dev.inmo.tgbotapi.types.message.content.ChecklistContent import dev.inmo.tgbotapi.types.tasksField import dev.inmo.tgbotapi.types.userField @@ -14,6 +17,7 @@ import kotlinx.serialization.Serializable @Serializable data class ChecklistTasksAdded( @SerialName(checklistMessageField) + @Serializable(TelegramBotAPIMessageDeserializeOnlySerializerClass::class) val checklistMessage: CommonMessage, @SerialName(tasksField) val tasks: List, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksDone.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksDone.kt index a2fe468d8a..369f1aa67b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksDone.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/checklists/ChecklistTasksDone.kt @@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.markedAsDoneTaskIdsField import dev.inmo.tgbotapi.types.markedAsNotDoneTaskIdsField import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass import dev.inmo.tgbotapi.types.message.content.ChecklistContent import dev.inmo.tgbotapi.types.userField import kotlinx.serialization.SerialName @@ -13,6 +14,7 @@ import kotlinx.serialization.Serializable @Serializable data class ChecklistTasksDone( @SerialName(checklistMessageField) + @Serializable(TelegramBotAPIMessageDeserializeOnlySerializerClass::class) val checklistMessage: CommonMessage, @SerialName(markedAsDoneTaskIdsField) val markedAsDone: List? = null, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 4f5b5134d2..53d0d8f698 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.checklists.Checklist import dev.inmo.tgbotapi.types.checklists.ChecklistTasksAdded import dev.inmo.tgbotapi.types.checklists.ChecklistTasksDone import dev.inmo.tgbotapi.types.dice.Dice @@ -168,6 +169,7 @@ internal data class RawMessage( private val giveaway_completed: GiveawayPrivateResults? = null, // Checklists + private val checklist: Checklist.Created? = null, private val checklist_tasks_done: ChecklistTasksDone? = null, private val checklist_tasks_added: ChecklistTasksAdded? = null, @@ -249,6 +251,7 @@ internal data class RawMessage( venue != null -> VenueContent(venue) poll != null -> PollContent(poll) invoice != null -> InvoiceContent(invoice) + checklist != null -> ChecklistContent(checklist) giveaway != null -> GiveawayContent(chat, messageId, giveaway) giveaway_winners is GiveawayPublicResults -> GiveawayPublicResultsContent(giveaway_winners) else -> null diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt index 548291cd5c..db0d24576e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt @@ -35,5 +35,6 @@ typealias AnimationMessage = CommonMessage typealias ScheduledGiveawayContentMessage = CommonMessage typealias GiveawayPublicResultsContentMessage = CommonMessage typealias PaidMediaInfoContentMessage = CommonMessage +typealias ChecklistMessage = CommonMessage