mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-01 22:40:07 +00:00
add behaviour builder events updates
This commit is contained in:
parent
ded501d963
commit
696822db02
@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|
||||||
@ -63,6 +64,39 @@ suspend fun BehaviourContext.waitChatEvents(
|
|||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
filter: EventMessageToEventMapper<ChatEvent>? = null
|
filter: EventMessageToEventMapper<ChatEvent>? = null
|
||||||
) = waitEvents(count, initRequest, errorFactory, filter)
|
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitVoiceChatEvents(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
count: Int = 1,
|
||||||
|
filter: EventMessageToEventMapper<VoiceChatEvent>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||||
|
suspend fun BehaviourContext.waitVoiceChatStartedEvents(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
count: Int = 1,
|
||||||
|
filter: EventMessageToEventMapper<VoiceChatStarted>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||||
|
suspend fun BehaviourContext.waitVoiceChatEndedEvents(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
count: Int = 1,
|
||||||
|
filter: EventMessageToEventMapper<VoiceChatEnded>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||||
|
suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
count: Int = 1,
|
||||||
|
filter: EventMessageToEventMapper<VoiceChatParticipantsInvited>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents(
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
count: Int = 1,
|
||||||
|
filter: EventMessageToEventMapper<MessageAutoDeleteTimerChanged>? = null
|
||||||
|
) = waitEvents(count, initRequest, errorFactory, filter)
|
||||||
|
|
||||||
suspend fun BehaviourContext.waitCommonEvents(
|
suspend fun BehaviourContext.waitCommonEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
|
@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.extensions.utils.*
|
|||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||||
|
|
||||||
internal suspend inline fun <reified T : ChatEvent> BehaviourContext.onEvent(
|
internal suspend inline fun <reified T : ChatEvent> BehaviourContext.onEvent(
|
||||||
@ -43,6 +44,31 @@ suspend fun BehaviourContext.onChatEvent(
|
|||||||
additionalFilter: (suspend (ChatEventMessage<ChatEvent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ChatEventMessage<ChatEvent>) -> Boolean)? = null,
|
||||||
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<ChatEvent>>
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<ChatEvent>>
|
||||||
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
||||||
|
suspend fun BehaviourContext.onVoiceChatEvent(
|
||||||
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
|
additionalFilter: (suspend (ChatEventMessage<VoiceChatEvent>) -> Boolean)? = null,
|
||||||
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatEvent>>
|
||||||
|
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
||||||
|
suspend fun BehaviourContext.onVoiceChatStartedEvent(
|
||||||
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
|
additionalFilter: (suspend (ChatEventMessage<VoiceChatStarted>) -> Boolean)? = null,
|
||||||
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatStarted>>
|
||||||
|
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
||||||
|
suspend fun BehaviourContext.onVoiceChatEndedEvent(
|
||||||
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
|
additionalFilter: (suspend (ChatEventMessage<VoiceChatEnded>) -> Boolean)? = null,
|
||||||
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatEnded>>
|
||||||
|
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
||||||
|
suspend fun BehaviourContext.onVoiceChatParticipantsInvitedEvent(
|
||||||
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
|
additionalFilter: (suspend (ChatEventMessage<VoiceChatParticipantsInvited>) -> Boolean)? = null,
|
||||||
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<VoiceChatParticipantsInvited>>
|
||||||
|
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
||||||
|
suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent(
|
||||||
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
|
additionalFilter: (suspend (ChatEventMessage<MessageAutoDeleteTimerChanged>) -> Boolean)? = null,
|
||||||
|
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<MessageAutoDeleteTimerChanged>>
|
||||||
|
) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver)
|
||||||
suspend fun BehaviourContext.onCommonEvent(
|
suspend fun BehaviourContext.onCommonEvent(
|
||||||
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
includeFilterByChatInBehaviourSubContext: Boolean = true,
|
||||||
additionalFilter: (suspend (ChatEventMessage<CommonEvent>) -> Boolean)? = null,
|
additionalFilter: (suspend (ChatEventMessage<CommonEvent>) -> Boolean)? = null,
|
||||||
|
Loading…
Reference in New Issue
Block a user