mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
fix of #546
This commit is contained in:
parent
0e6a708eea
commit
8331d4edd7
@ -12,6 +12,8 @@ __All the `tgbotapi.extensions.*` packages have been removed__
|
|||||||
* `PassportFile` has been replaced to `dev.inmo.tgbotapi.types.files`
|
* `PassportFile` has been replaced to `dev.inmo.tgbotapi.types.files`
|
||||||
* `WebApps`:
|
* `WebApps`:
|
||||||
* Created 🎉
|
* Created 🎉
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* `SimpleFilter` now is a `fun interface` instead of just callback (fix of [#546](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/546))
|
||||||
|
|
||||||
## 0.38.13
|
## 0.38.13
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ private suspend inline fun <reified T : CallbackQuery> BehaviourContext.waitCall
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<T>? = null,
|
filter: SimpleFilter<T>? = null,
|
||||||
noinline mapper: CallbackQueryMapper<T>? = null
|
noinline mapper: CallbackQueryMapper<T>? = null
|
||||||
) : List<T> = waitCallbackQueries<T>(
|
) : List<T> = waitCallbackQueries<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -15,7 +15,7 @@ private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContex
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<T>? = null,
|
filter: SimpleFilter<T>? = null,
|
||||||
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>
|
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>
|
||||||
): List<ChatMemberUpdated> = expectFlow(
|
): List<ChatMemberUpdated> = expectFlow(
|
||||||
initRequest,
|
initRequest,
|
||||||
@ -34,7 +34,7 @@ private suspend inline fun <reified T : ChatMemberUpdatedUpdate> BehaviourContex
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<T>? = null,
|
filter: SimpleFilter<T>? = null,
|
||||||
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
noinline mapper: ChatMemberUpdatedMapper<ChatMemberUpdated>? = null
|
||||||
) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>(
|
) : List<ChatMemberUpdated> = waitChatMemberUpdated<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -34,7 +34,7 @@ private suspend inline fun <reified T : ChosenInlineResult> BehaviourContext.wai
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<T>? = null,
|
filter: SimpleFilter<T>? = null,
|
||||||
noinline mapper: ChosenInlineResultMapper<T>? = null
|
noinline mapper: ChosenInlineResultMapper<T>? = null
|
||||||
) : List<T> = this@waitChosenInlineResults.waitChosenInlineResultsUpdates<T>(
|
) : List<T> = this@waitChosenInlineResults.waitChosenInlineResultsUpdates<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -75,7 +75,7 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitCon
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<CommonMessage<T>>? = null,
|
filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||||
noinline mapper: CommonMessageToContentMapper<T>? = null
|
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||||
) : List<T> = waitCommonContent<T>(
|
) : List<T> = waitCommonContent<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -78,7 +78,7 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitCon
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<CommonMessage<T>>? = null,
|
filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||||
noinline mapper: CommonMessageToCommonMessageMapper<T>? = null
|
noinline mapper: CommonMessageToCommonMessageMapper<T>? = null
|
||||||
) : List<CommonMessage<T>> = waitCommonMessage<T>(
|
) : List<CommonMessage<T>> = waitCommonMessage<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -58,7 +58,7 @@ private suspend inline fun <reified T : MessageContent> BehaviourContext.waitEdi
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
includeMediaGroups: Boolean = true,
|
includeMediaGroups: Boolean = true,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<CommonMessage<T>>? = null,
|
filter: SimpleFilter<CommonMessage<T>>? = null,
|
||||||
noinline mapper: CommonMessageToContentMapper<T>? = null
|
noinline mapper: CommonMessageToContentMapper<T>? = null
|
||||||
) : List<T> = waitEditedCommonMessage<T>(
|
) : List<T> = waitEditedCommonMessage<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -41,7 +41,7 @@ private suspend inline fun <reified T : ChatEvent> BehaviourContext.waitEvents(
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<ChatEventMessage<T>>? = null,
|
filter: SimpleFilter<ChatEventMessage<T>>? = null,
|
||||||
noinline mapper: EventMessageToEventMapper<T>? = null
|
noinline mapper: EventMessageToEventMapper<T>? = null
|
||||||
) : List<T> = waitEventMessages<T>(
|
) : List<T> = waitEventMessages<T>(
|
||||||
initRequest,
|
initRequest,
|
||||||
|
@ -33,7 +33,7 @@ private suspend inline fun <reified T : InlineQuery> BehaviourContext.waitInline
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<T>? = null,
|
filter: SimpleFilter<T>? = null,
|
||||||
noinline mapper: InlineQueryMapper<T>? = null
|
noinline mapper: InlineQueryMapper<T>? = null
|
||||||
) : List<T> = waitInlineQueries<T>(
|
) : List<T> = waitInlineQueries<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -37,7 +37,7 @@ suspend inline fun <reified T : EncryptedPassportElement> BehaviourContext.waitP
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<PassportMessage>? = null,
|
filter: SimpleFilter<PassportMessage>? = null,
|
||||||
noinline mapper: PassportMessageMapper? = null
|
noinline mapper: PassportMessageMapper? = null
|
||||||
) : List<PassportData> = waitPassportMessages(
|
) : List<PassportData> = waitPassportMessages(
|
||||||
initRequest,
|
initRequest,
|
||||||
|
@ -33,7 +33,7 @@ private suspend inline fun BehaviourContext.waitPollAnswers(
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<PollAnswer>? = null,
|
filter: SimpleFilter<PollAnswer>? = null,
|
||||||
noinline mapper: PollAnswerMapper? = null
|
noinline mapper: PollAnswerMapper? = null
|
||||||
) : List<PollAnswer> = this@waitPollAnswers.waitPollsAnswers<PollAnswer>(
|
) : List<PollAnswer> = this@waitPollAnswers.waitPollsAnswers<PollAnswer>(
|
||||||
count,
|
count,
|
||||||
|
@ -33,7 +33,7 @@ private suspend inline fun <reified T : Poll> BehaviourContext.waitPolls(
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
noinline errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
noinline filter: SimpleFilter<T>? = null,
|
filter: SimpleFilter<T>? = null,
|
||||||
noinline mapper: PollMapper<T>? = null
|
noinline mapper: PollMapper<T>? = null
|
||||||
) : List<T> = this@waitPolls.waitPollsUpdates<T>(
|
) : List<T> = this@waitPolls.waitPollsUpdates<T>(
|
||||||
count,
|
count,
|
||||||
|
@ -2,8 +2,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.CommonMessageFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.CommonMessageFilter
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,6 +17,6 @@ val MessageFilterExcludingMediaGroups: BehaviourContextAndTwoTypesReceiver<Boole
|
|||||||
/**
|
/**
|
||||||
* Allow only messages which are not [MediaGroupMessage]
|
* Allow only messages which are not [MediaGroupMessage]
|
||||||
*/
|
*/
|
||||||
val CommonMessageFilterExcludeMediaGroups: CommonMessageFilter<*> = {
|
val CommonMessageFilterExcludeMediaGroups = SimpleFilter<Message> {
|
||||||
it !is MediaGroupMessage<*>
|
it !is MediaGroupMessage<*>
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import dev.inmo.tgbotapi.types.CallbackQuery.*
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : CallbackQuery> BC.onCallbackQuery(
|
internal suspend inline fun <BC : BehaviourContext, reified T : CallbackQuery> BC.onCallbackQuery(
|
||||||
noinline initialFilter: SimpleFilter<T>? = null,
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = CallbackQueryFilterByUser,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = CallbackQueryFilterByUser,
|
||||||
markerFactory: MarkerFactory<in T, Any> = ByUserCallbackQueryMarkerFactory,
|
markerFactory: MarkerFactory<in T, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||||
|
@ -14,7 +14,7 @@ import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified U : ChatMemberUpdatedUpdate> BC.onChatMemberUpdatedInternal(
|
internal suspend inline fun <BC : BehaviourContext, reified U : ChatMemberUpdatedUpdate> BC.onChatMemberUpdatedInternal(
|
||||||
noinline initialFilter: SimpleFilter<ChatMemberUpdated>? = null,
|
initialFilter: SimpleFilter<ChatMemberUpdated>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMemberUpdated, Update>? = ChatMemberUpdatedFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMemberUpdated, Update>? = ChatMemberUpdatedFilterByChat,
|
||||||
markerFactory: MarkerFactory<ChatMemberUpdated, Any> = ByChatChatMemberUpdatedMarkerFactory,
|
markerFactory: MarkerFactory<ChatMemberUpdated, Any> = ByChatChatMemberUpdatedMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMemberUpdated>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMemberUpdated>
|
||||||
|
@ -12,7 +12,7 @@ import dev.inmo.tgbotapi.types.polls.*
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChosenInlineResult> BC.onChosenInlineResultBase(
|
internal suspend inline fun <BC : BehaviourContext, reified T : ChosenInlineResult> BC.onChosenInlineResultBase(
|
||||||
noinline initialFilter: SimpleFilter<T>? = null,
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
||||||
markerFactory: MarkerFactory<in T, Any> = ByUserIdChosenInlineResultMarkerFactory,
|
markerFactory: MarkerFactory<in T, Any> = ByUserIdChosenInlineResultMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||||
|
@ -55,7 +55,7 @@ suspend fun <BC : BehaviourContext> BC.command(
|
|||||||
suspend inline fun <BC : BehaviourContext> BC.onCommand(
|
suspend inline fun <BC : BehaviourContext> BC.onCommand(
|
||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
noinline initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
@ -64,7 +64,7 @@ suspend inline fun <BC : BehaviourContext> BC.onCommand(
|
|||||||
suspend inline fun <BC : BehaviourContext> BC.onCommand(
|
suspend inline fun <BC : BehaviourContext> BC.onCommand(
|
||||||
command: String,
|
command: String,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
noinline initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
@ -106,7 +106,7 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
|
|
||||||
suspend inline fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend inline fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
noinline initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||||
@ -114,7 +114,7 @@ suspend inline fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
|||||||
|
|
||||||
suspend inline fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend inline fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
command: String,
|
command: String,
|
||||||
noinline initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||||
|
@ -22,10 +22,9 @@ import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
typealias CommonMessageFilter<T> = SimpleFilter<CommonMessage<T>>
|
typealias CommonMessageFilter<T> = SimpleFilter<CommonMessage<T>>
|
||||||
inline fun <T : MessageContent> CommonMessageFilter(noinline block: CommonMessageFilter<T>) = block
|
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onContentMessageWithType(
|
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onContentMessageWithType(
|
||||||
noinline initialFilter: CommonMessageFilter<T>? = null,
|
initialFilter: CommonMessageFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<T>, Update>? = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<T>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<T>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<T>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<T>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<T>>
|
||||||
|
@ -36,7 +36,7 @@ import dev.inmo.tgbotapi.utils.PreviewFeature
|
|||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onEditedContent(
|
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onEditedContent(
|
||||||
noinline initialFilter: CommonMessageFilter<T>? = null,
|
initialFilter: CommonMessageFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<T>, Update>? = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<T>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<T>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<T>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<T>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<T>>
|
||||||
|
@ -18,7 +18,7 @@ import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
||||||
noinline initialFilter: SimpleFilter<ChatEventMessage<T>>? = null,
|
initialFilter: SimpleFilter<ChatEventMessage<T>>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<T>, Update>? = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<T>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ChatEventMessage<T>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ChatEventMessage<T>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<T>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<T>>
|
||||||
|
@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.query.*
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : InlineQuery> BC.onInlineQuery(
|
internal suspend inline fun <BC : BehaviourContext, reified T : InlineQuery> BC.onInlineQuery(
|
||||||
noinline initialFilter: SimpleFilter<T>? = null,
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = InlineQueryFilterByUser,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = InlineQueryFilterByUser,
|
||||||
markerFactory: MarkerFactory<in T, Any> = ByUserInlineQueryMarkerFactory,
|
markerFactory: MarkerFactory<in T, Any> = ByUserInlineQueryMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||||
|
@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T> BC.on(
|
internal suspend inline fun <BC : BehaviourContext, reified T> BC.on(
|
||||||
markerFactory: MarkerFactory<in T, Any>,
|
markerFactory: MarkerFactory<in T, Any>,
|
||||||
noinline initialFilter: SimpleFilter<T>? = null,
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>,
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>,
|
||||||
noinline updateToData: (Update) -> List<T>?
|
noinline updateToData: (Update) -> List<T>?
|
||||||
|
@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.utils.PreviewFeature
|
|||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : MediaGroupContent> BC.buildMediaGroupTrigger(
|
internal suspend inline fun <BC : BehaviourContext, reified T : MediaGroupContent> BC.buildMediaGroupTrigger(
|
||||||
noinline initialFilter: SimpleFilter<List<MediaGroupMessage<T>>>? = null,
|
initialFilter: SimpleFilter<List<MediaGroupMessage<T>>>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<T>>, Update>? = MessagesFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<T>>, Update>? = MessagesFilterByChat,
|
||||||
markerFactory: MarkerFactory<in List<MediaGroupMessage<T>>, Any> = ByChatMediaGroupMarkerFactory,
|
markerFactory: MarkerFactory<in List<MediaGroupMessage<T>>, Any> = ByChatMediaGroupMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<T>>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<T>>>
|
||||||
|
@ -12,7 +12,7 @@ import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportEle
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : EncryptedPassportElement> BC.onPassportMessageWith(
|
internal suspend inline fun <BC : BehaviourContext, reified T : EncryptedPassportElement> BC.onPassportMessageWith(
|
||||||
noinline initialFilter: SimpleFilter<PassportMessage>? = null,
|
initialFilter: SimpleFilter<PassportMessage>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PassportMessage, Update>? = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PassportMessage, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in PassportMessage, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in PassportMessage, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PassportMessage>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PassportMessage>
|
||||||
|
@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.polls.*
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext> BC.onPollAnswered(
|
internal suspend inline fun <BC : BehaviourContext> BC.onPollAnswered(
|
||||||
noinline initialFilter: SimpleFilter<PollAnswer>? = null,
|
initialFilter: SimpleFilter<PollAnswer>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PollAnswer, Update>? = null,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PollAnswer, Update>? = null,
|
||||||
markerFactory: MarkerFactory<in PollAnswer, Any> = ByIdPollAnswerMarkerFactory,
|
markerFactory: MarkerFactory<in PollAnswer, Any> = ByIdPollAnswerMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PollAnswer>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PollAnswer>
|
||||||
|
@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.polls.*
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : Poll> BC.onPollUpdatedBase(
|
internal suspend inline fun <BC : BehaviourContext, reified T : Poll> BC.onPollUpdatedBase(
|
||||||
noinline initialFilter: SimpleFilter<T>? = null,
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
||||||
markerFactory: MarkerFactory<in T, Any> = ByIdPollMarkerFactory,
|
markerFactory: MarkerFactory<in T, Any> = ByIdPollMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils
|
||||||
|
|
||||||
typealias SimpleFilter<T> = suspend (T) -> Boolean
|
fun interface SimpleFilter<in T> {
|
||||||
|
suspend operator fun invoke(o: T): Boolean
|
||||||
inline fun <T> SimpleFilter(noinline block: SimpleFilter<T>) = block
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return [SimpleFilter] which will return true in case when all the items in incoming data passed [this] filter
|
* @return [SimpleFilter] which will return true in case when all the items in incoming data passed [this] filter
|
||||||
@ -28,20 +28,20 @@ fun <T> SimpleFilter<T>.listNone() = SimpleFilter<Iterable<T>> {
|
|||||||
/**
|
/**
|
||||||
* Makes an AND (&&) operation between [this] and [other]
|
* Makes an AND (&&) operation between [this] and [other]
|
||||||
*/
|
*/
|
||||||
operator fun <T> SimpleFilter<T>.times(other: SimpleFilter<T>): SimpleFilter<T> = {
|
operator fun <T> SimpleFilter<T>.times(other: SimpleFilter<T>) = SimpleFilter<T> {
|
||||||
this(it) && other(it)
|
this(it) && other(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes an OR (||) operation between [this] and [other]
|
* Makes an OR (||) operation between [this] and [other]
|
||||||
*/
|
*/
|
||||||
operator fun <T> SimpleFilter<T>.plus(other: SimpleFilter<T>): SimpleFilter<T> = {
|
operator fun <T> SimpleFilter<T>.plus(other: SimpleFilter<T>) = SimpleFilter<T> {
|
||||||
this(it) || other(it)
|
this(it) || other(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse results of [this]
|
* Reverse results of [this]
|
||||||
*/
|
*/
|
||||||
operator fun <T> SimpleFilter<T>.not(): SimpleFilter<T> = {
|
operator fun <T> SimpleFilter<T>.not() = SimpleFilter<T> {
|
||||||
!this(it)
|
!this(it)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user