mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-21 15:53:47 +00:00
Bot API 7.7
added waiters, triggers, and class casts for refunded payment event. added property handler in RawMessage.
This commit is contained in:
parent
0457792d99
commit
d865a60151
@ -17,6 +17,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidde
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
@ -140,6 +141,10 @@ suspend fun BehaviourContext.waitSuccessfulPaymentEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<SuccessfulPaymentEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitRefundedPaymentEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<RefundedPaymentEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitUserLoggedInEvents(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
|
@ -17,6 +17,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidde
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
@ -137,6 +138,10 @@ suspend fun BehaviourContext.waitSuccessfulPaymentEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<SuccessfulPaymentEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitRefundedPaymentEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<RefundedPaymentEvent>(initRequest, errorFactory)
|
||||
suspend fun BehaviourContext.waitUserLoggedInEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
|
@ -24,6 +24,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
@ -513,6 +514,14 @@ suspend fun <BC : BehaviourContext> BC.onSuccessfulPayment(
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<SuccessfulPaymentEvent>>
|
||||
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
// TODO: add documentation
|
||||
suspend fun <BC : BehaviourContext> BC.onRefundedPayment(
|
||||
initialFilter: SimpleFilter<ChatEventMessage<RefundedPaymentEvent>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<RefundedPaymentEvent>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<RefundedPaymentEvent>, Any>? = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<RefundedPaymentEvent>>
|
||||
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, 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,
|
||||
|
@ -264,6 +264,7 @@ internal data class RawMessage(
|
||||
pinned_message != null -> PinnedMessage(pinned_message.asMessage)
|
||||
proximity_alert_triggered != null -> proximity_alert_triggered
|
||||
successful_payment != null -> SuccessfulPaymentEvent(successful_payment)
|
||||
refunded_payment != null -> RefundedPaymentEvent(refunded_payment)
|
||||
connected_website != null -> UserLoggedIn(connected_website)
|
||||
web_app_data != null -> web_app_data
|
||||
users_shared != null -> users_shared
|
||||
|
@ -34,6 +34,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.content.*
|
||||
import dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||
import dev.inmo.tgbotapi.types.passport.*
|
||||
@ -3225,6 +3226,16 @@ inline fun ChatEvent.asSuccessfulPaymentEvent(): SuccessfulPaymentEvent? = this
|
||||
@PreviewFeature
|
||||
inline fun ChatEvent.requireSuccessfulPaymentEvent(): SuccessfulPaymentEvent = this as SuccessfulPaymentEvent
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> ChatEvent.whenRefundedPaymentEvent(block: (RefundedPaymentEvent) -> T) =
|
||||
asRefundedPaymentEvent()?.let(block)
|
||||
|
||||
@PreviewFeature
|
||||
inline fun ChatEvent.asRefundedPaymentEvent(): RefundedPaymentEvent? = this as? RefundedPaymentEvent
|
||||
|
||||
@PreviewFeature
|
||||
inline fun ChatEvent.requireRefundedPaymentEvent(): RefundedPaymentEvent = this as RefundedPaymentEvent
|
||||
|
||||
@PreviewFeature
|
||||
inline fun <T> ChatEvent.whenProximityAlertTriggered(block: (ProximityAlertTriggered) -> T) =
|
||||
asProximityAlertTriggered()?.let(block)
|
||||
|
@ -340,6 +340,7 @@ import dev.inmo.tgbotapi.types.message.content.VideoNoteContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VoiceContent
|
||||
import dev.inmo.tgbotapi.types.message.content.WithCustomizedCaptionMediaContent
|
||||
import dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BlockquoteTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BoldTextSource
|
||||
@ -3441,6 +3442,15 @@ public inline fun ChatEvent.successfulPaymentEventOrThrow(): SuccessfulPaymentEv
|
||||
public inline fun <T> ChatEvent.ifSuccessfulPaymentEvent(block: (SuccessfulPaymentEvent) -> T): T? =
|
||||
successfulPaymentEventOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.refundedPaymentEventOrNull(): RefundedPaymentEvent? = this as?
|
||||
dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
|
||||
public inline fun ChatEvent.refundedPaymentEventOrThrow(): RefundedPaymentEvent = this as
|
||||
dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
|
||||
public inline fun <T> ChatEvent.ifRefundedPaymentEvent(block: (RefundedPaymentEvent) -> T): T? =
|
||||
refundedPaymentEventOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.chatSharedOrNull(): ChatShared? = this as?
|
||||
dev.inmo.tgbotapi.types.request.ChatShared
|
||||
|
||||
|
@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.payments.RefundedPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
@ -60,6 +61,8 @@ inline fun Flow<ChatEventMessage<*>>.newChannelPinnedMessageEvents() = filterCha
|
||||
inline fun FlowsUpdatesFilter.newChannelPinnedMessageEvents() = filterChannelEvents<PinnedMessage>()
|
||||
inline fun Flow<ChatEventMessage<*>>.successfulPaymentInChannelEvents() = filterChannelEvents<SuccessfulPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.successfulPaymentInChannelEvents() = filterChannelEvents<SuccessfulPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.refundedPaymentInChannelEvents() = filterChannelEvents<RefundedPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.refundedPaymentInChannelEvents() = filterChannelEvents<RefundedPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.channelEvents() = filterChannelEvents<ChannelEvent>()
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
@ -84,6 +87,8 @@ inline fun Flow<ChatEventMessage<*>>.proximityAlertTriggeredInGroupEvents() = fi
|
||||
inline fun FlowsUpdatesFilter.proximityAlertTriggeredInGroupEvents() = filterGroupEvents<ProximityAlertTriggered>()
|
||||
inline fun Flow<ChatEventMessage<*>>.successfulPaymentInGroupEvents() = filterGroupEvents<SuccessfulPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.successfulPaymentInGroupEvents() = filterGroupEvents<SuccessfulPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.refundedPaymentInGroupEvents() = filterGroupEvents<RefundedPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.refundedPaymentInGroupEvents() = filterGroupEvents<RefundedPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.groupEvents() = filterGroupEvents<GroupEvent>()
|
||||
|
||||
|
||||
@ -109,6 +114,8 @@ inline fun Flow<ChatEventMessage<*>>.proximityAlertTriggeredInSupergroupEvents()
|
||||
inline fun FlowsUpdatesFilter.proximityAlertTriggeredInSupergroupEvents() = filterSupergroupEvents<ProximityAlertTriggered>()
|
||||
inline fun Flow<ChatEventMessage<*>>.successfulPaymentInSupergroupEvents() = filterSupergroupEvents<SuccessfulPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.successfulPaymentInSupergroupEvents() = filterSupergroupEvents<SuccessfulPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.refundedPaymentInSupergroupEvents() = filterSupergroupEvents<RefundedPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.refundedPaymentInSupergroupEvents() = filterSupergroupEvents<RefundedPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.supergroupEvents() = filterSupergroupEvents<SupergroupEvent>()
|
||||
|
||||
@RiskFeature("Use with caution")
|
||||
@ -117,6 +124,8 @@ inline fun <reified T : PrivateEvent> Flow<ChatEventMessage<*>>.filterPrivateEve
|
||||
inline fun <reified T : PrivateEvent> FlowsUpdatesFilter.filterPrivateEvents() = privateEvents().filterByChatEvent<T, PrivateEventMessage<T>>()
|
||||
inline fun Flow<ChatEventMessage<*>>.successfulPaymentInPrivateEvents() = filterPrivateEvents<SuccessfulPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.successfulPaymentInPrivateEvents() = filterPrivateEvents<SuccessfulPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.refundedPaymentInPrivateEvents() = filterPrivateEvents<RefundedPaymentEvent>()
|
||||
inline fun FlowsUpdatesFilter.refundedPaymentInPrivateEvents() = filterPrivateEvents<RefundedPaymentEvent>()
|
||||
inline fun Flow<ChatEventMessage<*>>.newPrivatePinnedMessageEvents() = filterPrivateEvents<PinnedMessage>()
|
||||
inline fun FlowsUpdatesFilter.newPrivatePinnedMessageEvents() = filterPrivateEvents<PinnedMessage>()
|
||||
inline fun Flow<ChatEventMessage<*>>.privateEvents() = filterPrivateEvents<PrivateEvent>()
|
||||
|
Loading…
Reference in New Issue
Block a user